23 #include <ipfs/http/transport.h> 26 #include <nlohmann/json.hpp> 36 using Json = nlohmann::json;
56 const std::string& host,
132 const std::string& key,
149 const std::string& key,
181 const std::string& peer_id,
198 const std::string& hash,
215 const std::string& block_id,
218 std::iostream* block);
250 const std::string& block_id,
268 const std::string& path,
271 std::iostream* response);
286 const std::vector<http::FileUpload>& files,
305 const std::string& path,
348 const std::string& key_name,
350 const std::string& key_type,
354 std::string* key_id);
384 const std::string& key_name);
399 const std::string& object_id,
402 const std::string& key_name,
416 std::string* name_id);
431 const std::string& name_id,
434 std::string* path_string);
449 std::string* object_id);
467 Json* object_stored);
482 const std::string& object_id,
501 const std::string& object_id,
518 const std::string& object_id,
536 const std::string& object_id,
554 const std::string& source,
556 const std::string& link_name,
558 const std::string& link_target,
560 std::string* cloned);
576 const std::string& source,
578 const std::string& link_name,
580 std::string* cloned);
595 const std::string& source,
599 std::string* cloned);
614 const std::string& source,
618 std::string* cloned);
633 const std::string& object_id);
663 const std::string& object_id,
690 const std::string& object_id,
724 const std::string& peer);
741 const std::string& peer);
760 void FetchAndParseJson(
763 const std::string& url,
769 void FetchAndParseJson(
771 const std::string& url,
773 const std::vector<http::FileUpload>& files,
781 static void ParseJson(
783 const std::string& input,
791 template <
class PropertyType>
792 static void GetProperty(
796 const std::string& property_name,
800 PropertyType* property_value);
811 const std::string& path,
813 const std::vector<std::pair<std::string, std::string>>& parameters = {});
817 std::string url_prefix_;
820 http::Transport* http_;
~Client()
Destructor.
Definition: client.cc:75
nlohmann::json Json
Type of the output of some methods, aliased for convenience.
Definition: client.h:36
void ObjectNew(std::string *object_id)
Create a new MerkleDAG node.
Definition: client.cc:310
void DhtFindPeer(const std::string &peer_id, Json *addresses)
Retrieve the peer info of a reachable node in the network.
Definition: client.cc:123
void ObjectPatchAppendData(const std::string &source, const http::FileUpload &data, std::string *cloned)
Create a new object from an existing MerkleDAG node and append data to it.
Definition: client.cc:375
void SwarmDisconnect(const std::string &peer)
Close a connection on a given address.
Definition: client.cc:444
void ConfigGet(const std::string &key, Json *config)
Query the current config of the peer.
Definition: client.cc:83
void SwarmPeers(Json *peers)
List the peers that we have connections with.
Definition: client.cc:449
void ObjectPatchRmLink(const std::string &source, const std::string &link_name, std::string *cloned)
Create a new object from an existing MerkleDAG node and remove one of its links.
Definition: client.cc:363
void ObjectStat(const std::string &object_id, Json *stat)
Get stats about a MerkleDAG node.
Definition: client.cc:345
void ObjectGet(const std::string &object_id, Json *object)
Get a MerkleDAG node.
Definition: client.cc:325
void BlockPut(const http::FileUpload &block, Json *stat)
Store a raw block in IPFS.
Definition: client.cc:189
void ObjectPut(const Json &object, Json *object_stored)
Store a MerkleDAG node.
Definition: client.cc:318
void PinAdd(const std::string &object_id)
Pin a given IPFS object.
Definition: client.cc:397
void BlockStat(const std::string &block_id, Json *stat)
Get information for a raw IPFS block.
Definition: client.cc:193
void FilesGet(const std::string &path, std::iostream *response)
Get a file from IPFS.
Definition: client.cc:197
void PinLs(Json *pinned)
List all the objects pinned to local storage.
Definition: client.cc:416
void ConfigReplace(const Json &config)
Replace the entire config at the peer.
Definition: client.cc:115
void DhtFindProvs(const std::string &hash, Json *providers)
Retrieve the providers for a content that is addressed by a hash.
Definition: client.cc:154
void BlockGet(const std::string &block_id, std::iostream *block)
Get a raw IPFS block.
Definition: client.cc:185
void SwarmConnect(const std::string &peer)
Open a connection to a given address.
Definition: client.cc:439
Recursively unpin the objects.
void ObjectData(const std::string &object_id, std::string *data)
Get the data field of a MerkleDAG node.
Definition: client.cc:329
void SwarmAddrs(Json *addresses)
List of known addresses of each peer connected.
Definition: client.cc:435
void PinRm(const std::string &object_id, PinRmOptions options)
Unpin an object.
Definition: client.cc:424
void NameResolve(const std::string &name_id, std::string *path_string)
Resolve an IPNS name.
Definition: client.cc:302
void KeyGen(const std::string &key_name, const std::string &key_type, size_t key_size, std::string *key_id)
Generate a new key.
Definition: client.cc:264
void FilesAdd(const std::vector< http::FileUpload > &files, Json *result)
Add files to IPFS.
Definition: client.cc:201
Client & operator=(const Client &)
Copy assignment operator.
Definition: client.cc:47
Client(const std::string &host, long port)
Constructor.
Definition: client.cc:34
void FilesLs(const std::string &path, Json *result)
List directory contents for Unix filesystem objects.
Definition: client.cc:260
IPFS client.
Definition: client.h:46
void Id(Json *id)
Return the identity of the peer.
Definition: client.cc:77
void KeyList(Json *key_list)
List all the keys.
Definition: client.cc:275
IPFS namespace.
Definition: client.h:32
Just unpin the specified object.
void ObjectLinks(const std::string &object_id, Json *links)
Get links of a MerkleDAG node.
Definition: client.cc:337
void NamePublish(const std::string &object_id, const std::string &key_name, const Json &options, std::string *name_id)
Publish an IPNS name attached to a given value.
Definition: client.cc:286
void ConfigSet(const std::string &key, const Json &value)
Add or replace a config knob at the peer.
Definition: client.cc:109
void ObjectPatchSetData(const std::string &source, const http::FileUpload &data, std::string *cloned)
Create a new object from an existing MerkleDAG node and set its data.
Definition: client.cc:386
HTTP file upload.
Definition: transport.h:32
void Version(Json *version)
Return the implementation version of the peer.
Definition: client.cc:79
void KeyRm(const std::string &key_name)
Remove a key.
Definition: client.cc:281
PinRmOptions
Options to control the PinRm() method.
Definition: client.h:668
void ObjectPatchAddLink(const std::string &source, const std::string &link_name, const std::string &link_target, std::string *cloned)
Create a new object from an existing MerkleDAG node and add to its links.
Definition: client.cc:349