Dynamic API's Addition Script
Dynamic APIs allow you to create and expose new API endpoints through
configuration, without plugins or code redeployment. They can invoke existing APIs or trigger
workflows with optional request transformations. To expose a dynamic API, the details should
be manually added to the avx_dynamic_apis collection in MongoDB, and the config map
should be updated. To avoid manual errors, use the patch_dynamic_api.sh script, which
automates updates to both the database and configmap. Create or edit dynamic_api.json
in appviewx_kubernetes/scripts (refer to
dynamic_api.json.template), run the script, and restart the platform
gateway pods. Keep dynamic_api.json updated to retain changes after plugin installs or
patches.
Steps to Add/Update dynamic APIs:
- Ensure that the kube-context is set to the admin user before proceeding.
Check the current context using the command
below:
kubectl config current-contextExpected output:
If not set, switch to the admin context (use your admin-context name if different):kubernetes-admin@kubernetes
- Create the JSON file (first-time add). Place the file
dynamic_api.jsonin the scripts folder (appviewx_kubernetes/scripts). Example:vi dynamic_api.jsonNote: Add one or more dynamic API objects in valid JSON (seedynamic_api.json.templatefor reference). Do not remove or modify the dynamic_api.json file unnecessarily to preserve dynamic APIs during plugin installations or apply patches) - Run the
patch_dynamic_api.shscript located inappviewx_kubernetes/scriptsdirectory.cd <appviewx_installer_path>/scripts ./patch_dynamic_api.sh - Once the script is executed,
- Upserts all records from
dynamic_api.jsoninto theavx_dynamic_apiscollection (create or update). - Adds the API
_idvalues toPUBLIC/apisinavxgw-profile.templateinside the platform-gateway Helm chart (for persistence across helm upgrades). - Patches the
avx-platform-gateway-configconfig map usingavxgw-profile.json.
- Restarts platform-gateway pods automatically to apply the new config map.If the new API IDs already exist in
avxgw-profile.template, the script skips the configmap patch and pod restart.
- Upserts all records from
- Script logs are written to the
appviewx_kubernetes/logsdirectory.
- Edit/append entries in
dynamic_api.jsonand re-run./patch_dynamic_api.sh. The script will update changed entries and will restart gateway pods only if new API IDs were added to the config map.
- During plugin installs or patch operations, the installer checks for
dynamic_api.json; if present, it triggerspatch_dynamic_api.shautomatically to reapply dynamic APIs to both the database and the platform gateway config map, ensuring that all dynamic APIs remain persistent after any plugin or patch operations.
