Hello Community,
I have a requirement to get a list of API Proxies deployed in a Particular environment and dump them into an CSV/Excel file. is there any sample python script file to run on Jenkins and get the list into a file.
Please Suggest
Regards,
You can use the Get API Proxy Deployments for an Environment API,
or the apigeetool command line tool
apigeetool listdeployments -u $APIGEE_USER -p $APIGEE_PASSWORD -o $APIGEE_ORG -e $APIGEE_ENV
From there it's pretty straightforward to convert the result into a csv file
What data do you need in the CSV?
It's pretty simple to use the API.
# to use this you must install requests, see https://2.python-requests.org/en/master/ import requests import netrc mgmtserver = 'api.enterprise.apigee.com' org = 'MYORG' env = 'MYENV' # obtain credentials from .netrc netrc = netrc.netrc() authTokens = netrc.authenticators(mgmtserver) username = authTokens[0] password = authTokens[2] baseurl = 'https://' + mgmtserver + '/v1/o/' + org url = baseurl + '/apis' #print('GET ' + url) r = requests.get(url, auth=(username, password), headers = {'accept': 'application/json'}) print("PROXYNAME, REVISION, ENV") for proxy in r.json(): proxyurl = baseurl + '/apis/' + proxy + '/deployments' #print('GET ' + proxyurl) p = requests.get(proxyurl, auth=(authTokens[0], authTokens[2]), headers = {'accept': 'application/json'}) #print(p.json()) for deployment in p.json()['environment']: if deployment['name'] == env: for revision in deployment['revision']: #print(revision) s = '%s,%s,%s' % (proxy, revision['name'], env) print(s)