diff --git a/src/Api/Basics.php b/src/Api/Basics.php index 9c9c29f..06c9d4b 100644 --- a/src/Api/Basics.php +++ b/src/Api/Basics.php @@ -24,11 +24,11 @@ final class Basics implements Api { /** - * Add a file to ipfs. + * Add a file or directory to ipfs. * * @Endpoint(name="add") * - * @param string $file the path to a file to be added to IPFS + * @param string $file the path to a file to be added to ipfs * @param bool $recursive add directory paths recursively * @param bool $quiet write minimal output * @param bool $silent write no output @@ -39,10 +39,11 @@ final class Basics implements Api * @param bool $hidden include files that are hidden * @param string $chunker chunking algorithm to use * @param bool $pin pin this object when adding + * @param bool $rawLeaves use raw blocks for leaf nodes * * @return Command */ - public function add(string $file, bool $recursive = false, bool $quiet = false, bool $silent = false, bool $progress = null, bool $trickle = false, bool $onlyHash = false, bool $wrapWithDirectory = false, bool $hidden = false, string $chunker = null, bool $pin = true): Command + public function add(string $file, bool $recursive = false, bool $quiet = null, bool $silent = null, bool $progress = null, bool $trickle = null, bool $onlyHash = null, bool $wrapWithDirectory = null, bool $hidden = null, string $chunker = null, bool $pin = true, bool $rawLeaves = null): Command { return new Command(__METHOD__, get_defined_vars()); } @@ -76,7 +77,7 @@ public function commands(bool $flags = false): Command } /** - * DNS link resolver. + * Resolve DNS links. * * @Endpoint(name="dns") * @@ -109,7 +110,7 @@ public function get(string $arg, string $output = null, bool $archive = false, b } /** - * Show IPFS Node ID info. + * Show ipfs node id info. * * @Endpoint(name="id") * @@ -124,7 +125,7 @@ public function id(string $arg = null, string $format = null): Command } /** - * List links from an object. + * List directory contents for Unix filesystem objects. * * @Endpoint(name="ls") * @@ -197,7 +198,7 @@ public function update(string $arg = null): Command } /** - * Shows ipfs version information. + * Show ipfs version information. * * @Endpoint(name="version") * diff --git a/src/Api/Bitswap.php b/src/Api/Bitswap.php index be08bca..8c127fd 100644 --- a/src/Api/Bitswap.php +++ b/src/Api/Bitswap.php @@ -23,6 +23,20 @@ */ final class Bitswap implements Api { + /** + * Show the current ledger for a peer. + * + * @Endpoint(name="bitswap:ledger") + * + * @param string $arg the PeerID (B58) of the ledger to inspect + * + * @return Command + */ + public function ledger(string $arg): Command + { + return new Command(__METHOD__, get_defined_vars()); + } + /** * Show some diagnostic information on the bitswap agent. * diff --git a/src/Api/Block.php b/src/Api/Block.php index fad73cf..0ed5f7a 100644 --- a/src/Api/Block.php +++ b/src/Api/Block.php @@ -38,15 +38,34 @@ public function get(string $arg): Command } /** - * Stores input as an IPFS block. + * Store input as an IPFS block. * * @Endpoint(name="block:put") * - * @param string $file the data to be stored as an IPFS block + * @param string $file the data to be stored as an IPFS block + * @param string $format cid format for blocks to be created with + * @param string $mhtype multihash hash function + * @param int $mhlen multihash hash length * * @return Command */ - public function put(string $file): Command + public function put(string $file, string $format = 'v0', string $mhtype = 'sha2-256', int $mhlen = -1): Command + { + return new Command(__METHOD__, get_defined_vars()); + } + + /** + * Remove IPFS block(s). + * + * @Endpoint(name="block:rm") + * + * @param string $arg bash58 encoded multihash of block(s) to remove + * @param bool $force ignore nonexistent blocks + * @param bool $quiet write minimal output + * + * @return Command + */ + public function rm(string $arg, bool $force = false, bool $quiet = false): Command { return new Command(__METHOD__, get_defined_vars()); } diff --git a/src/Api/Bootstrap.php b/src/Api/Bootstrap.php index 6779c1e..eca99c9 100644 --- a/src/Api/Bootstrap.php +++ b/src/Api/Bootstrap.php @@ -48,7 +48,7 @@ public function list(): Command } /** - * Removes all peers from the bootstrap list. + * Remove all peers from the bootstrap list. * * @Endpoint(name="bootstrap:rm:all") * diff --git a/src/Api/Config.php b/src/Api/Config.php index 4e4e609..a653d47 100644 --- a/src/Api/Config.php +++ b/src/Api/Config.php @@ -24,7 +24,7 @@ final class Config implements Api { /** - * Opens the config file for editing in $EDITOR. + * Open the config file for editing in $EDITOR. * * @Endpoint(name="config:edit") * @@ -36,7 +36,7 @@ public function edit(): Command } /** - * Replaces the config with . + * Replace the config with . * * @Endpoint(name="config:replace") * @@ -50,7 +50,7 @@ public function replace(string $file): Command } /** - * Outputs the content of the config file. + * Output config file contents. * * @Endpoint(name="config:show") * diff --git a/src/Api/Dag.php b/src/Api/Dag.php new file mode 100644 index 0000000..de207a6 --- /dev/null +++ b/src/Api/Dag.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace IPFS\Api; + +use IPFS\Annotation\Api as Endpoint; +use IPFS\Command\Command; + +/** + * @author Robert Schönthal + * @autogenerated + * @codeCoverageIgnore + */ +final class Dag implements Api +{ + /** + * Get a dag node from ipfs. + * + * @Endpoint(name="dag:get") + * + * @param string $arg the object to get Required: + * + * @return Command + */ + public function get(string $arg): Command + { + return new Command(__METHOD__, get_defined_vars()); + } + + /** + * Add a dag node to ipfs. + * + * @Endpoint(name="dag:put") + * + * @param string $file the object to put Required: + * @param string $format format that the object will be added as + * @param string $inputEnc format that the input object will be + * + * @return Command + */ + public function put(string $file, string $format = 'cbor', string $inputEnc = 'json'): Command + { + return new Command(__METHOD__, get_defined_vars()); + } +} diff --git a/src/Api/Dht.php b/src/Api/Dht.php index 2344d3e..bc6589a 100644 --- a/src/Api/Dht.php +++ b/src/Api/Dht.php @@ -1,21 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - +declare (strict_types=1); namespace IPFS\Api; use IPFS\Annotation\Api as Endpoint; use IPFS\Command\Command; - /** * @author Robert Schönthal * @autogenerated @@ -24,78 +13,89 @@ final class Dht implements Api { /** - * Query the DHT for all of the multiaddresses associated with a Peer ID. - * - * @Endpoint(name="dht:findpeer") - * - * @param string $arg the ID of the peer to search for - * @param bool $verbose print extra information - * - * @return Command - */ - public function findpeer(string $arg, bool $verbose = false): Command + * Query the DHT for all of the multiaddresses associated with a Peer ID. + * + * @Endpoint(name="dht:findpeer") + * + * @param string $arg The ID of the peer to search for. + * @param bool $verbose Print extra information. + * + * @return Command + */ + public function findpeer(string $arg, bool $verbose = false) : Command { return new Command(__METHOD__, get_defined_vars()); } - /** - * Find peers in the DHT that can provide a specific value, given a key. - * - * @Endpoint(name="dht:findprovs") - * - * @param string $arg the key to find providers for - * @param bool $verbose print extra information - * - * @return Command - */ - public function findprovs(string $arg, bool $verbose = false): Command + * Find peers in the DHT that can provide a specific value, given a key. + * + * @Endpoint(name="dht:findprovs") + * + * @param string $arg The key to find providers for. + * @param bool $verbose Print extra information. + * + * @return Command + */ + public function findprovs(string $arg, bool $verbose = false) : Command { return new Command(__METHOD__, get_defined_vars()); } - /** - * Given a key, query the DHT for its best value. - * - * @Endpoint(name="dht:get") - * - * @param string $arg the key to find a value for - * @param bool $verbose print extra information - * - * @return Command - */ - public function get(string $arg, bool $verbose = false): Command + * Given a key, query the DHT for its best value. + * + * @Endpoint(name="dht:get") + * + * @param string $arg The key to find a value for. + * @param bool $verbose Print extra information. + * + * @return Command + */ + public function get(string $arg, bool $verbose = false) : Command { return new Command(__METHOD__, get_defined_vars()); } - /** - * Write a key/value pair to the DHT. - * - * @Endpoint(name="dht:put") - * - * @param string $arg the key to store the value at - * @param string $arg1 the value to store - * @param bool $verbose print extra information - * - * @return Command - */ - public function put(string $arg, string $arg1, bool $verbose = false): Command + * Announce to the network that you are providing given values. + * + * @Endpoint(name="dht:provide") + * + * @param string]: The key[s $arg The key[s] to send provide records for. + * @param bool $verbose Print extra information. + * @param bool $recursive Recursively provide entire graph. + * + * @return Command + */ + public function provide(string]: The key[s $arg, bool $verbose = false, bool $recursive = false) : Command + { + return new Command(__METHOD__, get_defined_vars()); + } + /** + * Write a key/value pair to the DHT. + * + * @Endpoint(name="dht:put") + * + * @param string $arg The key to store the value at. + * @param string $arg1 The value to store. + * @param bool $verbose Print extra information. + * + * @return Command + */ + public function put(string $arg, string $arg1, bool $verbose = false) : Command { return new Command(__METHOD__, get_defined_vars()); } - /** - * Find the closest Peer IDs to a given Peer ID by querying the DHT. - * - * @Endpoint(name="dht:query") - * - * @param string $arg the peerID to run the query against - * @param bool $verbose print extra information - * - * @return Command - */ - public function query(string $arg, bool $verbose = false): Command + * Find the closest Peer IDs to a given Peer ID by querying the DHT. + * + * @Endpoint(name="dht:query") + * + * @param string $arg The peerID to run the query against. + * @param bool $verbose Print extra information. + * + * @return Command + */ + public function query(string $arg, bool $verbose = false) : Command { return new Command(__METHOD__, get_defined_vars()); } -} +} \ No newline at end of file diff --git a/src/Api/Diag.php b/src/Api/Diag.php index 6dad500..3bfa694 100644 --- a/src/Api/Diag.php +++ b/src/Api/Diag.php @@ -50,7 +50,7 @@ public function cmdsSetTime(string $arg): Command } /** - * Generates a network diagnostics report. + * Generate a network diagnostics report. * * @Endpoint(name="diag:net") * @@ -64,7 +64,7 @@ public function net(string $vis = 'text'): Command } /** - * Prints out system diagnostic information. + * Print system diagnostic information. * * @Endpoint(name="diag:sys") * diff --git a/src/Api/Files.php b/src/Api/Files.php index a64c866..898f5b3 100644 --- a/src/Api/Files.php +++ b/src/Api/Files.php @@ -53,7 +53,7 @@ public function flush(string $arg = null): Command } /** - * List directories. + * List directories in the local mutable namespace. * * @Endpoint(name="files:ls") * diff --git a/src/Api/Key.php b/src/Api/Key.php new file mode 100644 index 0000000..087a9cf --- /dev/null +++ b/src/Api/Key.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace IPFS\Api; + +use IPFS\Annotation\Api as Endpoint; +use IPFS\Command\Command; + +/** + * @author Robert Schönthal + * @autogenerated + * @codeCoverageIgnore + */ +final class Key implements Api +{ + /** + * Create a new keypair. + * + * @Endpoint(name="key:gen") + * + * @param string $arg name of key to create Required: + * @param string $type type of the key to create + * @param int $size size of the key to generate + * + * @return Command + */ + public function gen(string $arg, string $type = null, int $size = 0): Command + { + return new Command(__METHOD__, get_defined_vars()); + } + + /** + * List all local keypairs. + * + * @Endpoint(name="key:list") + * + * @param bool $l show extra information about keys + * + * @return Command + */ + public function list(bool $l = null): Command + { + return new Command(__METHOD__, get_defined_vars()); + } +} diff --git a/src/Api/Log.php b/src/Api/Log.php index 82144fb..9057924 100644 --- a/src/Api/Log.php +++ b/src/Api/Log.php @@ -51,7 +51,7 @@ public function ls(): Command } /** - * Read the logs. + * Read the event log. * * @Endpoint(name="log:tail") * diff --git a/src/Api/Name.php b/src/Api/Name.php index 7196a4e..d31d8e3 100644 --- a/src/Api/Name.php +++ b/src/Api/Name.php @@ -28,20 +28,21 @@ final class Name implements Api * * @Endpoint(name="name:publish") * - * @param string $arg iPFS path of the object to be published + * @param string $arg ipfs path of the object to be published * @param bool $resolve resolve given path before publishing * @param string $lifetime time duration that the record will be valid for * @param string $ttl time duration this record should be cached for (caution: experimental) + * @param string $key name of key to use * * @return Command */ - public function publish(string $arg, bool $resolve = true, string $lifetime = '24h', string $ttl = null): Command + public function publish(string $arg, bool $resolve = true, string $lifetime = '24h', string $ttl = null, string $key = 'self'): Command { return new Command(__METHOD__, get_defined_vars()); } /** - * Gets the value currently published at an IPNS name. + * Get the value currently published at an IPNS name. * * @Endpoint(name="name:resolve") * diff --git a/src/Api/Object.php b/src/Api/Object.php index 9027d55..dd8caa2 100644 --- a/src/Api/Object.php +++ b/src/Api/Object.php @@ -24,7 +24,7 @@ final class Object implements Api { /** - * Outputs the raw bytes in an IPFS object. + * Output the raw bytes of an IPFS object. * * @Endpoint(name="object:data") * @@ -38,7 +38,7 @@ public function data(string $arg): Command } /** - * Takes a diff of the two given objects. + * Display the diff between two ipfs objects. * * @Endpoint(name="object:diff") * @@ -68,7 +68,7 @@ public function get(string $arg): Command } /** - * Outputs the links pointed to by the specified object. + * Output the links pointed to by the specified object. * * @Endpoint(name="object:links") * @@ -83,7 +83,7 @@ public function links(string $arg, bool $headers = false): Command } /** - * Creates a new object from an ipfs template. + * Create a new object from an ipfs template. * * @Endpoint(name="object:new") * @@ -144,7 +144,7 @@ public function patchRmLink(string $arg, string $arg1): Command } /** - * Set the data field of an ipfs object. + * Set the data field of an IPFS object. * * @Endpoint(name="object:patch:set-data") * @@ -159,7 +159,7 @@ public function patchSetData(string $arg, string $file): Command } /** - * Stores input as a DAG object, outputs its key. + * Store input as a DAG object, print its key. * * @Endpoint(name="object:put") * diff --git a/src/Api/Pin.php b/src/Api/Pin.php index f39ba16..a9c10f6 100644 --- a/src/Api/Pin.php +++ b/src/Api/Pin.php @@ -24,7 +24,7 @@ final class Pin implements Api { /** - * Pins objects to local storage. + * Pin objects to local storage. * * @Endpoint(name="pin:add") * @@ -55,7 +55,7 @@ public function ls(string $arg = null, string $type = 'all', bool $quiet = false } /** - * Removes the pinned object from local storage. + * Remove pinned objects from local storage. * * @Endpoint(name="pin:rm") * diff --git a/src/Api/Pubsub.php b/src/Api/Pubsub.php new file mode 100644 index 0000000..c7722f3 --- /dev/null +++ b/src/Api/Pubsub.php @@ -0,0 +1,81 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace IPFS\Api; + +use IPFS\Annotation\Api as Endpoint; +use IPFS\Command\Command; + +/** + * @author Robert Schönthal + * @autogenerated + * @codeCoverageIgnore + */ +final class Pubsub implements Api +{ + /** + * List subscribed topics by name. + * + * @Endpoint(name="pubsub:ls") + * + * @return Command + */ + public function ls(): Command + { + return new Command(__METHOD__, get_defined_vars()); + } + + /** + * List peers we are currently pubsubbing with. + * + * @Endpoint(name="pubsub:peers") + * + * @param string $arg topic to list connected peers of Required: no + * + * @return Command + */ + public function peers(string $arg = null): Command + { + return new Command(__METHOD__, get_defined_vars()); + } + + /** + * Publish a message to a given pubsub topic. + * + * @Endpoint(name="pubsub:pub") + * + * @param string $arg topic to publish to + * @param string $arg1 payload of message to publish + * + * @return Command + */ + public function pub(string $arg, string $arg1): Command + { + return new Command(__METHOD__, get_defined_vars()); + } + + /** + * Subscribe to messages on a given topic. + * + * @Endpoint(name="pubsub:sub") + * + * @param string $arg string name of topic to subscribe to + * @param bool $discover try to discover other peers subscribed to the same topic + * + * @return Command + */ + public function sub(string $arg, bool $discover = null): Command + { + return new Command(__METHOD__, get_defined_vars()); + } +} diff --git a/src/Api/Refs.php b/src/Api/Refs.php index ec137b6..525606e 100644 --- a/src/Api/Refs.php +++ b/src/Api/Refs.php @@ -24,7 +24,7 @@ final class Refs implements Api { /** - * Lists all local references. + * List all local references. * * @Endpoint(name="refs:local") * diff --git a/src/Api/Repo.php b/src/Api/Repo.php index f35d63e..2f72919 100644 --- a/src/Api/Repo.php +++ b/src/Api/Repo.php @@ -24,7 +24,7 @@ final class Repo implements Api { /** - * Removes repo lockfiles. + * Remove repo lockfiles. * * @Endpoint(name="repo:fsck") * diff --git a/src/Api/Swarm.php b/src/Api/Swarm.php index 1e4d6b9..b87dd4b 100644 --- a/src/Api/Swarm.php +++ b/src/Api/Swarm.php @@ -98,11 +98,13 @@ public function filtersRm(string $arg): Command * * @Endpoint(name="swarm:peers") * - * @param bool $verbose also display latency along with peer information in the following form: + * @param bool $verbose display all extra information + * @param bool $streams also list information about open streams for each peer + * @param bool $latency also list information about latency to each peer * * @return Command */ - public function peers(bool $verbose = null): Command + public function peers(bool $verbose = null, bool $streams = null, bool $latency = null): Command { return new Command(__METHOD__, get_defined_vars()); } diff --git a/src/Api/Tar.php b/src/Api/Tar.php index 1124d55..d544827 100644 --- a/src/Api/Tar.php +++ b/src/Api/Tar.php @@ -42,7 +42,7 @@ public function add(string $file): Command * * @Endpoint(name="tar:cat") * - * @param string $arg iPFS path of archive to export + * @param string $arg ipfs path of archive to export * * @return Command */ diff --git a/tests/spec/Api/ApiParserSpec.php b/tests/spec/Api/ApiParserSpec.php index 2bdb03c..9121ac4 100644 --- a/tests/spec/Api/ApiParserSpec.php +++ b/tests/spec/Api/ApiParserSpec.php @@ -48,12 +48,12 @@ public function it_can_parse_the_api_docs_correctly() $addApi->shouldBeLike([ 'parts' => 'add', - 'description' => 'Add a file to ipfs.', + 'description' => 'Add a file or directory to ipfs.', 'arguments' => [ [ 'name' => 'file', 'required' => true, - 'description' => 'The path to a file to be added to IPFS.', + 'description' => 'The path to a file to be added to ipfs.', 'default' => null, 'type' => 'string', ], [ @@ -66,13 +66,13 @@ public function it_can_parse_the_api_docs_correctly() 'name' => 'quiet', 'required' => false, 'description' => 'Write minimal output.', - 'default' => false, + 'default' => null, 'type' => 'bool', ], [ 'name' => 'silent', 'required' => false, 'description' => 'Write no output.', - 'default' => false, + 'default' => null, 'type' => 'bool', ], [ 'name' => 'progress', @@ -84,25 +84,25 @@ public function it_can_parse_the_api_docs_correctly() 'name' => 'trickle', 'required' => false, 'description' => 'Use trickle-dag format for dag generation.', - 'default' => false, + 'default' => null, 'type' => 'bool', ], [ 'name' => 'onlyHash', 'required' => false, 'description' => 'Only chunk and hash - do not write to disk.', - 'default' => false, + 'default' => null, 'type' => 'bool', ], [ 'name' => 'wrapWithDirectory', 'required' => false, 'description' => 'Wrap files with a directory object.', - 'default' => false, + 'default' => null, 'type' => 'bool', ], [ 'name' => 'hidden', 'required' => false, 'description' => 'Include files that are hidden.', - 'default' => false, + 'default' => null, 'type' => 'bool', ], [ 'name' => 'chunker', @@ -116,6 +116,12 @@ public function it_can_parse_the_api_docs_correctly() 'description' => 'Pin this object when adding.', 'default' => true, 'type' => 'bool', + ], [ + 'name' => 'rawLeaves', + 'required' => false, + 'description' => 'Use raw blocks for leaf nodes.', + 'default' => null, + 'type' => 'bool', ], ], 'class' => 'Basics',