- 1. Create Backend API
- 2. Create an Account for API Consumer
- 3. Create API Product
- 4. Create Application Plan
- 5. Create Application
- 6. Configure Backend API for Product
- 7. Configure Mapping Rules
- 8. Configure Credential Location
- 9. Promote Changes to APIcasts (API Gateways)
- 10. Testing
-
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.
-
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.
-
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.
-
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.
- Name:
-
A new backend should be created.
-
Repeat the steps above to add the Department and Organization service backends.
-
Click on dropdown list menu then select Audience.
-
Click on Create link to create a new account.
-
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.
- Username:
-
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.
-
Click the Edit link next to the application name.
-
Click Delete. The popup will be shown then click OK button.
-
Click on dropdown list menu then select Product.
-
Click on Create Product button.
-
Enter
Human Resource Services
in the Name field then click Create Product button. -
A new API product should be created
-
From the Product Overview dashboard, click on Create Application Plan link.
-
Enter
Free
to the Name field then click Create Application Plan button. -
Application plan should be created.
-
Click on 3 dots menu then select Publish to publish application plan.
-
Click on Application -> Listing menu from left panel.
-
Click Create application button.
-
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
- Account:
-
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.
-
Click on Integration -> Backends from left panel.
-
Click Add Backend button.
-
Enter following details then click Add to Product button.
- Backend:
Employee Service Backend
- Path:
/employee
- Backend:
-
Repeat the steps above to add Department and Organization Backend services.
- Backend:
Department Service Backend
- Path:
/depatment
- Backend:
Organization Service Backend
- Path:
/organization
- Backend:
-
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.
-
Click Create Mapping Rule button.
-
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.
- Verb:
-
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.
- Verb:
-
Organization API
- Verb:
GET
- Pattern:
/organization/organizations
- method or Metric to increment: Select
Metric
option andHits
from dropdown list menu.
- Verb:
-
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.
-
Scroll down to the bottom of the page then click Update Product button.
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.
-
Then click Promote v.1 to Production APIcast button to promote changes to production API gateway.
-
The URLs for both staging and production should be displayed.
-
Click on Applications -> Listing menu from left panel. Then click Test Corp HR Mobile link to open Application dashboard.
-
Copy User Key.
-
Open Postman then update
user-key
variable and click Save button. -
Test the APIs using 3Scale API Testing (API Key Auth) collection.