-
Language:
English
-
Language:
English
Getting Started with APIs in Red Hat Integration
Getting Started with APIs in Red Hat Integration
fuse-docs-support@redhat.com
Abstract
Preface
Use the Task API quickstart to learn how to develop and deploy REST APIs with Red Hat Integration.
Chapter 1. Overview
For developing and deploying REST APIs, use these Red Hat Integration components:
- Fuse Online
- Red Hat Fuse is a distributed, cloud-native integration platform. Fuse Online is Red Hat’s web-based Fuse distribution. It is provided pre-installed on the OpenShift Online Professional tier (and also available for installing on an on premise OpenShift cluster). Fuse Online is for business users who prefer low code development.
- Apicurito
- Red Hat provides a lightweight version of the Apicurio Studio API designer, enabling you to create API definitions in OpenAPI (Swagger) format. Apicurito is accessible within the Fuse Online API provider.
- 3scale API Management
- With Red Hat 3scale API Management, API security, performance, control, and monetization are managed for you.
For more details, see Developing and Deploying APIs with Red Hat Integration.
Chapter 2. Viewing, publishing, and discovering the Task API quickstart
2.1. About the Quickstart
The Task Management API quickstart helps you to quickly learn how to configure, publish, and test an API provider integration.
The Task Management API example simulates a simple API that sales consultants might use to track the tasks that they need to do when interacting with customer contacts. Example "to-do" tasks might be "create an account for a new contact" or "place an order for an existing contact".
2.2. Overview of steps for the Quickstart
- Optionally, if you want to view the API in the Apicurito web-based designer, import the provided OpenAPI JSON file.
- Import the provided ZIP file and edit the API operation return codes.
- Publish the Fuse Online integration as an API service to make it available on OpenShift.
- In 3scale API Management, discover the published API service.
2.3. Before you begin
Go to https://github.com/syndesisio/syndesis-quickstarts/tree/1.7 and download these two files:
-
task-api.json
-
TaskAPI-export.zip
2.4. Configuration requirements
Before you can use Red Hat Integration to run the quickstart, make sure that your OpenShift environment meets the following configuration requirements:
- Your OpenShift Container Platform (OCP) on premise administrator must deploy Fuse Online and 3scale API Management on the same cluster.
The published API service must have the correct 3scale annotations.
Fuse Online automatically adds the correct annotations if the CONTROLLERS_EXPOSE_VIA3SCALE environment variable is set to true before you publish the API.
- The 3scale API Management administrator must configure 3scale for service discovery.
For Fuse Online, the default behavior is that APIs are not exposed for automatic discovery in 3scale. The OpenShift administrator must configure Fuse Online to enable 3scale discovery. You need OpenShift administrator permissions to verify this setting as follows:
On OpenShift 4.x:
- In OpenShift, open the Fuse Online project.
- On the Project Status page, select syndesis-server.
- Select Actions > Edit Environment.
- On the Environment page, verify that the CONTROLLERS_EXPOSE_VIA3SCALE variable is set to true.
On OpenShift 3.11:
- In OpenShift, open the Fuse Online project.
- Select Applications> Deployments, and then select syndesis-server.
- Click the Environment tab.
- Verify that the CONTROLLERS_EXPOSE_VIA3SCALE variable is set to true.
2.5. Viewing the API in Apicurito (optional)
- In Fuse Online, in the left navigation panel, click Integrations.
- Click Create Integration.
- On the Choose a connection page, click the API Provider card.
-
For the Upload an OpenAPI file option, drag and drop the
task-api.json
file that you downloaded. Fuse Online indicates that it has successfully imported the file. - Click Next.
Click Review/Edit.
The API opens in Apicurito.
Explore the structure of the API.
It has two paths:
-
/todo
for tasks -
/todo/{id}
for a specific task
-
And three operations:
- Create a task
- Get a task by its ID
- Delete a task by its ID
To save time, rather than building the integration from the OpenAPI specification, you can use the already built integration that is also provided with the quickstart download.
- Cancel and confirm the cancellation until you return to the Fuse Online dashboard.
2.6. Importing and completing the Task API integration in Fuse Online
- In Fuse Online, in the left navigation panel, click Integrations.
- In the upper right, click Import.
-
Drag and drop the
TaskAPI-export.zip
file that you downloaded. Fuse Online shows a message to indicate that it has successfully imported the file. - In the left navigation panel, click Integrations to see an entry for the Task API integration that you just imported. The entry indicates that configuration is required.
Open the integration editor:
- In the row for the Task API entry, select .
- Click Edit to display a list of the operations that the API provides.
Configure the flow for the Create Task operation:
- In the row for the POST operation, click Create flow.
- In the operation flow visualization panel, scroll down to Provided API Return Path at the end of the flow.
- Click Configure.
- For the Return Code field, select 201 Created.
- Click Next.
- Return to the list of operations by selecting Task API at the top of the page.
- Repeat step 6 for the Delete and Get operations to change the return codes from 501 to 200.
2.7. Publishing the integration in Fuse Online
- Click Save.
On the Save the integration page, accept the default Name and click Save and publish.
Fuse Online displays the Integration Summary page and shows the publication progress as it assemblies, builds, deploys, and starts the integration.
When the Published message appears, the API is available for discovery by 3scale.
2.8. Discovering the published API in 3scale
- Log in to the 3scale Administration Portal.
- From the Admin Portal’s Dashboard, click New API.
- Choose Import from OpenShift.
-
In the Namespace field, specify or select the OpenShift project that contains the API, for example
fuse
. -
In the Name field, type or select the name of an OpenShift service within that namespace, for example
i-task-api
. - Click Create Service.
-
Wait for the new API service to be asynchronously imported into 3scale. A message appears in the upper right section of the Admin Portal:
The service will be imported shortly. You will receive a notification when it is done.
2.9. Next steps
See the Red Hat 3scale API Management documentation for information about managing the API.