can we update/delete the policy from existing proxy on same version in apigee-x ?

We have patch request to update the proxy , but the policy attached to the proxy is not getting updated , can we have a sample patch request?

I refer this link : https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.apis/patch 

 

0 3 254
3 REPLIES 3

Hmmm
I've never used that Patch method.  

I am certain that it will not allow you to update a POLICY, though.  To the extent that it works, the PATCH will update the API proxy metadata - maybe the name, the description, that sort of thing.  Even there I am not sure, since those data items apply to REVISIONS of APIs, not to the APIs themselves. Really the API entity in the REST model is just a container for a bunch of revisions. 

The way to update is: download revision X, unzip, make the policy modifications (delete, remove, add, rename, change config, etc), zip up, then import the new zip.  You will get a new revision of the API proxy from that. 

Good luck.  

Hi dchiesa1,

But the way you are saying , this will update api proxy revision, also if i am having 100s of apis , making a same change in all manually is not acceptable.

I want to try something that will not update my proxy revision but still i am able to update my policy.

Reason for this is apigee-x has limitation over proxy revision count and if my api proxy is getting updated in every release say , then it would be difficult for me to maintain.

I want to try something that will not update my proxy revision but still i am able to update my policy.

[EDITED] This is not always possible in Apigee X. For any API proxy that has been previously deployed, even if it is not currently deployed, If you update a policy, that implicitly means you will be creating a new revision of that api proxy. Each revision of an API proxy has a set of zero or more policies. That set of policies and the configuration within them is immutable for that proxy revision, if it has been previously deployed. Cannot be changed. If you want to have a very similar proxy with a slightly different configuration in one policy, it implies creating a new proxy revision. A good way to do that is what I described above (export/download, unzip, modify file, re-zip, import).

For a proxy revision that has never been deployed, you can update it without introducing a new revision.  You still need to go through the same (export, unzip... ) process in order to do the update. 

apigee-x has limitation over proxy revision count and if my api proxy is getting updated in every release say , then it would be difficult for me to maintain.

Yes I'm sorry about that. There are tools out there that clean out old proxy revisions. For example, this tool will allow you to specify the number of revisions of a proxy to keep. You can set it to 10, and the tool will delete all but the most recent 10 revisions of each api proxy. If you run that once a day it should keep things clean.

 

 

node ~/dev/apigee-edge-js-examples/cleanOldRevisions.js 
Apigee Proxy / Sharedflow revision cleaner tool, version: 20220623-1527
Node.js v16.17.0

You must specify an Apigee organization
Usage:
  node cleanOldRevisions.js [OPTION]

Options:
  -M, --mgmtserver=ARG the base path, including optional port, of the Apigee mgmt server. Defaults to https://api.enterprise.apigee.com .
  -u, --username=ARG   org user with permissions to read Apigee configuration.
  -p, --password=ARG   password for the org user.
  -n, --netrc          retrieve the username + password from the .netrc file. In lieu of -u/-p
  -o, --org=ARG        the Apigee organization.
  -Z, --ssoZone=ARG    specify the SSO zone to use when authenticating.
      --ssoUrl=ARG     specify the SSO url to use when authenticating.
  -C, --passcode=ARG   specify the passcode to use when authenticating.
  -J, --keyfile=ARG    the keyfile for a service account, for use with apigee.googleapis.com.
      --token=ARG      use this explicitly-provided oauth token.
      --apigeex        use apigee.googleapis.com for the mgmtserver.
  -T, --notoken        do not try to obtain an oauth token.
  -N, --forcenew       force obtain a new oauth token.
  -v, --verbose
  -h, --help
  -R, --regexp=ARG     Optional. Cull only proxies with names matching this regexp.
  -K, --numToKeep=ARG  Required. Max number of revisions of each proxy to retain.
  -S, --sharedflows    Optional. Cull only sharedflows, not apiproxies.