remkohdev
  • Learn to Code
  • About Me
  • CI/CD
    • DevOps101
      • Welcome
  • OpenShift
    • Setup OpenShift
      • Setup Minishift
    • Builds
      • Source-to-Image (S2I)
        • Setup S2I
        • Build, Run, Deploy from Source
      • Jenkins Pipeline
    • Jenkins as a Service
      • Setup Jenkins on Openshift
      • Create a Pipeline for Java Spring Boot
  • Istio
    • Setup Istio on IKS
      • Login to IKS
    • Setup Istio on Openshift 3.11
    • Traffic Shifts with a VirtualService
    • Telemetry of Metrics using Prometheus
    • Telemetry of Distributed Tracing using Jaeger
    • Security with Mutual TLS (mTLS)
  • Apache Kafka
    • Setup Apache Kafka on IBM Cloud
    • Setup Apache Kafka on OpenShift
    • Produce and Consume Streams with Kafka Console Tools
    • Produce and Consume Streams with Spring Boot
    • Using the Event Streams CLI
    • Kafka Admin API
  • API Connect
    • APIC CLI
      • Manage API Lifecycle with apic
    • Securing your API
      • Setup AppID
      • Setup API Connect
      • Optional: Add Node-RED Test Server
      • Add 3rd Party OAuth OIDC
        • Create a Custom AppID API
        • Add a Security Definition to your API
Powered by GitBook
On this page
  • Login - gets JSON Web Token
  • List Catalogs
  • Create Catalog
  • Push API to Drafts
  • Push API to Drafts replacing specified x-ibm-name:version
  • List product
  • Create Product on localhost
  • Stage product
  • Publish product to state Staged to catalog
  • Publish product to state Published to catalog

Was this helpful?

  1. API Connect
  2. APIC CLI

Manage API Lifecycle with apic

PreviousAPIC CLINextSecuring your API

Last updated 5 years ago

Was this helpful?

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]