clj / src / ird / sharing.clj
248 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
(ns ird.sharing
  "Delegated access grants: invite other customers to manage parts of a
  domain, and handle invites you receive. Inviting/revoking on a domain is
  subject to the client's domain gate (ird.gate) when configured.

  NOTE: every operation here requires an account JWT (see
  ird.auth/device-login); API keys are not accepted."
  (:require
   [ird.gate :as gate]
   [ird.transport :as transport]))

(defn list-domain-grants
  "GET /domains/registrations/{id}/grants — Who has delegated access to
  this domain (outgoing).
  Returns the parsed response map."
  [client id]
  (transport/request client :get (str "/domains/registrations/" id "/grants")))

(defn invite
  "POST /domains/registrations/{id}/grants — Invite another customer to
  manage parts of this domain. BODY keys include :email, :scopes, :payer,
  :totp_code.
  Returns the parsed response map."
  [client id body]
  (gate/check! client "POST /domains/registrations/{id}/grants" {:registration-id id})
  (transport/request client :post (str "/domains/registrations/" id "/grants")
                     {:body body}))

(defn revoke-grant
  "DELETE /domains/registrations/{id}/grants/{grant-id} — Revoke delegated
  access.
  Returns the parsed response map."
  [client id grant-id]
  (gate/check! client "DELETE /domains/registrations/{id}/grants/{grant-id}" {:registration-id id})
  (transport/request client :delete
                     (str "/domains/registrations/" id "/grants/" grant-id)))

(defn list-grants
  "GET /grants — Domains shared with this account (incoming).
  Returns the parsed response map."
  [client]
  (transport/request client :get "/grants"))

(defn accept-grant
  "POST /grants/{id}/accept — Accept a delegated-access invite.
  Returns the parsed response map."
  [client id]
  (transport/request client :post (str "/grants/" id "/accept")))

(defn decline-grant
  "POST /grants/{id}/decline — Decline a delegated-access invite.
  Returns the parsed response map."
  [client id]
  (transport/request client :post (str "/grants/" id "/decline")))

(defn leave-grant
  "POST /grants/{id}/leave — Walk away from an active grant.
  Returns the parsed response map."
  [client id]
  (transport/request client :post (str "/grants/" id "/leave")))

static mirror of HEAD · about · clone: git clone https://ird.cod-sursa.ro/clj.git