Medplum.Client (medplum_elixir v0.3.0)

Copy Markdown View Source

Client configuration shared by Medplum API requests.

Summary

Types

Bearer token used directly for authenticated requests.

Authentication strategy used to authorize requests.

Base Medplum URL without a trailing slash.

OAuth client id used for the client credentials grant.

OAuth client secret paired with the client id.

FHIR version segment used in request paths. Defaults to "R4".

Default headers merged into every FHIR request.

Extra Req options forwarded to outgoing requests.

Retry strategy passed through to Req.

t()

Client state used to authenticate requests and build FHIR URLs.

Functions

Builds a Medplum client.

Builds a Medplum client and raises on invalid configuration.

Builds a Medplum client that uses an existing bearer token directly.

Types

access_token()

@type access_token() :: String.t() | nil

Bearer token used directly for authenticated requests.

auth_mode()

@type auth_mode() :: :client_credentials | :access_token

Authentication strategy used to authorize requests.

base_url()

@type base_url() :: String.t()

Base Medplum URL without a trailing slash.

client_id()

@type client_id() :: String.t()

OAuth client id used for the client credentials grant.

client_secret()

@type client_secret() :: String.t()

OAuth client secret paired with the client id.

fhir_version()

@type fhir_version() :: String.t()

FHIR version segment used in request paths. Defaults to "R4".

headers()

@type headers() :: [{String.t(), String.t()}]

Default headers merged into every FHIR request.

req_options()

@type req_options() :: keyword()

Extra Req options forwarded to outgoing requests.

retry()

@type retry() :: false | :safe_transient | :transient

Retry strategy passed through to Req.

t()

@type t() :: %Medplum.Client{
  access_token: access_token(),
  auth_mode: auth_mode(),
  auth_req_options: req_options(),
  base_url: base_url(),
  cache_tokens: boolean(),
  client_id: client_id(),
  client_secret: client_secret(),
  default_headers: headers(),
  fhir_version: fhir_version(),
  max_retries: non_neg_integer(),
  req_options: req_options(),
  retry: retry(),
  token_refresh_skew: non_neg_integer()
}

Client state used to authenticate requests and build FHIR URLs.

Functions

new(opts)

@spec new(keyword() | map()) :: t()

Builds a Medplum client.

The base_url value is normalized by trimming a trailing slash, and fhir_version defaults to "R4" when it is not provided.

By default the client uses the OAuth client credentials grant. When access_token is provided, the client switches to direct bearer-token mode unless auth_mode is set explicitly.

new!(opts)

@spec new!(keyword() | map()) :: t()

Builds a Medplum client and raises on invalid configuration.

new_with_access_token(opts, access_token)

@spec new_with_access_token(keyword() | map(), String.t()) :: t()

Builds a Medplum client that uses an existing bearer token directly.