Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interface for the remote pinning API #314

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ipfshttpclient/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from . import name
from . import object
from . import pin
from . import pinremote
from . import pubsub
from . import repo
#TODO: `from . import stats`
Expand Down Expand Up @@ -186,6 +187,7 @@ def close(self): # Call this when you're done
name = base.SectionProperty(name.Section)
object = base.SectionProperty(object.Section)
pin = base.SectionProperty(pin.Section)
pinremote = base.SectionProperty(pinremote.Section)
pubsub = base.SectionProperty(pubsub.Section)
repo = base.SectionProperty(repo.Section)
swarm = base.SectionProperty(swarm.Section)
Expand Down Expand Up @@ -330,4 +332,4 @@ def get_json(self, cid, **kwargs):
object
Deserialized IPFS JSON object value
"""
return self.cat(cid, decoder='json', **kwargs)
return self.cat(cid, decoder='json', **kwargs)
81 changes: 81 additions & 0 deletions ipfshttpclient/client/pinremote.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
from . import base


class Section(base.SectionBase):
def service_add(self, service: str, endpoint: str,
key: str,
**kwargs: base.CommonArgs):
args = (service, endpoint, key)
return self._client.request('/pin/remote/service/add',
args, **kwargs)

@base.returns_single_item(base.ResponseBase)
def service_ls(self, stat: bool = False, **kwargs: base.CommonArgs):
kwargs.setdefault('opts', {'stat': stat})

return self._client.request('/pin/remote/service/ls', (),
decoder='json', **kwargs)

def service_rm(self, service: str, **kwargs: base.CommonArgs):
args = (service,)
return self._client.request('/pin/remote/service/rm', args, **kwargs)

@base.returns_single_item(base.ResponseBase)
def add(self, service: str, path: base.cid_t,
name: str = None, background = False,
**kwargs: base.CommonArgs):
opts = {
'service': service,
'arg': path,
'background': background
}
if name:
opts['name'] = name

kwargs.setdefault('opts', opts)

return self._client.request('/pin/remote/add', (),
decoder='json', **kwargs)

@base.returns_multiple_items(base.ResponseBase)
def ls(self, service: str,
name: str = None, cid: list = [],
status: list = ['pinned'],
**kwargs: base.CommonArgs):
opts = {
'service': service,
'status': status
}

if len(cid) > 0:
opts['cid'] = cid

if name:
opts['name'] = name

kwargs.setdefault('opts', opts)

return self._client.request('/pin/remote/ls', (),
decoder='json', **kwargs)

def rm(self, service: str,
name: str = None, cid: list = [],
status: list = ['pinned'],
force: bool = False,
**kwargs: base.CommonArgs):
opts = {
'service': service,
'cid': cid,
'status': status,
'force': force
}

if len(cid) > 0:
opts['cid'] = cid

if name is not None:
opts['name'] = name

kwargs.setdefault('opts', opts)

return self._client.request('/pin/remote/rm', (), **kwargs)
2 changes: 1 addition & 1 deletion ipfshttpclient/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
# `0.4.1` and so on. When IPFS `0.5.0` is released, the first client version
# to support it will also be released as `0.5.0`.

__version__ = "0.8.0a2"
__version__ = "0.8.0a3"