Deploy Proxy with Scripted Deployments

For a proxy with the scripted deployment type, the deployment, undeployment, and redeployment of APIs to the proxy is performed manually by a process outside of the control of the Portal. This deployment type is ideal for explicit control of proxies and not allowing any automated deployment of APIs happening from the Portal. 
apip43
For a proxy with the scripted deployment type, the deployment, undeployment, and redeployment of APIs to the proxy is performed manually by a process outside of the control of the Portal. This deployment type is ideal for explicit control of proxies and not allowing any automated deployment of APIs happening from the Portal. 
 Scripted deployments only apply to Portal-published APIs.
The following information is an example workflow of deployment API calls:
  1. View the current deployments of an API
  2. Create a deployment for an API
  3. Retrieve the API bundle for the API to deploy the API to the proxy
  4. Redeploy the API to the proxy after it was updated using an updated API bundle
  5. Retrieve the undeploy API bundle for the API to undeploy the API from the proxy
  6. Delete the API deployment to denote to other users that it was undeployed from the proxy
View the Current Deployments 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/43e52d60-d4e3-4c15-89c1-8764de4e3106/proxies
Example response:
[ { "apiUuid": "43e52d60-d4e3-4c15-89c1-8764de4e3106", "proxyUuid": "8f6bc46c-a131-4388-b654-1e2b599b0ee9", "proxyName": "DEV", "lastTimeDeployed": 1511994241499, "status": "DEPLOYED" } ]
From the response, you can see that the API with uuid 43e52d60-d4e3-4c15-89c1-8764de4e3106, was deployed to the DEV proxy automatically.
Create a New Deployment
To deploy this API to the PROD proxy, create a new 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 860c9661-3e83-4672-ad36-ac8ea65c639b' -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/43e52d60-d4e3-4c15-89c1-8764de4e3106/proxies \ -d '{"proxyUuid": "639536fc-230d-434e-8b88-3e13d5069c34"}'
Example response:
{ "apiUuid": "43e52d60-d4e3-4c15-89c1-8764de4e3106", "proxyUuid": "639536fc-230d-434e-8b88-3e13d5069c34", "proxyName": "PROD", "lastTimeDeployed": 0, "status": "PENDING_DEPLOYMENT" }
Because this proxy is configured with scripted deployment type, the API is manually deployed to the proxy and the deployment has a state of PENDING_DEPLOYMENT until it is manually updated. If you make the previous API call to retrieve an API deployments, you see the following information:
[ { "apiUuid": "43e52d60-d4e3-4c15-89c1-8764de4e3106", "proxyUuid": "8f6bc46c-a131-4388-b654-1e2b599b0ee9", "proxyName": "DEV", "lastTimeDeployed": 1512077761305, "status": "DEPLOYED" }, { "apiUuid": "43e52d60-d4e3-4c15-89c1-8764de4e3106", "proxyUuid": "639536fc-230d-434e-8b88-3e13d5069c34", "proxyName": "PROD", "lastTimeDeployed": 0, "status": "PENDING_DEPLOYMENT" } ]
Retrieve the API Bundle
To deploy the API to the proxy manually, retrieve the API bundle from the Portal by making the following request:
curl -H 'Authorization: Bearer {token}' https://{portalApiHost}/{tenantId}/api-management/1.0/apis/{apiUuid}/bundle
Example request which saves the response to api-bundle.xml:
curl -H 'Authorization: Bearer 14f1f709-1b19-4c29-a0fc-c93cdc683159' \ https://apim-ssg-apim-uswest-prod.app.prod.w2.dev.ca.com:443/atenant/api-management/1.0/apis/43e52d60-d4e3-4c15-89c1-8764de4e3106/bundle \ -o api-bundle.xml
The following information displays the contents of the api-bundle.xml:
<l7:Bundle xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management"> <l7:References> <l7:Item xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management"> <l7:Name>Demo Api 294ece4a - updated-fragment</l7:Name> <l7:Id>43e52d60d4e34c1589c18764de4e3106</l7:Id> <l7:Type>POLICY</l7:Type> <l7:Resource> <l7:Policy guid="43e52d60-d4e3-4c15-89c1-8764de4e3106" id="43e52d60d4e34c1589c18764de4e3106" version="0"> <l7:PolicyDetail folderId="ddb84c6f397d7dbd3cca71d3043f019c" guid="43e52d60-d4e3-4c15-89c1-8764de4e3106" id="43e52d60d4e34c1589c18764de4e3106"> <l7:Name>Demo Api 294ece4a - updated-fragment</l7:Name> <l7:PolicyType>Include</l7:PolicyType> <l7:Properties> <l7:Property key="revision"> <l7:LongValue>1</l7:LongValue> </l7:Property> <l7:Property key="soap"> <l7:BooleanValue>false</l7:BooleanValue> </l7:Property> </l7:Properties> </l7:PolicyDetail> <l7:Resources> <l7:ResourceSet tag="policy"> <l7:Resource type="policy">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;wsp:Policy xmlns:L7p=&quot;http://www.layer7tech.com/ws/policy&quot; xmlns:wsp=&quot;http://schemas.xmlsoap.org/ws/2002/12/policy&quot;&gt; &lt;wsp:All wsp:Usage=&quot;Required&quot;&gt; &lt;L7p:CommentAssertion&gt; &lt;L7p:Comment stringValue=&quot;=============================&quot;/&gt; &lt;/L7p:CommentAssertion&gt; &lt;L7p:CommentAssertion&gt; &lt;L7p:Comment stringValue=&quot;======= Published thru API Portal =======&quot;/&gt; &lt;/L7p:CommentAssertion&gt; &lt;L7p:CommentAssertion&gt; &lt;L7p:Comment stringValue=&quot;======= Don&apos;t modify block starts =======&quot;/&gt; &lt;/L7p:CommentAssertion&gt; &lt;L7p:CommentAssertion&gt; &lt;L7p:Comment stringValue=&quot;=============================&quot;/&gt; &lt;/L7p:CommentAssertion&gt; &lt;L7p:ApiPortalIntegration&gt; &lt;L7p:ApiGroup stringValue=&quot;&quot;/&gt; &lt;L7p:ApiId stringValue=&quot;43e52d60-d4e3-4c15-89c1-8764de4e3106&quot;/&gt; &lt;L7p:PortalManagedApiFlag stringValue=&quot;L7p:ApiPortalManagedServiceAssertion&quot;/&gt; &lt;/L7p:ApiPortalIntegration&gt; &lt;L7p:SetVariable&gt; &lt;L7p:Base64Expression stringValue=&quot;aGVyZS5jb20=&quot;/&gt; &lt;L7p:VariableToSet stringValue=&quot;apiLocation&quot;/&gt; &lt;/L7p:SetVariable&gt; &lt;L7p:SetVariable&gt; &lt;L7p:Base64Expression stringValue=&quot;ZDRkM2UyNmY=&quot;/&gt; &lt;L7p:VariableToSet stringValue=&quot;serviceUrl&quot;/&gt; &lt;/L7p:SetVariable&gt; &lt;L7p:SetVariable&gt; &lt;L7p:Base64Expression stringValue=&quot;JHtwb3J0YWwubWFuYWdlZC5zZXJ2aWNlLmFwaUlkfQ==&quot;/&gt; &lt;L7p:VariableToSet stringValue=&quot;counterName&quot;/&gt; &lt;/L7p:SetVariable&gt; &lt;L7p:Encapsulated&gt; &lt;L7p:EncapsulatedAssertionConfigGuid stringValue=&quot;172594b6-18ba-4b0c-8d61-807db457e81d&quot;/&gt; &lt;L7p:Parameters mapValue=&quot;included&quot;&gt; &lt;L7p:entry xmlns:L7p=&quot;http://www.layer7tech.com/ws/policy&quot; &gt; &lt;L7p:key stringValue=&quot;sslEnabled&quot;/&gt; &lt;L7p:value stringValue=&quot;true&quot;/&gt; &lt;/L7p:entry&gt; &lt;L7p:entry xmlns:L7p=&quot;http://www.layer7tech.com/ws/policy&quot; &gt; &lt;L7p:key stringValue=&quot;sla&quot;/&gt; &lt;L7p:value stringValue=&quot;414353&quot;/&gt; &lt;/L7p:entry&gt; &lt;L7p:entry xmlns:L7p=&quot;http://www.layer7tech.com/ws/policy&quot; &gt; &lt;L7p:key stringValue=&quot;email&quot;/&gt; &lt;L7p:value stringValue=&quot;Test Value 888266&quot;/&gt; &lt;/L7p:entry&gt; &lt;L7p:entry xmlns:L7p=&quot;http://www.layer7tech.com/ws/policy&quot; &gt; &lt;L7p:key stringValue=&quot;smtpServer&quot;/&gt; &lt;L7p:value stringValue=&quot;Test Value 414571&quot;/&gt; &lt;/L7p:entry&gt; &lt;/L7p:Parameters&gt; &lt;/L7p:Encapsulated&gt; &lt;L7p:CommentAssertion&gt; &lt;L7p:Comment stringValue=&quot;=============================&quot;/&gt; &lt;/L7p:CommentAssertion&gt; &lt;L7p:CommentAssertion&gt; &lt;L7p:Comment stringValue=&quot;======= Don&apos;t modify block ends =======&quot;/&gt; &lt;/L7p:CommentAssertion&gt; &lt;L7p:CommentAssertion&gt; &lt;L7p:Comment stringValue=&quot;=============================&quot;/&gt; &lt;/L7p:CommentAssertion&gt; &lt;/wsp:All&gt; &lt;/wsp:Policy&gt; </l7:Resource> </l7:ResourceSet> </l7:Resources> </l7:Policy> </l7:Resource> </l7:Item> <l7:Item xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management"> <l7:Name>Demo Api 294ece4a - updated</l7:Name> <l7:Id>144251a872943a3a8be915f4eaf1e69f</l7:Id> <l7:Type>SERVICE</l7:Type> <l7:Resource> <l7:Service id="144251a872943a3a8be915f4eaf1e69f" xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management"> <l7:ServiceDetail folderId="ddb84c6f397d7dbd3cca71d3043f019c" id="144251a872943a3a8be915f4eaf1e69f"> <l7:Name>Demo Api 294ece4a - updated</l7:Name> <l7:Enabled>true</l7:Enabled> <l7:ServiceMappings> <l7:HttpMapping> <l7:UrlPattern>/d4d3e26f*</l7:UrlPattern> <l7:Verbs> <l7:Verb>GET</l7:Verb> <l7:Verb>POST</l7:Verb> <l7:Verb>PUT</l7:Verb> <l7:Verb>DELETE</l7:Verb> <l7:Verb>OPTIONS</l7:Verb> <l7:Verb>PATCH</l7:Verb> <l7:Verb>HEAD</l7:Verb> </l7:Verbs> </l7:HttpMapping> </l7:ServiceMappings> <l7:Properties> <l7:Property key="internal"> <l7:BooleanValue>false</l7:BooleanValue> </l7:Property> <l7:Property key="soap"> <l7:BooleanValue>false</l7:BooleanValue> </l7:Property> <l7:Property key="tracingEnabled"> <l7:BooleanValue>false</l7:BooleanValue> </l7:Property> <l7:Property key="wssProcessingEnabled"> <l7:BooleanValue>false</l7:BooleanValue> </l7:Property> <l7:Property key="property.portalID"> <l7:StringValue>43e52d60-d4e3-4c15-89c1-8764de4e3106</l7:StringValue> </l7:Property> <l7:Property key="property.internal.portalAPIEnabled"> <l7:StringValue>true</l7:StringValue> </l7:Property> </l7:Properties> </l7:ServiceDetail> <l7:Resources> <l7:ResourceSet tag="policy"> <l7:Resource type="policy">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;wsp:Policy xmlns:L7p=&quot;http://www.layer7tech.com/ws/policy&quot; xmlns:wsp=&quot;http://schemas.xmlsoap.org/ws/2002/12/policy&quot;&gt; &lt;wsp:All wsp:Usage=&quot;Required&quot;&gt; &lt;L7p:CommentAssertion&gt; &lt;L7p:Comment stringValue=&quot;------ Portal Created Fragment . Do not Modify ------&quot;/&gt; &lt;/L7p:CommentAssertion&gt; &lt;L7p:CommentAssertion&gt; &lt;L7p:Comment stringValue=&quot;------- Encass has a route in it. ------&quot;/&gt; &lt;/L7p:CommentAssertion&gt; &lt;L7p:SetVariable&gt; &lt;L7p:Base64Expression stringValue=&quot;ZmFsc2U=&quot;/&gt; &lt;L7p:VariableToSet stringValue=&quot;override_template_routing&quot;/&gt; &lt;/L7p:SetVariable&gt; &lt;L7p:Include&gt; &lt;L7p:PolicyGuid stringValue=&quot;812ed196-c315-4e92-b630-b5c64c5c043c&quot;/&gt; &lt;L7p:PolicyName stringValue=&quot;Portal Service Preface&quot;/&gt; &lt;/L7p:Include&gt; &lt;L7p:Include&gt; &lt;L7p:PolicyGuid stringValue=&quot;43e52d60-d4e3-4c15-89c1-8764de4e3106&quot;/&gt; &lt;/L7p:Include&gt; &lt;L7p:CommentAssertion&gt; &lt;L7p:Comment stringValue=&quot;------ Portal Created Fragment . Do not Modify ------&quot;/&gt; &lt;/L7p:CommentAssertion&gt; &lt;L7p:CommentAssertion&gt; &lt;L7p:Comment stringValue=&quot;------ This routing path will be executed if using override template routing ------&quot;/&gt; &lt;/L7p:CommentAssertion&gt; &lt;wsp:OneOrMore wsp:Usage=&quot;Required&quot;&gt; &lt;L7p:ComparisonAssertion&gt; &lt;L7p:CaseSensitive booleanValue=&quot;false&quot;/&gt; &lt;L7p:Expression1 stringValue=&quot;${override_template_routing}&quot;/&gt; &lt;L7p:Expression2 stringValue=&quot;false&quot;/&gt; &lt;L7p:Predicates predicates=&quot;included&quot;&gt; &lt;L7p:item binary=&quot;included&quot;&gt; &lt;L7p:CaseSensitive booleanValue=&quot;false&quot;/&gt; &lt;L7p:RightValue stringValue=&quot;false&quot;/&gt; &lt;/L7p:item&gt; &lt;/L7p:Predicates&gt; &lt;/L7p:ComparisonAssertion&gt; &lt;wsp:All wsp:Usage=&quot;Required&quot;&gt; &lt;L7p:SetVariable&gt; &lt;L7p:Base64Expression stringValue=&quot;JHtyZXF1ZXN0Lmh0dHAudXJpfQ==&quot;/&gt; &lt;L7p:VariableToSet stringValue=&quot;param.uri&quot;/&gt; &lt;/L7p:SetVariable&gt; &lt;L7p:Regex&gt; &lt;L7p:AutoTarget booleanValue=&quot;false&quot;/&gt; &lt;L7p:OtherTargetMessageVariable stringValue=&quot;param.uri&quot;/&gt; &lt;L7p:PatternContainsVariables booleanValue=&quot;true&quot;/&gt; &lt;L7p:Regex stringValue=&quot;/${serviceUrl}&quot;/&gt; &lt;L7p:RegexName stringValue=&quot;process uri&quot;/&gt; &lt;L7p:Replace booleanValue=&quot;true&quot;/&gt; &lt;L7p:Replacement stringValue=&quot;&quot;/&gt; &lt;L7p:Target target=&quot;OTHER&quot;/&gt; &lt;/L7p:Regex&gt; &lt;wsp:OneOrMore wsp:Usage=&quot;Required&quot;&gt; &lt;wsp:All wsp:Usage=&quot;Required&quot;&gt; &lt;L7p:HttpRoutingAssertion&gt; &lt;L7p:FailOnErrorStatus booleanValue=&quot;false&quot;/&gt; &lt;L7p:ProtectedServiceUrl stringValue=&quot;${apiLocation}${param.uri}${request.url.query}&quot;/&gt; &lt;L7p:ProxyPassword stringValueNull=&quot;null&quot;/&gt; &lt;L7p:ProxyUsername stringValueNull=&quot;null&quot;/&gt; &lt;L7p:RequestHeaderRules httpPassthroughRuleSet=&quot;included&quot;&gt; &lt;L7p:Rules httpPassthroughRules=&quot;included&quot;&gt; &lt;L7p:item httpPassthroughRule=&quot;included&quot;&gt; &lt;L7p:Name stringValue=&quot;Cookie&quot;/&gt; &lt;/L7p:item&gt; &lt;L7p:item httpPassthroughRule=&quot;included&quot;&gt; &lt;L7p:Name stringValue=&quot;SOAPAction&quot;/&gt; &lt;/L7p:item&gt; &lt;/L7p:Rules&gt; &lt;/L7p:RequestHeaderRules&gt; &lt;L7p:RequestParamRules httpPassthroughRuleSet=&quot;included&quot;&gt; &lt;L7p:ForwardAll booleanValue=&quot;true&quot;/&gt; &lt;L7p:Rules httpPassthroughRules=&quot;included&quot;/&gt; &lt;/L7p:RequestParamRules&gt; &lt;L7p:ResponseHeaderRules httpPassthroughRuleSet=&quot;included&quot;&gt; &lt;L7p:Rules httpPassthroughRules=&quot;included&quot;&gt; &lt;L7p:item httpPassthroughRule=&quot;included&quot;&gt; &lt;L7p:Name stringValue=&quot;Set-Cookie&quot;/&gt; &lt;/L7p:item&gt; &lt;/L7p:Rules&gt; &lt;/L7p:ResponseHeaderRules&gt; &lt;L7p:SamlAssertionVersion intValue=&quot;2&quot;/&gt; &lt;/L7p:HttpRoutingAssertion&gt; &lt;L7p:SetVariable&gt; &lt;L7p:Base64Expression stringValue=&quot;JHtyZXNwb25zZS5odHRwLnN0YXR1c30=&quot;/&gt; &lt;L7p:VariableToSet stringValue=&quot;portal.analytics.response.code&quot;/&gt; &lt;/L7p:SetVariable&gt; &lt;/wsp:All&gt; &lt;wsp:All wsp:Usage=&quot;Required&quot;&gt; &lt;L7p:SetVariable&gt; &lt;L7p:Base64Expression stringValue=&quot;JHtyZXNwb25zZS5odHRwLnN0YXR1c30=&quot;/&gt; &lt;L7p:VariableToSet stringValue=&quot;portal.analytics.response.code&quot;/&gt; &lt;/L7p:SetVariable&gt; &lt;L7p:SetVariable&gt; &lt;L7p:Base64Expression stringValue=&quot;VW5hYmxlIHRvIHJvdXRlIHRvIEFQSS4=&quot;/&gt; &lt;L7p:VariableToSet stringValue=&quot;errorMsg&quot;/&gt; &lt;/L7p:SetVariable&gt; &lt;wsp:OneOrMore wsp:Usage=&quot;Required&quot;&gt; &lt;L7p:ComparisonAssertion&gt; &lt;L7p:CaseSensitive booleanValue=&quot;false&quot;/&gt; &lt;L7p:Expression1 stringValue=&quot;${portal.analytics.response.code}&quot;/&gt; &lt;L7p:ExpressionIsVariable booleanValue=&quot;false&quot;/&gt; &lt;L7p:Operator operatorNull=&quot;null&quot;/&gt; &lt;L7p:Predicates predicates=&quot;included&quot;&gt; &lt;L7p:item dataType=&quot;included&quot;&gt; &lt;L7p:Type variableDataType=&quot;string&quot;/&gt; &lt;/L7p:item&gt; &lt;L7p:item stringLength=&quot;included&quot;&gt; &lt;L7p:Max intValue=&quot;-1&quot;/&gt; &lt;L7p:Min intValue=&quot;1&quot;/&gt; &lt;/L7p:item&gt; &lt;/L7p:Predicates&gt; &lt;/L7p:ComparisonAssertion&gt; &lt;L7p:SetVariable&gt; &lt;L7p:Base64Expression stringValue=&quot;NDA4&quot;/&gt; &lt;L7p:VariableToSet stringValue=&quot;portal.analytics.response.code&quot;/&gt; &lt;/L7p:SetVariable&gt; &lt;/wsp:OneOrMore&gt; &lt;L7p:FalseAssertion/&gt; &lt;/wsp:All&gt; &lt;/wsp:OneOrMore&gt; &lt;L7p:SetVariable&gt; &lt;L7p:Base64Expression stringValue=&quot;JHtyZXF1ZXN0LnJvdXRpbmdUb3RhbFRpbWV9&quot;/&gt; &lt;L7p:VariableToSet stringValue=&quot;portal.analytics.routingTotalTime&quot;/&gt; &lt;/L7p:SetVariable&gt; &lt;L7p:ExportVariables&gt; &lt;L7p:ExportedVars stringArrayValue=&quot;included&quot;&gt; &lt;L7p:item stringValue=&quot;portal.analytics.response.code&quot;/&gt; &lt;L7p:item stringValue=&quot;portal.analytics.routingTotalTime&quot;/&gt; &lt;/L7p:ExportedVars&gt; &lt;/L7p:ExportVariables&gt; &lt;/wsp:All&gt; &lt;/wsp:OneOrMore&gt; &lt;/wsp:All&gt; &lt;/wsp:Policy&gt; </l7:Resource> </l7:ResourceSet> </l7:Resources> </l7:Service> </l7:Resource> </l7:Item> </l7:References> <l7:Mappings> <l7:Mapping action="NewOrUpdate" srcId="43e52d60d4e34c1589c18764de4e3106" type="POLICY" xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management"/> <l7:Mapping action="NewOrUpdate" srcId="144251a872943a3a8be915f4eaf1e69f" type="SERVICE" xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management"/> </l7:Mappings> </l7:Bundle>
The bundle in the previous example can be used to create an API on the proxy via the REST management API (restman) and it contains all the runtime metadata for the API such as its:
  • name
  • state
  • policy template(s)
  • policy template(s) values
  • custom field(s)
  • custom field(s) values.
