@@ -19,6 +19,7 @@ public enum PinType {all, direct, indirect, recursive}
1919 public final String host ;
2020 public final int port ;
2121 private final String version ;
22+ public final Key key = new Key ();
2223 public final Pin pin = new Pin ();
2324 public final Repo repo = new Repo ();
2425 public final IPFSObject object = new IPFSObject ();
@@ -181,6 +182,14 @@ public List<MultiAddress> update(Multihash existing, Multihash modified, boolean
181182 }
182183 }
183184
185+ /* 'ipfs repo' is a plumbing command used to manipulate the repo.
186+ */
187+ public class Key {
188+ public Object gen (String name , Optional <String > type , Optional <String > size ) throws IOException {
189+ return retrieveAndParse ("key/gen?arg=" + name + type .map (t -> "&type=" + t ).orElse ("" ) + size .map (s -> "&size=" + s ).orElse ("" ));
190+ }
191+ }
192+
184193 /* 'ipfs repo' is a plumbing command used to manipulate the repo.
185194 */
186195 public class Repo {
@@ -299,11 +308,11 @@ public MerkleNode patch(Multihash base, String command, Optional<byte[]> data, O
299308
300309 public class Name {
301310 public Map publish (Multihash hash ) throws IOException {
302- return publish (Optional .empty (), hash );
311+ return publish (hash , Optional .empty ());
303312 }
304313
305- public Map publish (Optional <String > id , Multihash hash ) throws IOException {
306- return retrieveMap ("name/publish?arg=" + ( id .isPresent () ? id + "&arg =" : "" ) + "/ipfs/" + hash );
314+ public Map publish (Multihash hash , Optional <String > id ) throws IOException {
315+ return retrieveMap ("name/publish?arg=/ipfs/ " + hash + id .map ( name -> "&key =" + name ). orElse ( "" ) );
307316 }
308317
309318 public String resolve (Multihash hash ) throws IOException {
0 commit comments