How to use the ipfshttpclient.client.base.SectionBase 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 / bitswap.py View on Github external
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from . import base


class Section(base.SectionBase):
	@base.returns_single_item
	def wantlist(self, peer=None, **kwargs):
		"""Returns blocks currently on the bitswap wantlist.
		
		.. code-block:: python
			
			>>> client.bitswap.wantlist()
			{'Keys': [
				'QmeV6C6XVt1wf7V7as7Yak3mxPma8jzpqyhtRtCvpKcfBb',
				'QmdCWFLDXqgdWQY9kVubbEHBbkieKd3uo7MtCm7nTZZE9K',
				'QmVQ1XvYGF19X4eJqz1s7FJYJqAxFC4oqh3vWJJEXn66cp'
			]}
		
		Parameters
		----------
		peer : str
github ipfs / py-ipfs-http-client / ipfshttpclient / client / key.py View on Github external
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from . import base


class Section(base.SectionBase):
	#TODO: Add `export(name, password)`
	
	
	@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
		----------
github ipfs / py-ipfs-http-client / ipfshttpclient / client / config.py View on Github external
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from . import base


class Section(base.SectionBase):
	@base.returns_single_item
	def get(self, **kwargs):
		#TODO: Support the optional `key` parameter
		"""Returns the current used server configuration.

		.. code-block:: python

			>>> config = client.config.get()
			>>> config['Addresses']
			{'API': '/ip4/127.0.0.1/tcp/5001',
			 'Gateway': '/ip4/127.0.0.1/tcp/8080',
			 'Swarm': ['/ip4/0.0.0.0/tcp/4001', '/ip6/::/tcp/4001']},
			>>> config['Discovery']
			{'MDNS': {'Enabled': True, 'Interval': 10}}

		Returns
github ipfs / py-ipfs-http-client / ipfshttpclient / client / files.py View on Github external
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from . import base

from .. import multipart


class Section(base.SectionBase):
	"""
	Functions used to manage files in IPFS's virtual “Mutable File System” (MFS)
	file storage space.
	"""
	
	@base.returns_no_item
	def cp(self, source, dest, **kwargs):
		"""Copies files within the MFS.

		Due to the nature of IPFS this will not actually involve any of the
		file's content being copied.

		.. code-block:: python

			>>> client.files.ls("/")
			{'Entries': [
github ipfs / py-ipfs-http-client / ipfshttpclient / client / pubsub.py View on Github external
return next(self.__sub)

	def __iter__(self):
		return self.__sub

	def close(self):
		self.__sub.close()

	def __enter__(self):
		return self

	def __exit__(self, *a):
		self.close()


class Section(base.SectionBase):
	@base.returns_single_item
	def ls(self, **kwargs):
		"""Lists subscribed topics by name

		This method returns data that contains a list of
		all topics the user is subscribed to. In order
		to subscribe to a topic ``pubsub.sub`` must be called.

		.. code-block:: python

			# subscribe to a channel
			>>> with client.pubsub.sub("hello") as sub:
			...     client.pubsub.ls()
			{
				'Strings' : ["hello"]
			}
github ipfs / py-ipfs-http-client / ipfshttpclient / client / object.py View on Github external
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from . import base

from .. import multipart


class PatchSection(base.SectionBase):
	@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 / swarm.py View on Github external
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from . import base


class FiltersSection(base.SectionBase):
	@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
github ipfs / py-ipfs-http-client / ipfshttpclient / client / block.py View on Github external
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from . import base

from .. import multipart


class Section(base.SectionBase):
	"""
	Functions for interacting with raw IPFS blocks.
	"""

	def get(self, cid, **kwargs):
		r"""Returns the raw contents of a block.

		.. code-block:: python

			>>> client.block.get('QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D')
			b'\x121\n"\x12 \xdaW>\x14\xe5\xc1\xf6\xe4\x92\xd1 … \n\x02\x08\x01'

		Parameters
		----------
		cid : Union[str, cid.CIDv0, cid.CIDv1]
			The CID of an existing block to get
github ipfs / py-ipfs-http-client / ipfshttpclient / client / bootstrap.py View on Github external
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from . import base


class Section(base.SectionBase):
	@base.returns_single_item
	def add(self, peer, *peers, **kwargs):
		"""Adds peers to the bootstrap list.

		Parameters
		----------
		peer : str
			IPFS MultiAddr of a peer to add to the list

		Returns
		-------
			dict
		"""
		args = (peer,) + peers
		return self._client.request('/bootstrap/add', args, decoder='json', **kwargs)
github ipfs / py-ipfs-http-client / ipfshttpclient / client / pin.py View on Github external
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from . import base


class Section(base.SectionBase):
	@base.returns_single_item
	def add(self, path, *paths, **kwargs):
		"""Pins objects to local storage.

		Stores an IPFS object(s) from a given path locally to disk.

		.. code-block:: python

			>>> client.pin.add("QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d")
			{'Pins': ['QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d']}

		Parameters
		----------
		path : str
			Path to object(s) to be pinned
		recursive : bool