Create the API on the proxy, using the bundle returned from the previous call:
curl -X PUT -H 'Content-Type: application/xml' \ -u {username}:{password} -d @api-bundle.xml \ https://{proxyHost}/restman/1.0/bundle
Example request:
curl -X PUT -H 'Content-Type: application/xml' \ -u username:password -d @api-bundle.xml \ https://atenant-ssg.dev.ca.com:8443/restman/1.0/bundle
Example response:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <l7:Item xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management"> <l7:Name>Bundle mappings</l7:Name> <l7:Type>BUNDLE MAPPINGS</l7:Type> <l7:TimeStamp>2017-11-30T22:58:31.116Z</l7:TimeStamp> <l7:Link rel="self" uri="https://otk:8447/restman/1.0/bundle"/> <l7:Resource> <l7:Mappings> <l7:Mapping action="NewOrUpdate" actionTaken="CreatedNew" srcId="43e52d60d4e34c1589c18764de4e3106" targetId="43e52d60d4e34c1589c18764de4e3106" targetUri="https://otk:8447/restman/1.0/policies/43e52d60d4e34c1589c18764de4e3106" type="POLICY"/> <l7:Mapping action="NewOrUpdate" actionTaken="CreatedNew" srcId="144251a872943a3a8be915f4eaf1e69f" targetId="144251a872943a3a8be915f4eaf1e69f" targetUri="https://otk:8447/restman/1.0/services/144251a872943a3a8be915f4eaf1e69f" type="SERVICE"/> </l7:Mappings> </l7:Resource> </l7:Item>
Now that the API has been deployed to the proxy, we can update its deployment to denote to other users it has been deployed.
Update the 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": "DEPLOYED"}'
Example request:
curl -X PUT -H 'Authorization: Bearer 14f1f709-1b19-4c29-a0fc-c93cdc683159' -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/43e52d60-d4e3-4c15-89c1-8764de4e3106/proxies/639536fc-230d-434e-8b88-3e13d5069c34 \ -d '{"status": "DEPLOYED", "message": "API deployment successful"}'  Example response:
{ "apiUuid": "43e52d60-d4e3-4c15-89c1-8764de4e3106", "proxyUuid": "639536fc-230d-434e-8b88-3e13d5069c34", "proxyName": "PROD", "lastTimeDeployed": 1512084419249, "status": "DEPLOYED", "message": "Deployment successful" }
Retrieving the API deployments so you can see that the deployment has been updated accordingly:
[ { "apiUuid": "43e52d60-d4e3-4c15-89c1-8764de4e3106", "proxyUuid": "8f6bc46c-a131-4388-b654-1e2b599b0ee9", "proxyName": "DEV", "lastTimeDeployed": 1512084601218, "status": "DEPLOYED" }, { "apiUuid": "43e52d60-d4e3-4c15-89c1-8764de4e3106", "proxyUuid": "639536fc-230d-434e-8b88-3e13d5069c34", "proxyName": "PROD", "lastTimeDeployed": 1512084419249, "status": "DEPLOYED", "message": "Deployment successful" } ]
Redeploy API
Redeploy an API if any of the API properties that impact its deployment to a Proxy are changed.
Examples of the API properties:
  • name
  • state
  • policy template(s)
  • policy template(s) values
  • custom field(s)
  • custom field(s) values
