23#include <ipfs/http/transport.h>
27#include <nlohmann/json.hpp>
37using Json = nlohmann::json;
58 const std::string& host,
63 const std::string& timeout =
"",
65 const std::string& protocol =
"http://",
67 const std::string& apiPath =
"/api/v0",
69 bool verbose =
false);
143 const std::string& key,
160 const std::string& key,
192 const std::string& peer_id,
209 const std::string& hash,
226 const std::string& block_id,
229 std::iostream* block);
261 const std::string& block_id,
279 const std::string& path,
282 std::iostream* response);
297 const std::vector<http::FileUpload>& files,
316 const std::string& path,
359 const std::string& key_name,
361 const std::string& key_type,
365 std::string* key_id);
395 const std::string& key_name);
410 const std::string& old_key,
412 const std::string& new_key);
427 const std::string& object_id,
430 const std::string& key_name,
444 std::string* name_id);
459 const std::string& name_id,
462 std::string* path_string);
477 std::string* object_id);
495 Json* object_stored);
510 const std::string& object_id,
529 const std::string& object_id,
546 const std::string& object_id,
564 const std::string& object_id,
582 const std::string& source,
584 const std::string& link_name,
586 const std::string& link_target,
588 std::string* cloned);
604 const std::string& source,
606 const std::string& link_name,
608 std::string* cloned);
623 const std::string& source,
627 std::string* cloned);
642 const std::string& source,
646 std::string* cloned);
661 const std::string& object_id);
691 const std::string& object_id,
718 const std::string& object_id,
742 Json* bandwidth_info);
797 const std::string& peer);
814 const std::string& peer);
863 void FetchAndParseJson(
866 const std::string& url,
872 void FetchAndParseJson(
874 const std::string& url,
876 const std::vector<http::FileUpload>& files,
884 static void ParseJson(
886 const std::string& input,
894 template <
class PropertyType>
895 static void GetProperty(
899 const std::string& property_name,
903 PropertyType* property_value);
913 const std::string& path,
915 const std::vector<std::pair<std::string, std::string>>& parameters = {});
919 std::string url_prefix_;
922 std::unique_ptr<http::Transport> http_;
925 std::string timeout_value_;
IPFS client.
Definition client.h:48
void BlockStat(const std::string &block_id, Json *stat)
Get information for a raw IPFS block.
Definition client.cc:202
void FilesLs(const std::string &path, Json *result)
List directory contents for Unix filesystem objects.
Definition client.cc:269
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:378
void BlockPut(const http::FileUpload &block, Json *stat)
Store a raw block in IPFS.
Definition client.cc:198
void PinAdd(const std::string &object_id)
Pin a given IPFS object.
Definition client.cc:412
void PinRm(const std::string &object_id, PinRmOptions options)
Unpin an object.
Definition client.cc:439
void SwarmConnect(const std::string &peer)
Open a connection to a given address.
Definition client.cc:462
void ObjectStat(const std::string &object_id, Json *stat)
Get stats about a MerkleDAG node.
Definition client.cc:360
void SwarmPeers(Json *peers)
List the peers that we have connections with.
Definition client.cc:472
void KeyList(Json *key_list)
List all the keys.
Definition client.cc:284
void BlockGet(const std::string &block_id, std::iostream *block)
Get a raw IPFS block.
Definition client.cc:194
void ConfigGet(const std::string &key, Json *config)
Query the current config of the peer.
Definition client.cc:92
void KeyRename(const std::string &old_key, const std::string &new_key)
Rename an existing key.
Definition client.cc:295
void PinLs(Json *pinned)
List all the objects pinned to local storage.
Definition client.cc:431
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:364
void Reset()
Resets the abort call, allowing to execute new API requests again.
Definition client.cc:483
void NameResolve(const std::string &name_id, std::string *path_string)
Resolve an IPNS name.
Definition client.cc:317
void ObjectNew(std::string *object_id)
Create a new MerkleDAG node.
Definition client.cc:325
void FilesGet(const std::string &path, std::iostream *response)
Get a file from IPFS.
Definition client.cc:206
void ObjectPut(const Json &object, Json *object_stored)
Store a MerkleDAG node.
Definition client.cc:333
void KeyRm(const std::string &key_name)
Remove a key.
Definition client.cc:290
void ObjectLinks(const std::string &object_id, Json *links)
Get links of a MerkleDAG node.
Definition client.cc:352
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:301
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:401
void DhtFindProvs(const std::string &hash, Json *providers)
Retrieve the providers for a content that is addressed by a hash.
Definition client.cc:163
void SwarmAddrs(Json *addresses)
List of known addresses of each peer connected.
Definition client.cc:458
void ConfigReplace(const Json &config)
Replace the entire config at the peer.
Definition client.cc:124
void ObjectData(const std::string &object_id, std::string *data)
Get the data field of a MerkleDAG node.
Definition client.cc:344
void Abort()
Abort any current running IPFS API request.
Definition client.cc:476
Client & operator=(const Client &)
Copy assignment operator.
Definition client.cc:55
void ConfigSet(const std::string &key, const Json &value)
Add or replace a config knob at the peer.
Definition client.cc:118
void ObjectGet(const std::string &object_id, Json *object)
Get a MerkleDAG node.
Definition client.cc:340
void FilesAdd(const std::vector< http::FileUpload > &files, Json *result)
Add files to IPFS.
Definition client.cc:210
void StatsBw(Json *bandwidth_info)
Get IPFS bandwidth (bw) information.
Definition client.cc:450
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:273
void Version(Json *version)
Return the implementation version of the peer.
Definition client.cc:88
PinRmOptions
Options to control the PinRm() method.
Definition client.h:696
@ RECURSIVE
Recursively unpin the objects.
@ NON_RECURSIVE
Just unpin the specified object.
void Id(Json *id)
Return the identity of the peer.
Definition client.cc:86
void StatsRepo(Json *repo_stats)
Get IPFS Repo Stats.
Definition client.cc:454
void DhtFindPeer(const std::string &peer_id, Json *addresses)
Retrieve the peer info of a reachable node in the network.
Definition client.cc:132
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:390
void SwarmDisconnect(const std::string &peer)
Close a connection on a given address.
Definition client.cc:467
IPFS namespace.
Definition client.h:33
nlohmann::json Json
Type of the output of some methods, aliased for convenience.
Definition client.h:37
HTTP file upload.
Definition transport.h:33