clj / src / ird / pins.clj
210 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
(ns ird.pins
  "The standard IPFS Pinning Service API (1.0.0) served at /pins — the same
  pins as ird.ipfs but with the spec's {:count :results} envelope and
  requestid addressing, so standard tooling works:
    ipfs pin remote service add ird https://api.ird.ro ird_...
  Use ird.ipfs for the richer native API."
  (:require
   [ird.transport :as transport]))

(defn list-pins
  "GET /pins — List pin objects (Pinning Service API).
  Optional QUERY keys include :cid, :name, :match, :status, :before,
  :after, :limit.
  Returns the parsed response map ({:count :results})."
  ([client] (list-pins client nil))
  ([client query]
   (transport/request client :get "/pins" {:query query})))

(defn add-pin
  "POST /pins — Add a pin (Pinning Service API, 202).
  BODY keys include :cid, :name, :origins, :meta.
  Returns the parsed pin status object."
  [client body]
  (transport/request client :post "/pins" {:body body}))

(defn get-pin
  "GET /pins/{requestid} — Pin object (Pinning Service API).
  Returns the parsed pin status object."
  [client requestid]
  (transport/request client :get (str "/pins/" requestid)))

(defn replace-pin
  "POST /pins/{requestid} — Replace a pin (Pinning Service API, 202).
  BODY keys include :cid, :name, :origins, :meta.
  Returns the parsed pin status object."
  [client requestid body]
  (transport/request client :post (str "/pins/" requestid) {:body body}))

(defn remove-pin
  "DELETE /pins/{requestid} — Remove a pin (Pinning Service API, 202).
  Returns the parsed response map."
  [client requestid]
  (transport/request client :delete (str "/pins/" requestid)))

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