Chronicle.ExternalServices.DefinitionBuilder (cratis_chronicle v2.2.0)

Copy Markdown View Source

Immutable, pipe-friendly builder for external service definitions.

Mirrors the C# client's IExternalServiceBuilder: http/2 configures an HTTP endpoint, ms_sql/6 and postgre_sql/6 configure a database endpoint (mutually exclusive with http/2 and each other — the last call wins), and with_basic_auth/3, with_bearer_token/2, and with_oauth/4 are likewise mutually exclusive with each other and only meaningful for HTTP endpoints.

Summary

Functions

Builds an external service definition.

Configures the service as an HTTP endpoint.

Configures the service as a Microsoft SQL Server database endpoint.

Creates a new definition builder.

Configures the service as a PostgreSQL database endpoint.

Configures HTTP basic authentication.

Configures HTTP bearer-token authentication.

Adds or replaces an HTTP header sent with every request.

Configures OAuth client-credentials authentication.

Adds a provider-specific option to a database endpoint's connection configuration.

Types

t()

@type t() :: %Chronicle.ExternalServices.DefinitionBuilder{
  authorization: Chronicle.ExternalServices.Definition.authorization() | nil,
  database: String.t(),
  headers: %{optional(String.t()) => String.t()},
  host: String.t(),
  options: %{optional(String.t()) => String.t()},
  password: String.t(),
  port: non_neg_integer(),
  type: :http | :ms_sql | :postgre_sql,
  url: String.t(),
  username: String.t()
}

Functions

build(builder, id, name)

Builds an external service definition.

http(builder, url)

@spec http(t(), String.t()) :: t()

Configures the service as an HTTP endpoint.

ms_sql(builder, host, database, username, password, port \\ 0)

@spec ms_sql(t(), String.t(), String.t(), String.t(), String.t(), non_neg_integer()) ::
  t()

Configures the service as a Microsoft SQL Server database endpoint.

new()

@spec new() :: t()

Creates a new definition builder.

postgre_sql(builder, host, database, username, password, port \\ 0)

@spec postgre_sql(
  t(),
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  non_neg_integer()
) :: t()

Configures the service as a PostgreSQL database endpoint.

with_basic_auth(builder, username, password)

@spec with_basic_auth(t(), String.t(), String.t()) :: t()

Configures HTTP basic authentication.

with_bearer_token(builder, token)

@spec with_bearer_token(t(), String.t()) :: t()

Configures HTTP bearer-token authentication.

with_header(builder, key, value)

@spec with_header(t(), String.t(), String.t()) :: t()

Adds or replaces an HTTP header sent with every request.

with_oauth(builder, authority, client_id, client_secret)

@spec with_oauth(t(), String.t(), String.t(), String.t()) :: t()

Configures OAuth client-credentials authentication.

with_option(builder, key, value)

@spec with_option(t(), String.t(), String.t()) :: t()

Adds a provider-specific option to a database endpoint's connection configuration.