Skip to content

Commit

Permalink
update apis
Browse files Browse the repository at this point in the history
digitalkaoz committed Feb 27, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent e0da087 commit 2b00d72
Showing 20 changed files with 344 additions and 110 deletions.
15 changes: 8 additions & 7 deletions src/Api/Basics.php
Original file line number Diff line number Diff line change
@@ -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")
*
14 changes: 14 additions & 0 deletions src/Api/Bitswap.php
Original file line number Diff line number Diff line change
@@ -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.
*
25 changes: 22 additions & 3 deletions src/Api/Block.php
Original file line number Diff line number Diff line change
@@ -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());
}
2 changes: 1 addition & 1 deletion src/Api/Bootstrap.php
Original file line number Diff line number Diff line change
@@ -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")
*
6 changes: 3 additions & 3 deletions src/Api/Config.php
Original file line number Diff line number Diff line change
@@ -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")
*
55 changes: 55 additions & 0 deletions src/Api/Dag.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

declare(strict_types=1);

/*
* This file is part of the "php-ipfs" package.
*
* (c) Robert Schönthal <[email protected]>
*
* 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 <[email protected]>
* @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());
}
}
136 changes: 68 additions & 68 deletions src/Api/Dht.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
<?php

declare(strict_types=1);

/*
* This file is part of the "php-ipfs" package.
*
* (c) Robert Schönthal <[email protected]>
*
* 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 <[email protected]>
* @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());
}
}
}
4 changes: 2 additions & 2 deletions src/Api/Diag.php
Original file line number Diff line number Diff line change
@@ -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")
*
2 changes: 1 addition & 1 deletion src/Api/Files.php
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ public function flush(string $arg = null): Command
}

/**
* List directories.
* List directories in the local mutable namespace.
*
* @Endpoint(name="files:ls")
*
55 changes: 55 additions & 0 deletions src/Api/Key.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

declare(strict_types=1);

/*
* This file is part of the "php-ipfs" package.
*
* (c) Robert Schönthal <robert.schoenthal@gmail.com>
*
* 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 <robert.schoenthal@gmail.com>
* @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());
}
}
2 changes: 1 addition & 1 deletion src/Api/Log.php
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ public function ls(): Command
}

/**
* Read the logs.
* Read the event log.
*
* @Endpoint(name="log:tail")
*
7 changes: 4 additions & 3 deletions src/Api/Name.php
Original file line number Diff line number Diff line change
@@ -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")
*
12 changes: 6 additions & 6 deletions src/Api/Object.php
Original file line number Diff line number Diff line change
@@ -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")
*
4 changes: 2 additions & 2 deletions src/Api/Pin.php
Original file line number Diff line number Diff line change
@@ -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")
*
81 changes: 81 additions & 0 deletions src/Api/Pubsub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

declare(strict_types=1);

/*
* This file is part of the "php-ipfs" package.
*
* (c) Robert Schönthal <robert.schoenthal@gmail.com>
*
* 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 <robert.schoenthal@gmail.com>
* @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());
}
}
2 changes: 1 addition & 1 deletion src/Api/Refs.php
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
final class Refs implements Api
{
/**
* Lists all local references.
* List all local references.
*
* @Endpoint(name="refs:local")
*
2 changes: 1 addition & 1 deletion src/Api/Repo.php
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
final class Repo implements Api
{
/**
* Removes repo lockfiles.
* Remove repo lockfiles.
*
* @Endpoint(name="repo:fsck")
*
6 changes: 4 additions & 2 deletions src/Api/Swarm.php
Original file line number Diff line number Diff line change
@@ -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());
}
2 changes: 1 addition & 1 deletion src/Api/Tar.php
Original file line number Diff line number Diff line change
@@ -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
*/
22 changes: 14 additions & 8 deletions tests/spec/Api/ApiParserSpec.php
Original file line number Diff line number Diff line change
@@ -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',

0 comments on commit 2b00d72

Please sign in to comment.