@@ -17,6 +17,7 @@ public class IPFS {
1717
1818 public static final Version MIN_VERSION = Version .parse ("0.4.11" );
1919 public enum PinType {all , direct , indirect , recursive }
20+ public enum PinStatus {queued , pinning , pinned , failed }
2021 public List <String > ObjectTemplates = Arrays .asList ("unixfs-dir" );
2122 public List <String > ObjectPatchTypes = Arrays .asList ("add-link" , "rm-link" , "set-data" , "append-data" );
2223 private static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = 10_000 ;
@@ -206,7 +207,10 @@ public List<Multihash> add(Multihash hash) throws IOException {
206207 .map (x -> Cid .decode ((String ) x ))
207208 .collect (Collectors .toList ());
208209 }
209-
210+ public Map addRemote (String service , Multihash hash , Optional <String > name , boolean background ) throws IOException {
211+ String nameArg = name .isPresent () ? "&name=" + name .get () : "" ;
212+ return retrieveMap ("pin/remote/add?arg=" + hash + "&service=" + service + nameArg + "&background=" + background );
213+ }
210214 public Map <Multihash , Object > ls () throws IOException {
211215 return ls (PinType .direct );
212216 }
@@ -217,6 +221,13 @@ public Map<Multihash, Object> ls(PinType type) throws IOException {
217221 .collect (Collectors .toMap (x -> Cid .decode (x .getKey ()), x -> x .getValue ()));
218222 }
219223
224+ public Map lsRemote (String service , Optional <String > name , Optional <List <PinStatus >> statusList ) throws IOException {
225+ String nameArg = name .isPresent () ? "&name=" + name .get () : "" ;
226+ String statusArg = statusList .isPresent () ? statusList .get ().stream ().
227+ map (p -> "&status=" + p ).collect (Collectors .joining ()) : "" ;
228+ return retrieveMap ("pin/remote/ls?service=" + service + nameArg + statusArg );
229+ }
230+
220231 public List <Multihash > rm (Multihash hash ) throws IOException {
221232 return rm (hash , true );
222233 }
@@ -226,12 +237,36 @@ public List<Multihash> rm(Multihash hash, boolean recursive) throws IOException
226237 return ((List <Object >) json .get ("Pins" )).stream ().map (x -> Cid .decode ((String ) x )).collect (Collectors .toList ());
227238 }
228239
240+ public String rmRemote (String service , Optional <String > name , Optional <List <PinStatus >> statusList , Optional <List <Multihash >> cidList ) throws IOException {
241+ String nameArg = name .isPresent () ? "&name=" + name .get () : "" ;
242+ String statusArg = statusList .isPresent () ? statusList .get ().stream ().
243+ map (p -> "&status=" + p ).collect (Collectors .joining ()) : "" ;
244+ String cidArg = cidList .isPresent () ? cidList .get ().stream ().
245+ map (p -> "&cid=" + p .toBase58 ()).collect (Collectors .joining ()) : "" ;
246+ return retrieveString ("pin/remote/rm?service=" + service + nameArg + statusArg + cidArg );
247+ }
248+
249+ public String addRemoteService (String service , String endPoint , String key ) throws IOException {
250+ return retrieveString ("pin/remote/service/add?arg=" + service + "&arg=" + endPoint + "&arg=" + key );
251+ }
252+
253+ public Map lsRemoteService (boolean stat ) throws IOException {
254+ return retrieveMap ("pin/remote/service/ls?stat=" + stat );
255+ }
256+
257+ public String rmRemoteService (String service ) throws IOException {
258+ return retrieveString ("pin/remote/service/rm?arg=" + service );
259+ }
260+
229261 public List <Multihash > update (Multihash existing , Multihash modified , boolean unpin ) throws IOException {
230262 return ((List <Object >)((Map )retrieveAndParse ("pin/update?stream-channels=true&arg=" + existing + "&arg=" + modified + "&unpin=" + unpin )).get ("Pins" ))
231263 .stream ()
232264 .map (x -> Cid .decode ((String ) x ))
233265 .collect (Collectors .toList ());
234266 }
267+ public Map verify (boolean verbose , boolean quite ) throws IOException {
268+ return retrieveMap ("pin/verify?verbose=" + verbose + "&quite=" + quite );
269+ }
235270 }
236271
237272 /* 'ipfs key' is a command for dealing with IPNS keys.
0 commit comments