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
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.
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:
- 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.
- 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.
- 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:
- Log in to the API Manager user
interface.
- On the Dashboard, by default, you see the development Catalog, called Sandbox.
- Click the Show catalog identifier icon: .
- Copy the Catalog identifier from the Catalog Identifier dialog.
Keep this string handy, because you use it in the following procedure.
- Click
.
- 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.
- The API Manager dashboard displays the App tile.
- Click the Show app identifier icon and copy the App identifier from the App Identifier window.
Keep this string handy, since you use it in the procedure below.
- Complete the following steps in a command console on the machine where you installed the toolkit:
- 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.
- 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.
- 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]
- 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.