Manage API Lifecycle with apic

The diagram below show the API lifecycle in API Connect.

To push a local API to a catalog in API Connect Manager and consecutively stage and publish the state of the API, this is the appropriate workflow:

  1. Edit your API on localhost

  2. Login to APIC to get a JSON Web Token

  3. List the Catalogs in API Connect: apic catalogs

  4. Create a new Catalog: apic catalogs:create

  5. Push or Replace a Draft API: apic drafts:push [-r ibm-x-name:version]

  6. List the API Products: apic products:list

  7. Create a new API Product on localhost: apic create --type product

  8. Push an API Product (only the product artifact without the API spec) to the Catalog: apic drafts:push test-product.yaml --product-only

  9. Stage the Product with associated API: apic publish --stage

  10. Publish the Product: apic publish

To find the organization, server etc, urldecode the apim_url parameter in the URL to access API Connect Manager (apim) via your browser,

https://cloud.ibm.com/apis/apiconnect?apim_url=https%3A%2F%2Fapimanager.us-south.
apiconnect.cloud.ibm.com%2Fapim%2F%3Forg%3D1a23bc456de78f901gh23ij4%26region%3D
us-south%26spaceId%3D12345678-a90b-1234-56c7-8d9012345678%26authUrl%3Dhttps%253A%252F%252Fmccp.
us-south.cf.cloud.ibm.com

decodes to

https://apimanager.us-south.apiconnect.cloud.ibm.com/apim/?
org=1a23bc456de78f901gh23ij4&
region=us-south&
spaceId=12345678-a90b-1234-56c7-8d9012345678&
authUrl=https%3A%2F%2Fmccp.us-south.cf.cloud.ibm.com

Note that the organization to be used in apic commands is not your IBM Cloud organization, but a separate API Connect organization.

Login - gets JSON Web Token

$ apic login -u user1@us.ibm.com -p passw0rd -s apimanager.us-south.apiconnect.cloud.ibm.com

List Catalogs

$ apic catalogs --organization 1a23bc456de78f901gh23ij4 --server apimanager.us-south.apiconnect.cloud.ibm.com apic-catalog://apimanager.us-south.apiconnect.cloud.ibm.com/orgs/1a23bc456de78f901gh23ij4/catalogs/sandbox apic-catalog://apimanager.us-south.apiconnect.cloud.ibm.com/orgs/1a23bc456de78f901gh23ij4/catalogs/test

Create Catalog

$ apic catalogs:create Test --name test -o 1a23bc456de78f901gh23ij4 -s apimanager.us-south.apiconnect.cloud.ibm.com Created 1a23bc456de78f901gh23ij4:Test

Push API to Drafts

$ apic drafts:push guestbook-api-swagger.json -o 1a23bc456de78f901gh23ij4 -s apimanager.us-south.apiconnect.cloud.ibm.com

Push API to Drafts replacing specified x-ibm-name:version

$ apic drafts:push guestbook-api-swagger.json -r api-f75f1:1.0.0 -o 1a23bc456de78f901gh23ij4 -s apimanager.us-south.apiconnect.cloud.ibm.com

Your Open API Spec or Swagger definition of the API must include an IBM extension property called x-ibm-name , e.g. api-f75f1 , using <x-ibm-name>:<version> to replace a specific version of your API.

List product

$ apic products:list -o 1a23bc456de78f901gh23ij4 -s apimanager.us-south.apiconnect.cloud.ibm.com appid-test-api:1.0.0 in sl1234567-dev:sandbox [status: published] guestbook-api:1.0.0 in sl1234567-dev:sandbox [status: published] app-id-oauth-proxy-product:1.0.0 in sl1234567-dev:sandbox [status: retired] test-api-product:1.0.0 in sl1234567-dev:sandbox [status: retired]

Create Product on localhost

$ apic create --type product --title "Test-Product" --apis "guestbook-api-swagger.json" Created test-product.yaml product definition [test-product:1.0.0]

Stage product

$ apic drafts:push test-product.yaml --product-only -o 1a23bc456de78f901gh23ij4 -s apimanager.us-south.apiconnect.cloud.ibm.com Pushed test-product.yaml product definition to 1a23bc456de78f901gh23ij4:drafts [test-product:1.0.0]

Publish product to state Staged to catalog

$ apic publish --stage test-product.yaml --catalog test -o 1a23bc456de78f901gh23ij4 -s apimanager.us-south.apiconnect.cloud.ibm.com Staged test-product.yaml to 1a23bc456de78f901gh23ij4:test [test-product:1.0.0]

Publish product to state Published to catalog

apic publish test-product.yaml --catalog test -o 1a23bc456de78f901gh23ij4 -s apimanager.us-south.apiconnect.cloud.ibm.com Staged test-product.yaml to 1a23bc456de78f901gh23ij4:test [test-product:1.0.0] Published test-product.yaml to 1a23bc456de78f901gh23ij4:test [test-product:1.0.0]

Last updated