Kantoor. Karta. Client behaviour
(Kantoor v1.0.0)
Behaviour and dispatcher for Kantoor's calls to Karta (/kantoor/v1).
The shapes follow Karta's own description of the interface (its guide
guides/operations/kantoor.md); docs/karta-contract.md lists them and what
was checked.
Operations:
fetch_raw/2GET /kantoor/v1/messages/:id/raw(optionalRange)delete_delivery/1DELETE /kantoor/v1/deliveries/:idlist_domains/0GET /kantoor/v1/domainssend_raw/2POST /kantoor/v1/messages/raw(data,retention,source=kantoor;auto_reply: truefor the null envelope sender)message/1GET /kantoor/v1/messages/:id(metadata)health/0GET /kantoor/v1/healthattach_domain/2POST /kantoor/v1/endpointsthenPOST /kantoor/v1/routes(one HTTP endpoint and one*route for the domain; both idempotent)set_route_mode/2POST /kantoor/v1/routeswithtakeover: true(mode:endpoint|hold); Karta'sPATCHon a route changes retention onlydomain_routes/1GET /kantoor/v1/domains: the domain's routes as Karta lists them (address, mode, endpoint), with the domain's own keyput_route/4POST /kantoor/v1/routesfor one address: creates it, or takes an existing route at that address over when it already points at the same endpoint
A refusal with a code in Karta's error body is {:error, {:refused, status, code, detail}}; {:http, status} is an answer with no code, or not_found.
The implementation module is Kantoor.Karta.ReqClient unless
config :kantoor, Kantoor.Karta, client: Mod says otherwise. Credentials come
from Kantoor.Karta.Settings; the API key is never logged or inspected.
Summary
Functions
Creates the Karta endpoint (this instance's inbound URL, option :url) and the
* route that delivers the domain to it. domain is the listing entry
("id", "name"). Registering again changes nothing, so a failed attach can
be repeated.
Deletes this Kantoor's delivery (idempotent). Option :domain for per-domain keys.
The routes Karta lists at domain, with the domain's own key. Each route is a
map with at least "local_part", "mode" and "endpoint_id".
Fetches the raw RFC822 bytes. Option :range is {first, last} (inclusive);
:domain names the mail domain when the domain has its own Karta key.
Karta health/contract version.
Lists the domains Kantoor may attach to.
One message's metadata (size, subject, addresses, deliveries).
Creates the route local_part@domain to the endpoint in opts[:endpoint_id],
or takes an existing route at that address over when it already points there
(opts[:takeover], default true). Options: :endpoint_id, :takeover,
:spam_mode (default "mark"), :spam_threshold, :dmarc_reject,
:fail_closed, :plus_addressing.
Sends a raw MIME message. Options: :mail_from, :rcpt_to (list),
:retention ("keep" or days, default "keep").
Switches a domain's route to :endpoint (deliver) or :hold (keep in Karta, do
not push). route is %{domain: name, endpoint_id: id}.
Types
@type error() :: :not_configured | {:http, pos_integer()} | {:refused, pos_integer(), String.t(), String.t() | nil} | {:transport, Exception.t()} | term()
Callbacks
@callback set_route_mode(route :: Kantoor.MailSource.route(), mode :: :endpoint | :hold) :: :ok | {:error, error()}
Functions
Creates the Karta endpoint (this instance's inbound URL, option :url) and the
* route that delivers the domain to it. domain is the listing entry
("id", "name"). Registering again changes nothing, so a failed attach can
be repeated.
Deletes this Kantoor's delivery (idempotent). Option :domain for per-domain keys.
The routes Karta lists at domain, with the domain's own key. Each route is a
map with at least "local_part", "mode" and "endpoint_id".
Fetches the raw RFC822 bytes. Option :range is {first, last} (inclusive);
:domain names the mail domain when the domain has its own Karta key.
Karta health/contract version.
Lists the domains Kantoor may attach to.
One message's metadata (size, subject, addresses, deliveries).
Creates the route local_part@domain to the endpoint in opts[:endpoint_id],
or takes an existing route at that address over when it already points there
(opts[:takeover], default true). Options: :endpoint_id, :takeover,
:spam_mode (default "mark"), :spam_threshold, :dmarc_reject,
:fail_closed, :plus_addressing.
Returns {:ok, route_id, :created | :existing} (:existing covers both a
route that already matched and one taken over).
Sends a raw MIME message. Options: :mail_from, :rcpt_to (list),
:retention ("keep" or days, default "keep").
Switches a domain's route to :endpoint (deliver) or :hold (keep in Karta, do
not push). route is %{domain: name, endpoint_id: id}.