Browse code

Add object calls (er, most of them)

Jaidyn Levesque authored on 2019-06-18 08:22:59
Showing 2 changed files
... ...
@@ -718,6 +718,68 @@
718 718
 
719 719
 
720 720
 
721
+;; —————————————————————————————————————
722
+;; OBJECT CALLS
723
+
724
+;; STRING → STRING || (NIL STRING)
725
+(defun object-data (key)
726
+  "Output the raw data of an IPFS object.
727
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-object-data"
728
+  (bind-api-result (ipfs-call "object/data" `(("arg" ,key))) result))
729
+
730
+;; STRING STRING → ALIST || (NIL STRING)
731
+(defun object-diff (object-a object-b)
732
+  "Display the differences between two IPFS objects.
733
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-object-diff"
734
+  (bind-api-alist
735
+    (ipfs-call "object/diff" `(("arg" ,object-a)("arg" ,object-b)))))
736
+
737
+;; STRING [:STRING] → STRING || (NIL STRING)
738
+(defun object-get (key &key (data-encoding "text"))
739
+  "Get and serialize the named DAG node.
740
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-object-get"
741
+  (bind-api-result
742
+    (ipfs-call "object/get" `(("arg" ,key)("data-encoding" ,data-encoding)))
743
+    result))
744
+
745
+;; STRING → ALIST || (NIL STRING)
746
+(defun object-links (key)
747
+  "Output the links pointed to by the specified object.
748
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-object-links"
749
+  (bind-api-alist (ipfs-call "object/links" `(("arg" ,key)))))
750
+
751
+;; [:STRING] → ALIST || (NIL STRING)
752
+(defun object-new (&key (template nil))
753
+  "Create a new object from an IPFS template.
754
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-object-new"
755
+  (bind-api-alist
756
+    (ipfs-call "object/new"`(,(if template `("template" ,template))))))
757
+
758
+;; STRING STRING STRING [:BOOLEAN] → ALIST || (NIL STRING)
759
+(defun object-patch-add-link (hash name object &key (create ""))
760
+  "Add a link to a given object.
761
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-object-patch-add-link"
762
+  (bind-api-alist
763
+    (ipfs-call "object/patch/add-link"
764
+	       `(("arg" ,hash)("arg" ,name)("arg" ,object)
765
+		 ,(when (not (empty-string-p create)) `("create" ,create))))))
766
+
767
+;; STRING STRING → ALIST || (NIL STRING)
768
+(defun object-patch-rm-link (hash name)
769
+  "Remove a link from a given object.
770
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-object-patch-rm-link"
771
+  (bind-api-alist
772
+    (ipfs-call "object/patch/rm-link" `(("arg" ,hash)("arg" ,name)))))
773
+
774
+;; STRING → ALIST || (NIL STRING)
775
+(defun object-stat (key)
776
+  "Get stats for a DAG node.
777
+  /ipns/docs.ipfs.io/reference/api/http/#api-v0-object-stat"
778
+  (bind-api-alist (ipfs-call "object/stat" `(("arg" ,key)))))
779
+
780
+
781
+
782
+
721 783
 ;; —————————————————————————————————————
722 784
 ;; PUBSUB CALLS
723 785
 
... ...
@@ -101,6 +101,17 @@
101 101
     :name-pubsub-subs
102 102
     :name-resolve
103 103
 
104
+    ;; object calls
105
+    :object-data
106
+    :object-diff
107
+    :object-get
108
+    :object-links
109
+    :object-new
110
+    :object-patch-add-link
111
+    :object-patch-rm-link
112
+    :object-stat
113
+    ;; absentees— :object-put, :object-set-data, :object-patch-append-data
114
+
104 115
     ;; pubsub calls
105 116
     :pubsub-sub
106 117
     :pubsub-sub-process