The API deployment status is set back to PENDING_DEPLOYMENT to indicate that API must be redeployed.
To redeploy an API for a proxy configured as scripted, repeat the previous API calls to:
  1. Retrieve the API bundle
  2. update the API on the proxy by making the same restman call using the updated API bundle.
Because API deployments and re-deployments to a proxy are manual, undeploying an API is manual too.
To start, retrieve a delete API bundle using the following command:
curl -H 'Authorization: Bearer {token}' https://{portalApiHost}/{tenantId}/api-management/1.0/apis/{apiUuid}/bundle
Example request which saves the response to api-bundle.xml:
curl -H 'Authorization: Bearer 14f1f709-1b19-4c29-a0fc-c93cdc683159' \ https://apim-ssg-apim-uswest-prod.app.prod.w2.dev.ca.com:443/atenant/api-management/1.0/apis/43e52d60-d4e3-4c15-89c1-8764de4e3106/bundle?type=delete \ -o api-bundle.xml
The following information displays the contents of the api-bundle.xml:
<l7:Bundle xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management"> <l7:Mappings> <l7:Mapping action="Delete" srcId="144251a872943a3a8be915f4eaf1e69f" type="SERVICE" xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management"> </l7:Mapping> <l7:Mapping action="Delete" srcId="43e52d60d4e34c1589c18764de4e3106" type="POLICY" xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management"> </l7:Mapping> </l7:Mappings> </l7:Bundle>
To delete the API on the proxy, use the bundle that is returned from the previous call using the following command:
curl -X PUT -H 'Content-Type: application/xml' \ -u {username}:{password} -d @api-bundle.xml \ https://{proxyHost}/restman/1.0/bundle
Example request:
curl -X PUT -H 'Content-Type: application/xml' \ -u username:password -d @api-bundle.xml \ https://atenant-ssg.dev.ca.com:8443/restman/1.0/bundle
Example response:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <l7:Item xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management"> <l7:Name>Bundle mappings</l7:Name> <l7:Type>BUNDLE MAPPINGS</l7:Type> <l7:TimeStamp>2017-11-30T23:43:50.634Z</l7:TimeStamp> <l7:Link rel="self" uri="https://otk:8447/restman/1.0/bundle"/> <l7:Resource> <l7:Mappings> <l7:Mapping action="Delete" actionTaken="Deleted" srcId="144251a872943a3a8be915f4eaf1e69f" targetId="144251a872943a3a8be915f4eaf1e69f" targetUri="https://otk:8447/restman/1.0/services/144251a872943a3a8be915f4eaf1e69f" type="SERVICE"/> <l7:Mapping action="Delete" actionTaken="Deleted" srcId="43e52d60d4e34c1589c18764de4e3106" targetId="43e52d60d4e34c1589c18764de4e3106" targetUri="https://otk:8447/restman/1.0/policies/43e52d60d4e34c1589c18764de4e3106" type="POLICY"/> </l7:Mappings> </l7:Resource> </l7:Item>
Delete API Deployment
With the API deleted from the proxy, delete the deployment using 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 14f1f709-1b19-4c29-a0fc-c93cdc683159' \ https://apim-ssg-apim-uswest-prod.app.prod.w2.dev.ca.com:443/atenant/deployments/1.0/apis/43e52d60-d4e3-4c15-89c1-8764de4e3106/proxies/639536fc-230d-434e-8b88-3e13d5069c34
Retrieving the API deployments shows that the deployment is deleted:
[ { "apiUuid": "43e52d60-d4e3-4c15-89c1-8764de4e3106", "proxyUuid": "8f6bc46c-a131-4388-b654-1e2b599b0ee9", "proxyName": "DEV", "lastTimeDeployed": 1512001260997, "status": "DEPLOYED" } ]