@@ -35,6 +35,8 @@ public enum PinType {all, direct, indirect, recursive}
3535 public final Swarm swarm = new Swarm ();
3636 public final Bootstrap bootstrap = new Bootstrap ();
3737 public final Block block = new Block ();
38+
39+ public final CidAPI cid = new CidAPI ();
3840 public final Dag dag = new Dag ();
3941 public final Diag diag = new Diag ();
4042 public final Config config = new Config ();
@@ -310,6 +312,32 @@ public void sub(String topic, Consumer<Map<String, Object>> results, Consumer<IO
310312 }
311313 }
312314
315+ public class CidAPI {
316+ public Map base32 (Cid hash ) throws IOException {
317+ return (Map )retrieveAndParse ("cid/base32?arg=" + hash );
318+ }
319+
320+ public List <Map > bases (boolean prefix , boolean numeric ) throws IOException {
321+ return (List )retrieveAndParse ("cid/bases?prefix=" + prefix + "&numeric=" + numeric );
322+ }
323+
324+ public List <Map > codecs (boolean numeric , boolean supported ) throws IOException {
325+ return (List )retrieveAndParse ("cid/codecs?numeric=" + numeric + "&supported=" + supported );
326+ }
327+
328+ public Map format (Cid hash , Optional <String > f , Optional <String > v , Optional <String > mc , Optional <String > b ) throws IOException {
329+ String fArg = f .isPresent () ? "&f=" + URLEncoder .encode (f .get ()) : "" ;
330+ String vArg = v .isPresent () ? "&v=" + v .get () : "" ;
331+ String mcArg = mc .isPresent () ? "&mc=" + mc .get () : "" ;
332+ String bArg = b .isPresent () ? "&b=" + b .get () : "" ;
333+ return (Map )retrieveAndParse ("cid/format?arg=" + hash + fArg + vArg + mcArg + bArg );
334+ }
335+
336+ public List <Map > hashes (boolean numeric , boolean supported ) throws IOException {
337+ return (List )retrieveAndParse ("cid/hashes?numeric=" + numeric + "&supported=" + supported );
338+ }
339+
340+ }
313341 /* 'ipfs block' is a plumbing command used to manipulate raw ipfs blocks.
314342 */
315343 public class Block {
@@ -578,21 +606,30 @@ public List<MultiAddress> bootstrap() throws IOException {
578606 }
579607
580608 public class Bootstrap {
581- public List <MultiAddress > list () throws IOException {
582- return bootstrap ();
583- }
584609
585610 public List <MultiAddress > add (MultiAddress addr ) throws IOException {
586611 return ((List <String >)retrieveMap ("bootstrap/add?arg=" +addr ).get ("Peers" )).stream ().map (x -> new MultiAddress (x )).collect (Collectors .toList ());
587612 }
588613
614+ public List <MultiAddress > add () throws IOException {
615+ return ((List <String >)retrieveMap ("bootstrap/add/default" ).get ("Peers" )).stream ().map (x -> new MultiAddress (x )).collect (Collectors .toList ());
616+ }
617+
618+ public List <MultiAddress > list () throws IOException {
619+ return ((List <String >)retrieveMap ("bootstrap/list" ).get ("Peers" )).stream ().map (x -> new MultiAddress (x )).collect (Collectors .toList ());
620+ }
621+
589622 public List <MultiAddress > rm (MultiAddress addr ) throws IOException {
590623 return rm (addr , false );
591624 }
592625
593626 public List <MultiAddress > rm (MultiAddress addr , boolean all ) throws IOException {
594627 return ((List <String >)retrieveMap ("bootstrap/rm?" +(all ? "all=true&" :"" )+"arg=" +addr ).get ("Peers" )).stream ().map (x -> new MultiAddress (x )).collect (Collectors .toList ());
595628 }
629+
630+ public List <MultiAddress > rmAll () throws IOException {
631+ return ((List <String >)retrieveMap ("bootstrap/rm/all" ).get ("Peers" )).stream ().map (x -> new MultiAddress (x )).collect (Collectors .toList ());
632+ }
596633 }
597634
598635 /* ipfs swarm is a tool to manipulate the network swarm. The swarm is the
0 commit comments