Connect to the API
Choose an API transport and authenticate an integration with a service account.
Use the API to connect your application to OpenETL. This guide assumes that you know HTTP and API authentication.
The API
Everything the CLI and the console do goes through OpenETL's API, served by openetld server. The same API is served four ways:
- REST, with JSON, under
/v1, such asGET /v1/workspaces/default/pipelines. The server serves its OpenAPI description at/openapi.yaml. - Connect, gRPC and gRPC-Web, from the protos in
proto/openetl/api/v1, such asopenetl.api.v1.PipelineService/ListPipelines.
Send an API key in the Authorization: Bearer KEY header. Give each integration a separate service account with the minimum required role:
viewerreads resources.operatorcan also start syncs and pause or resume pipelines.editorcan also apply and delete resources.
openetl principal create reporting
openetl principal grant reporting viewer
openetl key create --out reporting.key reporting
curl -H "Authorization: Bearer $(cat reporting.key)" http://localhost:8080/v1/workspaces/default/pipelinesResponses use protobuf JSON. Enum values use their full names, such as PIPELINE_MODE_SCHEDULED. Durations use seconds, such as 3600s.
Use ApplyService (POST /v1/workspaces/default:apply) to create or update sources, destinations, pipelines and other resources. It accepts the same documents sent by openetl apply.
For check and preflight response fields, see Check results in the API.
Lists
Every List call returns its results a page at a time. Set page_size to the most results you want in one page. If you do not set it, a page holds at most 50 results. A page never holds more than 500.
A response that has more results after it has next_page_token. To get the next page, send that token as page_token, with the same other fields. The last page has no next_page_token. The token is opaque: do not make or change one.
curl -H "Authorization: Bearer $(cat reporting.key)" "http://localhost:8080/v1/workspaces/default/pipelines?page_size=100"ReadSyncLog pages a sync's log the same way. Its page_size is the most log entries in a page, and a page also holds at most 256 KiB of the log.
Errors
An error has a status code, such as FAILED_PRECONDITION, and a message for people. Except for an internal error, it also has a reason: a google.rpc.ErrorInfo detail, whose reason says what went wrong, such as RESOURCE_IN_USE, and whose domain is openetl.io. Some reasons carry metadata, such as used_by, the resources that use the one you tried to delete. API errors lists every reason.
Codes and reasons are stable, so a program can act on them. The message text changes, so do not parse it.
Over REST, the reason is in the response body's details. A call without a credential gets this:
curl http://localhost:8080/v1/workspaces/default/pipelines{
"code": 16,
"message": "sign in, or send an API key as Authorization: Bearer",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "CREDENTIAL_MISSING",
"domain": "openetl.io",
"metadata": {}
}
]
}Over Connect and gRPC, the same ErrorInfo is one of the error's details, which every Connect and gRPC client library reads.