This walkthrough starts from a Camel integration typed in the console and ends with an address that answers over HTTPS. There is no repository, build file or container image to prepare. You only need a business unit and an environment in which integrations are activated.
1. Create the integration
In Runtime Manager, open Integrations and choose Create Integration. Name it orders-api, create it on its own rather than in a group, keep the source mode on Inline and add this YAML file.
- from:
uri: "rest:get:/orders/{id}"
steps:
- setHeader:
name: Content-Type
constant: application/json
- setBody:
simple: '{"order": "${header.id}", "status": "shipped"}'
- to: "log:info" The route declares a REST endpoint that answers GET requests on /orders followed by an identifier. Whatever is needed to serve HTTP is added to the build for you. Leave the HTTP endpoint option on, since it is what gives the integration a service inside its environment.
2. Deploy it
Bind the integration to an environment and apply the changes. The first time, the environment downloads the dependencies, builds and publishes an image, then starts it, which takes a few minutes. Changing a setting later does not trigger a new build.
curl http://orders-api/orders/42
{"order": "42", "status": "shipped"} At this stage the service can only be reached from inside the environment.
3. Give it a public address
Store a TLS certificate for the host name in Secret Manager and make it available to the environment. Then, in API Manager, create a gateway with an HTTPS access point that uses this certificate. Finally, create an API instance that points to the gateway and its access point, gives the host name and names orders-api as the service that answers.
curl https://orders.example.com/orders/42
{"order": "42", "status": "shipped"} 4. Before sharing the address
The API is now public and answers anyone, so add a security policy before giving the address to anybody. A token or an API key is enough to start with. From there, the integration can move to a Git repository and be deployed as a release, and the Monitoring section already shows its logs, metrics and traces.
Each of these steps is covered in more detail in the documentation.