REST API On-Demand Deployment

This topic includes the workflow for deploying a REST API on demand.
View the Current Deployment of an API
Use the following command:
curl -H 'Authorization: Bearer {token}' https://{portalApiHost}/{tenantId}/deployments/1.0/apis/{apiUuid}/proxies
Example request:
curl -H 'Authorization: Bearer cde69bcc-3bed-44e0-af5b-c33fcb9020d5' \
https://apim-ssg-apim-uswest-prod.app.prod.w2.dev.ca.com:443/atenant/deployments/1.0/apis/430924a3-d279-4d42-9eec-46da03ea3846/proxies
Example response:
[ { "apiUuid": "43e52d60-d4e3-4c15-89c1-8764de4e3106", "proxyUuid": "8f6bc46c-a131-4388-b654-1e2b599b0ee9", "proxyName": "DEV", "lastTimeDeployed": 1511994241499, "status": "DEPLOYED" } ]
In this example, the API with uuid 43e52d60-d4e3-4c15-89c1-8764de4e3106 has been deployed to the DEV proxy automatically.
Create an API Deployment
Creating an API deployment deploys an API to the UAT proxy that uses the On Demand API deployment type. Issue the following command:
curl -X POST -H 'Authorization: Bearer {token}' -H 'Content-Type:application/json;charset=utf-8' \ https://{portalApiHost}/{tenantId}/deployments/1.0/apis/{apiUuid}/proxies \ -d '{"proxyUuid": "{proxyUuid}"}'
Example request:
curl -X POST -H 'Authorization: Bearer cde69bcc-3bed-44e0-af5b-c33fcb9020d5' -H 'Content-Type:application/json;charset=utf-8' \ https://apim-ssg-apim-uswest-prod.app.prod.w2.dev.ca.com:443/atenant/deployments/1.0/apis/430924a3-d279-4d42-9eec-46da03ea3846/proxies \ -d '{"proxyUuid": "de484ed2-cea4-4adc-885b-bf495f94b9f7"}'
Example response:
{ "apiUuid": "43e52d60-d4e3-4c15-89c1-8764de4e3106", "proxyUuid": "de484ed2-cea4-4adc-885b-bf495f94b9f7", "proxyName": "UAT", "lastTimeDeployed": 0, "status": "PENDING_DEPLOYMENT" }
When you create the API deployment,
API Management SaaS
publishes a deployment event for the UAT proxy Portal Deployer client to consume. If you make the previous API call to retrieve an API deployment, the following information appears:
[ { "apiUuid": "43e52d60-d4e3-4c15-89c1-8764de4e3106", "proxyUuid": "8f6bc46c-a131-4388-b654-1e2b599b0ee9", "proxyName": "DEV", "lastTimeDeployed": 1511994960953, "status": "DEPLOYED" }, { "apiUuid": "43e52d60-d4e3-4c15-89c1-8764de4e3106", "proxyUuid": "de484ed2-cea4-4adc-885b-bf495f94b9f7", "proxyName": "UAT", "lastTimeDeployed": 1511994641295, "status": "DEPLOYED", "message": "[{\"targetLocation\":\"https://localhost:8443/restman/1.0/bundle\",\"message\":\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\\n<l7:Item xmlns:l7=\\\"http://ns.l7tech.com/2010/04/gateway-management\\\">\\n <l7:Name>Bundle mappings</l7:Name>\\n <l7:Type>BUNDLE MAPPINGS</l7:Type>\\n <l7:TimeStamp>2017-11-29T22:30:41.069Z</l7:TimeStamp>\\n <l7:Link rel=\\\"self\\\" uri=\\\"https://localhost:8443/restman/1.0/bundle\\\"/>\\n <l7:Resource>\\n <l7:Mappings>\\n <l7:Mapping action=\\\"NewOrUpdate\\\" actionTaken=\\\"CreatedNew\\\" srcId=\\\"43e52d60d4e34c1589c18764de4e3106\\\" targetId=\\\"43e52d60d4e34c1589c18764de4e3106\\\" targetUri=\\\"https://localhost:8443/restman/1.0/policies/43e52d60d4e34c1589c18764de4e3106\\\" type=\\\"POLICY\\\"/>\\n <l7:Mapping action=\\\"NewOrUpdate\\\" actionTaken=\\\"CreatedNew\\\" srcId=\\\"144251a872943a3a8be915f4eaf1e69f\\\" targetId=\\\"144251a872943a3a8be915f4eaf1e69f\\\" targetUri=\\\"https://localhost:8443/restman/1.0/services/144251a872943a3a8be915f4eaf1e69f\\\" type=\\\"SERVICE\\\"/>\\n </l7:Mappings>\\n </l7:Resource>\\n</l7:Item>\\n\",\"status\":\"DEPLOYED\"}]" } ]
From the response example, the Portal Deployer client has deployed the API to the UAT proxy and has set its status to DEPLOYED from PENDING_DEPLOYMENT. It has set lastTimeDeployed. If an error occurred during the API deployment, the Portal Deployer client sets the status to ERROR instead and the message field contains the error. If the Portal Deployer client has not deployed the API to the proxy and the API deployment itself is stuck in PENDING_DEPLOYMENT, there might be a connectivity issue between the Portal Deployer client and
API Management SaaS
. For more information about issues with the Portal Deployer client, see Troubleshoot API Deployments.
Redeploy the API
The following API properties can impact API deployment to a proxy when changed:
  • name
  • state
  • policy templates
  • policy templates values
  • custom fields
  • custom fields values
