Via API Manager¶
Step 1 - Configure Choreo Connect with API Manager¶
- To start Choreo Connect with an existing API Manager instance, follow the steps here
- To start a complete deployment setup that includes an API Manager instance and a Choreo Connect instance already configured to work with API Manager, follow the steps here
Step 2 - Create an API in API Manager¶
Follow the steps here.
Step 3 - Deploy the API in API Manager¶
The guide here will explain how you could easily deploy the API you just created.
That's it! To invoke the API follow the steps here.
During the startup, Choreo Connect will check the
config.toml to see if the
controlPlane.eventHub configuration has been enabled. If so, it will start fetching all the necessary artifacts that belongs to the gateway environment given in
environmentLabels. These artifacts include deployed APIs, Applications, Subscriptions, Polices, information related to Key Managers, etc.
Whenever a new event occurs in API Manager such as an API being deployed, API Manager will notify Choreo Connect via Event Hub. Choreo Connect will then start fetching all the new artifacts related to its environment.
To be able to invoke an API via the Developer Portal TryOut Console, make sure at least one of the certificates used by the enforcer is same as the certificate used by the Key Manager configured in API-M. In Choreo Connect, the certs for enforcer are located at
<CHOREO-CONNECT_HOME>/docker-compose/resources/enforcer/security/truststore. In API-M, Key Managers can be configured from the API-M Admin Portal.
You might find the following content useful here onwards,
Step 4 - Invoke the API¶
After the APIs are exposed via Choreo Connect, you can invoke an API with a valid token (JWT or opaque access token).
Let's use the following command to generate a JWT to access the API, and set it to the variable
Execute the following cURL command to Invoke the API using the JWT.
TOKEN=$(curl -X POST "https://localhost:9095/testkey" -H "Authorization: Basic YWRtaW46YWRtaW4=" -k -v)
curl -X GET "https://<CHOREO-CONNECT_ROUTER_HOST>:<CHOREO-CONNECT_ROUTER_PORT>/<API-context>/<API-resource>" -H "accept:application/xml" -H "Authorization:Bearer $TOKEN" -k
curl -X GET "https://localhost:9095/v2/pet/findByStatus?status=available" -H "accept: application/xml" -H "Authorization:Bearer $TOKEN" -k
Refer to Generate a Test JWT for more details.Top