How to use the ipfshttpclient.client.base.returns_single_item function in ipfshttpclient

To help you get started, we’ve selected a few ipfshttpclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ipfs / py-ipfs-http-client / ipfshttpclient / client / object.py View on Github external
	@base.returns_single_item
	def add_link(self, root, name, ref, create=False, **kwargs):
		"""Creates a new merkledag object based on an existing one.

		The new object will have a link to the provided object.

		.. code-block:: python

			>>> client.object.patch.add_link(
			...     'QmR79zQQj2aDfnrNgczUhvf2qWapEfQ82YQRt3QjrbhSb2',
			...     'Johnny',
			...     'QmR79zQQj2aDfnrNgczUhvf2qWapEfQ82YQRt3QjrbhSb2'
			... )
			{'Hash': 'QmNtXbF3AjAk59gQKRgEdVabHcSsiPUnJwHnZKyj2x8Z3k'}

		Parameters
		----------
github ipfs / py-ipfs-http-client / ipfshttpclient / client / dht.py View on Github external
	@base.returns_single_item
	def get(self, key, *keys, **kwargs):
		"""Queries the DHT for its best value related to given key.

		There may be several different values for a given key stored in the
		DHT; in this context *best* means the record that is most desirable.
		There is no one metric for *best*: it depends entirely on the key type.
		For IPNS, *best* is the record that is both valid and has the highest
		sequence number (freshest). Different key types may specify other rules
		for what they consider to be the *best*.

		Parameters
		----------
		key : str
			One or more keys whose values should be looked up

		Returns
github ipfs / py-ipfs-http-client / ipfshttpclient / client / name.py View on Github external
	@base.returns_single_item
	def resolve(self, name=None, recursive=False, nocache=False,
	            dht_record_count=None, dht_timeout=None, **kwargs):
		"""Gets the value currently published at an IPNS name.

		IPNS is a PKI namespace, where names are the hashes of public keys, and
		the private key enables publishing new (signed) values. In resolve, the
		default value of ``name`` is your own identity public key.

		.. code-block:: python

			>>> client.name.resolve()
			{'Path': '/ipfs/QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d'}

		Parameters
		----------
		name : str
github ipfs / py-ipfs-http-client / ipfshttpclient / client / swarm.py View on Github external
	@base.returns_single_item
	def add(self, address, *addresses, **kwargs):
		"""Adds a given multiaddr filter to the filter list.

		This will add an address filter to the daemons swarm. Filters applied
		this way will not persist daemon reboots, to achieve that, add your
		filters to the configuration file.

		.. code-block:: python

			>>> client.swarm.filters.add("/ip4/192.168.0.0/ipcidr/16")
			{'Strings': ['/ip4/192.168.0.0/ipcidr/16']}

		Parameters
		----------
		address : str
			Multiaddr to filter
github ipfs / py-ipfs-http-client / ipfshttpclient / client / key.py View on Github external
	@base.returns_single_item
	def gen(self, key_name, type, size=2048, **kwargs):
		"""Adds a new public key that can be used for
		:meth:`~ipfshttpclient.Client.name.publish`.

		.. code-block:: python

			>>> client.key.gen('example_key_name')
			{'Name': 'example_key_name',
			 'Id': 'QmQLaT5ZrCfSkXTH6rUKtVidcxj8jrW3X2h75Lug1AV7g8'}

		Parameters
		----------
		key_name : str
			Name of the new Key to be generated. Used to reference the Keys.
		type : str
			Type of key to generate. The current possible keys types are:
github ipfs / py-ipfs-http-client / ipfshttpclient / client / swarm.py View on Github external
	@base.returns_single_item
	def addrs(self, **kwargs):
		"""Returns the addresses of currently connected peers by peer id.

		.. code-block:: python

			>>> pprint(client.swarm.addrs())
			{'Addrs': {
				'QmNMVHJTSZHTWMWBbmBrQgkA1hZPWYuVJx2DpSGESWW6Kn': [
					'/ip4/10.1.0.1/tcp/4001',
					'/ip4/127.0.0.1/tcp/4001',
					'/ip4/51.254.25.16/tcp/4001',
					'/ip6/2001:41d0:b:587:3cae:6eff:fe40:94d8/tcp/4001',
					'/ip6/2001:470:7812:1045::1/tcp/4001',
					'/ip6/::1/tcp/4001',
					'/ip6/fc02:2735:e595:bb70:8ffc:5293:8af8:c4b7/tcp/4001',
					'/ip6/fd00:7374:6172:100::1/tcp/4001',
github ipfs / py-ipfs-http-client / ipfshttpclient / client / key.py View on Github external
	@base.returns_single_item
	def rename(self, key_name, new_key_name, **kwargs):
		"""Rename a keypair

		.. code-block:: python

			>>> client.key.rename("bla", "personal")
			{"Was": "bla",
			 "Now": "personal",
			 "Id": "QmeyrRNxXaasZaoDXcCZgryoBCga9shaHQ4suHAYXbNZF3",
			 "Overwrite": False}

		Parameters
		----------
		key_name : str
			Current name of the key to rename
		new_key_name : str
github ipfs / py-ipfs-http-client / ipfshttpclient / client / swarm.py View on Github external
	@base.returns_single_item
	def connect(self, address, *addresses, **kwargs):
		"""Opens a connection to a given address.

		This will open a new direct connection to a peer address. The address
		format is an IPFS multiaddr::

			/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ

		.. code-block:: python

			>>> client.swarm.connect("/ip4/104.131.131.82/tcp/4001/ipfs/Qma … uvuJ")
			{'Strings': ['connect QmaCpDMGvV2BGHeYERUEnRQAwe3 … uvuJ success']}

		Parameters
		----------
		address : str
github ipfs / py-ipfs-http-client / ipfshttpclient / client / repo.py View on Github external
	@base.returns_single_item
	def stat(self, **kwargs):
		"""Displays the repo's status.

		Returns the number of objects in the repo and the repo's size,
		version, and path.

		.. code-block:: python

			>>> client.repo.stat()
			{'NumObjects': 354,
			 'RepoPath': '…/.local/share/ipfs',
			 'Version': 'fs-repo@4',
			 'RepoSize': 13789310}

		Returns
		-------
github ipfs / py-ipfs-http-client / ipfshttpclient / client / bitswap.py View on Github external
	@base.returns_single_item
	def stat(self, **kwargs):
		"""Returns some diagnostic information from the bitswap agent.
		
		.. code-block:: python
			
			>>> client.bitswap.stat()
			{'BlocksReceived': 96,
			 'DupBlksReceived': 73,
			 'DupDataReceived': 2560601,
			 'ProviderBufLen': 0,
			 'Peers': [
				'QmNZFQRxt9RMNm2VVtuV2Qx7q69bcMWRVXmr5CEkJEgJJP',
				'QmNfCubGpwYZAQxX8LQDsYgB48C4GbfZHuYdexpX9mbNyT',
				'QmNfnZ8SCs3jAtNPc8kf3WJqJqSoX7wsX7VqkLdEYMao4u',
				…
			 ],