Tutorial: Publishing a project from the command line

This tutorial shows you how to publish a LoopBack® project from the command line in IBM® API Connect Version 5.0.7 and later. You publish a LoopBack project to make its APIs available to application developers through the Developer Portal.

Before you begin

Note: For tutorials about working with the developer toolkit in IBM API Connect Version 5.0.6 and earlier, see Developer toolkit tutorials for V5.0.6 and earlier.

Before you begin, you must install the developer toolkit on your local machine. For details, see Installing the toolkit.

The following diagram shows the sequential flow through the IBM API Connect Developer toolkit tutorials for working with LoopBack projects. Before beginning a tutorial, ensure that you have completed the previous tutorials in the sequence. You can click a tutorial in the diagram to open the instructions for that tutorial.
Tutorial flow diagram for working with LoopBack projects Installing the toolkit Tutorial: Creating a LoopBack project from the command line Tutorial: Creating a model and a data source from the command line Tutorial: Creating a model and a data source in the API Designer Tutorial: Testing a LoopBack project Tutorial: Publishing a project from the command line Tutorial: Staging and publishing a project from the API Designer
Also ensure your current working directory is the project top-level directory. Enter the following command:
cd acme-bank

To stage or publish to API Connect collective, you must install and configure an API Connect collective. You must add a Collective and a Collective controller by using the Cloud Manager. See Installing an API Connect collective.

Note: IBM API Connect collectives are deprecated in IBM API Connect Version 5.0.7 in favor of container runtimes. However, for this tutorial you will continue to publish to an API Connect collective.
You must also fulfill the following additional prerequisites to stage or publish project:
  1. You must be the owner of a provider organization, or have been added to a provider organization as a user with the Publisher role. For details on creating a provider organization and specifying the owner, see Creating a provider organization account. For details on adding a user to a provider organization with the Publisher role, see Adding users and assigning roles.
  2. You must have followed the instructions in the provider organization email invitation to activate your API Connect account.

About this tutorial

In this tutorial, you will publish a LoopBack project to an API Connect collective from the command line.

Display general command-line help information by entering the following command: apic --help or apic -h. Display help information for a specific apic command by entering the following command: apic command_name --help or apic command_name -h.

Publishing a project to API Connect collective from the command line

Be sure you have added the API Connect collective and a Collective controller to the Cloud Manager as described in Installing an API Connect collective.

Note: If your application has binary modules (for example, if it uses the DB2®, SQLLite3, or Oracle connectors), then you must create the application on the same type of platform as that of the target API Connect collective.
  1. Obtain the identifier for the development Catalog, to which you will publish your project, by completing the following steps in the API Manager user interface:
    1. Log in to the API Manager user interface.
    2. On the Dashboard, by default, you see the development Catalog, called Sandbox.
      Sandbox Catalog
    3. Click the Show catalog identifier icon: Show catalog identifier.
    4. Copy the Catalog identifier from the Catalog Identifier dialog.
      Catalog Identifier dialog

      Keep this string handy, because you use it in the following procedure.

    5. Click Add Add > App.
    6. In the Add App dialog, enter Acme Bank for Display Name, and keep the automatically-generated default value of Name. Select the collective you created previously, then click Add.
    7. The API Manager dashboard displays the App tile.
      Acme Bank App tile
    8. Click the Show app identifier icon Show app identifier and copy the App identifier from the App Identifier window.
      App Identifier dialog

      Keep this string handy, since you use it in the procedure below.

  2. Complete the following steps in a command console on the machine where you installed the toolkit:
    1. If you haven't already done so, log in to API Manager by entering the following command:
      apic login -s API_manager_hostname -u username -p password
      where API_manager_hostname is the server name or IP address of the API Manager, username is your API Manager user name and password is your API Manager password.
    2. Paste the command strings you copied in steps 1.d and 1.h into your command line console. For example:
      apic config:set catalog=apic-catalog://API_manager_hostname/orgs/climbon/catalogs/sb
      apic config:set app=apic-app://API_manager_hostname/orgs/climbon/apps/acme-bank
      where API_manager_hostname is the server name or IP address of the API Manager.
    3. Ensure your current working directory is the project root directory (acme-bank). Publish the Product by entering the following command:
      apic publish -s API_manager_hostname definitions/acme-bank-product.yaml
      where API_manager_hostname is the server name or IP address of the API Manager. The console displays messages that confirm the Product has been published, for example:
      Staged definitions/acme-bank-product.yaml to climbon:sb [acme-bank1:1.0.0]
      Published definitions/acme-bank-product.yaml to climbon:sb [acme-bank1:1.0.0]
    4. Publish the application by entering the following command:
      apic apps:publish
      The console displays messages such as this:
      ...preparing project
      ...building package for deploy
      ...uploading packages to 161.51.151.222:9443, scale: 1
      Upload successful: acme-bank-5707fc46e4b07dfbe0999be6-1460148297009-package.tgz
      Upload successful: acme-bank-5707fc46e4b07dfbe0999be6-1460148297009.deploy.xml
      Upload successful: apic.acme-bank-5707fc46e4b07dfbe0999be6-1460148297009.scalingPolicy.xml
      
      Upload to liberty server completed succesfully.
      Applications may take a few minutes to update and start.
      Collectives admin center: https://161.51.151.222:9443/adminCenter.

The project is now published to your API Connect collective.

What you did in this tutorial

In this tutorial, you published a project to API Connect collective by using the command-line tools.

What to do next

If you want to use an application with a DataPower® Gateway, configure your collective and gateway and then modify your assembly. For more information, see Configuring your DataPower Gateway and API Connect collective controller to communicate and Modifying the assembly to call an application endpoint hosted on a collective.