The Portal Deployer client sets back the API deployment status to PENDING_DEPLOYMENT to denote to the user that the API
must
be redeployed, as the version deployed on the proxy is no longer the same as the one published in
API Management SaaS
. Update the API deployment to
PENDING_DEPLOYMENT
by issuing the following command:
curl -X PUT -H 'Authorization: Bearer {token}' -H 'Content-Type:application/json;charset=utf-8' \ https://{portalApiHost}/{tenantId}/deployments/1.0/apis/{apiUuid}/proxies/{proxyUuid} \ -d '{"status": "PENDING_DEPLOYMENT"}'
Example request:
curl -X PUT -H 'Authorization: Bearer cde69bcc-3bed-44e0-af5b-c33fcb9020d5' -H 'Content-Type:application/json;charset=utf-8' \ https://apim-ssg-apim-uswest-prod.app.prod.w2.dev.ca.com:443/atenant/deployments/1.0/apis/430924a3-d279-4d42-9eec-46da03ea3846/proxies/de484ed2-cea4-4adc-885b-bf495f94b9f7 \ -d '{"status": "PENDING_DEPLOYMENT"}'
Example response:
{ "apiUuid": "43e52d60-d4e3-4c15-89c1-8764de4e3106", "proxyUuid": "de484ed2-cea4-4adc-885b-bf495f94b9f7", "proxyName": "UAT", "lastTimeDeployed": 1512000698619, "status": "PENDING_DEPLOYMENT" }
Retrieving the API deployments, you can see that the following API was deployed again and has a new lastTimeDeployed:
[ { "apiUuid": "43e52d60-d4e3-4c15-89c1-8764de4e3106", "proxyUuid": "8f6bc46c-a131-4388-b654-1e2b599b0ee9", "proxyName": "DEV", "lastTimeDeployed": 1512000901396, "status": "DEPLOYED" }, { "apiUuid": "43e52d60-d4e3-4c15-89c1-8764de4e3106", "proxyUuid": "de484ed2-cea4-4adc-885b-bf495f94b9f7", "proxyName": "UAT", "lastTimeDeployed": 1512000847136, "status": "DEPLOYED", "message": "[{\"targetLocation\":\"https://localhost:8443/restman/1.0/bundle\",\"message\":\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\\n<l7:Item xmlns:l7=\\\"http://ns.l7tech.com/2010/04/gateway-management\\\">\\n <l7:Name>Bundle mappings</l7:Name>\\n <l7:Type>BUNDLE MAPPINGS</l7:Type>\\n <l7:TimeStamp>2017-11-30T00:14:06.916Z</l7:TimeStamp>\\n <l7:Link rel=\\\"self\\\" uri=\\\"https://localhost:8443/restman/1.0/bundle\\\"/>\\n <l7:Resource>\\n <l7:Mappings>\\n <l7:Mapping action=\\\"NewOrUpdate\\\" actionTaken=\\\"UpdatedExisting\\\" srcId=\\\"43e52d60d4e34c1589c18764de4e3106\\\" targetId=\\\"43e52d60d4e34c1589c18764de4e3106\\\" targetUri=\\\"https://localhost:8443/restman/1.0/policies/43e52d60d4e34c1589c18764de4e3106\\\" type=\\\"POLICY\\\"/>\\n <l7:Mapping action=\\\"NewOrUpdate\\\" actionTaken=\\\"UpdatedExisting\\\" srcId=\\\"144251a872943a3a8be915f4eaf1e69f\\\" targetId=\\\"144251a872943a3a8be915f4eaf1e69f\\\" targetUri=\\\"https://localhost:8443/restman/1.0/services/144251a872943a3a8be915f4eaf1e69f\\\" type=\\\"SERVICE\\\"/>\\n </l7:Mappings>\\n </l7:Resource>\\n</l7:Item>\\n\",\"status\":\"DEPLOYED\"}]" } ]
Undeploy the API
You undeploy an API by deleting it from the proxy. Issue the following command:
curl -X DELETE -H 'Authorization: Bearer {token}' https://{portalApiHost}/{tenantId}/deployments/1.0/apis/{apiUuid}/proxies/{proxyUuid}
Example request:
curl -X DELETE -H 'Authorization: Bearer cde69bcc-3bed-44e0-af5b-c33fcb9020d5' \ https://apim-ssg-apim-uswest-prod.app.prod.w2.dev.ca.com:443/atenant/deployments/1.0/apis/430924a3-d279-4d42-9eec-46da03ea3846/proxies/de484ed2-cea4-4adc-885b-bf495f94b9f7
When deleting an API from the proxy, the following events occur:
  • The API state is set to PENDING_UNDEPLOYMENT.
  • API Management SaaS
    publishes an undeploy event.
If the the Portal Deployer client successfully processes the undeploy event on the proxy, it deletes the API from the proxy and deletes the API deployment from
API Management SaaS
. If deleting the API fails, the Portal Deployer client updates the API deployment with an ERROR state and the message field contains the actual error. If the API deployment is stuck in PENDING_UNDEPLOYMENT, there might be a connectivity issue between the Portal Deployer client and
API Management SaaS
. For more information, see Troubleshoot API Deployments. If successful, retrieving the API deployments displays that the API deployment as deleted:
[ { "apiUuid": "43e52d60-d4e3-4c15-89c1-8764de4e3106", "proxyUuid": "8f6bc46c-a131-4388-b654-1e2b599b0ee9", "proxyName": "DEV", "lastTimeDeployed": 1512001260997, "status": "DEPLOYED" } ]