A client for the EndPointBlank organization management API (/api/v1,
sc-1504): your organization, API packages, clients and what they hold,
applications, environments, runtime credentials and managed clients.
It is separate from the runtime SDK on purpose. It reads none of
EndPointBlank.configure/1's settings and sends none of them: the only
credential it sends is the management key you give it, as
Authorization: Bearer epb_mk_..., and only to :base_url. Create a
management key in the portal; keys cannot be created through the API.
mgmt = EndPointBlank.Management.new(key: System.fetch_env!("EPB_MGMT_KEY"))
{:ok, organization} = EndPointBlank.Management.Organization.get(mgmt)One module per resource, each taking this client first:
EndPointBlank.Management.OrganizationEndPointBlank.Management.ApiPackages(and what a package publishes)EndPointBlank.Management.EndpointsEndPointBlank.Management.ClientsEndPointBlank.Management.ClientPackagesEndPointBlank.Management.ClientGrantsEndPointBlank.Management.ApplicationsEndPointBlank.Management.ApplicationEnvironmentsEndPointBlank.Management.EnvironmentsEndPointBlank.Management.CredentialsEndPointBlank.Management.ManagedClients
Results
Every call answers {:ok, result} or {:error, %EndPointBlank.Management.Error{}}
and never raises. result is the API's data, decoded JSON with string
keys. A list call answers one EndPointBlank.Management.Page; the matching
stream function pages through all of them lazily and raises the error
instead, since a stream cannot answer a tuple.
Retries and idempotency
Every POST sends an Idempotency-Key: a random UUID, or the one passed as
idempotency_key:. A retry sends the same key, so the API runs the request
once. The client retries, up to :max_retries times:
- a
429 rate_limitedanswer, after itsRetry-Afterseconds (any method); - a
409 idempotency_request_in_progressanswer (a POST); - a 5xx answer or a request that got no answer, for GET, DELETE and POST only. A PATCH is never retried for these.
409 idempotency_replay_unavailable is never retried: the first request
succeeded and its answer held a credential secret shown once. Get or list
the credential instead.
Managed clients
for_managed_client/2 gives a client that acts on one of your unclaimed
managed clients' applications, environments and credentials, under
/api/v1/clients/:client_id/....
Summary
Functions
The base URL every call goes to.
A client that acts on your managed client client_id's organization: the
Applications, ApplicationEnvironments, Environments and Credentials
modules then call /api/v1/clients/:client_id/.... Every other module
refuses it with "not_available_for_managed_client", without a request.
Builds a management client. Raises ArgumentError for a bad option; the
message never repeats the key.
Types
@type result(value) :: {:ok, value} | {:error, EndPointBlank.Management.Error.t()}
What every management call answers.
@type t() :: %EndPointBlank.Management{ base_url: String.t(), key: String.t(), managed_client_id: String.t() | nil, max_retries: non_neg_integer(), max_retry_wait_ms: non_neg_integer(), receive_timeout: pos_integer(), req_options: keyword(), sleep: (non_neg_integer() -> any()) }
Functions
The base URL every call goes to.
A client that acts on your managed client client_id's organization: the
Applications, ApplicationEnvironments, Environments and Credentials
modules then call /api/v1/clients/:client_id/.... Every other module
refuses it with "not_available_for_managed_client", without a request.
The API answers 404 once the customer has claimed the client.
Builds a management client. Raises ArgumentError for a bad option; the
message never repeats the key.
Options:
:key(required) -- a management API key,epb_mk_....:base_url-- defaults tohttps://app.endpointblank.com.:max_retries-- how many times one call is retried (see the module docs). Defaults to 2;0turns retries off.:max_retry_wait_ms-- the longestRetry-Afterthe client waits out (default 60 000). A longer one is answered as therate_limitederror, with:retry_afterset.:receive_timeout-- per attempt, in milliseconds (default 15 000).:sleep-- the function that waits between retries, given milliseconds. Defaults toProcess.sleep/1; tests pass their own.:req_options-- extraReqoptions for every request (for exampleplug:in tests). Options this client sets itself win, and:authis dropped: the only credential sent is the management key.