Karta. Provisioning. Access
(Karta v1.0.0)
The credentials and webhooks of a provisioned organisation, by the
calling system's references (Karta.Provisioning). They belong to the
organisation's mail server.
Credentials. put_credential/3 makes an API key or an SMTP login
named by reference, or returns the active one with that reference
without a secret: a secret is shown only when it is made. rotate/2 makes
a new secret under the same reference and revokes the old one at once; for
a changeover with no gap, make a second credential under another
reference, move the client, and delete the first. delete_credential/2
revokes. At most 50 credentials are active at a time.
Webhooks. put_webhook/3 makes a webhook named by reference or
updates it, so the URL and events of the system's record are the ones
Karta has; its signing secret is shown when it is made and with
rotate_webhook_secret/2.
Summary
Functions
Revokes the credential; :ok also when there is none.
Removes the webhook; :ok also when there is none.
The active credential with this reference, or nil.
The webhook with this reference (its name), or nil.
The organisation's credentials made through the API, oldest first, revoked ones included.
The organisation's webhooks, oldest first.
Makes the credential or returns it. attrs: kind ("api" or "smtp"),
scopes (API keys; default the scopes to send and read messages) and
rate_limit_per_minute.
Adds the webhook or updates the one with this reference. attrs: url,
format, events, enabled (the format cannot change once made).
{:ok, :created, webhook, secret}, {:ok, :existing, webhook} or
{:error, changeset}.
A new secret for the credential, under the same reference; the old one is
revoked. {:ok, credential, secret} or {:error, :not_found}.
A new signing secret (the old one keeps signing for a day, in Standard Webhooks' format).
Functions
@spec delete_credential(Karta.Accounts.Organisation.t(), String.t()) :: :ok
Revokes the credential; :ok also when there is none.
@spec delete_webhook(Karta.Accounts.Organisation.t(), String.t()) :: :ok
Removes the webhook; :ok also when there is none.
@spec get_credential(Karta.Accounts.Organisation.t(), String.t()) :: Karta.Credentials.Credential.t() | nil
The active credential with this reference, or nil.
@spec get_webhook(Karta.Accounts.Organisation.t(), String.t()) :: Karta.Webhooks.Webhook.t() | nil
The webhook with this reference (its name), or nil.
@spec list_credentials(Karta.Accounts.Organisation.t()) :: [ Karta.Credentials.Credential.t() ]
The organisation's credentials made through the API, oldest first, revoked ones included.
@spec list_webhooks(Karta.Accounts.Organisation.t()) :: [Karta.Webhooks.Webhook.t()]
The organisation's webhooks, oldest first.
@spec put_credential(Karta.Accounts.Organisation.t(), String.t(), map()) :: {:ok, :created, Karta.Credentials.Credential.t(), String.t()} | {:ok, :existing, Karta.Credentials.Credential.t()} | {:error, :kind_differs | :too_many | Ecto.Changeset.t()}
Makes the credential or returns it. attrs: kind ("api" or "smtp"),
scopes (API keys; default the scopes to send and read messages) and
rate_limit_per_minute.
{:ok, :created, credential, secret}; {:ok, :existing, credential}
(its scopes and rate limit are set to the ones given, if any);
{:error, :kind_differs} when the active credential with the reference
is of another kind; {:error, :too_many}; or {:error, changeset}.
@spec put_webhook(Karta.Accounts.Organisation.t(), String.t(), map()) :: {:ok, :created, Karta.Webhooks.Webhook.t(), String.t() | nil} | {:ok, :existing, Karta.Webhooks.Webhook.t()} | {:error, Ecto.Changeset.t()}
Adds the webhook or updates the one with this reference. attrs: url,
format, events, enabled (the format cannot change once made).
{:ok, :created, webhook, secret}, {:ok, :existing, webhook} or
{:error, changeset}.
@spec rotate(Karta.Accounts.Organisation.t(), String.t()) :: {:ok, Karta.Credentials.Credential.t(), String.t()} | {:error, :not_found}
A new secret for the credential, under the same reference; the old one is
revoked. {:ok, credential, secret} or {:error, :not_found}.
@spec rotate_webhook_secret(Karta.Accounts.Organisation.t(), String.t()) :: {:ok, Karta.Webhooks.Webhook.t(), String.t() | nil} | {:error, :not_found | :no_secret}
A new signing secret (the old one keeps signing for a day, in Standard Webhooks' format).