Management API / Runtime deployment of a new Proxy endpoint

Not applicable

Is there any management API through which we can add a new proxy endpoint (new API) in an existing API proxy ?

Or any node.js / utility available for the same ? Basically the requirement is to automate the process of adding a new API resource in existing API proxy.

1 1 277
1 REPLY 1

yes, you can. You can walk the hierarchy.

you can do a

POST /v1/o/ORGNAME/apis/PROXYNAME/revisions/NN/proxyendpoints -d '{ ...payload here...}'

...to add a proxy endpoint to an existing API Proxy.

However, I strongly advise that you should NOT do this. The reason is: the API proxy may be deployed, and may not be. Modifying the API Proxy without deploying and undeploying will get you into a questionable state. If your view is: if the API allows it, then it ought to have correct semantics..., you'd be exactly right. But I'm explaining to you how it works, not how it ought to work.

In light of this, instead of adding an endpoint to an existing revision of an Existing API Proxy, I advise you to create a new revision of the existing API Proxy, adding the endpoint to THAT.

What you would do is:

  1. export the latest revision of the API Proxy in zip form
  2. unzip that zip archive to a filesystem (or in-memory stream)
  3. add the new proxy endpoint to the unzipped artifact same
  4. re-zip the modified directory tree with the new endpoint (and any of its new policies etc)
  5. import the new (modified) zip as a new apiproxy revision.
  6. optionally deploy the new apiproxy revision

All of this can be automated as well, via the Administrative API.

I don't know of a nodejs utility that does *Exactly this*, but you could script together some apigeetool commands to make it happen pretty easily.

For example:

apigeetool fetchproxy -u sdoe@example.com -o sdoe -n example-proxy -r 1
unzip whatever.zip -d tmpwork
cp -r /source/to/proxy/endpoint tmpwork/apiproxy/proxies
apigeetool deployproxy  -u sdoe@example.com -o sdoe  -e test --import-only -n example-proxy -d tmpwork

NB: Using the deployproxy command, the apigeetool zips the dfirectory, then Imports the zip, then optionally deploys. Given that it does all that, and the dpeloy part is optional, the name of the command, "deployproxy", is inaccurate. Be that as it may, the behavior of the command is zip, import, and maybe deploy. That is why you see no explicit step in the above to "re-zip" the proxy.