cpp-ipfs-http-client
IPFS C++ client library
|
23 #include <ipfs/http/transport.h>
26 #include <nlohmann/json.hpp>
36 using Json = nlohmann::json;
56 const std::string& host,
60 const std::string& timeout =
"",
62 const std::string& protocol =
"http://",
64 const std::string& apiPath =
"/api/v0");
138 const std::string& key,
155 const std::string& key,
187 const std::string& peer_id,
204 const std::string& hash,
221 const std::string& block_id,
224 std::iostream* block);
256 const std::string& block_id,
274 const std::string& path,
277 std::iostream* response);
292 const std::vector<http::FileUpload>& files,
311 const std::string& path,
354 const std::string& key_name,
356 const std::string& key_type,
360 std::string* key_id);
390 const std::string& key_name);
405 const std::string& object_id,
408 const std::string& key_name,
422 std::string* name_id);
437 const std::string& name_id,
440 std::string* path_string);
455 std::string* object_id);
473 Json* object_stored);
488 const std::string& object_id,
507 const std::string& object_id,
524 const std::string& object_id,
542 const std::string& object_id,
560 const std::string& source,
562 const std::string& link_name,
564 const std::string& link_target,
566 std::string* cloned);
582 const std::string& source,
584 const std::string& link_name,
586 std::string* cloned);
601 const std::string& source,
605 std::string* cloned);
620 const std::string& source,
624 std::string* cloned);
639 const std::string& object_id);
669 const std::string& object_id,
696 const std::string& object_id,
730 const std::string& peer);
747 const std::string& peer);
766 void FetchAndParseJson(
769 const std::string& url,
775 void FetchAndParseJson(
777 const std::string& url,
779 const std::vector<http::FileUpload>& files,
787 static void ParseJson(
789 const std::string& input,
797 template <
class PropertyType>
798 static void GetProperty(
802 const std::string& property_name,
806 PropertyType* property_value);
817 const std::string& path,
819 const std::vector<std::pair<std::string, std::string>>& parameters = {});
823 std::string url_prefix_;
826 http::Transport* http_;
829 std::string timeout_value_;
void ObjectNew(std::string *object_id)
Create a new MerkleDAG node.
Definition: client.cc:312
void KeyList(Json *key_list)
List all the keys.
Definition: client.cc:277
void ConfigGet(const std::string &key, Json *config)
Query the current config of the peer.
Definition: client.cc:85
void ObjectGet(const std::string &object_id, Json *object)
Get a MerkleDAG node.
Definition: client.cc:327
Client(const std::string &host, long port, const std::string &timeout="", const std::string &protocol="http://", const std::string &apiPath="/api/v0")
Constructor.
Definition: client.cc:34
void ObjectStat(const std::string &object_id, Json *stat)
Get stats about a MerkleDAG node.
Definition: client.cc:347
PinRmOptions
Options to control the PinRm() method.
Definition: client.h:674
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:365
IPFS client.
Definition: client.h:46
void FilesLs(const std::string &path, Json *result)
List directory contents for Unix filesystem objects.
Definition: client.cc:262
void SwarmAddrs(Json *addresses)
List of known addresses of each peer connected.
Definition: client.cc:437
void ConfigSet(const std::string &key, const Json &value)
Add or replace a config knob at the peer.
Definition: client.cc:111
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:388
void FilesGet(const std::string &path, std::iostream *response)
Get a file from IPFS.
Definition: client.cc:199
void PinAdd(const std::string &object_id)
Pin a given IPFS object.
Definition: client.cc:399
void FilesAdd(const std::vector< http::FileUpload > &files, Json *result)
Add files to IPFS.
Definition: client.cc:203
void ConfigReplace(const Json &config)
Replace the entire config at the peer.
Definition: client.cc:117
void DhtFindPeer(const std::string &peer_id, Json *addresses)
Retrieve the peer info of a reachable node in the network.
Definition: client.cc:125
void BlockStat(const std::string &block_id, Json *stat)
Get information for a raw IPFS block.
Definition: client.cc:195
void ObjectData(const std::string &object_id, std::string *data)
Get the data field of a MerkleDAG node.
Definition: client.cc:331
void SwarmPeers(Json *peers)
List the peers that we have connections with.
Definition: client.cc:451
void BlockGet(const std::string &block_id, std::iostream *block)
Get a raw IPFS block.
Definition: client.cc:187
void KeyRm(const std::string &key_name)
Remove a key.
Definition: client.cc:283
@ RECURSIVE
Recursively unpin the objects.
void ObjectPut(const Json &object, Json *object_stored)
Store a MerkleDAG node.
Definition: client.cc:320
nlohmann::json Json
Type of the output of some methods, aliased for convenience.
Definition: client.h:36
~Client()
Destructor.
Definition: client.cc:77
void ObjectLinks(const std::string &object_id, Json *links)
Get links of a MerkleDAG node.
Definition: client.cc:339
void PinLs(Json *pinned)
List all the objects pinned to local storage.
Definition: client.cc:418
void SwarmConnect(const std::string &peer)
Open a connection to a given address.
Definition: client.cc:441
void NameResolve(const std::string &name_id, std::string *path_string)
Resolve an IPNS name.
Definition: client.cc:304
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:266
Client & operator=(const Client &)
Copy assignment operator.
Definition: client.cc:49
@ NON_RECURSIVE
Just unpin the specified object.
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:351
void DhtFindProvs(const std::string &hash, Json *providers)
Retrieve the providers for a content that is addressed by a hash.
Definition: client.cc:156
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:288
void Id(Json *id)
Return the identity of the peer.
Definition: client.cc:79
void BlockPut(const http::FileUpload &block, Json *stat)
Store a raw block in IPFS.
Definition: client.cc:191
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:377
void SwarmDisconnect(const std::string &peer)
Close a connection on a given address.
Definition: client.cc:446
IPFS namespace.
Definition: client.h:32
void PinRm(const std::string &object_id, PinRmOptions options)
Unpin an object.
Definition: client.cc:426
void Version(Json *version)
Return the implementation version of the peer.
Definition: client.cc:81
HTTP file upload.
Definition: transport.h:32