Onboarding New API Consumer
Steps
1. Create Backend API
Go to OpenShift web console, make sure you're in Administrator perspective, change Project to demo, then go to Networking -> Services menu, and then click on the service you need to expose it's API(s) through API gateway.
expose rest api Copy the Hostname of the service and note the port number as well. Note that we use the Service object hostname instead of the Route's URL because:
the API gateway (APIcast) is deployed on the same cluster so it can internally access the Service in different projects/namespaces.
We need API consumers to access the API via API gateway only so the (public) Route's URL shouldn't be used and should be deleted later.
expose rest api Open 3scale API Management admin web console using the URL and credential provided at the end of the installation process. Then from the main dashboard, click on Create Backend button.
expose rest api Enter following details then click Create Backend button.
Name:
Employee Service Backend
Private Base URL:
http://employee.demo.svc.cluster.local:8080
Note. System name and Description are optional fields.
expose rest api A new backend should be created.
expose rest api Repeat the steps above to add the Department and Organization service backends.
expose rest api
2. Create an Account for API Consumer
Click on dropdown list menu then select Audience.
expose rest api Click on Create link to create a new account.
expose rest api Enter following details then click Create button.
Username:
testcorp
Email:
admin@testcorp.com
Password:
123456
Organization/Group Name:
Test Corp
Note. These are just example input, in reality, these information should be configured properly.
expose rest api A new account as well as a default application should be created. Note that the default application is currently associated with the API Product (the initial Product comes with 3scale after installation).
However, we don't need the default application also we need to create an application and configure the associated product by ourself. So, let's delete the default application by click on the Test Corp's App link to open the application.
expose rest api Click the Edit link next to the application name.
expose rest api Click Delete. The popup will be shown then click OK button.
expose rest api expose rest api
3. Create API Product
Click on dropdown list menu then select Product.
expose rest api Click on Create Product button.
expose rest api Enter
Human Resource Services
in the Name field then click Create Product button.expose rest api A new API product should be created
expose rest api
4. Create Application Plan
From the Product Overview dashboard, click on Create Application Plan link.
expose rest api Enter
Free
to the Name field then click Create Application Plan button.expose rest api Application plan should be created.
expose rest api Click on 3 dots menu then select Publish to publish application plan.
expose rest api
5. Create Application
Click on Application -> Listing menu from left panel.
expose rest api Click Create application button.
expose rest api Enter following details then click Create application button.
Account:
Test Corp
Application plan:
Free
Name:
Test Corp HR Mobile
Description:
Test Corp HR Mobile Application
expose rest api A new application should be created with assigned Application Plan as well as an auto genereated API Key. This API Key will be used as a credential for API calls.
expose rest api
6. Configure Backend API for Product
Click on Integration -> Backends from left panel.
expose rest api Click Add Backend button.
expose rest api Enter following details then click Add to Product button.
Backend:
Employee Service Backend
Path:
/employee
expose rest api Repeat the steps above to add Department and Organization Backend services.
Backend:
Department Service Backend
Path:
/depatment
Backend:
Organization Service Backend
Path:
/organization
expose rest api
7. Configure Mapping Rules
First, let's delete existing default mapping rule. Select Integration -> Mapping Rules menu from left panel, then click on the bin icon to delete the existing mapping rule, and then click OK button to confirm.
expose rest api Click Create Mapping Rule button.
expose rest api Enter following details then click Create Mapping Rule button.
Verb:
GET
(HTTP method for a particular API)Pattern:
/employee/employees
(A particular REST API endpoint exposed via API gateway)method or Metric to increment: Select
Metric
option andHits
from dropdown list menu.
expose rest api Repeat the steps above to create Mapping Rules for the Department (
/department/departments
) and Organization (/organization/organizations
) APIs with follwing details:Department API
Verb:
GET
Pattern:
/department/departments
method or Metric to increment: Select
Metric
option andHits
from dropdown list menu.
Organization API
Verb:
GET
Pattern:
/organization/organizations
method or Metric to increment: Select
Metric
option andHits
from dropdown list menu.
expose rest api
8. Configure Credential Location
By default, 3scale will use API Key as an authentication mode. API consumer must provide the given API Key (credential) along with each API request when sending the request to API Gateway. Again, by default, 3scale will be looking for the credential (API Key) from query paramenters or body parameters based on HTTP methods.
Click on Integration -> Settings menu from left panel. Under the CREDENTIALS LOCATION section, select As HTTP Headers option.
expose rest api Scroll down to the bottom of the page then click Update Product button.
expose rest api
9. Promote Changes to APIcasts (API Gateways)
Once we've configured everything in place in API Manager, we have to promote all changes to API Gateway (APIcast) to apply those changes.
Click on Integration -> Configuration menu from left panel. Then click Promote v.1 to Staging APIcast button to promote changes to staging API gateway.
expose rest api Then click Promote v.1 to Production APIcast button to promote changes to production API gateway.
expose rest api The URLs for both staging and production should be displayed.
expose rest api
10. Testing
Click on Applications -> Listing menu from left panel. Then click Test Corp HR Mobile link to open Application dashboard.
expose rest api Copy User Key.
expose rest api Open Postman then update
user-key
variable and click Save button.expose rest api Test the APIs using 3Scale API Testing (API Key Auth) collection.
Last updated