Hi,
Following up on my blog about getting started using the API Connect v10 REST API calls ( here ) I thought I would share some calls around the API Lifecycle that might be of interest.
All the calls for the API Connect v10 Provider-API are described here https://apic-api.apiconnect.ibmcloud.com/v10/#/IBMAPIConnectPlatformProviderAPI_200/overview but I will list some useful calls around the API Lifecycle from the Provider-API in this blog:
Here $mgmt-url is the URL for the API Manager (you can get all you credentials from the API Manager's "Download Toolkit" tile) and $b is the Bearer Token generated based on those credentials (see my getting started blog for details).
curl -v -k -X GET -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: bearer $b" $mgmt-url/api/orgs/{org}/drafts
curl -v -k -X GET -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: bearer $b" $mgmt-url/api/orgs/{org}/drafts/draft-apis/<API-ID>
curl -v -k -X GET -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: bearer $b" $mgmt-url/api/orgs/{org}/drafts/draft-apis/<API-ID>/document
curl -v -k -X GET -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: bearer $b" $mgmt-url/api/orgs/{org}/drafts/draft-products/<PRODUCT-ID>
curl -v -k -X GET -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: bearer $b" $mgmt-url/api/orgs/{org}/drafts/draft-products/<PRODUCT-ID>/document
curl -v -k -X GET -H 'Accept: application/json' -H "Authorization: bearer $b" https://$mgmt-url/api/catalogs/{org}/{catalog}/products
curl -v -k -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: bearer $b" $mgmt-url/api/orgs/{org}/drafts/draft-apis --data-raw '{"draft_api":{"swagger":"2.0","info":{"title":"theAPI","x-ibm-name":"theapi","version":"v1.0"},"schemes":["https"],"basePath":"/theapi","security":[{"clientID":[]}],"securityDefinitions":{"clientID":{"type":"apiKey","in":"header","name":"X-IBM-Client-Id"}},"x-ibm-configuration":{"phase":"realized","testable":true,"enforced":true,"properties":{"target-url":{"value":"https://randomuser.me/api","description":"The URL of the target service","encoded":false}},"catalogs":{},"cors":{"enabled":true},"application-authentication":{"certificate":false},"assembly":{"execute":[{"invoke":{"title":"invoke","version":"2.0.0","verb":"keep","target-url":"$(target-url)"}}]},"gateway":"datapower-api-gateway","type":"rest"},"paths":{"/getTestResults":{"get":{"responses":{"200":{"description":"Success!","schema":{"type":"object"}}},"consumes":[],"produces":[]}}}}}'
- Create a Draft Product (using API yaml/json & containing the Draft API created above) in your API Manager Provider Organization:
curl -v -k -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: bearer $b" $mgmt-url/api/orgs/{org}/drafts/draft-products --data-raw '{"draft_product":{"info":{"version":"1.0.0","title":"theProduct","name":"theproduct"},"gateways":["datapower-api-gateway"],"plans":{"default-plan":{"title":"Default Plan","description":"Default Plan","rate-limits":{"default":{"value":"100/1hour"}}}},"apis":{"theapiv1.0":{"name":"theapi:v1.0"}},"visibility":{"view":{"type":"public","orgs":[],"tags":[],"enabled":true},"subscribe":{"type":"authenticated","orgs":[],"tags":[],"enabled":true}},"product":"1.0.0"}}'
curl -v -k -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: bearer $b" $mgmt-url/api/catalogs/{org}/dev/publish-draft-product --data-raw '{"draft_product_url":"$mgmt-url/api/orgs/{org}/drafts/draft-products/{product-id}"}'
curl -v -k -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: bearer $b" $mgmt-url/api/catalogs/{org}/test/publish-draft-product --data-raw '{"draft_product_url":"$mgmt-url/api/orgs/{org}/drafts/draft-products/{product-id}"}'
curl -v -k -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: bearer $b" $mgmt-url/api/catalogs/{org}/prod/publish-draft-product --data-raw '{"draft_product_url":"$mgmt-url/api/orgs/{org}/drafts/draft-products/{product-id}"}'
curl -v -k -X POST $mgmt-url/api/catalogs/{org}/{catalog}/publish -H 'Accept: application/json' -H "Authorization: Bearer $b" -H "content-type: multipart/form-data" -F "product=@theproduct_1.0.0.yaml;type=application/yaml" -F "openapi=@theapi_1.0.0.yaml;type=application/yaml"
curl -v -k -X POST $mgmt-url/api/catalogs/{org}/{catalog}/publish -H 'Accept: application/json' -H "Content-Type: multipart/form-data" -H "Authorization: Bearer $b" -F "product=@/directory/file/location/fromwsdlProduct_1.0.0.yaml;type=application/yaml" -F "openapi=@/directory/file/location/fromwsdlAPI_1.0.0.yaml;type=application/yaml" -F "wsdl=@/directory/file/location/Client-backend-system-WSDL.wsdl;type=application/wsdl"
curl -v -k -X PATCH -H 'Accept: application/json' -H 'content-type: application/json' -H "Authorization: bearer $b" -d '{"state": "deprecated"}' https://$mgmt-url/api/catalogs/{org}/{catalog}/products/<PRODUCT-ID>
curl -v -k -X PATCH -H 'Accept: application/json' -H 'content-type: application/json' -H "Authorization: bearer $b" -d '{"state": "retired"}' https://$mgmt-url/api/catalogs/{org}/{catalog}/products/<PRODUCT-ID>
curl -v -k -X PATCH -H 'Accept: application/json' -H 'content-type: application/json' -H "Authorization: bearer $b" -d '{"state": "archived"}' https://$mgmt-url/api/catalogs/{org}/{catalog}/products/<PRODUCT-ID>
curl -v -k -X DELETE -H 'Accept: application/json' -H "Authorization: bearer $b" https://$mgmt-url/api/orgs/{org}/drafts/draft-apis/<API-ID>
curl -v -k -X DELETE -H 'Accept: application/json' -H "Authorization: bearer $b" https://$mgmt-url/api/orgs/{org}/drafts/draft-products/<PRODUCT-ID>
I hope you find this guide useful.
-------------------------------------------------
Nick Cawood
API Connect Consultant
IBM Hybrid Cloud Integration Expert Labs
IBM UK Ltd
https://www.linkedin.com/in/nickcawood/
-------------------------------------------------
#APIConnect