Browse code

Add pin calls

Jaidyn Levesque authored on 2019-06-18 17:18:08
Showing 2 changed files
... ...
@@ -851,6 +851,47 @@
851 851
 
852 852
 
853 853
 
854
+;; —————————————————————————————————————
855
+;; PIN CALLS
856
+
857
+;; STRING [:BOOLEAN] → ALIST || (NIL STRING)
858
+(defun pin-add (path &key (recursive 'T))
859
+  "Pin an object to local storage.
860
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-pin-add"
861
+  (bind-api-alist
862
+    (ipfs-call "pin/add" `(("arg" ,path)("recursive" ,recursive)))))
863
+
864
+;; [:STRING :STRING] → ALIST || (NIL STRING)
865
+(defun pin-ls (&key (path nil) (type "all"))
866
+  "List objects pinned to local storage.
867
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-pin-ls"
868
+  (bind-api-alist
869
+    (ipfs-call "pin/ls" `(,(when path `("arg" ,path)) ("type" ,type)))))
870
+
871
+;; STRING [:BOOLEAN] → ALIAS || (NIL STRING)
872
+(defun pin-rm (path &key (recursive 'T))
873
+  "Remove pinned objects from local storage.
874
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-pin-rm"
875
+  (bind-api-alist
876
+    (ipfs-call "pin/rm" `(("arg" ,path)("recursive" ,recursive)))))
877
+
878
+;; STRING STRING [:BOOLEAN] → ALIST || (NIL STRING)
879
+(defun pin-update (old-path new-path &key (unpin 'T))
880
+  "Update a recursive pin.
881
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-pin-update"
882
+  (bind-api-alist
883
+    (ipfs-call "pin/update"
884
+	       `(("arg" ,old-path)("arg" ,new-path)("unpin" ,unpin)))))
885
+
886
+;; NIL → ALIST || (NIL STRING)
887
+(defun pin-verify ()
888
+  "Verify that recursive pins are complete.
889
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-pin-verify"
890
+  (bind-api-alist (ipfs-call "pin/verify" '())))
891
+
892
+
893
+
894
+
854 895
 ;; —————————————————————————————————————
855 896
 ;; PUBSUB CALLS
856 897
 
... ...
@@ -119,6 +119,13 @@
119 119
     :p2p-stream-close
120 120
     :p2p-stream-ls
121 121
 
122
+    ;; pin calls
123
+    :pin-add
124
+    :pin-ls
125
+    :pin-rm
126
+    :pin-update
127
+    :pin-verify
128
+
122 129
     ;; pubsub calls
123 130
     :pubsub-sub
124 131
     :pubsub-sub-process