Connection settings for a Glean deployment.
A config carries the backend domain, an API token and the transport knobs used for every request made with it.
Tokens are scoped
Glean issues separate tokens for the Client and Indexing APIs, and they are not interchangeable. Build one config per scope:
client = Gleanex.new(domain: "mycompany", token: client_token)
indexing = Gleanex.new(domain: "mycompany", token: indexing_token, scope: :indexing)Using the wrong scope fails before the request is sent, with a clear message rather than an opaque 401.
Where settings come from
Highest precedence first:
options passed to
new/1application environment under
:gleanexthe
GLEAN_API_TOKENandGLEAN_INSTANCEenvironment variablesconfig :gleanex, domain: "mycompany", token: {:system, "GLEAN_API_TOKEN"}
Domain and base URL
Glean serves each customer from https://{domain}-be.glean.com, where domain
is usually the email domain without the TLD. The four APIs then live under
different path prefixes, which this module appends for you.
:base_url overrides the host root only — always give it scheme and host with
no path, for example https://mycompany-be.glean.com. The per-API prefix is
still appended.
Summary
Functions
The list of known APIs.
The full base URL for one of the four APIs, including its path prefix.
Check that this config's token scope can be used against api.
Build a config from the application environment and system environment alone.
Build a config.
The path prefix for an API, without the host.
Types
@type api() :: :client | :indexing | :platform | :admin
One of the four Glean APIs.
@type scope() :: :client | :indexing
Which family of token this config holds.
Functions
@spec apis() :: [api()]
The list of known APIs.
The full base URL for one of the four APIs, including its path prefix.
iex> config = Gleanex.new(domain: "mycompany", token: "t")
iex> Gleanex.Config.base_url(config, :client)
"https://mycompany-be.glean.com/rest/api/v1"
iex> Gleanex.Config.base_url(config, :indexing)
"https://mycompany-be.glean.com/api/index/v1"
@spec check_scope(t(), api()) :: :ok | {:error, Gleanex.Error.t()}
Check that this config's token scope can be used against api.
Only the documented hard rule is enforced: Indexing tokens work against the Indexing API and nothing else, and Client tokens work everywhere except the Indexing API.
@spec default() :: t()
Build a config from the application environment and system environment alone.
Used when an operation is called without an explicit :config option.
Build a config.
Raises Gleanex.Error when the token is missing, or when neither :domain
nor :base_url can be resolved.
Options
:domain- backend subdomain, for example"mycompany".:instanceis accepted as an alias, matching the Go SDK'sWithInstance.:base_url- host root override, skipping domain templating.:token- API token. Defaults toGLEAN_API_TOKEN.:scope-:client(default) or:indexing.:retry- aGleanex.Retrypolicy.:receive_timeout- milliseconds to wait for a response, default30_000.:req_options- options passed straight through toReq.
The path prefix for an API, without the host.