Endpoints

class restfly.endpoint.APIEndpoint(api: restfly.session.APISession)[source]

APIEndpoint is the base model for which all API endpoint classes are sired from. The main benefit is the addition of the _check() function from which it’s possible to check the type & content of a variable to ensure that we are passing good data to the API.

_path

The URI path to append to the base path as is specified in the APISession object. This can become quite useful if most of the CRUD follows the same pathing. It is only used when using the APIEndpoint verbs (_get, _post, _put, etc.).

Type:str
_box

An endpoint-specific version of APISession._box.

Type:bool
_box_attrs

An endpoint-specific version of APISession._box_attrs.

Type:bool
_conv_json

An endpoint-specific version of APISession._conv_json.

Type:bool
Parameters:api (APISession) – The APISession (or sired child) instance that the endpoint will be using to perform calls to the API.
_delete(path: Optional[str] = None, **kwargs) → Union[<Mock name='mock.Box' id='139657312062928'>, <Mock name='mock.BoxList' id='139657312062992'>, requests.models.Response][source]

An abstraction of the APISession.delete method leveraging the local APIEndpoint _path attribute as well. This isn’t intended to be called directly, and instead is offered as a shortcut for methods within the endpoint to use instead of self._api.delete.

Parameters:
  • path (str, optional) – The URI path to append to the base path and _path attribute.
  • **kwargs (dict) – The keyword arguments to pass to the requests lib.

Examples

>>> class Endpoint(APIEndpoint):
...     _path = 'test'
...     def list(**kwargs):
...         return self._delete(**kwargs)
_get(path: Optional[str] = None, **kwargs) → Union[<Mock name='mock.Box' id='139657312062928'>, <Mock name='mock.BoxList' id='139657312062992'>, requests.models.Response][source]

An abstraction of the APISession.get method leveraging the local APIEndpoint _path attribute as well. This isn’t intended to be called directly, and instead is offered as a shortcut for methods within the endpoint to use instead of self._api.get.

Parameters:
  • path (str, optional) – The URI path to append to the base path and _path attribute.
  • **kwargs (dict) – The keyword arguments to pass to the requests lib.

Examples

>>> class Endpoint(APIEndpoint):
...     _path = 'test'
...     def list(**kwargs):
...         return self._get(**kwargs)
_head(path: Optional[str] = None, **kwargs) → Union[<Mock name='mock.Box' id='139657312062928'>, <Mock name='mock.BoxList' id='139657312062992'>, requests.models.Response][source]

An abstraction of the APISession.head method leveraging the local APIEndpoint _path attribute as well. This isn’t intended to be called directly, and instead is offered as a shortcut for methods within the endpoint to use instead of self._api.head.

Parameters:
  • path (str, optional) – The URI path to append to the base path and _path attribute.
  • **kwargs (dict) – The keyword arguments to pass to the requests lib.

Examples

>>> class Endpoint(APIEndpoint):
...     _path = 'test'
...     def list(**kwargs):
...         return self._head(**kwargs)
_patch(path: Optional[str] = None, **kwargs) → Union[<Mock name='mock.Box' id='139657312062928'>, <Mock name='mock.BoxList' id='139657312062992'>, requests.models.Response][source]

An abstraction of the APISession.patch method leveraging the local APIEndpoint _path attribute as well. This isn’t intended to be called directly, and instead is offered as a shortcut for methods within the endpoint to use instead of self._api.patch.

Parameters:
  • path (str, optional) – The URI path to append to the base path and _path attribute.
  • **kwargs (dict) – The keyword arguments to pass to the requests lib.

Examples

>>> class Endpoint(APIEndpoint):
...     _path = 'test'
...     def list(**kwargs):
...         return self._patch(**kwargs)
_post(path: Optional[str] = None, **kwargs) → Union[<Mock name='mock.Box' id='139657312062928'>, <Mock name='mock.BoxList' id='139657312062992'>, requests.models.Response][source]

An abstraction of the APISession.post method leveraging the local APIEndpoint _path attribute as well. This isn’t intended to be called directly, and instead is offered as a shortcut for methods within the endpoint to use instead of self._api.post.

Parameters:
  • path (str, optional) – The URI path to append to the base path and _path attribute.
  • **kwargs (dict) – The keyword arguments to pass to the requests lib.

Examples

>>> class Endpoint(APIEndpoint):
...     _path = 'test'
...     def list(**kwargs):
...         return self._post(**kwargs)
_put(path: Optional[str] = None, **kwargs) → Union[<Mock name='mock.Box' id='139657312062928'>, <Mock name='mock.BoxList' id='139657312062992'>, requests.models.Response][source]

An abstraction of the APISession.put method leveraging the local APIEndpoint _path attribute as well. This isn’t intended to be called directly, and instead is offered as a shortcut for methods within the endpoint to use instead of self._api.put.

Parameters:
  • path (str, optional) – The URI path to append to the base path and _path attribute.
  • **kwargs (dict) – The keyword arguments to pass to the requests lib.

Examples

>>> class Endpoint(APIEndpoint):
...     _path = 'test'
...     def list(**kwargs):
...         return self._put(**kwargs)
_req(method: str, path: Optional[str] = None, **kwargs) → Union[<Mock name='mock.Box' id='139657312062928'>, <Mock name='mock.BoxList' id='139657312062992'>, requests.models.Response][source]

An abstraction of the APISession._req method leveraging the local APIEndpoint _path attribute as well. This isn’t intended to be called directly, and instead is offered as a shortcut for methods within the endpoint to use instead of self._api._req.

Parameters:
  • method (str) – The HTTP method
  • path (str, optional) – The URI path to append to the base path and _path attribute.
  • **kwargs (dict) – The keyword arguments to pass to the requests lib.

Examples

>>> class Endpoint(APIEndpoint):
...     _path = 'test'
...     def list(**kwargs):
...         return self._req('GET', **kwargs)