While exporting APIs which environment APIs gets downloaded ?

Not applicable

I was trying to export some of the APIs created in my org. I noticed that export URL does not take environment parameter, so would like to know by default which environment's APIs gets download

Solved Solved
0 9 473
2 ACCEPTED SOLUTIONS

Not applicable

I think this API should help you: https://api.enterprise.apigee.com/v1/organizations/{org_name}/apis/{api_name}/deployments

This will give you the deployments on all of your environments and you should be able to download whichever you want and upload it to a different environment.

View solution in original post

adas
New Member

The export api is not specific environment , but revision number. So if you want to export an apiproxy which is deployed to the test environment, you need to get the revision number deployed in the test environment using the following api:

GET /v1/o/{org-id}/e/test/apis/{apiproxy}/deployments

The response would look like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <APIProxyDeployment name="myapi"> <Environment>test</Environment> <Organization>myorg</Organization> <Revision xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="revisionStatusInEnvironment" name="2"> <Configuration>....

You can then use the export api to export that specific revision. I believe you already have the details for the export api and its signature. Hope this solves your query. Have fun...

View solution in original post

9 REPLIES 9

Not applicable

The API https://api.enterprise.apigee.com/v1/organizations...{org_name}/apis/{api_name}/revisions/{revision_number}

exports an API based on its revision number, regardless of which environment it is deployed to. You can read more about it here. Other APIs are available that give information such as the API revision deployed to each environment (see here).

Not applicable

I was actually trying to integrate the API promotion process with Jenkins. So typically what I will be doing is, export APIs from one environment, say test environment and promote that to stage environment. I understand I can export a particular revision number but I am little confused how would that help me here. May be the point you are trying to convey is, any revision (say revision 2) should be deployed across all environments ?

Not applicable

I think this API should help you: https://api.enterprise.apigee.com/v1/organizations/{org_name}/apis/{api_name}/deployments

This will give you the deployments on all of your environments and you should be able to download whichever you want and upload it to a different environment.

I am not sure whether you really understood what I was trying to convey. I do agree that I can deploy any environment using below API,

https://api.enterprise.apigee.com/v1/organizations/{org_name}/environments/{env_name}/apis/{api_name}/revisions/{revision_number}/deployments

I am looking for similar API to export APIs as well [API which has {env_name} So suppose I have deployed my APIs in test environment, once that is qualified jenkins can export it from test environment and promote to stage and prod environment. How will I know when i export the APIs from which environment is it getting exported? Say If i have to promote something to prod environment, I shouldn't export the test environment APIS and promote correct? it should come from stage environment.

Not applicable

I see what you are doing now. I don't believe that this requires you to download and upload your API unless you are using different orgs. What you do need to do to promote from test to prod is find out the version of the API deployed on test and then deploy the same API revision to prod.

There are some customers who do download each revision of their API as a precaution and there is certainly no harm in doing that.

But the problem here is, we don't always promote from test environment to prod. There can be n environments, dev -> test -> stage ->prod etc. This pipeline is in parallel with our code development platform environment. so dev api will be for dev stacks, test for test stacks, stage for stage stacks and prod for prod stacks. So to be able to export from one environment and promote next environment is very important for us. So we can actually automate the promotion process. That is how our code promotion works.

Thanks. I think I understand your situation a little better. What can certainly be automated and plugged into Jenkins is a script that chooses a particular environment and uses the Management Server API to find the deployed version of the API there and then downloads the API to a zip file that you can use to promote to whichever branch you choose.

adas
New Member

The export api is not specific environment , but revision number. So if you want to export an apiproxy which is deployed to the test environment, you need to get the revision number deployed in the test environment using the following api:

GET /v1/o/{org-id}/e/test/apis/{apiproxy}/deployments

The response would look like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <APIProxyDeployment name="myapi"> <Environment>test</Environment> <Organization>myorg</Organization> <Revision xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="revisionStatusInEnvironment" name="2"> <Configuration>....

You can then use the export api to export that specific revision. I believe you already have the details for the export api and its signature. Hope this solves your query. Have fun...