|
| 1 | +from . import base |
| 2 | + |
| 3 | + |
| 4 | +class Section(base.SectionBase): |
| 5 | + def service_add(self, service: str, endpoint: str, |
| 6 | + key: str, |
| 7 | + **kwargs: base.CommonArgs): |
| 8 | + args = (service, endpoint, key) |
| 9 | + return self._client.request('/pin/remote/service/add', |
| 10 | + args, **kwargs) |
| 11 | + |
| 12 | + @base.returns_single_item(base.ResponseBase) |
| 13 | + def service_ls(self, stat: bool = False, **kwargs: base.CommonArgs): |
| 14 | + kwargs.setdefault('opts', {'stat': stat}) |
| 15 | + |
| 16 | + return self._client.request('/pin/remote/service/ls', (), |
| 17 | + decoder='json', **kwargs) |
| 18 | + |
| 19 | + def service_rm(self, service: str, **kwargs: base.CommonArgs): |
| 20 | + args = (service,) |
| 21 | + return self._client.request('/pin/remote/service/rm', args, **kwargs) |
| 22 | + |
| 23 | + @base.returns_single_item(base.ResponseBase) |
| 24 | + def add(self, service: str, path: base.cid_t, |
| 25 | + name: str = None, background = False, |
| 26 | + **kwargs: base.CommonArgs): |
| 27 | + opts = { |
| 28 | + 'service': service, |
| 29 | + 'arg': path, |
| 30 | + 'background': background |
| 31 | + } |
| 32 | + if name: |
| 33 | + opts['name'] = name |
| 34 | + |
| 35 | + kwargs.setdefault('opts', opts) |
| 36 | + |
| 37 | + return self._client.request('/pin/remote/add', (), |
| 38 | + decoder='json', **kwargs) |
| 39 | + |
| 40 | + @base.returns_multiple_items(base.ResponseBase) |
| 41 | + def ls(self, service: str, |
| 42 | + name: str = None, cid: list = [], |
| 43 | + status: list = ['pinned'], |
| 44 | + **kwargs: base.CommonArgs): |
| 45 | + opts = { |
| 46 | + 'service': service, |
| 47 | + 'status': status |
| 48 | + } |
| 49 | + |
| 50 | + if len(cid) > 0: |
| 51 | + opts['cid'] = cid |
| 52 | + |
| 53 | + if name: |
| 54 | + opts['name'] = name |
| 55 | + |
| 56 | + kwargs.setdefault('opts', opts) |
| 57 | + |
| 58 | + return self._client.request('/pin/remote/ls', (), |
| 59 | + decoder='json', **kwargs) |
| 60 | + |
| 61 | + def rm(self, service: str, |
| 62 | + name: str = None, cid: list = [], |
| 63 | + status: list = ['pinned'], |
| 64 | + force: bool = False, |
| 65 | + **kwargs: base.CommonArgs): |
| 66 | + opts = { |
| 67 | + 'service': service, |
| 68 | + 'cid': cid, |
| 69 | + 'status': status, |
| 70 | + 'force': force |
| 71 | + } |
| 72 | + |
| 73 | + if len(cid) > 0: |
| 74 | + opts['cid'] = cid |
| 75 | + |
| 76 | + if name is not None: |
| 77 | + opts['name'] = name |
| 78 | + |
| 79 | + kwargs.setdefault('opts', opts) |
| 80 | + |
| 81 | + return self._client.request('/pin/remote/rm', (), **kwargs) |
0 commit comments