$ docker-compose -f docker-compose-microgateway.yaml up -d
The command will take a while to start all services.
Confirm that the IBM API Connect services are running by entering the following command,
$ docker-compose -f docker-compose-microgateway.yaml ps
You should see a response similar to the following.
Name Command State Ports
--------------------------------------------------------------------------------------
apim /tini -- /startup.sh Up
esmaster /docker-entrypoint.sh /bin ... Up 9200/tcp, 9300/tcp
ibmlogstash /bin/sh -c /startup.sh Up
ibmportal /root/tini -- /root/start_ ... Up
make-ssh-keys /bin/sh -c /genkey.sh Exit 0
microgateway /bin/sh -c /usr/bin/app.sh ... Up
microservice /bin/sh -c /usr/bin/app.sh ... Up 8080/tcp
nginx /bin/sh -c /run.sh Up 0.0.0.0:443->443/tcp, 80/tcp
Service make-ssh-keys
has completed and exited.
To enable access to all the services, edit your local /etc/hosts file to map the IP address of your Docker host to the IBM API Connect host names,
<docker-host-ip> apim ibmportal microgateway microservice
-
In a web browser, enter the URL https://apim/cmc/, the cloud console login window opens.
-
Log in with the following credentials:
Username: admin Password: !n0r1t5@C
-
Accept the license agreement.
-
On the
Create your profile
page, enter your email address, and a new password, then clickUpdate profile
. The Cloud Manager user interface opens. -
Make sure the SMTP service is reachable. Click
Settings
, selectEmail
, fill in information, and selectTest Configuration
. -
Add a new provider organization In the Cloud Manager, click
Organizations
. ClickAdd
, and enterDisplay Name: <organization_display_name> Name: <organization_name>
Note: The value of the Name field is included in the organization segment of the URL for API calls
Click
New User
, and enterEmail: <your_email>
Click
Add
to create the provider organization. An invitation email is sent to the specified email address.In the invitation email, click the activation link and follow the instructions to sign up.
Enter your name and password, and click
Sign Up
.When you have completed the sign up instructions, the login page for the API Manager user interface opens; log in with your email address and password.
-
If it is not already open, launch the API Manager user interface in a browser by entering URL https://apim/apim/. Log in with your email and password.
-
Click the
Navigate to
icon . The API Manager UI navigation pane opens. ClickDashboard
. -
Click the
Sandbox
catalog to display its details. -
Customize the gateway endpoint Select the Sandbox catalog, click
Settings
>Endpoints
. And addCustom Gateway URL: https://microgateway/
-
Enable Portal in the Sandbox catalog
Click
Portal
.From
Select Portal
drop down, selectIBM Developer Portal
. The URL is set automatically to:https://ibmportal/organization_name/sb
, where organization_name is the Name value that you specified when you created the provider organization in step 2.click
Save
icon to save your Developer Portal configuration.After a few minutes, you will receive an email with a link to the Developer Portal site for the
Sandbox
catalog. The link is a single use only link for the administrator account. When the link is active and you have accessed it, you can change the password of this administrator account.
-
If you have not, install IBM API Connect Toolkit on your host.
$ npm install -g apiconnect
For more details, see Install Toolkit.
-
Log into the API Connect server
$ cd microservice $ apic login Enter the API Connect server ? Server: apim ? Username: <your_apim_account_email> ? Password (typing will be hidden) ******** Logged into apim successfully
-
Publishing the microservice application
$ apic publish definitions/loopback-example-database-product.yaml --catalog sb --organization organization_name --server apim
where organization_name is the Name value that you specified when you created the provider organization in step 2.
-
In a web browser, enter url https://ibmportal/organization_name/sb/. where organization_name is the Name value that you specified when you created the provider organization in step 2.
You can see the
loopback-example-database 1.0.0
microservice in theFeatured APIs
pane. -
Create a developer account
Note: You cannot use the same email address as the one you used in step 2 when creating your provider organization, because this email address is used for the Developer Portal admin account.
Click
Create an account
, enter answers for the following itemsE-mail address Password Confirm password First name Last name Developer organization What code is in the image?
An invitation email is send to the specified email address. Follow the account activation link in the confirmation email to activate your account.
-
Log in as a developer
To use the Developer Portal, click
Login
and sign in with the user credentials you just specified. -
Creating a new App in Developer Portal
In the Developer Portal, click
Apps
>Create new App
, enterTitle: microservice Description: <your_description>
Click
Submit
. Your application is displayed. -
Select the
Show Client Secret
check box and make a note of your client secret because it is displayed only once. You must supply the client secret when you call an API that requires you to identify your application by using a client ID and client secret.Note: The client secret cannot be retrieved. If you forget it, you must reset it.
-
Optional: The client ID is hidden, to display the client ID for your application, select the Show check box for Client ID. The client ID is displayed and can be hidden again by clearing the check box.
-
Optional: You can add an additional client ID and client secret to the application. For more details, see Registering an application
-
Subscribe to a plan
Select
API Products
, then clickloopback-example-database 1.0.0
to open the Product detail page. ClickSubscribe
to subscribe to the default plan. Checkmicroservice
application, clickSubscribe
.Note: it will take up to 10 minutes for Micro Gateway to get synced with APIM. After then the subscription credentials will be accepted by Micro Gateway.
Note: In the following examples, we are using a sample of Client ID and Client Secret from the previous step. You must replace these values with your own credentials from step 5.
Client ID: ad37d0e2-4551-41f7-a011-88f0447f4560
Client Secret: yY7xL8hA0iD1tR0qD5hY0kG3rR3nC2eA3mM8iN2yL4hD2bQ2gU
-
Accessing POST API via Micro Gateway
$ curl -k --request POST \ --url https://microgateway/api/Accounts \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-ibm-client-id: ad37d0e2-4551-41f7-a011-88f0447f4560' \ --header 'x-ibm-client-secret: yY7xL8hA0iD1tR0qD5hY0kG3rR3nC2eA3mM8iN2yL4hD2bQ2gU' \ --data '{"email":"[email protected]","createdAt":"2016-11-26T15:29:45.233Z","lastModifiedAt":"2016-11-25T20:17:02.033Z"}'
-
Accessing GET API via Micro Gateway
$ curl -k --request GET \ --url 'https://microgateway/api/Accounts' \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-ibm-client-id: ad37d0e2-4551-41f7-a011-88f0447f4560' \ --header 'x-ibm-client-secret: yY7xL8hA0iD1tR0qD5hY0kG3rR3nC2eA3mM8iN2yL4hD2bQ2gU'