Deploy Proxy with On-Demand Deployments

For a proxy with the on-demand deployment type, the Portal Deployer client handles the deployment, undeployment, and redeployment of APIs to the proxy.
apip43
For a proxy with the on-demand deployment type, the Portal Deployer client handles the deployment, undeployment, and redeployment of APIs to the proxy.
On-demand deployments only apply to Portal-published APIs.
Workflow
The following information is an example workflow of deployment API calls:
3
View the Current Deployment of an API
View the current deployments of an API using 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" } ]
You can see the API with uuid 43e52d60-d4e3-4c15-89c1-8764de4e3106 was deployed to the DEV proxy automatically.
Create a Deployment for an API
To deploy this API to the UAT proxy which used on-demand deployment type, create an API deployment.
Create an API deployment using 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 the API deployment is created, the Portal publishes a deployment event to be consumed by the UAT proxy Portal Deployer client. If you make the previous API call to retrieve an API deployment, you see the following information:
[ { "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 API has now been deployed to the UAT proxy as its status is set to DEPLOYED from PENDING_DEPLOYMENT. The lastTimeDeployed is set. If an error occurred during the API deployment, the status is set to ERROR instead and the message field contains the error. If you notice that the API has not been deployed to the proxy and the deployment itself is stuck in PENDING_DEPLOYMENT, there may be a connectivity issue between the Portal Deployer client and the Portal. See Troubleshoot API Deployments for more information about issues with the Portal Deployer.
Redeploy the API 
The following API properties can impact the deployment to a proxy when changed:
  • name
  • state
  • policy templates
  • policy templates values
  • custom fields
  • custom fields values
The API deployment status is set back to PENDING_DEPLOYMENT to denote to the user that API
must
be redeployed, as the version deployed on the proxy is no longer the same as the one published in the Portal.
Update the deployment to
PENDING_DEPLOYMENT
using 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 the API from a proxy.
To delete the API from a proxy, execute 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 a deployment, the following events occur:
  • State is set to PENDING_UNDEPLOYMENT
  • An undeploy event is published by the Portal
If the undeploy event is successfully processed by the Portal Deployer client on the proxy, the API is deleted from the proxy and the deployment is deleted from the Portal. If deleting the API fails, the deployment is updated with an ERROR state and the message field contains the actual error. If the deployment is stuck in PENDING_UNDEPLOYMENT, there may be a connectivity issue between the portal deployer client and the Portal. See Troubleshoot API Deployments
If successful, retrieving the API deployments displays that the deployment as deleted:
[ { "apiUuid": "43e52d60-d4e3-4c15-89c1-8764de4e3106", "proxyUuid": "8f6bc46c-a131-4388-b654-1e2b599b0ee9", "proxyName": "DEV", "lastTimeDeployed": 1512001260997, "status": "DEPLOYED" } ]