Managing API Products

Use the apic products and apic apis commands to manage Products and APIs that have been published to API Connect Catalogs. [V5.0.5 or later]Use the --scope space option to manage Products and APIs that have been published to Spaces within Catalogs.

Here's an example of using the products and apis commands through a full lifecycle:

Example command Description
apic config:set catalog=apic-catalog://mgmnthost.com/orgs/climbon/catalogs/sb Set the default Catalog.
apic login --username some-user --password some-password --server mgmnthost.com Login into the mgmnthost.com cloud.
apic create --type api --title Routes --product "ClimbOn" Create the Product and API.
apic publish --stage climbon.yaml Publish the Product to staged status.
apic products List the Products in the Catalog.
apic products:get climbon Display the Product's properties.
apic apis List the APIs in the Catalog.
apic apis:get routes Get the API's properties.
apic products:set climbon --status published Publish the Product, making the API online.
apic apis:set routes --status offline Take the API offline.
apic apis:set routes --status online Bring the API online.
apic products:set climbon --status deprecated Deprecate the Product.
apic products:set climbon --status retired Retire the Product.
apic products:set climbon --status archived Archive the Product.
apic products:delete climbon Delete the Product from the Catalog.
[V5.0.5 or later]Note: If the OpenAPI (Swagger 2.0) file that defines your API uses a $ref field to reference a fragment of OpenAPI (Swagger 2.0) code that is defined in a separate file, the $ref field is replaced with the contents of the target file before the product that contains the API is staged or published with the apic publish command. For more information, see [V5.0.5 or later]Using $ref to reuse code fragments in your OpenAPI (Swagger 2.0) files.

Here's an example of a more complex lifecycle where a new version of a Product and API replaces the original version at runtime.

Set the default Catalog and login to the mgmnthost.com API Connect cloud:

apic config:set catalog=apic-catalog://mgmnthost.com/orgs/climbon/catalogs/sb
apic login --username some-user --password some-password --server mgmnthost.com

Create and publish an initial version:

apic create --type api --title Routes --version 1.0.0 --filename routes100.yaml
apic create --type product --title "Climb On" --version 1.0.0 --apis routes100.yaml --filename climbon100.yaml
apic publish climbon100.yaml

Create a new version to fix a bug in the API, stage it to the Catalog:

apic create --type api --title Routes --version 1.0.1 --filename routes101.yaml
apic create --type product --title "Climb On" --version 1.0.1 --apis routes101.yaml --filename climbon101.yaml
apic publish --stage climbon101.yaml

Inspect the Catalog:

apic products
apic products:get climbon:1.0.0
apic products:get climbon:1.0.1

"Hot-replace" version 1.0.0 with 1.0.1:

apic products:replace climbon:1.0.0 climbon:1.0.1 --plans default:default

In addition to the lifecycle management capabilities, you can download Products and APIs in Catalogs using the pull and clone sub-commands:

Command Description
apic products:clone Download all Products and their APIs from the Catalog.
apic products:pull climbon:1.0.0 Download the climbon:1.0.0 Product and its APIs from the Catalog.
apic apis:clone Download all APIs from the Catalog.
apic apis:pull routes:1.0.0 Download the routes:1.0.0 API from the Catalog.

It can also be useful to clear all products and their APIs from a Catalog, particularly for a development Catalog (you must provide the name of the Catalog as the value of the --confirm parameter):

apic products:clear --confirm catalog_name
where catalog_name is the name of the Catalog.

[V5.0.5 or later]You can use a Space to partition a Catalog so multiple teams can manage Products and APIs independently in a single Catalog. A Space is conceptually like a sub-catalog, except that Products and APIs in all Spaces in a given Catalog are published to the same developer portal. For more information about Spaces, see Using syndication in IBM API Connect®.

To enable Spaces for a Catalog, use the following command:
apic catalogs:set catalog_name --spaces enabled
[V5.0.5 or later]If Spaces are enabled for a Catalog, Products can be staged and published only to a Space within that Catalog. To publish to a Space, the --scope space option must be included in the publish command, for example:
apic publish --scope space product.yaml --space space --catalog catalog --organization organization --server server
where
  • product is the name of the product that you want to publish.
  • space is the name of the Space to publish to.
  • catalog is name of the Catalog that contains the Space.
  • organization is the name of the organization.
  • server is the management server; portnumber is optional (default is 443).
To manage the Products and APIs that have been published to a Space, include the --scope space option with the apic products and apic apis commands. For example, to list the Products that are contained in a Space called flights, use the following command:
apic products --scope space --space flights --catalog production --organization climbonorg --server mgmnthost.com