From e91f09faf41504c6f388dfbdc36faa7d3cc02a9a Mon Sep 17 00:00:00 2001 From: David Esner Date: Fri, 5 Nov 2021 10:45:52 +0100 Subject: [PATCH 1/2] FEATURE Authentication Methods support --- docs/build_docs.bat | 1 + docs/html/keboola/http_client/auth.html | 444 ++ .../keboola}/http_client/http.html | 5364 +++++++++-------- .../keboola}/http_client/index.html | 135 +- setup.py | 6 +- src/keboola/http_client/auth.py | 98 + src/keboola/http_client/http.py | 21 +- tests/test_auth.py | 52 + 8 files changed, 3394 insertions(+), 2727 deletions(-) create mode 100644 docs/build_docs.bat create mode 100644 docs/html/keboola/http_client/auth.html rename docs/{api-html => html/keboola}/http_client/http.html (96%) rename docs/{api-html => html/keboola}/http_client/index.html (95%) create mode 100644 src/keboola/http_client/auth.py create mode 100644 tests/test_auth.py diff --git a/docs/build_docs.bat b/docs/build_docs.bat new file mode 100644 index 0000000..a73c08f --- /dev/null +++ b/docs/build_docs.bat @@ -0,0 +1 @@ +pdoc --html -f -o .\docs\html keboola.http_client diff --git a/docs/html/keboola/http_client/auth.html b/docs/html/keboola/http_client/auth.html new file mode 100644 index 0000000..145ac10 --- /dev/null +++ b/docs/html/keboola/http_client/auth.html @@ -0,0 +1,444 @@ + + + + + + +keboola.http_client.auth API documentation + + + + + + + + + + + +
+
+
+

Module keboola.http_client.auth

+
+
+
+ +Expand source code + +
import inspect
+from abc import ABC, abstractmethod
+from typing import Callable, Union, Dict
+
+from requests.auth import AuthBase, HTTPBasicAuth
+
+
+class AuthBuilderError(Exception):
+    pass
+
+
+class AuthMethodBase(ABC):
+    """
+    Base class to implement the authentication method. To mark secret constructor parameters prefix them with secret__
+    e.g. __init__(self, username, secret__password)
+    """
+
+    @abstractmethod
+    def login(self):
+        """
+        Perform steps to login and returns requests.aut.AuthBase callable that modifies the request.
+
+        """
+        pass
+
+
+class AuthMethodBuilder:
+    SECRET_PREFIX = "secret__"
+
+    @classmethod
+    def build(cls, method_name: str, **parameters):
+        """
+
+        Args:
+            method_name:
+            **parameters: dictionary of named parameters.
+            Note that parameters prefixed # will be converted to prefix secret__. e.g. #password -> secret__password
+            argument in the AuthMethod
+
+        Returns:
+
+        """
+        supported_actions = cls.get_methods()
+
+        if method_name not in list(supported_actions.keys()):
+            raise AuthBuilderError(f'{method_name} is not supported auth method, '
+                                   f'supported values are: [{list(supported_actions.keys())}]')
+        parameters = cls._convert_secret_parameters(supported_actions[method_name], **parameters)
+        cls._validate_method_arguments(supported_actions[method_name], **parameters)
+
+        return supported_actions[method_name](**parameters)
+
+    @staticmethod
+    def _validate_method_arguments(method: object, **args):
+
+        arguments = [p for p in inspect.signature(method.__init__).parameters if p != 'self']
+        missing_arguments = []
+        for p in arguments:
+            if p not in args:
+                missing_arguments.append(p.replace(AuthMethodBuilder.SECRET_PREFIX, '#'))
+        if missing_arguments:
+            raise AuthBuilderError(f'Some arguments of method {method.__name__} are missing: {missing_arguments}')
+
+    @staticmethod
+    def _convert_secret_parameters(method: object, **parameters):
+        new_parameters = {}
+        for p in parameters:
+            new_parameters[p.replace('#', AuthMethodBuilder.SECRET_PREFIX)] = parameters[p]
+        return new_parameters
+
+    @staticmethod
+    def get_methods() -> Dict[str, Callable]:
+        supported_actions = {}
+        for c in AuthMethodBase.__subclasses__():
+            supported_actions[c.__name__] = c
+        return supported_actions
+
+    @classmethod
+    def get_supported_methods(cls):
+        return list(cls.get_methods().keys())
+
+
+# ########### SUPPORTED AUTHENTICATION METHODS
+
+class BasicHttp(AuthMethodBase):
+
+    def __init__(self, username, secret__password):
+        self.username = username
+        self.password = secret__password
+
+    def login(self) -> Union[AuthBase, Callable]:
+        return HTTPBasicAuth(username=self.username, password=self.password)
+
+    def __eq__(self, other):
+        return all([
+            self.username == getattr(other, 'username', None),
+            self.password == getattr(other, 'password', None)
+        ])
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class AuthBuilderError +(*args, **kwargs) +
+
+

Common base class for all non-exit exceptions.

+
+ +Expand source code + +
class AuthBuilderError(Exception):
+    pass
+
+

Ancestors

+
    +
  • builtins.Exception
  • +
  • builtins.BaseException
  • +
+
+
+class AuthMethodBase +
+
+

Base class to implement the authentication method. To mark secret constructor parameters prefix them with secret__ +e.g. init(self, username, secret__password)

+
+ +Expand source code + +
class AuthMethodBase(ABC):
+    """
+    Base class to implement the authentication method. To mark secret constructor parameters prefix them with secret__
+    e.g. __init__(self, username, secret__password)
+    """
+
+    @abstractmethod
+    def login(self):
+        """
+        Perform steps to login and returns requests.aut.AuthBase callable that modifies the request.
+
+        """
+        pass
+
+

Ancestors

+
    +
  • abc.ABC
  • +
+

Subclasses

+ +

Methods

+
+
+def login(self) +
+
+

Perform steps to login and returns requests.aut.AuthBase callable that modifies the request.

+
+ +Expand source code + +
@abstractmethod
+def login(self):
+    """
+    Perform steps to login and returns requests.aut.AuthBase callable that modifies the request.
+
+    """
+    pass
+
+
+
+
+
+class AuthMethodBuilder +
+
+
+
+ +Expand source code + +
class AuthMethodBuilder:
+    SECRET_PREFIX = "secret__"
+
+    @classmethod
+    def build(cls, method_name: str, **parameters):
+        """
+
+        Args:
+            method_name:
+            **parameters: dictionary of named parameters.
+            Note that parameters prefixed # will be converted to prefix secret__. e.g. #password -> secret__password
+            argument in the AuthMethod
+
+        Returns:
+
+        """
+        supported_actions = cls.get_methods()
+
+        if method_name not in list(supported_actions.keys()):
+            raise AuthBuilderError(f'{method_name} is not supported auth method, '
+                                   f'supported values are: [{list(supported_actions.keys())}]')
+        parameters = cls._convert_secret_parameters(supported_actions[method_name], **parameters)
+        cls._validate_method_arguments(supported_actions[method_name], **parameters)
+
+        return supported_actions[method_name](**parameters)
+
+    @staticmethod
+    def _validate_method_arguments(method: object, **args):
+
+        arguments = [p for p in inspect.signature(method.__init__).parameters if p != 'self']
+        missing_arguments = []
+        for p in arguments:
+            if p not in args:
+                missing_arguments.append(p.replace(AuthMethodBuilder.SECRET_PREFIX, '#'))
+        if missing_arguments:
+            raise AuthBuilderError(f'Some arguments of method {method.__name__} are missing: {missing_arguments}')
+
+    @staticmethod
+    def _convert_secret_parameters(method: object, **parameters):
+        new_parameters = {}
+        for p in parameters:
+            new_parameters[p.replace('#', AuthMethodBuilder.SECRET_PREFIX)] = parameters[p]
+        return new_parameters
+
+    @staticmethod
+    def get_methods() -> Dict[str, Callable]:
+        supported_actions = {}
+        for c in AuthMethodBase.__subclasses__():
+            supported_actions[c.__name__] = c
+        return supported_actions
+
+    @classmethod
+    def get_supported_methods(cls):
+        return list(cls.get_methods().keys())
+
+

Class variables

+
+
var SECRET_PREFIX
+
+
+
+
+

Static methods

+
+
+def build(method_name: str, **parameters) +
+
+

Args

+
+
method_name:
+
**parameters
+
dictionary of named parameters.
+
+

Note that parameters prefixed # will be converted to prefix secret__. e.g. #password -> secret__password +argument in the AuthMethod +Returns:

+
+ +Expand source code + +
@classmethod
+def build(cls, method_name: str, **parameters):
+    """
+
+    Args:
+        method_name:
+        **parameters: dictionary of named parameters.
+        Note that parameters prefixed # will be converted to prefix secret__. e.g. #password -> secret__password
+        argument in the AuthMethod
+
+    Returns:
+
+    """
+    supported_actions = cls.get_methods()
+
+    if method_name not in list(supported_actions.keys()):
+        raise AuthBuilderError(f'{method_name} is not supported auth method, '
+                               f'supported values are: [{list(supported_actions.keys())}]')
+    parameters = cls._convert_secret_parameters(supported_actions[method_name], **parameters)
+    cls._validate_method_arguments(supported_actions[method_name], **parameters)
+
+    return supported_actions[method_name](**parameters)
+
+
+
+def get_methods() ‑> Dict[str, Callable] +
+
+
+
+ +Expand source code + +
@staticmethod
+def get_methods() -> Dict[str, Callable]:
+    supported_actions = {}
+    for c in AuthMethodBase.__subclasses__():
+        supported_actions[c.__name__] = c
+    return supported_actions
+
+
+
+def get_supported_methods() +
+
+
+
+ +Expand source code + +
@classmethod
+def get_supported_methods(cls):
+    return list(cls.get_methods().keys())
+
+
+
+
+
+class BasicHttp +(username, secret__password) +
+
+

Base class to implement the authentication method. To mark secret constructor parameters prefix them with secret__ +e.g. init(self, username, secret__password)

+
+ +Expand source code + +
class BasicHttp(AuthMethodBase):
+
+    def __init__(self, username, secret__password):
+        self.username = username
+        self.password = secret__password
+
+    def login(self) -> Union[AuthBase, Callable]:
+        return HTTPBasicAuth(username=self.username, password=self.password)
+
+    def __eq__(self, other):
+        return all([
+            self.username == getattr(other, 'username', None),
+            self.password == getattr(other, 'password', None)
+        ])
+
+

Ancestors

+ +

Inherited members

+ +
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/docs/api-html/http_client/http.html b/docs/html/keboola/http_client/http.html similarity index 96% rename from docs/api-html/http_client/http.html rename to docs/html/keboola/http_client/http.html index 9a07eb3..e33da5d 100644 --- a/docs/api-html/http_client/http.html +++ b/docs/html/keboola/http_client/http.html @@ -1,2656 +1,2710 @@ - - - - - - -keboola.http_client.http API documentation - - - - - - - - - - - -
-
-
-

Module keboola.http_client.http

-
-
-
- -Expand source code - -
import functools
-import logging
-import urllib.parse as urlparse
-from http.cookiejar import CookieJar
-from typing import Dict, Union, Tuple, Optional
-
-import requests
-from requests.adapters import HTTPAdapter
-from requests.packages.urllib3.util.retry import Retry
-
-Cookie = Union[Dict[str, str], CookieJar]
-
-METHOD_RETRY_WHITELIST = ('GET', 'POST', 'PATCH', 'UPDATE', 'PUT', 'DELETE')
-ALLOWED_METHODS = ['GET', 'POST', 'PATCH', 'UPDATE', 'PUT', 'DELETE']
-
-
-class HttpClient:
-    """
-    Base class for implementing a simple HTTP client. Typically used as a base for a REST service client.
-
-
-    Usage:
-
-    ```python
-    from keboola.http_client import HttpClient
-
-    BASE_URL = 'https://connection.keboola.com/v2/storage/'
-    AUTH_HEADER = {
-        'x-storageapi-token': '1234-STORAGETOKENSTRING'
-    }
-    DEFAULT_PARAMS = {
-        'include': 'columns'
-    }
-    DEFAULT_HEADER = {
-        'Content-Type': 'application/json'
-    }
-
-    cl = HttpClient(BASE_URL, default_http_header=DEFAULT_HEADER,
-                    auth_header=AUTH_HEADER, default_params=DEFAULT_PARAMS)
-
-    files_response = cl.get("files", params={"showExpired": True})
-    ```
-
-    """
-
-    def __init__(self, base_url: str, max_retries: int = 10, backoff_factor: float = 0.3,
-                 status_forcelist: Tuple[int, ...] = (500, 502, 504), default_http_header: Dict = None,
-                 auth_header: Dict = None, auth: Tuple = None, default_params: Dict = None,
-                 allowed_methods: Tuple = METHOD_RETRY_WHITELIST):
-        """
-        Create an endpoint.
-
-        Args:
-            base_url: The base URL for this endpoint. e.g. https://exampleservice.com/api_v1/
-            max_retries: Total number of retries to allow.
-            backoff_factor:  A back-off factor to apply between attempts.
-            status_forcelist:  A set of HTTP status codes that we should force a retry on. e.g. [500,502]
-            default_http_header: Default header to be sent with each request
-                eg. ```{
-                        'Content-Type' : 'application/json',
-                        'Accept' : 'application/json'
-                    }```
-            auth_header: Auth header to be sent with each request
-                eg. `{'Authorization': 'Bearer ' + token}`
-            auth: Default Authentication tuple or object to attach to (from  requests.Session().auth).
-                eg. auth = (user, password)
-            default_params: default parameters to be sent with each request eg. `{'param':'value'}`
-            allowed_methods (tuple): Set of upper-cased HTTP method verbs that we should retry on.
-        """
-        if base_url is None:
-            raise ValueError("Base URL is required.")
-        # Add trailing slash because of nature of urllib.parse.urljoin()
-        self.base_url = base_url if base_url.endswith('/') else base_url + '/'
-        self.max_retries = max_retries
-        self.backoff_factor = backoff_factor
-        self.status_forcelist = status_forcelist
-        self._auth = auth
-        self._auth_header = auth_header if auth_header else {}
-        self._default_header = default_http_header if default_http_header else {}
-        self._default_params = default_params
-        self.allowed_methods = allowed_methods
-
-    def _requests_retry_session(self, session=None):
-        session = session or requests.Session()
-        retry = Retry(
-            total=self.max_retries,
-            read=self.max_retries,
-            connect=self.max_retries,
-            backoff_factor=self.backoff_factor,
-            status_forcelist=self.status_forcelist,
-            allowed_methods=self.allowed_methods
-        )
-        adapter = HTTPAdapter(max_retries=retry)
-        session.mount('http://', adapter)
-        session.mount('https://', adapter)
-        return session
-
-    def _build_url(self, endpoint_path: Optional[str] = None, is_absolute_path=False):
-        # build URL Specification
-        url_path = str(endpoint_path).strip() if endpoint_path is not None else ''
-
-        if not url_path:
-            url = self.base_url
-        elif not is_absolute_path:
-            url = urlparse.urljoin(self.base_url, endpoint_path)
-        else:
-            url = endpoint_path
-
-        return url
-
-    def _request_raw(self, method: str, endpoint_path: Optional[str] = None, **kwargs) -> requests.Response:
-        """
-        Construct a requests call with args and kwargs and process the
-        results.
-
-        Args:
-            method: A HTTP method to be used. One of PUT/POST/PATCH/GET/UPDATE/DELETE
-            endpoint_path (Optional[str]): Optional full URL or a relative URL path. If empty the base_url is used.
-            **kwargs: Key word arguments to pass to the
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-                Accepts supported params in requests.sessions.Session#request
-                eg. params = {'locId':'1'}, header = {some additional header}
-                parameters and headers are appended to the default ones
-                ignore_auth  - True to skip authentication
-                is_absolute_path - False to append URL to base url; True to override base url with value of url arg.
-
-        Returns:
-            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-        """
-        s = requests.Session()
-
-        # build URL Specification
-        is_absolute_path = kwargs.pop('is_absolute_path', False)
-        url = self._build_url(endpoint_path, is_absolute_path)
-
-        # Update headers
-        headers = kwargs.pop('headers', {})
-        if headers is None:
-            headers = {}
-
-        # Default headers
-        headers.update(self._default_header)
-
-        # Auth headers
-        if kwargs.pop('ignore_auth', False) is False:
-            headers.update(self._auth_header)
-            s.headers.update(headers)
-            s.auth = self._auth
-
-        s.headers.update(headers)
-
-        # Update parameters
-        params = kwargs.pop('params', {})
-        if params is None:
-            params = {}
-
-        # Default parameters
-        if self._default_params is not None:
-            all_pars = {**params, **self._default_params}
-            kwargs.update({'params': all_pars})
-
-        else:
-            kwargs.update({'params': params})
-
-        r = self._requests_retry_session(session=s).request(method, url, **kwargs)
-        return r
-
-    def response_error_handling(func):
-        """Function, that handles response handling of HTTP requests.
-        """
-
-        @functools.wraps(func)
-        def wrapper(*args, **kwargs):
-            try:
-                r = func(*args, **kwargs)
-                r.raise_for_status()
-            except requests.HTTPError as e:
-                logging.warning(e, exc_info=True)
-                # Handle different error codes
-                raise
-            else:
-                return r.json()
-
-        return wrapper
-
-    def update_auth_header(self, updated_header: Dict, overwrite: bool = False):
-        """
-        Updates the default auth header by providing new values.
-
-        Args:
-            updated_header: An updated header which will be used to update the current header.
-            overwrite: If `False`, the existing header will be updated with new header. If `True`, the new header will
-                overwrite (replace) the current authentication header.
-        """
-
-        if overwrite is False:
-            self._auth_header.update(updated_header)
-        else:
-            self._auth_header = updated_header
-
-    def get_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-                is_absolute_path: bool = False, cookies: Cookie = None,
-                ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests GET call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-        """
-
-        method = 'GET'
-        return self._request_raw(method, endpoint_path, params=params, headers=headers, cookies=cookies,
-                                 is_absolute_path=is_absolute_path, ignore_auth=ignore_auth, **kwargs)
-
-    @response_error_handling
-    def get(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-            is_absolute_path: bool = False, cookies: Cookie = None,
-            ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests GET call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A JSON-encoded response of the request.
-
-        Raises:
-            requests.HTTPError: If the API request fails.
-        """
-
-        return self.get_raw(endpoint_path, params=params, headers=headers, cookies=cookies,
-                            is_absolute_path=is_absolute_path, ignore_auth=ignore_auth, **kwargs)
-
-    def post_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-                 data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
-                 files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests POST call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-        """
-
-        method = 'POST'
-        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
-                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
-                                 ignore_auth=ignore_auth, **kwargs)
-
-    @response_error_handling
-    def post(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
-             json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
-             ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests POST call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A JSON-encoded response of the request.
-
-        Raises:
-            requests.HTTPError: If the API request fails.
-        """
-
-        return self.post_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
-                             is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
-
-    def patch_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-                  data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
-                  files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests PATCH call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-        """
-
-        method = 'PATCH'
-        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
-                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
-                                 ignore_auth=ignore_auth, **kwargs)
-
-    @response_error_handling
-    def patch(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
-              json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
-              ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests PATCH call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A JSON-encoded response of the request.
-
-        Raises:
-            requests.HTTPError: If the API request fails.
-        """
-
-        return self.patch_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
-                              is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
-
-    def update_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-                   data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
-                   files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests UPDATE call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-        """
-
-        method = 'UPDATE'
-        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
-                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
-                                 ignore_auth=ignore_auth, **kwargs)
-
-    @response_error_handling
-    def update(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
-               json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
-               ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests UPDATE call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A JSON-encoded response of the request.
-
-        Raises:
-            requests.HTTPError: If the API request fails.
-        """
-
-        return self.update_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
-                               is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
-
-    def put_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-                data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
-                files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests PUT call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-        """
-
-        method = 'PUT'
-        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
-                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
-                                 ignore_auth=ignore_auth, **kwargs)
-
-    @response_error_handling
-    def put(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
-            json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
-            ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests PUT call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A JSON-encoded response of the request.
-
-        Raises:
-            requests.HTTPError: If the API request fails.
-        """
-
-        return self.put_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
-                            is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
-
-    def delete_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-                   data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
-                   files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests DELETE call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-        """
-
-        method = 'DELETE'
-        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
-                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
-                                 ignore_auth=ignore_auth, **kwargs)
-
-    @response_error_handling
-    def delete(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
-               json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
-               ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests DELETE call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A JSON-encoded response of the request.
-
-        Raises:
-            requests.HTTPError: If the API request fails.
-        """
-
-        return self.delete_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
-                               is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
-
-
-
-
-
-
-
-
-
-

Classes

-
-
-class HttpClient -(base_url: str, max_retries: int = 10, backoff_factor: float = 0.3, status_forcelist: Tuple[int, ...] = (500, 502, 504), default_http_header: Dict = None, auth_header: Dict = None, auth: Tuple = None, default_params: Dict = None, allowed_methods: Tuple = ('GET', 'POST', 'PATCH', 'UPDATE', 'PUT', 'DELETE')) -
-
-

Base class for implementing a simple HTTP client. Typically used as a base for a REST service client.

-

Usage:

-
from keboola.http_client import HttpClient
-
-BASE_URL = 'https://connection.keboola.com/v2/storage/'
-AUTH_HEADER = {
-    'x-storageapi-token': '1234-STORAGETOKENSTRING'
-}
-DEFAULT_PARAMS = {
-    'include': 'columns'
-}
-DEFAULT_HEADER = {
-    'Content-Type': 'application/json'
-}
-
-cl = HttpClient(BASE_URL, default_http_header=DEFAULT_HEADER,
-                auth_header=AUTH_HEADER, default_params=DEFAULT_PARAMS)
-
-files_response = cl.get("files", params={"showExpired": True})
-
-

Create an endpoint.

-

Args

-
-
base_url
-
The base URL for this endpoint. e.g. https://exampleservice.com/api_v1/
-
max_retries
-
Total number of retries to allow.
-
backoff_factor
-
A back-off factor to apply between attempts.
-
status_forcelist
-
A set of HTTP status codes that we should force a retry on. e.g. [500,502]
-
default_http_header
-
Default header to be sent with each request -eg. { -'Content-Type' : 'application/json', -'Accept' : 'application/json' -}
-
auth_header
-
Auth header to be sent with each request -eg. {'Authorization': 'Bearer ' + token}
-
auth
-
Default Authentication tuple or object to attach to (from -requests.Session().auth). -eg. auth = (user, password)
-
default_params
-
default parameters to be sent with each request eg. {'param':'value'}
-
allowed_methods : tuple
-
Set of upper-cased HTTP method verbs that we should retry on.
-
-
- -Expand source code - -
class HttpClient:
-    """
-    Base class for implementing a simple HTTP client. Typically used as a base for a REST service client.
-
-
-    Usage:
-
-    ```python
-    from keboola.http_client import HttpClient
-
-    BASE_URL = 'https://connection.keboola.com/v2/storage/'
-    AUTH_HEADER = {
-        'x-storageapi-token': '1234-STORAGETOKENSTRING'
-    }
-    DEFAULT_PARAMS = {
-        'include': 'columns'
-    }
-    DEFAULT_HEADER = {
-        'Content-Type': 'application/json'
-    }
-
-    cl = HttpClient(BASE_URL, default_http_header=DEFAULT_HEADER,
-                    auth_header=AUTH_HEADER, default_params=DEFAULT_PARAMS)
-
-    files_response = cl.get("files", params={"showExpired": True})
-    ```
-
-    """
-
-    def __init__(self, base_url: str, max_retries: int = 10, backoff_factor: float = 0.3,
-                 status_forcelist: Tuple[int, ...] = (500, 502, 504), default_http_header: Dict = None,
-                 auth_header: Dict = None, auth: Tuple = None, default_params: Dict = None,
-                 allowed_methods: Tuple = METHOD_RETRY_WHITELIST):
-        """
-        Create an endpoint.
-
-        Args:
-            base_url: The base URL for this endpoint. e.g. https://exampleservice.com/api_v1/
-            max_retries: Total number of retries to allow.
-            backoff_factor:  A back-off factor to apply between attempts.
-            status_forcelist:  A set of HTTP status codes that we should force a retry on. e.g. [500,502]
-            default_http_header: Default header to be sent with each request
-                eg. ```{
-                        'Content-Type' : 'application/json',
-                        'Accept' : 'application/json'
-                    }```
-            auth_header: Auth header to be sent with each request
-                eg. `{'Authorization': 'Bearer ' + token}`
-            auth: Default Authentication tuple or object to attach to (from  requests.Session().auth).
-                eg. auth = (user, password)
-            default_params: default parameters to be sent with each request eg. `{'param':'value'}`
-            allowed_methods (tuple): Set of upper-cased HTTP method verbs that we should retry on.
-        """
-        if base_url is None:
-            raise ValueError("Base URL is required.")
-        # Add trailing slash because of nature of urllib.parse.urljoin()
-        self.base_url = base_url if base_url.endswith('/') else base_url + '/'
-        self.max_retries = max_retries
-        self.backoff_factor = backoff_factor
-        self.status_forcelist = status_forcelist
-        self._auth = auth
-        self._auth_header = auth_header if auth_header else {}
-        self._default_header = default_http_header if default_http_header else {}
-        self._default_params = default_params
-        self.allowed_methods = allowed_methods
-
-    def _requests_retry_session(self, session=None):
-        session = session or requests.Session()
-        retry = Retry(
-            total=self.max_retries,
-            read=self.max_retries,
-            connect=self.max_retries,
-            backoff_factor=self.backoff_factor,
-            status_forcelist=self.status_forcelist,
-            allowed_methods=self.allowed_methods
-        )
-        adapter = HTTPAdapter(max_retries=retry)
-        session.mount('http://', adapter)
-        session.mount('https://', adapter)
-        return session
-
-    def _build_url(self, endpoint_path: Optional[str] = None, is_absolute_path=False):
-        # build URL Specification
-        url_path = str(endpoint_path).strip() if endpoint_path is not None else ''
-
-        if not url_path:
-            url = self.base_url
-        elif not is_absolute_path:
-            url = urlparse.urljoin(self.base_url, endpoint_path)
-        else:
-            url = endpoint_path
-
-        return url
-
-    def _request_raw(self, method: str, endpoint_path: Optional[str] = None, **kwargs) -> requests.Response:
-        """
-        Construct a requests call with args and kwargs and process the
-        results.
-
-        Args:
-            method: A HTTP method to be used. One of PUT/POST/PATCH/GET/UPDATE/DELETE
-            endpoint_path (Optional[str]): Optional full URL or a relative URL path. If empty the base_url is used.
-            **kwargs: Key word arguments to pass to the
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-                Accepts supported params in requests.sessions.Session#request
-                eg. params = {'locId':'1'}, header = {some additional header}
-                parameters and headers are appended to the default ones
-                ignore_auth  - True to skip authentication
-                is_absolute_path - False to append URL to base url; True to override base url with value of url arg.
-
-        Returns:
-            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-        """
-        s = requests.Session()
-
-        # build URL Specification
-        is_absolute_path = kwargs.pop('is_absolute_path', False)
-        url = self._build_url(endpoint_path, is_absolute_path)
-
-        # Update headers
-        headers = kwargs.pop('headers', {})
-        if headers is None:
-            headers = {}
-
-        # Default headers
-        headers.update(self._default_header)
-
-        # Auth headers
-        if kwargs.pop('ignore_auth', False) is False:
-            headers.update(self._auth_header)
-            s.headers.update(headers)
-            s.auth = self._auth
-
-        s.headers.update(headers)
-
-        # Update parameters
-        params = kwargs.pop('params', {})
-        if params is None:
-            params = {}
-
-        # Default parameters
-        if self._default_params is not None:
-            all_pars = {**params, **self._default_params}
-            kwargs.update({'params': all_pars})
-
-        else:
-            kwargs.update({'params': params})
-
-        r = self._requests_retry_session(session=s).request(method, url, **kwargs)
-        return r
-
-    def response_error_handling(func):
-        """Function, that handles response handling of HTTP requests.
-        """
-
-        @functools.wraps(func)
-        def wrapper(*args, **kwargs):
-            try:
-                r = func(*args, **kwargs)
-                r.raise_for_status()
-            except requests.HTTPError as e:
-                logging.warning(e, exc_info=True)
-                # Handle different error codes
-                raise
-            else:
-                return r.json()
-
-        return wrapper
-
-    def update_auth_header(self, updated_header: Dict, overwrite: bool = False):
-        """
-        Updates the default auth header by providing new values.
-
-        Args:
-            updated_header: An updated header which will be used to update the current header.
-            overwrite: If `False`, the existing header will be updated with new header. If `True`, the new header will
-                overwrite (replace) the current authentication header.
-        """
-
-        if overwrite is False:
-            self._auth_header.update(updated_header)
-        else:
-            self._auth_header = updated_header
-
-    def get_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-                is_absolute_path: bool = False, cookies: Cookie = None,
-                ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests GET call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-        """
-
-        method = 'GET'
-        return self._request_raw(method, endpoint_path, params=params, headers=headers, cookies=cookies,
-                                 is_absolute_path=is_absolute_path, ignore_auth=ignore_auth, **kwargs)
-
-    @response_error_handling
-    def get(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-            is_absolute_path: bool = False, cookies: Cookie = None,
-            ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests GET call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A JSON-encoded response of the request.
-
-        Raises:
-            requests.HTTPError: If the API request fails.
-        """
-
-        return self.get_raw(endpoint_path, params=params, headers=headers, cookies=cookies,
-                            is_absolute_path=is_absolute_path, ignore_auth=ignore_auth, **kwargs)
-
-    def post_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-                 data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
-                 files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests POST call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-        """
-
-        method = 'POST'
-        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
-                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
-                                 ignore_auth=ignore_auth, **kwargs)
-
-    @response_error_handling
-    def post(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
-             json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
-             ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests POST call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A JSON-encoded response of the request.
-
-        Raises:
-            requests.HTTPError: If the API request fails.
-        """
-
-        return self.post_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
-                             is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
-
-    def patch_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-                  data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
-                  files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests PATCH call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-        """
-
-        method = 'PATCH'
-        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
-                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
-                                 ignore_auth=ignore_auth, **kwargs)
-
-    @response_error_handling
-    def patch(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
-              json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
-              ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests PATCH call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A JSON-encoded response of the request.
-
-        Raises:
-            requests.HTTPError: If the API request fails.
-        """
-
-        return self.patch_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
-                              is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
-
-    def update_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-                   data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
-                   files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests UPDATE call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-        """
-
-        method = 'UPDATE'
-        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
-                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
-                                 ignore_auth=ignore_auth, **kwargs)
-
-    @response_error_handling
-    def update(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
-               json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
-               ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests UPDATE call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A JSON-encoded response of the request.
-
-        Raises:
-            requests.HTTPError: If the API request fails.
-        """
-
-        return self.update_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
-                               is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
-
-    def put_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-                data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
-                files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests PUT call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-        """
-
-        method = 'PUT'
-        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
-                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
-                                 ignore_auth=ignore_auth, **kwargs)
-
-    @response_error_handling
-    def put(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
-            json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
-            ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests PUT call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A JSON-encoded response of the request.
-
-        Raises:
-            requests.HTTPError: If the API request fails.
-        """
-
-        return self.put_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
-                            is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
-
-    def delete_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-                   data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
-                   files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests DELETE call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-        """
-
-        method = 'DELETE'
-        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
-                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
-                                 ignore_auth=ignore_auth, **kwargs)
-
-    @response_error_handling
-    def delete(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
-               json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
-               ignore_auth: bool = False, **kwargs) -> requests.Response:
-        """
-        Constructs a requests DELETE call with specified url and kwargs to process the result.
-
-        Args:
-            endpoint_path: Relative URL path or absolute URL to which the request will be made.
-                By default a relative path is expected and will be appended to the `self.base_url` value.
-
-                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-                or used as an absolute URL.
-            params: Dictionary to send in the query string for the request.
-            headers: Dictionary of HTTP Headers to send with the request.
-            data: Dictionary to send in the body of the request.
-            json: A JSON serializable Python object to send in the body of the request.
-            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-                is an absolute path or not.
-
-                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-                function.
-
-                If set to True, base url will be overridden and the value of the `endpoint_path` will
-                used instead.
-            cookies: Dict or CookieJar object of cookies to send with the request
-            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-            **kwargs: All other keyword arguments supported by
-                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-        Returns:
-            A JSON-encoded response of the request.
-
-        Raises:
-            requests.HTTPError: If the API request fails.
-        """
-
-        return self.delete_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
-                               is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
-
-

Methods

-
-
-def delete(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response -
-
-

Constructs a requests DELETE call with specified url and kwargs to process the result.

-

Args

-
-
endpoint_path
-
-

Relative URL path or absolute URL to which the request will be made. -By default a relative path is expected and will be appended to the self.base_url value.

-

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, -or used as an absolute URL.

-
-
params
-
Dictionary to send in the query string for the request.
-
headers
-
Dictionary of HTTP Headers to send with the request.
-
data
-
Dictionary to send in the body of the request.
-
json
-
A JSON serializable Python object to send in the body of the request.
-
is_absolute_path
-
-

A boolean value specifying, whether the URL specified in endpoint_path parameter -is an absolute path or not.

-

If set to False, the value of endpoint_path will be appended to self.base_url using -urllib.parse.urljoin() -function.

-

If set to True, base url will be overridden and the value of the endpoint_path will -used instead.

-
-
cookies
-
Dict or CookieJar object of cookies to send with the request
-
files
-
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-
ignore_auth
-
Boolean marking, whether the default auth_header should be ignored.
-
**kwargs
-
All other keyword arguments supported by -requests.request.
-
-

Returns

-

A JSON-encoded response of the request.

-

Raises

-
-
requests.HTTPError
-
If the API request fails.
-
-
- -Expand source code - -
@response_error_handling
-def delete(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
-           json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
-           ignore_auth: bool = False, **kwargs) -> requests.Response:
-    """
-    Constructs a requests DELETE call with specified url and kwargs to process the result.
-
-    Args:
-        endpoint_path: Relative URL path or absolute URL to which the request will be made.
-            By default a relative path is expected and will be appended to the `self.base_url` value.
-
-            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-            or used as an absolute URL.
-        params: Dictionary to send in the query string for the request.
-        headers: Dictionary of HTTP Headers to send with the request.
-        data: Dictionary to send in the body of the request.
-        json: A JSON serializable Python object to send in the body of the request.
-        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-            is an absolute path or not.
-
-            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-            function.
-
-            If set to True, base url will be overridden and the value of the `endpoint_path` will
-            used instead.
-        cookies: Dict or CookieJar object of cookies to send with the request
-        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-        **kwargs: All other keyword arguments supported by
-            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-    Returns:
-        A JSON-encoded response of the request.
-
-    Raises:
-        requests.HTTPError: If the API request fails.
-    """
-
-    return self.delete_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
-                           is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
-
-
-
-def delete_raw(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response -
-
-

Constructs a requests DELETE call with specified url and kwargs to process the result.

-

Args

-
-
endpoint_path
-
-

Relative URL path or absolute URL to which the request will be made. -By default a relative path is expected and will be appended to the self.base_url value.

-

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, -or used as an absolute URL.

-
-
params
-
Dictionary to send in the query string for the request.
-
headers
-
Dictionary of HTTP Headers to send with the request.
-
data
-
Dictionary to send in the body of the request.
-
json
-
A JSON serializable Python object to send in the body of the request.
-
is_absolute_path
-
-

A boolean value specifying, whether the URL specified in endpoint_path parameter -is an absolute path or not.

-

If set to False, the value of endpoint_path will be appended to self.base_url using -urllib.parse.urljoin() -function.

-

If set to True, base url will be overridden and the value of the endpoint_path will -used instead.

-
-
cookies
-
Dict or CookieJar object of cookies to send with the request
-
files
-
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-
ignore_auth
-
Boolean marking, whether the default auth_header should be ignored.
-
**kwargs
-
All other keyword arguments supported by -requests.request.
-
-

Returns

-

A requests.Response object.

-
- -Expand source code - -
def delete_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-               data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
-               files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
-    """
-    Constructs a requests DELETE call with specified url and kwargs to process the result.
-
-    Args:
-        endpoint_path: Relative URL path or absolute URL to which the request will be made.
-            By default a relative path is expected and will be appended to the `self.base_url` value.
-
-            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-            or used as an absolute URL.
-        params: Dictionary to send in the query string for the request.
-        headers: Dictionary of HTTP Headers to send with the request.
-        data: Dictionary to send in the body of the request.
-        json: A JSON serializable Python object to send in the body of the request.
-        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-            is an absolute path or not.
-
-            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-            function.
-
-            If set to True, base url will be overridden and the value of the `endpoint_path` will
-            used instead.
-        cookies: Dict or CookieJar object of cookies to send with the request
-        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-        **kwargs: All other keyword arguments supported by
-            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-    Returns:
-        A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-    """
-
-    method = 'DELETE'
-    return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
-                             cookies=cookies, is_absolute_path=is_absolute_path, files=files,
-                             ignore_auth=ignore_auth, **kwargs)
-
-
-
-def get(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response -
-
-

Constructs a requests GET call with specified url and kwargs to process the result.

-

Args

-
-
endpoint_path
-
-

Relative URL path or absolute URL to which the request will be made. -By default a relative path is expected and will be appended to the self.base_url value.

-

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, -or used as an absolute URL.

-
-
params
-
Dictionary to send in the query string for the request.
-
headers
-
Dictionary of HTTP Headers to send with the request.
-
is_absolute_path
-
-

A boolean value specifying, whether the URL specified in endpoint_path parameter -is an absolute path or not.

-

If set to False, the value of endpoint_path will be appended to self.base_url using -urllib.parse.urljoin() -function.

-

If set to True, base url will be overridden and the value of the endpoint_path will -used instead.

-
-
cookies
-
Dict or CookieJar object of cookies to send with the request
-
files
-
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-
ignore_auth
-
Boolean marking, whether the default auth_header should be ignored.
-
**kwargs
-
All other keyword arguments supported by -requests.request.
-
-

Returns

-

A JSON-encoded response of the request.

-

Raises

-
-
requests.HTTPError
-
If the API request fails.
-
-
- -Expand source code - -
@response_error_handling
-def get(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-        is_absolute_path: bool = False, cookies: Cookie = None,
-        ignore_auth: bool = False, **kwargs) -> requests.Response:
-    """
-    Constructs a requests GET call with specified url and kwargs to process the result.
-
-    Args:
-        endpoint_path: Relative URL path or absolute URL to which the request will be made.
-            By default a relative path is expected and will be appended to the `self.base_url` value.
-
-            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-            or used as an absolute URL.
-        params: Dictionary to send in the query string for the request.
-        headers: Dictionary of HTTP Headers to send with the request.
-        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-            is an absolute path or not.
-
-            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-            function.
-
-            If set to True, base url will be overridden and the value of the `endpoint_path` will
-            used instead.
-        cookies: Dict or CookieJar object of cookies to send with the request
-        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-        **kwargs: All other keyword arguments supported by
-            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-    Returns:
-        A JSON-encoded response of the request.
-
-    Raises:
-        requests.HTTPError: If the API request fails.
-    """
-
-    return self.get_raw(endpoint_path, params=params, headers=headers, cookies=cookies,
-                        is_absolute_path=is_absolute_path, ignore_auth=ignore_auth, **kwargs)
-
-
-
-def get_raw(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response -
-
-

Constructs a requests GET call with specified url and kwargs to process the result.

-

Args

-
-
endpoint_path
-
-

Relative URL path or absolute URL to which the request will be made. -By default a relative path is expected and will be appended to the self.base_url value.

-

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, -or used as an absolute URL.

-
-
params
-
Dictionary to send in the query string for the request.
-
headers
-
Dictionary of HTTP Headers to send with the request.
-
is_absolute_path
-
-

A boolean value specifying, whether the URL specified in endpoint_path parameter -is an absolute path or not.

-

If set to False, the value of endpoint_path will be appended to self.base_url using -urllib.parse.urljoin() -function.

-

If set to True, base url will be overridden and the value of the endpoint_path will -used instead.

-
-
cookies
-
Dict or CookieJar object of cookies to send with the request
-
ignore_auth
-
Boolean marking, whether the default auth_header should be ignored.
-
**kwargs
-
All other keyword arguments supported by -requests.request.
-
-

Returns

-

A requests.Response object.

-
- -Expand source code - -
def get_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-            is_absolute_path: bool = False, cookies: Cookie = None,
-            ignore_auth: bool = False, **kwargs) -> requests.Response:
-    """
-    Constructs a requests GET call with specified url and kwargs to process the result.
-
-    Args:
-        endpoint_path: Relative URL path or absolute URL to which the request will be made.
-            By default a relative path is expected and will be appended to the `self.base_url` value.
-
-            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-            or used as an absolute URL.
-        params: Dictionary to send in the query string for the request.
-        headers: Dictionary of HTTP Headers to send with the request.
-        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-            is an absolute path or not.
-
-            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-            function.
-
-            If set to True, base url will be overridden and the value of the `endpoint_path` will
-            used instead.
-        cookies: Dict or CookieJar object of cookies to send with the request
-        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-        **kwargs: All other keyword arguments supported by
-            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-    Returns:
-        A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-    """
-
-    method = 'GET'
-    return self._request_raw(method, endpoint_path, params=params, headers=headers, cookies=cookies,
-                             is_absolute_path=is_absolute_path, ignore_auth=ignore_auth, **kwargs)
-
-
-
-def patch(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response -
-
-

Constructs a requests PATCH call with specified url and kwargs to process the result.

-

Args

-
-
endpoint_path
-
-

Relative URL path or absolute URL to which the request will be made. -By default a relative path is expected and will be appended to the self.base_url value.

-

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, -or used as an absolute URL.

-
-
params
-
Dictionary to send in the query string for the request.
-
headers
-
Dictionary of HTTP Headers to send with the request.
-
data
-
Dictionary to send in the body of the request.
-
json
-
A JSON serializable Python object to send in the body of the request.
-
is_absolute_path
-
-

A boolean value specifying, whether the URL specified in endpoint_path parameter -is an absolute path or not.

-

If set to False, the value of endpoint_path will be appended to self.base_url using -urllib.parse.urljoin() -function.

-

If set to True, base url will be overridden and the value of the endpoint_path will -used instead.

-
-
cookies
-
Dict or CookieJar object of cookies to send with the request
-
files
-
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-
ignore_auth
-
Boolean marking, whether the default auth_header should be ignored.
-
**kwargs
-
All other keyword arguments supported by -requests.request.
-
-

Returns

-

A JSON-encoded response of the request.

-

Raises

-
-
requests.HTTPError
-
If the API request fails.
-
-
- -Expand source code - -
@response_error_handling
-def patch(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
-          json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
-          ignore_auth: bool = False, **kwargs) -> requests.Response:
-    """
-    Constructs a requests PATCH call with specified url and kwargs to process the result.
-
-    Args:
-        endpoint_path: Relative URL path or absolute URL to which the request will be made.
-            By default a relative path is expected and will be appended to the `self.base_url` value.
-
-            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-            or used as an absolute URL.
-        params: Dictionary to send in the query string for the request.
-        headers: Dictionary of HTTP Headers to send with the request.
-        data: Dictionary to send in the body of the request.
-        json: A JSON serializable Python object to send in the body of the request.
-        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-            is an absolute path or not.
-
-            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-            function.
-
-            If set to True, base url will be overridden and the value of the `endpoint_path` will
-            used instead.
-        cookies: Dict or CookieJar object of cookies to send with the request
-        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-        **kwargs: All other keyword arguments supported by
-            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-    Returns:
-        A JSON-encoded response of the request.
-
-    Raises:
-        requests.HTTPError: If the API request fails.
-    """
-
-    return self.patch_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
-                          is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
-
-
-
-def patch_raw(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response -
-
-

Constructs a requests PATCH call with specified url and kwargs to process the result.

-

Args

-
-
endpoint_path
-
-

Relative URL path or absolute URL to which the request will be made. -By default a relative path is expected and will be appended to the self.base_url value.

-

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, -or used as an absolute URL.

-
-
params
-
Dictionary to send in the query string for the request.
-
headers
-
Dictionary of HTTP Headers to send with the request.
-
data
-
Dictionary to send in the body of the request.
-
json
-
A JSON serializable Python object to send in the body of the request.
-
is_absolute_path
-
-

A boolean value specifying, whether the URL specified in endpoint_path parameter -is an absolute path or not.

-

If set to False, the value of endpoint_path will be appended to self.base_url using -urllib.parse.urljoin() -function.

-

If set to True, base url will be overridden and the value of the endpoint_path will -used instead.

-
-
cookies
-
Dict or CookieJar object of cookies to send with the request
-
files
-
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-
ignore_auth
-
Boolean marking, whether the default auth_header should be ignored.
-
**kwargs
-
All other keyword arguments supported by -requests.request.
-
-

Returns

-

A requests.Response object.

-
- -Expand source code - -
def patch_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-              data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
-              files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
-    """
-    Constructs a requests PATCH call with specified url and kwargs to process the result.
-
-    Args:
-        endpoint_path: Relative URL path or absolute URL to which the request will be made.
-            By default a relative path is expected and will be appended to the `self.base_url` value.
-
-            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-            or used as an absolute URL.
-        params: Dictionary to send in the query string for the request.
-        headers: Dictionary of HTTP Headers to send with the request.
-        data: Dictionary to send in the body of the request.
-        json: A JSON serializable Python object to send in the body of the request.
-        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-            is an absolute path or not.
-
-            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-            function.
-
-            If set to True, base url will be overridden and the value of the `endpoint_path` will
-            used instead.
-        cookies: Dict or CookieJar object of cookies to send with the request
-        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-        **kwargs: All other keyword arguments supported by
-            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-    Returns:
-        A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-    """
-
-    method = 'PATCH'
-    return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
-                             cookies=cookies, is_absolute_path=is_absolute_path, files=files,
-                             ignore_auth=ignore_auth, **kwargs)
-
-
-
-def post(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response -
-
-

Constructs a requests POST call with specified url and kwargs to process the result.

-

Args

-
-
endpoint_path
-
-

Relative URL path or absolute URL to which the request will be made. -By default a relative path is expected and will be appended to the self.base_url value.

-

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, -or used as an absolute URL.

-
-
params
-
Dictionary to send in the query string for the request.
-
headers
-
Dictionary of HTTP Headers to send with the request.
-
data
-
Dictionary to send in the body of the request.
-
json
-
A JSON serializable Python object to send in the body of the request.
-
is_absolute_path
-
-

A boolean value specifying, whether the URL specified in endpoint_path parameter -is an absolute path or not.

-

If set to False, the value of endpoint_path will be appended to self.base_url using -urllib.parse.urljoin() -function.

-

If set to True, base url will be overridden and the value of the endpoint_path will -used instead.

-
-
cookies
-
Dict or CookieJar object of cookies to send with the request
-
files
-
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-
ignore_auth
-
Boolean marking, whether the default auth_header should be ignored.
-
**kwargs
-
All other keyword arguments supported by -requests.request.
-
-

Returns

-

A JSON-encoded response of the request.

-

Raises

-
-
requests.HTTPError
-
If the API request fails.
-
-
- -Expand source code - -
@response_error_handling
-def post(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
-         json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
-         ignore_auth: bool = False, **kwargs) -> requests.Response:
-    """
-    Constructs a requests POST call with specified url and kwargs to process the result.
-
-    Args:
-        endpoint_path: Relative URL path or absolute URL to which the request will be made.
-            By default a relative path is expected and will be appended to the `self.base_url` value.
-
-            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-            or used as an absolute URL.
-        params: Dictionary to send in the query string for the request.
-        headers: Dictionary of HTTP Headers to send with the request.
-        data: Dictionary to send in the body of the request.
-        json: A JSON serializable Python object to send in the body of the request.
-        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-            is an absolute path or not.
-
-            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-            function.
-
-            If set to True, base url will be overridden and the value of the `endpoint_path` will
-            used instead.
-        cookies: Dict or CookieJar object of cookies to send with the request
-        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-        **kwargs: All other keyword arguments supported by
-            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-    Returns:
-        A JSON-encoded response of the request.
-
-    Raises:
-        requests.HTTPError: If the API request fails.
-    """
-
-    return self.post_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
-                         is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
-
-
-
-def post_raw(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response -
-
-

Constructs a requests POST call with specified url and kwargs to process the result.

-

Args

-
-
endpoint_path
-
-

Relative URL path or absolute URL to which the request will be made. -By default a relative path is expected and will be appended to the self.base_url value.

-

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, -or used as an absolute URL.

-
-
params
-
Dictionary to send in the query string for the request.
-
headers
-
Dictionary of HTTP Headers to send with the request.
-
data
-
Dictionary to send in the body of the request.
-
json
-
A JSON serializable Python object to send in the body of the request.
-
is_absolute_path
-
-

A boolean value specifying, whether the URL specified in endpoint_path parameter -is an absolute path or not.

-

If set to False, the value of endpoint_path will be appended to self.base_url using -urllib.parse.urljoin() -function.

-

If set to True, base url will be overridden and the value of the endpoint_path will -used instead.

-
-
cookies
-
Dict or CookieJar object of cookies to send with the request
-
files
-
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-
ignore_auth
-
Boolean marking, whether the default auth_header should be ignored.
-
**kwargs
-
All other keyword arguments supported by -requests.request.
-
-

Returns

-

A requests.Response object.

-
- -Expand source code - -
def post_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-             data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
-             files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
-    """
-    Constructs a requests POST call with specified url and kwargs to process the result.
-
-    Args:
-        endpoint_path: Relative URL path or absolute URL to which the request will be made.
-            By default a relative path is expected and will be appended to the `self.base_url` value.
-
-            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-            or used as an absolute URL.
-        params: Dictionary to send in the query string for the request.
-        headers: Dictionary of HTTP Headers to send with the request.
-        data: Dictionary to send in the body of the request.
-        json: A JSON serializable Python object to send in the body of the request.
-        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-            is an absolute path or not.
-
-            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-            function.
-
-            If set to True, base url will be overridden and the value of the `endpoint_path` will
-            used instead.
-        cookies: Dict or CookieJar object of cookies to send with the request
-        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-        **kwargs: All other keyword arguments supported by
-            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-    Returns:
-        A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-    """
-
-    method = 'POST'
-    return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
-                             cookies=cookies, is_absolute_path=is_absolute_path, files=files,
-                             ignore_auth=ignore_auth, **kwargs)
-
-
-
-def put(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response -
-
-

Constructs a requests PUT call with specified url and kwargs to process the result.

-

Args

-
-
endpoint_path
-
-

Relative URL path or absolute URL to which the request will be made. -By default a relative path is expected and will be appended to the self.base_url value.

-

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, -or used as an absolute URL.

-
-
params
-
Dictionary to send in the query string for the request.
-
headers
-
Dictionary of HTTP Headers to send with the request.
-
data
-
Dictionary to send in the body of the request.
-
json
-
A JSON serializable Python object to send in the body of the request.
-
is_absolute_path
-
-

A boolean value specifying, whether the URL specified in endpoint_path parameter -is an absolute path or not.

-

If set to False, the value of endpoint_path will be appended to self.base_url using -urllib.parse.urljoin() -function.

-

If set to True, base url will be overridden and the value of the endpoint_path will -used instead.

-
-
cookies
-
Dict or CookieJar object of cookies to send with the request
-
files
-
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-
ignore_auth
-
Boolean marking, whether the default auth_header should be ignored.
-
**kwargs
-
All other keyword arguments supported by -requests.request.
-
-

Returns

-

A JSON-encoded response of the request.

-

Raises

-
-
requests.HTTPError
-
If the API request fails.
-
-
- -Expand source code - -
@response_error_handling
-def put(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
-        json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
-        ignore_auth: bool = False, **kwargs) -> requests.Response:
-    """
-    Constructs a requests PUT call with specified url and kwargs to process the result.
-
-    Args:
-        endpoint_path: Relative URL path or absolute URL to which the request will be made.
-            By default a relative path is expected and will be appended to the `self.base_url` value.
-
-            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-            or used as an absolute URL.
-        params: Dictionary to send in the query string for the request.
-        headers: Dictionary of HTTP Headers to send with the request.
-        data: Dictionary to send in the body of the request.
-        json: A JSON serializable Python object to send in the body of the request.
-        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-            is an absolute path or not.
-
-            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-            function.
-
-            If set to True, base url will be overridden and the value of the `endpoint_path` will
-            used instead.
-        cookies: Dict or CookieJar object of cookies to send with the request
-        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-        **kwargs: All other keyword arguments supported by
-            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-    Returns:
-        A JSON-encoded response of the request.
-
-    Raises:
-        requests.HTTPError: If the API request fails.
-    """
-
-    return self.put_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
-                        is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
-
-
-
-def put_raw(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response -
-
-

Constructs a requests PUT call with specified url and kwargs to process the result.

-

Args

-
-
endpoint_path
-
-

Relative URL path or absolute URL to which the request will be made. -By default a relative path is expected and will be appended to the self.base_url value.

-

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, -or used as an absolute URL.

-
-
params
-
Dictionary to send in the query string for the request.
-
headers
-
Dictionary of HTTP Headers to send with the request.
-
data
-
Dictionary to send in the body of the request.
-
json
-
A JSON serializable Python object to send in the body of the request.
-
is_absolute_path
-
-

A boolean value specifying, whether the URL specified in endpoint_path parameter -is an absolute path or not.

-

If set to False, the value of endpoint_path will be appended to self.base_url using -urllib.parse.urljoin() -function.

-

If set to True, base url will be overridden and the value of the endpoint_path will -used instead.

-
-
cookies
-
Dict or CookieJar object of cookies to send with the request
-
files
-
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-
ignore_auth
-
Boolean marking, whether the default auth_header should be ignored.
-
**kwargs
-
All other keyword arguments supported by -requests.request.
-
-

Returns

-

A requests.Response object.

-
- -Expand source code - -
def put_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-            data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
-            files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
-    """
-    Constructs a requests PUT call with specified url and kwargs to process the result.
-
-    Args:
-        endpoint_path: Relative URL path or absolute URL to which the request will be made.
-            By default a relative path is expected and will be appended to the `self.base_url` value.
-
-            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-            or used as an absolute URL.
-        params: Dictionary to send in the query string for the request.
-        headers: Dictionary of HTTP Headers to send with the request.
-        data: Dictionary to send in the body of the request.
-        json: A JSON serializable Python object to send in the body of the request.
-        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-            is an absolute path or not.
-
-            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-            function.
-
-            If set to True, base url will be overridden and the value of the `endpoint_path` will
-            used instead.
-        cookies: Dict or CookieJar object of cookies to send with the request
-        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-        **kwargs: All other keyword arguments supported by
-            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-    Returns:
-        A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-    """
-
-    method = 'PUT'
-    return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
-                             cookies=cookies, is_absolute_path=is_absolute_path, files=files,
-                             ignore_auth=ignore_auth, **kwargs)
-
-
-
-def response_error_handling(func) -
-
-

Function, that handles response handling of HTTP requests.

-
- -Expand source code - -
def response_error_handling(func):
-    """Function, that handles response handling of HTTP requests.
-    """
-
-    @functools.wraps(func)
-    def wrapper(*args, **kwargs):
-        try:
-            r = func(*args, **kwargs)
-            r.raise_for_status()
-        except requests.HTTPError as e:
-            logging.warning(e, exc_info=True)
-            # Handle different error codes
-            raise
-        else:
-            return r.json()
-
-    return wrapper
-
-
-
-def update(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response -
-
-

Constructs a requests UPDATE call with specified url and kwargs to process the result.

-

Args

-
-
endpoint_path
-
-

Relative URL path or absolute URL to which the request will be made. -By default a relative path is expected and will be appended to the self.base_url value.

-

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, -or used as an absolute URL.

-
-
params
-
Dictionary to send in the query string for the request.
-
headers
-
Dictionary of HTTP Headers to send with the request.
-
data
-
Dictionary to send in the body of the request.
-
json
-
A JSON serializable Python object to send in the body of the request.
-
is_absolute_path
-
-

A boolean value specifying, whether the URL specified in endpoint_path parameter -is an absolute path or not.

-

If set to False, the value of endpoint_path will be appended to self.base_url using -urllib.parse.urljoin() -function.

-

If set to True, base url will be overridden and the value of the endpoint_path will -used instead.

-
-
cookies
-
Dict or CookieJar object of cookies to send with the request
-
files
-
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-
ignore_auth
-
Boolean marking, whether the default auth_header should be ignored.
-
**kwargs
-
All other keyword arguments supported by -requests.request.
-
-

Returns

-

A JSON-encoded response of the request.

-

Raises

-
-
requests.HTTPError
-
If the API request fails.
-
-
- -Expand source code - -
@response_error_handling
-def update(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
-           json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
-           ignore_auth: bool = False, **kwargs) -> requests.Response:
-    """
-    Constructs a requests UPDATE call with specified url and kwargs to process the result.
-
-    Args:
-        endpoint_path: Relative URL path or absolute URL to which the request will be made.
-            By default a relative path is expected and will be appended to the `self.base_url` value.
-
-            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-            or used as an absolute URL.
-        params: Dictionary to send in the query string for the request.
-        headers: Dictionary of HTTP Headers to send with the request.
-        data: Dictionary to send in the body of the request.
-        json: A JSON serializable Python object to send in the body of the request.
-        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-            is an absolute path or not.
-
-            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-            function.
-
-            If set to True, base url will be overridden and the value of the `endpoint_path` will
-            used instead.
-        cookies: Dict or CookieJar object of cookies to send with the request
-        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-        **kwargs: All other keyword arguments supported by
-            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-    Returns:
-        A JSON-encoded response of the request.
-
-    Raises:
-        requests.HTTPError: If the API request fails.
-    """
-
-    return self.update_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
-                           is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
-
-
-
-def update_auth_header(self, updated_header: Dict, overwrite: bool = False) -
-
-

Updates the default auth header by providing new values.

-

Args

-
-
updated_header
-
An updated header which will be used to update the current header.
-
overwrite
-
If False, the existing header will be updated with new header. If True, the new header will -overwrite (replace) the current authentication header.
-
-
- -Expand source code - -
def update_auth_header(self, updated_header: Dict, overwrite: bool = False):
-    """
-    Updates the default auth header by providing new values.
-
-    Args:
-        updated_header: An updated header which will be used to update the current header.
-        overwrite: If `False`, the existing header will be updated with new header. If `True`, the new header will
-            overwrite (replace) the current authentication header.
-    """
-
-    if overwrite is False:
-        self._auth_header.update(updated_header)
-    else:
-        self._auth_header = updated_header
-
-
-
-def update_raw(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response -
-
-

Constructs a requests UPDATE call with specified url and kwargs to process the result.

-

Args

-
-
endpoint_path
-
-

Relative URL path or absolute URL to which the request will be made. -By default a relative path is expected and will be appended to the self.base_url value.

-

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, -or used as an absolute URL.

-
-
params
-
Dictionary to send in the query string for the request.
-
headers
-
Dictionary of HTTP Headers to send with the request.
-
data
-
Dictionary to send in the body of the request.
-
json
-
A JSON serializable Python object to send in the body of the request.
-
is_absolute_path
-
-

A boolean value specifying, whether the URL specified in endpoint_path parameter -is an absolute path or not.

-

If set to False, the value of endpoint_path will be appended to self.base_url using -urllib.parse.urljoin() -function.

-

If set to True, base url will be overridden and the value of the endpoint_path will -used instead.

-
-
cookies
-
Dict or CookieJar object of cookies to send with the request
-
files
-
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-
ignore_auth
-
Boolean marking, whether the default auth_header should be ignored.
-
**kwargs
-
All other keyword arguments supported by -requests.request.
-
-

Returns

-

A requests.Response object.

-
- -Expand source code - -
def update_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
-               data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
-               files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
-    """
-    Constructs a requests UPDATE call with specified url and kwargs to process the result.
-
-    Args:
-        endpoint_path: Relative URL path or absolute URL to which the request will be made.
-            By default a relative path is expected and will be appended to the `self.base_url` value.
-
-            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
-            or used as an absolute URL.
-        params: Dictionary to send in the query string for the request.
-        headers: Dictionary of HTTP Headers to send with the request.
-        data: Dictionary to send in the body of the request.
-        json: A JSON serializable Python object to send in the body of the request.
-        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
-            is an absolute path or not.
-
-            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
-            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
-            function.
-
-            If set to True, base url will be overridden and the value of the `endpoint_path` will
-            used instead.
-        cookies: Dict or CookieJar object of cookies to send with the request
-        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
-        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
-        **kwargs: All other keyword arguments supported by
-            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
-
-    Returns:
-        A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
-    """
-
-    method = 'UPDATE'
-    return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
-                             cookies=cookies, is_absolute_path=is_absolute_path, files=files,
-                             ignore_auth=ignore_auth, **kwargs)
-
-
-
-
-
-
-
- -
- - + + + + + + +keboola.http_client.http API documentation + + + + + + + + + + + +
+
+
+

Module keboola.http_client.http

+
+
+
+ +Expand source code + +
import functools
+import logging
+import urllib.parse as urlparse
+from http.cookiejar import CookieJar
+from typing import Dict, Union, Tuple, Optional
+
+import requests
+from requests.adapters import HTTPAdapter
+from requests.packages.urllib3.util.retry import Retry
+
+from keboola.http_client.auth import AuthMethodBase
+
+Cookie = Union[Dict[str, str], CookieJar]
+
+METHOD_RETRY_WHITELIST = ('GET', 'POST', 'PATCH', 'UPDATE', 'PUT', 'DELETE')
+ALLOWED_METHODS = ['GET', 'POST', 'PATCH', 'UPDATE', 'PUT', 'DELETE']
+
+
+class HttpClient:
+    """
+    Base class for implementing a simple HTTP client. Typically used as a base for a REST service client.
+
+
+    Usage:
+
+    ```python
+    from keboola.http_client import HttpClient
+
+    BASE_URL = 'https://connection.keboola.com/v2/storage/'
+    AUTH_HEADER = {
+        'x-storageapi-token': '1234-STORAGETOKENSTRING'
+    }
+    DEFAULT_PARAMS = {
+        'include': 'columns'
+    }
+    DEFAULT_HEADER = {
+        'Content-Type': 'application/json'
+    }
+
+    cl = HttpClient(BASE_URL, default_http_header=DEFAULT_HEADER,
+                    auth_header=AUTH_HEADER, default_params=DEFAULT_PARAMS)
+
+    files_response = cl.get("files", params={"showExpired": True})
+    ```
+
+    """
+
+    def __init__(self, base_url: str, max_retries: int = 10, backoff_factor: float = 0.3,
+                 status_forcelist: Tuple[int, ...] = (500, 502, 504), default_http_header: Dict = None,
+                 auth_header: Dict = None, auth: Tuple = None, default_params: Dict = None,
+                 allowed_methods: Tuple = METHOD_RETRY_WHITELIST,
+                 auth_method: AuthMethodBase = None):
+        """
+        Create an endpoint.
+
+        Args:
+            base_url: The base URL for this endpoint. e.g. https://exampleservice.com/api_v1/
+            max_retries: Total number of retries to allow.
+            backoff_factor:  A back-off factor to apply between attempts.
+            status_forcelist:  A set of HTTP status codes that we should force a retry on. e.g. [500,502]
+            default_http_header: Default header to be sent with each request
+                eg. ```{
+                        'Content-Type' : 'application/json',
+                        'Accept' : 'application/json'
+                    }```
+            auth_header: Auth header to be sent with each request
+                eg. `{'Authorization': 'Bearer ' + token}`
+            auth: Default Authentication tuple or object to attach to (from  requests.Session().auth).
+                eg. auth = (user, password)
+            default_params: default parameters to be sent with each request eg. `{'param':'value'}`
+            allowed_methods (tuple): Set of upper-cased HTTP method verbs that we should retry on.
+            auth_method: AuthMethodBase: requests.aut.AuthBase callable that modifies the request to add
+                    authentication. login() method needs to be called to perform the authentication. All subsequent
+                    request will be authenticated.
+        """
+        if base_url is None:
+            raise ValueError("Base URL is required.")
+        # Add trailing slash because of nature of urllib.parse.urljoin()
+        self.base_url = base_url if base_url.endswith('/') else base_url + '/'
+        self.max_retries = max_retries
+        self.backoff_factor = backoff_factor
+        self.status_forcelist = status_forcelist
+        self._auth = auth
+        self._auth_header = auth_header if auth_header else {}
+        self._default_header = default_http_header if default_http_header else {}
+        self._default_params = default_params
+        self.allowed_methods = allowed_methods
+        self._auth_method = auth_method
+
+    def login(self):
+        """
+        Perform login based on auth method
+
+        """
+        # perform login
+        if self._auth_method:
+            self._auth = self._auth_method.login()
+
+    def _requests_retry_session(self, session=None):
+        session = session or requests.Session()
+        retry = Retry(
+            total=self.max_retries,
+            read=self.max_retries,
+            connect=self.max_retries,
+            backoff_factor=self.backoff_factor,
+            status_forcelist=self.status_forcelist,
+            allowed_methods=self.allowed_methods
+        )
+        adapter = HTTPAdapter(max_retries=retry)
+        session.mount('http://', adapter)
+        session.mount('https://', adapter)
+        return session
+
+    def _build_url(self, endpoint_path: Optional[str] = None, is_absolute_path=False):
+        # build URL Specification
+        url_path = str(endpoint_path).strip() if endpoint_path is not None else ''
+
+        if not url_path:
+            url = self.base_url
+        elif not is_absolute_path:
+            url = urlparse.urljoin(self.base_url, endpoint_path)
+        else:
+            url = endpoint_path
+
+        return url
+
+    def _request_raw(self, method: str, endpoint_path: Optional[str] = None, **kwargs) -> requests.Response:
+        """
+        Construct a requests call with args and kwargs and process the
+        results.
+
+        Args:
+            method: A HTTP method to be used. One of PUT/POST/PATCH/GET/UPDATE/DELETE
+            endpoint_path (Optional[str]): Optional full URL or a relative URL path. If empty the base_url is used.
+            **kwargs: Key word arguments to pass to the
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+                Accepts supported params in requests.sessions.Session#request
+                eg. params = {'locId':'1'}, header = {some additional header}
+                parameters and headers are appended to the default ones
+                ignore_auth  - True to skip authentication
+                is_absolute_path - False to append URL to base url; True to override base url with value of url arg.
+
+        Returns:
+            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+        """
+        s = requests.Session()
+
+        # build URL Specification
+        is_absolute_path = kwargs.pop('is_absolute_path', False)
+        url = self._build_url(endpoint_path, is_absolute_path)
+
+        # Update headers
+        headers = kwargs.pop('headers', {})
+        if headers is None:
+            headers = {}
+
+        # Default headers
+        headers.update(self._default_header)
+
+        # Auth headers
+        if kwargs.pop('ignore_auth', False) is False:
+            headers.update(self._auth_header)
+            s.headers.update(headers)
+            s.auth = self._auth
+
+        s.headers.update(headers)
+
+        # Update parameters
+        params = kwargs.pop('params', {})
+        if params is None:
+            params = {}
+
+        # Default parameters
+        if self._default_params is not None:
+            all_pars = {**params, **self._default_params}
+            kwargs.update({'params': all_pars})
+
+        else:
+            kwargs.update({'params': params})
+
+        r = self._requests_retry_session(session=s).request(method, url, **kwargs)
+        return r
+
+    def response_error_handling(func):
+        """Function, that handles response handling of HTTP requests.
+        """
+
+        @functools.wraps(func)
+        def wrapper(*args, **kwargs):
+            try:
+                r = func(*args, **kwargs)
+                r.raise_for_status()
+            except requests.HTTPError as e:
+                logging.warning(e, exc_info=True)
+                # Handle different error codes
+                raise
+            else:
+                return r.json()
+
+        return wrapper
+
+    def update_auth_header(self, updated_header: Dict, overwrite: bool = False):
+        """
+        Updates the default auth header by providing new values.
+
+        Args:
+            updated_header: An updated header which will be used to update the current header.
+            overwrite: If `False`, the existing header will be updated with new header. If `True`, the new header will
+                overwrite (replace) the current authentication header.
+        """
+
+        if overwrite is False:
+            self._auth_header.update(updated_header)
+        else:
+            self._auth_header = updated_header
+
+    def get_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+                is_absolute_path: bool = False, cookies: Cookie = None,
+                ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests GET call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+        """
+
+        method = 'GET'
+        return self._request_raw(method, endpoint_path, params=params, headers=headers, cookies=cookies,
+                                 is_absolute_path=is_absolute_path, ignore_auth=ignore_auth, **kwargs)
+
+    @response_error_handling
+    def get(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+            is_absolute_path: bool = False, cookies: Cookie = None,
+            ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests GET call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A JSON-encoded response of the request.
+
+        Raises:
+            requests.HTTPError: If the API request fails.
+        """
+
+        return self.get_raw(endpoint_path, params=params, headers=headers, cookies=cookies,
+                            is_absolute_path=is_absolute_path, ignore_auth=ignore_auth, **kwargs)
+
+    def post_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+                 data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
+                 files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests POST call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+        """
+
+        method = 'POST'
+        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
+                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
+                                 ignore_auth=ignore_auth, **kwargs)
+
+    @response_error_handling
+    def post(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
+             json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
+             ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests POST call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A JSON-encoded response of the request.
+
+        Raises:
+            requests.HTTPError: If the API request fails.
+        """
+
+        return self.post_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
+                             is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
+
+    def patch_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+                  data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
+                  files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests PATCH call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+        """
+
+        method = 'PATCH'
+        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
+                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
+                                 ignore_auth=ignore_auth, **kwargs)
+
+    @response_error_handling
+    def patch(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
+              json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
+              ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests PATCH call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A JSON-encoded response of the request.
+
+        Raises:
+            requests.HTTPError: If the API request fails.
+        """
+
+        return self.patch_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
+                              is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
+
+    def update_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+                   data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
+                   files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests UPDATE call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+        """
+
+        method = 'UPDATE'
+        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
+                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
+                                 ignore_auth=ignore_auth, **kwargs)
+
+    @response_error_handling
+    def update(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
+               json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
+               ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests UPDATE call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A JSON-encoded response of the request.
+
+        Raises:
+            requests.HTTPError: If the API request fails.
+        """
+
+        return self.update_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
+                               is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
+
+    def put_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+                data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
+                files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests PUT call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+        """
+
+        method = 'PUT'
+        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
+                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
+                                 ignore_auth=ignore_auth, **kwargs)
+
+    @response_error_handling
+    def put(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
+            json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
+            ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests PUT call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A JSON-encoded response of the request.
+
+        Raises:
+            requests.HTTPError: If the API request fails.
+        """
+
+        return self.put_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
+                            is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
+
+    def delete_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+                   data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
+                   files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests DELETE call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+        """
+
+        method = 'DELETE'
+        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
+                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
+                                 ignore_auth=ignore_auth, **kwargs)
+
+    @response_error_handling
+    def delete(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
+               json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
+               ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests DELETE call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A JSON-encoded response of the request.
+
+        Raises:
+            requests.HTTPError: If the API request fails.
+        """
+
+        return self.delete_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
+                               is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class HttpClient +(base_url: str, max_retries: int = 10, backoff_factor: float = 0.3, status_forcelist: Tuple[int, ...] = (500, 502, 504), default_http_header: Dict = None, auth_header: Dict = None, auth: Tuple = None, default_params: Dict = None, allowed_methods: Tuple = ('GET', 'POST', 'PATCH', 'UPDATE', 'PUT', 'DELETE'), auth_method: AuthMethodBase = None) +
+
+

Base class for implementing a simple HTTP client. Typically used as a base for a REST service client.

+

Usage:

+
from keboola.http_client import HttpClient
+
+BASE_URL = 'https://connection.keboola.com/v2/storage/'
+AUTH_HEADER = {
+    'x-storageapi-token': '1234-STORAGETOKENSTRING'
+}
+DEFAULT_PARAMS = {
+    'include': 'columns'
+}
+DEFAULT_HEADER = {
+    'Content-Type': 'application/json'
+}
+
+cl = HttpClient(BASE_URL, default_http_header=DEFAULT_HEADER,
+                auth_header=AUTH_HEADER, default_params=DEFAULT_PARAMS)
+
+files_response = cl.get("files", params={"showExpired": True})
+
+

Create an endpoint.

+

Args

+
+
base_url
+
The base URL for this endpoint. e.g. https://exampleservice.com/api_v1/
+
max_retries
+
Total number of retries to allow.
+
backoff_factor
+
A back-off factor to apply between attempts.
+
status_forcelist
+
A set of HTTP status codes that we should force a retry on. e.g. [500,502]
+
default_http_header
+
Default header to be sent with each request +eg. { +'Content-Type' : 'application/json', +'Accept' : 'application/json' +}
+
auth_header
+
Auth header to be sent with each request +eg. {'Authorization': 'Bearer ' + token}
+
auth
+
Default Authentication tuple or object to attach to (from +requests.Session().auth). +eg. auth = (user, password)
+
default_params
+
default parameters to be sent with each request eg. {'param':'value'}
+
allowed_methods : tuple
+
Set of upper-cased HTTP method verbs that we should retry on.
+
auth_method
+
AuthMethodBase: requests.aut.AuthBase callable that modifies the request to add +authentication. login() method needs to be called to perform the authentication. All subsequent +request will be authenticated.
+
+
+ +Expand source code + +
class HttpClient:
+    """
+    Base class for implementing a simple HTTP client. Typically used as a base for a REST service client.
+
+
+    Usage:
+
+    ```python
+    from keboola.http_client import HttpClient
+
+    BASE_URL = 'https://connection.keboola.com/v2/storage/'
+    AUTH_HEADER = {
+        'x-storageapi-token': '1234-STORAGETOKENSTRING'
+    }
+    DEFAULT_PARAMS = {
+        'include': 'columns'
+    }
+    DEFAULT_HEADER = {
+        'Content-Type': 'application/json'
+    }
+
+    cl = HttpClient(BASE_URL, default_http_header=DEFAULT_HEADER,
+                    auth_header=AUTH_HEADER, default_params=DEFAULT_PARAMS)
+
+    files_response = cl.get("files", params={"showExpired": True})
+    ```
+
+    """
+
+    def __init__(self, base_url: str, max_retries: int = 10, backoff_factor: float = 0.3,
+                 status_forcelist: Tuple[int, ...] = (500, 502, 504), default_http_header: Dict = None,
+                 auth_header: Dict = None, auth: Tuple = None, default_params: Dict = None,
+                 allowed_methods: Tuple = METHOD_RETRY_WHITELIST,
+                 auth_method: AuthMethodBase = None):
+        """
+        Create an endpoint.
+
+        Args:
+            base_url: The base URL for this endpoint. e.g. https://exampleservice.com/api_v1/
+            max_retries: Total number of retries to allow.
+            backoff_factor:  A back-off factor to apply between attempts.
+            status_forcelist:  A set of HTTP status codes that we should force a retry on. e.g. [500,502]
+            default_http_header: Default header to be sent with each request
+                eg. ```{
+                        'Content-Type' : 'application/json',
+                        'Accept' : 'application/json'
+                    }```
+            auth_header: Auth header to be sent with each request
+                eg. `{'Authorization': 'Bearer ' + token}`
+            auth: Default Authentication tuple or object to attach to (from  requests.Session().auth).
+                eg. auth = (user, password)
+            default_params: default parameters to be sent with each request eg. `{'param':'value'}`
+            allowed_methods (tuple): Set of upper-cased HTTP method verbs that we should retry on.
+            auth_method: AuthMethodBase: requests.aut.AuthBase callable that modifies the request to add
+                    authentication. login() method needs to be called to perform the authentication. All subsequent
+                    request will be authenticated.
+        """
+        if base_url is None:
+            raise ValueError("Base URL is required.")
+        # Add trailing slash because of nature of urllib.parse.urljoin()
+        self.base_url = base_url if base_url.endswith('/') else base_url + '/'
+        self.max_retries = max_retries
+        self.backoff_factor = backoff_factor
+        self.status_forcelist = status_forcelist
+        self._auth = auth
+        self._auth_header = auth_header if auth_header else {}
+        self._default_header = default_http_header if default_http_header else {}
+        self._default_params = default_params
+        self.allowed_methods = allowed_methods
+        self._auth_method = auth_method
+
+    def login(self):
+        """
+        Perform login based on auth method
+
+        """
+        # perform login
+        if self._auth_method:
+            self._auth = self._auth_method.login()
+
+    def _requests_retry_session(self, session=None):
+        session = session or requests.Session()
+        retry = Retry(
+            total=self.max_retries,
+            read=self.max_retries,
+            connect=self.max_retries,
+            backoff_factor=self.backoff_factor,
+            status_forcelist=self.status_forcelist,
+            allowed_methods=self.allowed_methods
+        )
+        adapter = HTTPAdapter(max_retries=retry)
+        session.mount('http://', adapter)
+        session.mount('https://', adapter)
+        return session
+
+    def _build_url(self, endpoint_path: Optional[str] = None, is_absolute_path=False):
+        # build URL Specification
+        url_path = str(endpoint_path).strip() if endpoint_path is not None else ''
+
+        if not url_path:
+            url = self.base_url
+        elif not is_absolute_path:
+            url = urlparse.urljoin(self.base_url, endpoint_path)
+        else:
+            url = endpoint_path
+
+        return url
+
+    def _request_raw(self, method: str, endpoint_path: Optional[str] = None, **kwargs) -> requests.Response:
+        """
+        Construct a requests call with args and kwargs and process the
+        results.
+
+        Args:
+            method: A HTTP method to be used. One of PUT/POST/PATCH/GET/UPDATE/DELETE
+            endpoint_path (Optional[str]): Optional full URL or a relative URL path. If empty the base_url is used.
+            **kwargs: Key word arguments to pass to the
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+                Accepts supported params in requests.sessions.Session#request
+                eg. params = {'locId':'1'}, header = {some additional header}
+                parameters and headers are appended to the default ones
+                ignore_auth  - True to skip authentication
+                is_absolute_path - False to append URL to base url; True to override base url with value of url arg.
+
+        Returns:
+            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+        """
+        s = requests.Session()
+
+        # build URL Specification
+        is_absolute_path = kwargs.pop('is_absolute_path', False)
+        url = self._build_url(endpoint_path, is_absolute_path)
+
+        # Update headers
+        headers = kwargs.pop('headers', {})
+        if headers is None:
+            headers = {}
+
+        # Default headers
+        headers.update(self._default_header)
+
+        # Auth headers
+        if kwargs.pop('ignore_auth', False) is False:
+            headers.update(self._auth_header)
+            s.headers.update(headers)
+            s.auth = self._auth
+
+        s.headers.update(headers)
+
+        # Update parameters
+        params = kwargs.pop('params', {})
+        if params is None:
+            params = {}
+
+        # Default parameters
+        if self._default_params is not None:
+            all_pars = {**params, **self._default_params}
+            kwargs.update({'params': all_pars})
+
+        else:
+            kwargs.update({'params': params})
+
+        r = self._requests_retry_session(session=s).request(method, url, **kwargs)
+        return r
+
+    def response_error_handling(func):
+        """Function, that handles response handling of HTTP requests.
+        """
+
+        @functools.wraps(func)
+        def wrapper(*args, **kwargs):
+            try:
+                r = func(*args, **kwargs)
+                r.raise_for_status()
+            except requests.HTTPError as e:
+                logging.warning(e, exc_info=True)
+                # Handle different error codes
+                raise
+            else:
+                return r.json()
+
+        return wrapper
+
+    def update_auth_header(self, updated_header: Dict, overwrite: bool = False):
+        """
+        Updates the default auth header by providing new values.
+
+        Args:
+            updated_header: An updated header which will be used to update the current header.
+            overwrite: If `False`, the existing header will be updated with new header. If `True`, the new header will
+                overwrite (replace) the current authentication header.
+        """
+
+        if overwrite is False:
+            self._auth_header.update(updated_header)
+        else:
+            self._auth_header = updated_header
+
+    def get_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+                is_absolute_path: bool = False, cookies: Cookie = None,
+                ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests GET call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+        """
+
+        method = 'GET'
+        return self._request_raw(method, endpoint_path, params=params, headers=headers, cookies=cookies,
+                                 is_absolute_path=is_absolute_path, ignore_auth=ignore_auth, **kwargs)
+
+    @response_error_handling
+    def get(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+            is_absolute_path: bool = False, cookies: Cookie = None,
+            ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests GET call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A JSON-encoded response of the request.
+
+        Raises:
+            requests.HTTPError: If the API request fails.
+        """
+
+        return self.get_raw(endpoint_path, params=params, headers=headers, cookies=cookies,
+                            is_absolute_path=is_absolute_path, ignore_auth=ignore_auth, **kwargs)
+
+    def post_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+                 data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
+                 files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests POST call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+        """
+
+        method = 'POST'
+        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
+                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
+                                 ignore_auth=ignore_auth, **kwargs)
+
+    @response_error_handling
+    def post(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
+             json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
+             ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests POST call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A JSON-encoded response of the request.
+
+        Raises:
+            requests.HTTPError: If the API request fails.
+        """
+
+        return self.post_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
+                             is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
+
+    def patch_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+                  data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
+                  files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests PATCH call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+        """
+
+        method = 'PATCH'
+        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
+                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
+                                 ignore_auth=ignore_auth, **kwargs)
+
+    @response_error_handling
+    def patch(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
+              json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
+              ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests PATCH call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A JSON-encoded response of the request.
+
+        Raises:
+            requests.HTTPError: If the API request fails.
+        """
+
+        return self.patch_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
+                              is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
+
+    def update_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+                   data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
+                   files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests UPDATE call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+        """
+
+        method = 'UPDATE'
+        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
+                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
+                                 ignore_auth=ignore_auth, **kwargs)
+
+    @response_error_handling
+    def update(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
+               json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
+               ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests UPDATE call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A JSON-encoded response of the request.
+
+        Raises:
+            requests.HTTPError: If the API request fails.
+        """
+
+        return self.update_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
+                               is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
+
+    def put_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+                data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
+                files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests PUT call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+        """
+
+        method = 'PUT'
+        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
+                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
+                                 ignore_auth=ignore_auth, **kwargs)
+
+    @response_error_handling
+    def put(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
+            json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
+            ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests PUT call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A JSON-encoded response of the request.
+
+        Raises:
+            requests.HTTPError: If the API request fails.
+        """
+
+        return self.put_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
+                            is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
+
+    def delete_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+                   data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
+                   files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests DELETE call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+        """
+
+        method = 'DELETE'
+        return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
+                                 cookies=cookies, is_absolute_path=is_absolute_path, files=files,
+                                 ignore_auth=ignore_auth, **kwargs)
+
+    @response_error_handling
+    def delete(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
+               json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
+               ignore_auth: bool = False, **kwargs) -> requests.Response:
+        """
+        Constructs a requests DELETE call with specified url and kwargs to process the result.
+
+        Args:
+            endpoint_path: Relative URL path or absolute URL to which the request will be made.
+                By default a relative path is expected and will be appended to the `self.base_url` value.
+
+                Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+                or used as an absolute URL.
+            params: Dictionary to send in the query string for the request.
+            headers: Dictionary of HTTP Headers to send with the request.
+            data: Dictionary to send in the body of the request.
+            json: A JSON serializable Python object to send in the body of the request.
+            is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+                is an absolute path or not.
+
+                If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+                [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+                function.
+
+                If set to True, base url will be overridden and the value of the `endpoint_path` will
+                used instead.
+            cookies: Dict or CookieJar object of cookies to send with the request
+            files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+            ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+            **kwargs: All other keyword arguments supported by
+                [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+        Returns:
+            A JSON-encoded response of the request.
+
+        Raises:
+            requests.HTTPError: If the API request fails.
+        """
+
+        return self.delete_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
+                               is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
+
+

Methods

+
+
+def delete(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response +
+
+

Constructs a requests DELETE call with specified url and kwargs to process the result.

+

Args

+
+
endpoint_path
+
+

Relative URL path or absolute URL to which the request will be made. +By default a relative path is expected and will be appended to the self.base_url value.

+

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, +or used as an absolute URL.

+
+
params
+
Dictionary to send in the query string for the request.
+
headers
+
Dictionary of HTTP Headers to send with the request.
+
data
+
Dictionary to send in the body of the request.
+
json
+
A JSON serializable Python object to send in the body of the request.
+
is_absolute_path
+
+

A boolean value specifying, whether the URL specified in endpoint_path parameter +is an absolute path or not.

+

If set to False, the value of endpoint_path will be appended to self.base_url using +urllib.parse.urljoin() +function.

+

If set to True, base url will be overridden and the value of the endpoint_path will +used instead.

+
+
cookies
+
Dict or CookieJar object of cookies to send with the request
+
files
+
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+
ignore_auth
+
Boolean marking, whether the default auth_header should be ignored.
+
**kwargs
+
All other keyword arguments supported by +requests.request.
+
+

Returns

+

A JSON-encoded response of the request.

+

Raises

+
+
requests.HTTPError
+
If the API request fails.
+
+
+ +Expand source code + +
@response_error_handling
+def delete(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
+           json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
+           ignore_auth: bool = False, **kwargs) -> requests.Response:
+    """
+    Constructs a requests DELETE call with specified url and kwargs to process the result.
+
+    Args:
+        endpoint_path: Relative URL path or absolute URL to which the request will be made.
+            By default a relative path is expected and will be appended to the `self.base_url` value.
+
+            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+            or used as an absolute URL.
+        params: Dictionary to send in the query string for the request.
+        headers: Dictionary of HTTP Headers to send with the request.
+        data: Dictionary to send in the body of the request.
+        json: A JSON serializable Python object to send in the body of the request.
+        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+            is an absolute path or not.
+
+            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+            function.
+
+            If set to True, base url will be overridden and the value of the `endpoint_path` will
+            used instead.
+        cookies: Dict or CookieJar object of cookies to send with the request
+        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+        **kwargs: All other keyword arguments supported by
+            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+    Returns:
+        A JSON-encoded response of the request.
+
+    Raises:
+        requests.HTTPError: If the API request fails.
+    """
+
+    return self.delete_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
+                           is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
+
+
+
+def delete_raw(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response +
+
+

Constructs a requests DELETE call with specified url and kwargs to process the result.

+

Args

+
+
endpoint_path
+
+

Relative URL path or absolute URL to which the request will be made. +By default a relative path is expected and will be appended to the self.base_url value.

+

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, +or used as an absolute URL.

+
+
params
+
Dictionary to send in the query string for the request.
+
headers
+
Dictionary of HTTP Headers to send with the request.
+
data
+
Dictionary to send in the body of the request.
+
json
+
A JSON serializable Python object to send in the body of the request.
+
is_absolute_path
+
+

A boolean value specifying, whether the URL specified in endpoint_path parameter +is an absolute path or not.

+

If set to False, the value of endpoint_path will be appended to self.base_url using +urllib.parse.urljoin() +function.

+

If set to True, base url will be overridden and the value of the endpoint_path will +used instead.

+
+
cookies
+
Dict or CookieJar object of cookies to send with the request
+
files
+
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+
ignore_auth
+
Boolean marking, whether the default auth_header should be ignored.
+
**kwargs
+
All other keyword arguments supported by +requests.request.
+
+

Returns

+

A requests.Response object.

+
+ +Expand source code + +
def delete_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+               data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
+               files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
+    """
+    Constructs a requests DELETE call with specified url and kwargs to process the result.
+
+    Args:
+        endpoint_path: Relative URL path or absolute URL to which the request will be made.
+            By default a relative path is expected and will be appended to the `self.base_url` value.
+
+            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+            or used as an absolute URL.
+        params: Dictionary to send in the query string for the request.
+        headers: Dictionary of HTTP Headers to send with the request.
+        data: Dictionary to send in the body of the request.
+        json: A JSON serializable Python object to send in the body of the request.
+        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+            is an absolute path or not.
+
+            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+            function.
+
+            If set to True, base url will be overridden and the value of the `endpoint_path` will
+            used instead.
+        cookies: Dict or CookieJar object of cookies to send with the request
+        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+        **kwargs: All other keyword arguments supported by
+            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+    Returns:
+        A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+    """
+
+    method = 'DELETE'
+    return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
+                             cookies=cookies, is_absolute_path=is_absolute_path, files=files,
+                             ignore_auth=ignore_auth, **kwargs)
+
+
+
+def get(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response +
+
+

Constructs a requests GET call with specified url and kwargs to process the result.

+

Args

+
+
endpoint_path
+
+

Relative URL path or absolute URL to which the request will be made. +By default a relative path is expected and will be appended to the self.base_url value.

+

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, +or used as an absolute URL.

+
+
params
+
Dictionary to send in the query string for the request.
+
headers
+
Dictionary of HTTP Headers to send with the request.
+
is_absolute_path
+
+

A boolean value specifying, whether the URL specified in endpoint_path parameter +is an absolute path or not.

+

If set to False, the value of endpoint_path will be appended to self.base_url using +urllib.parse.urljoin() +function.

+

If set to True, base url will be overridden and the value of the endpoint_path will +used instead.

+
+
cookies
+
Dict or CookieJar object of cookies to send with the request
+
files
+
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+
ignore_auth
+
Boolean marking, whether the default auth_header should be ignored.
+
**kwargs
+
All other keyword arguments supported by +requests.request.
+
+

Returns

+

A JSON-encoded response of the request.

+

Raises

+
+
requests.HTTPError
+
If the API request fails.
+
+
+ +Expand source code + +
@response_error_handling
+def get(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+        is_absolute_path: bool = False, cookies: Cookie = None,
+        ignore_auth: bool = False, **kwargs) -> requests.Response:
+    """
+    Constructs a requests GET call with specified url and kwargs to process the result.
+
+    Args:
+        endpoint_path: Relative URL path or absolute URL to which the request will be made.
+            By default a relative path is expected and will be appended to the `self.base_url` value.
+
+            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+            or used as an absolute URL.
+        params: Dictionary to send in the query string for the request.
+        headers: Dictionary of HTTP Headers to send with the request.
+        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+            is an absolute path or not.
+
+            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+            function.
+
+            If set to True, base url will be overridden and the value of the `endpoint_path` will
+            used instead.
+        cookies: Dict or CookieJar object of cookies to send with the request
+        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+        **kwargs: All other keyword arguments supported by
+            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+    Returns:
+        A JSON-encoded response of the request.
+
+    Raises:
+        requests.HTTPError: If the API request fails.
+    """
+
+    return self.get_raw(endpoint_path, params=params, headers=headers, cookies=cookies,
+                        is_absolute_path=is_absolute_path, ignore_auth=ignore_auth, **kwargs)
+
+
+
+def get_raw(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response +
+
+

Constructs a requests GET call with specified url and kwargs to process the result.

+

Args

+
+
endpoint_path
+
+

Relative URL path or absolute URL to which the request will be made. +By default a relative path is expected and will be appended to the self.base_url value.

+

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, +or used as an absolute URL.

+
+
params
+
Dictionary to send in the query string for the request.
+
headers
+
Dictionary of HTTP Headers to send with the request.
+
is_absolute_path
+
+

A boolean value specifying, whether the URL specified in endpoint_path parameter +is an absolute path or not.

+

If set to False, the value of endpoint_path will be appended to self.base_url using +urllib.parse.urljoin() +function.

+

If set to True, base url will be overridden and the value of the endpoint_path will +used instead.

+
+
cookies
+
Dict or CookieJar object of cookies to send with the request
+
ignore_auth
+
Boolean marking, whether the default auth_header should be ignored.
+
**kwargs
+
All other keyword arguments supported by +requests.request.
+
+

Returns

+

A requests.Response object.

+
+ +Expand source code + +
def get_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+            is_absolute_path: bool = False, cookies: Cookie = None,
+            ignore_auth: bool = False, **kwargs) -> requests.Response:
+    """
+    Constructs a requests GET call with specified url and kwargs to process the result.
+
+    Args:
+        endpoint_path: Relative URL path or absolute URL to which the request will be made.
+            By default a relative path is expected and will be appended to the `self.base_url` value.
+
+            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+            or used as an absolute URL.
+        params: Dictionary to send in the query string for the request.
+        headers: Dictionary of HTTP Headers to send with the request.
+        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+            is an absolute path or not.
+
+            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+            function.
+
+            If set to True, base url will be overridden and the value of the `endpoint_path` will
+            used instead.
+        cookies: Dict or CookieJar object of cookies to send with the request
+        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+        **kwargs: All other keyword arguments supported by
+            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+    Returns:
+        A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+    """
+
+    method = 'GET'
+    return self._request_raw(method, endpoint_path, params=params, headers=headers, cookies=cookies,
+                             is_absolute_path=is_absolute_path, ignore_auth=ignore_auth, **kwargs)
+
+
+
+def login(self) +
+
+

Perform login based on auth method

+
+ +Expand source code + +
def login(self):
+    """
+    Perform login based on auth method
+
+    """
+    # perform login
+    if self._auth_method:
+        self._auth = self._auth_method.login()
+
+
+
+def patch(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response +
+
+

Constructs a requests PATCH call with specified url and kwargs to process the result.

+

Args

+
+
endpoint_path
+
+

Relative URL path or absolute URL to which the request will be made. +By default a relative path is expected and will be appended to the self.base_url value.

+

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, +or used as an absolute URL.

+
+
params
+
Dictionary to send in the query string for the request.
+
headers
+
Dictionary of HTTP Headers to send with the request.
+
data
+
Dictionary to send in the body of the request.
+
json
+
A JSON serializable Python object to send in the body of the request.
+
is_absolute_path
+
+

A boolean value specifying, whether the URL specified in endpoint_path parameter +is an absolute path or not.

+

If set to False, the value of endpoint_path will be appended to self.base_url using +urllib.parse.urljoin() +function.

+

If set to True, base url will be overridden and the value of the endpoint_path will +used instead.

+
+
cookies
+
Dict or CookieJar object of cookies to send with the request
+
files
+
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+
ignore_auth
+
Boolean marking, whether the default auth_header should be ignored.
+
**kwargs
+
All other keyword arguments supported by +requests.request.
+
+

Returns

+

A JSON-encoded response of the request.

+

Raises

+
+
requests.HTTPError
+
If the API request fails.
+
+
+ +Expand source code + +
@response_error_handling
+def patch(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
+          json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
+          ignore_auth: bool = False, **kwargs) -> requests.Response:
+    """
+    Constructs a requests PATCH call with specified url and kwargs to process the result.
+
+    Args:
+        endpoint_path: Relative URL path or absolute URL to which the request will be made.
+            By default a relative path is expected and will be appended to the `self.base_url` value.
+
+            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+            or used as an absolute URL.
+        params: Dictionary to send in the query string for the request.
+        headers: Dictionary of HTTP Headers to send with the request.
+        data: Dictionary to send in the body of the request.
+        json: A JSON serializable Python object to send in the body of the request.
+        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+            is an absolute path or not.
+
+            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+            function.
+
+            If set to True, base url will be overridden and the value of the `endpoint_path` will
+            used instead.
+        cookies: Dict or CookieJar object of cookies to send with the request
+        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+        **kwargs: All other keyword arguments supported by
+            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+    Returns:
+        A JSON-encoded response of the request.
+
+    Raises:
+        requests.HTTPError: If the API request fails.
+    """
+
+    return self.patch_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
+                          is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
+
+
+
+def patch_raw(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response +
+
+

Constructs a requests PATCH call with specified url and kwargs to process the result.

+

Args

+
+
endpoint_path
+
+

Relative URL path or absolute URL to which the request will be made. +By default a relative path is expected and will be appended to the self.base_url value.

+

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, +or used as an absolute URL.

+
+
params
+
Dictionary to send in the query string for the request.
+
headers
+
Dictionary of HTTP Headers to send with the request.
+
data
+
Dictionary to send in the body of the request.
+
json
+
A JSON serializable Python object to send in the body of the request.
+
is_absolute_path
+
+

A boolean value specifying, whether the URL specified in endpoint_path parameter +is an absolute path or not.

+

If set to False, the value of endpoint_path will be appended to self.base_url using +urllib.parse.urljoin() +function.

+

If set to True, base url will be overridden and the value of the endpoint_path will +used instead.

+
+
cookies
+
Dict or CookieJar object of cookies to send with the request
+
files
+
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+
ignore_auth
+
Boolean marking, whether the default auth_header should be ignored.
+
**kwargs
+
All other keyword arguments supported by +requests.request.
+
+

Returns

+

A requests.Response object.

+
+ +Expand source code + +
def patch_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+              data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
+              files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
+    """
+    Constructs a requests PATCH call with specified url and kwargs to process the result.
+
+    Args:
+        endpoint_path: Relative URL path or absolute URL to which the request will be made.
+            By default a relative path is expected and will be appended to the `self.base_url` value.
+
+            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+            or used as an absolute URL.
+        params: Dictionary to send in the query string for the request.
+        headers: Dictionary of HTTP Headers to send with the request.
+        data: Dictionary to send in the body of the request.
+        json: A JSON serializable Python object to send in the body of the request.
+        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+            is an absolute path or not.
+
+            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+            function.
+
+            If set to True, base url will be overridden and the value of the `endpoint_path` will
+            used instead.
+        cookies: Dict or CookieJar object of cookies to send with the request
+        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+        **kwargs: All other keyword arguments supported by
+            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+    Returns:
+        A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+    """
+
+    method = 'PATCH'
+    return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
+                             cookies=cookies, is_absolute_path=is_absolute_path, files=files,
+                             ignore_auth=ignore_auth, **kwargs)
+
+
+
+def post(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response +
+
+

Constructs a requests POST call with specified url and kwargs to process the result.

+

Args

+
+
endpoint_path
+
+

Relative URL path or absolute URL to which the request will be made. +By default a relative path is expected and will be appended to the self.base_url value.

+

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, +or used as an absolute URL.

+
+
params
+
Dictionary to send in the query string for the request.
+
headers
+
Dictionary of HTTP Headers to send with the request.
+
data
+
Dictionary to send in the body of the request.
+
json
+
A JSON serializable Python object to send in the body of the request.
+
is_absolute_path
+
+

A boolean value specifying, whether the URL specified in endpoint_path parameter +is an absolute path or not.

+

If set to False, the value of endpoint_path will be appended to self.base_url using +urllib.parse.urljoin() +function.

+

If set to True, base url will be overridden and the value of the endpoint_path will +used instead.

+
+
cookies
+
Dict or CookieJar object of cookies to send with the request
+
files
+
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+
ignore_auth
+
Boolean marking, whether the default auth_header should be ignored.
+
**kwargs
+
All other keyword arguments supported by +requests.request.
+
+

Returns

+

A JSON-encoded response of the request.

+

Raises

+
+
requests.HTTPError
+
If the API request fails.
+
+
+ +Expand source code + +
@response_error_handling
+def post(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
+         json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
+         ignore_auth: bool = False, **kwargs) -> requests.Response:
+    """
+    Constructs a requests POST call with specified url and kwargs to process the result.
+
+    Args:
+        endpoint_path: Relative URL path or absolute URL to which the request will be made.
+            By default a relative path is expected and will be appended to the `self.base_url` value.
+
+            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+            or used as an absolute URL.
+        params: Dictionary to send in the query string for the request.
+        headers: Dictionary of HTTP Headers to send with the request.
+        data: Dictionary to send in the body of the request.
+        json: A JSON serializable Python object to send in the body of the request.
+        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+            is an absolute path or not.
+
+            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+            function.
+
+            If set to True, base url will be overridden and the value of the `endpoint_path` will
+            used instead.
+        cookies: Dict or CookieJar object of cookies to send with the request
+        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+        **kwargs: All other keyword arguments supported by
+            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+    Returns:
+        A JSON-encoded response of the request.
+
+    Raises:
+        requests.HTTPError: If the API request fails.
+    """
+
+    return self.post_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
+                         is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
+
+
+
+def post_raw(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response +
+
+

Constructs a requests POST call with specified url and kwargs to process the result.

+

Args

+
+
endpoint_path
+
+

Relative URL path or absolute URL to which the request will be made. +By default a relative path is expected and will be appended to the self.base_url value.

+

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, +or used as an absolute URL.

+
+
params
+
Dictionary to send in the query string for the request.
+
headers
+
Dictionary of HTTP Headers to send with the request.
+
data
+
Dictionary to send in the body of the request.
+
json
+
A JSON serializable Python object to send in the body of the request.
+
is_absolute_path
+
+

A boolean value specifying, whether the URL specified in endpoint_path parameter +is an absolute path or not.

+

If set to False, the value of endpoint_path will be appended to self.base_url using +urllib.parse.urljoin() +function.

+

If set to True, base url will be overridden and the value of the endpoint_path will +used instead.

+
+
cookies
+
Dict or CookieJar object of cookies to send with the request
+
files
+
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+
ignore_auth
+
Boolean marking, whether the default auth_header should be ignored.
+
**kwargs
+
All other keyword arguments supported by +requests.request.
+
+

Returns

+

A requests.Response object.

+
+ +Expand source code + +
def post_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+             data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
+             files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
+    """
+    Constructs a requests POST call with specified url and kwargs to process the result.
+
+    Args:
+        endpoint_path: Relative URL path or absolute URL to which the request will be made.
+            By default a relative path is expected and will be appended to the `self.base_url` value.
+
+            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+            or used as an absolute URL.
+        params: Dictionary to send in the query string for the request.
+        headers: Dictionary of HTTP Headers to send with the request.
+        data: Dictionary to send in the body of the request.
+        json: A JSON serializable Python object to send in the body of the request.
+        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+            is an absolute path or not.
+
+            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+            function.
+
+            If set to True, base url will be overridden and the value of the `endpoint_path` will
+            used instead.
+        cookies: Dict or CookieJar object of cookies to send with the request
+        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+        **kwargs: All other keyword arguments supported by
+            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+    Returns:
+        A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+    """
+
+    method = 'POST'
+    return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
+                             cookies=cookies, is_absolute_path=is_absolute_path, files=files,
+                             ignore_auth=ignore_auth, **kwargs)
+
+
+
+def put(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response +
+
+

Constructs a requests PUT call with specified url and kwargs to process the result.

+

Args

+
+
endpoint_path
+
+

Relative URL path or absolute URL to which the request will be made. +By default a relative path is expected and will be appended to the self.base_url value.

+

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, +or used as an absolute URL.

+
+
params
+
Dictionary to send in the query string for the request.
+
headers
+
Dictionary of HTTP Headers to send with the request.
+
data
+
Dictionary to send in the body of the request.
+
json
+
A JSON serializable Python object to send in the body of the request.
+
is_absolute_path
+
+

A boolean value specifying, whether the URL specified in endpoint_path parameter +is an absolute path or not.

+

If set to False, the value of endpoint_path will be appended to self.base_url using +urllib.parse.urljoin() +function.

+

If set to True, base url will be overridden and the value of the endpoint_path will +used instead.

+
+
cookies
+
Dict or CookieJar object of cookies to send with the request
+
files
+
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+
ignore_auth
+
Boolean marking, whether the default auth_header should be ignored.
+
**kwargs
+
All other keyword arguments supported by +requests.request.
+
+

Returns

+

A JSON-encoded response of the request.

+

Raises

+
+
requests.HTTPError
+
If the API request fails.
+
+
+ +Expand source code + +
@response_error_handling
+def put(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
+        json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
+        ignore_auth: bool = False, **kwargs) -> requests.Response:
+    """
+    Constructs a requests PUT call with specified url and kwargs to process the result.
+
+    Args:
+        endpoint_path: Relative URL path or absolute URL to which the request will be made.
+            By default a relative path is expected and will be appended to the `self.base_url` value.
+
+            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+            or used as an absolute URL.
+        params: Dictionary to send in the query string for the request.
+        headers: Dictionary of HTTP Headers to send with the request.
+        data: Dictionary to send in the body of the request.
+        json: A JSON serializable Python object to send in the body of the request.
+        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+            is an absolute path or not.
+
+            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+            function.
+
+            If set to True, base url will be overridden and the value of the `endpoint_path` will
+            used instead.
+        cookies: Dict or CookieJar object of cookies to send with the request
+        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+        **kwargs: All other keyword arguments supported by
+            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+    Returns:
+        A JSON-encoded response of the request.
+
+    Raises:
+        requests.HTTPError: If the API request fails.
+    """
+
+    return self.put_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
+                        is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
+
+
+
+def put_raw(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response +
+
+

Constructs a requests PUT call with specified url and kwargs to process the result.

+

Args

+
+
endpoint_path
+
+

Relative URL path or absolute URL to which the request will be made. +By default a relative path is expected and will be appended to the self.base_url value.

+

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, +or used as an absolute URL.

+
+
params
+
Dictionary to send in the query string for the request.
+
headers
+
Dictionary of HTTP Headers to send with the request.
+
data
+
Dictionary to send in the body of the request.
+
json
+
A JSON serializable Python object to send in the body of the request.
+
is_absolute_path
+
+

A boolean value specifying, whether the URL specified in endpoint_path parameter +is an absolute path or not.

+

If set to False, the value of endpoint_path will be appended to self.base_url using +urllib.parse.urljoin() +function.

+

If set to True, base url will be overridden and the value of the endpoint_path will +used instead.

+
+
cookies
+
Dict or CookieJar object of cookies to send with the request
+
files
+
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+
ignore_auth
+
Boolean marking, whether the default auth_header should be ignored.
+
**kwargs
+
All other keyword arguments supported by +requests.request.
+
+

Returns

+

A requests.Response object.

+
+ +Expand source code + +
def put_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+            data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
+            files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
+    """
+    Constructs a requests PUT call with specified url and kwargs to process the result.
+
+    Args:
+        endpoint_path: Relative URL path or absolute URL to which the request will be made.
+            By default a relative path is expected and will be appended to the `self.base_url` value.
+
+            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+            or used as an absolute URL.
+        params: Dictionary to send in the query string for the request.
+        headers: Dictionary of HTTP Headers to send with the request.
+        data: Dictionary to send in the body of the request.
+        json: A JSON serializable Python object to send in the body of the request.
+        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+            is an absolute path or not.
+
+            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+            function.
+
+            If set to True, base url will be overridden and the value of the `endpoint_path` will
+            used instead.
+        cookies: Dict or CookieJar object of cookies to send with the request
+        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+        **kwargs: All other keyword arguments supported by
+            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+    Returns:
+        A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+    """
+
+    method = 'PUT'
+    return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
+                             cookies=cookies, is_absolute_path=is_absolute_path, files=files,
+                             ignore_auth=ignore_auth, **kwargs)
+
+
+
+def response_error_handling(func) +
+
+

Function, that handles response handling of HTTP requests.

+
+ +Expand source code + +
def response_error_handling(func):
+    """Function, that handles response handling of HTTP requests.
+    """
+
+    @functools.wraps(func)
+    def wrapper(*args, **kwargs):
+        try:
+            r = func(*args, **kwargs)
+            r.raise_for_status()
+        except requests.HTTPError as e:
+            logging.warning(e, exc_info=True)
+            # Handle different error codes
+            raise
+        else:
+            return r.json()
+
+    return wrapper
+
+
+
+def update(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response +
+
+

Constructs a requests UPDATE call with specified url and kwargs to process the result.

+

Args

+
+
endpoint_path
+
+

Relative URL path or absolute URL to which the request will be made. +By default a relative path is expected and will be appended to the self.base_url value.

+

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, +or used as an absolute URL.

+
+
params
+
Dictionary to send in the query string for the request.
+
headers
+
Dictionary of HTTP Headers to send with the request.
+
data
+
Dictionary to send in the body of the request.
+
json
+
A JSON serializable Python object to send in the body of the request.
+
is_absolute_path
+
+

A boolean value specifying, whether the URL specified in endpoint_path parameter +is an absolute path or not.

+

If set to False, the value of endpoint_path will be appended to self.base_url using +urllib.parse.urljoin() +function.

+

If set to True, base url will be overridden and the value of the endpoint_path will +used instead.

+
+
cookies
+
Dict or CookieJar object of cookies to send with the request
+
files
+
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+
ignore_auth
+
Boolean marking, whether the default auth_header should be ignored.
+
**kwargs
+
All other keyword arguments supported by +requests.request.
+
+

Returns

+

A JSON-encoded response of the request.

+

Raises

+
+
requests.HTTPError
+
If the API request fails.
+
+
+ +Expand source code + +
@response_error_handling
+def update(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None, data: Dict = None,
+           json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None, files: Dict = None,
+           ignore_auth: bool = False, **kwargs) -> requests.Response:
+    """
+    Constructs a requests UPDATE call with specified url and kwargs to process the result.
+
+    Args:
+        endpoint_path: Relative URL path or absolute URL to which the request will be made.
+            By default a relative path is expected and will be appended to the `self.base_url` value.
+
+            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+            or used as an absolute URL.
+        params: Dictionary to send in the query string for the request.
+        headers: Dictionary of HTTP Headers to send with the request.
+        data: Dictionary to send in the body of the request.
+        json: A JSON serializable Python object to send in the body of the request.
+        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+            is an absolute path or not.
+
+            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+            function.
+
+            If set to True, base url will be overridden and the value of the `endpoint_path` will
+            used instead.
+        cookies: Dict or CookieJar object of cookies to send with the request
+        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+        **kwargs: All other keyword arguments supported by
+            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+    Returns:
+        A JSON-encoded response of the request.
+
+    Raises:
+        requests.HTTPError: If the API request fails.
+    """
+
+    return self.update_raw(endpoint_path, params=params, headers=headers, data=data, json=json, cookies=cookies,
+                           is_absolute_path=is_absolute_path, files=files, ignore_auth=ignore_auth, **kwargs)
+
+
+
+def update_auth_header(self, updated_header: Dict, overwrite: bool = False) +
+
+

Updates the default auth header by providing new values.

+

Args

+
+
updated_header
+
An updated header which will be used to update the current header.
+
overwrite
+
If False, the existing header will be updated with new header. If True, the new header will +overwrite (replace) the current authentication header.
+
+
+ +Expand source code + +
def update_auth_header(self, updated_header: Dict, overwrite: bool = False):
+    """
+    Updates the default auth header by providing new values.
+
+    Args:
+        updated_header: An updated header which will be used to update the current header.
+        overwrite: If `False`, the existing header will be updated with new header. If `True`, the new header will
+            overwrite (replace) the current authentication header.
+    """
+
+    if overwrite is False:
+        self._auth_header.update(updated_header)
+    else:
+        self._auth_header = updated_header
+
+
+
+def update_raw(self, endpoint_path: Union[str, NoneType] = None, params: Dict = None, headers: Dict = None, data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Union[Dict[str, str], http.cookiejar.CookieJar] = None, files: Dict = None, ignore_auth: bool = False, **kwargs) ‑> requests.models.Response +
+
+

Constructs a requests UPDATE call with specified url and kwargs to process the result.

+

Args

+
+
endpoint_path
+
+

Relative URL path or absolute URL to which the request will be made. +By default a relative path is expected and will be appended to the self.base_url value.

+

Depending on the value of is_absolute_path, the value will be either appended to self.base_url, +or used as an absolute URL.

+
+
params
+
Dictionary to send in the query string for the request.
+
headers
+
Dictionary of HTTP Headers to send with the request.
+
data
+
Dictionary to send in the body of the request.
+
json
+
A JSON serializable Python object to send in the body of the request.
+
is_absolute_path
+
+

A boolean value specifying, whether the URL specified in endpoint_path parameter +is an absolute path or not.

+

If set to False, the value of endpoint_path will be appended to self.base_url using +urllib.parse.urljoin() +function.

+

If set to True, base url will be overridden and the value of the endpoint_path will +used instead.

+
+
cookies
+
Dict or CookieJar object of cookies to send with the request
+
files
+
Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+
ignore_auth
+
Boolean marking, whether the default auth_header should be ignored.
+
**kwargs
+
All other keyword arguments supported by +requests.request.
+
+

Returns

+

A requests.Response object.

+
+ +Expand source code + +
def update_raw(self, endpoint_path: Optional[str] = None, params: Dict = None, headers: Dict = None,
+               data: Dict = None, json: Dict = None, is_absolute_path: bool = False, cookies: Cookie = None,
+               files: Dict = None, ignore_auth: bool = False, **kwargs) -> requests.Response:
+    """
+    Constructs a requests UPDATE call with specified url and kwargs to process the result.
+
+    Args:
+        endpoint_path: Relative URL path or absolute URL to which the request will be made.
+            By default a relative path is expected and will be appended to the `self.base_url` value.
+
+            Depending on the value of `is_absolute_path`, the value will be either appended to `self.base_url`,
+            or used as an absolute URL.
+        params: Dictionary to send in the query string for the request.
+        headers: Dictionary of HTTP Headers to send with the request.
+        data: Dictionary to send in the body of the request.
+        json: A JSON serializable Python object to send in the body of the request.
+        is_absolute_path: A boolean value specifying, whether the URL specified in `endpoint_path` parameter
+            is an absolute path or not.
+
+            If set to False, the value of `endpoint_path` will be appended to `self.base_url` using
+            [`urllib.parse.urljoin()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin)
+            function.
+
+            If set to True, base url will be overridden and the value of the `endpoint_path` will
+            used instead.
+        cookies: Dict or CookieJar object of cookies to send with the request
+        files: Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload.
+        ignore_auth: Boolean marking, whether the default auth_header should be ignored.
+        **kwargs: All other keyword arguments supported by
+            [`requests.request`](https://requests.readthedocs.io/en/latest/api/#requests.request).
+
+    Returns:
+        A [`requests.Response`](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.
+    """
+
+    method = 'UPDATE'
+    return self._request_raw(method, endpoint_path, params=params, headers=headers, data=data, json=json,
+                             cookies=cookies, is_absolute_path=is_absolute_path, files=files,
+                             ignore_auth=ignore_auth, **kwargs)
+
+
+
+
+
+
+
+ +
+ + \ No newline at end of file diff --git a/docs/api-html/http_client/index.html b/docs/html/keboola/http_client/index.html similarity index 95% rename from docs/api-html/http_client/index.html rename to docs/html/keboola/http_client/index.html index 7b8a7bd..df42d3f 100644 --- a/docs/api-html/http_client/index.html +++ b/docs/html/keboola/http_client/index.html @@ -1,66 +1,71 @@ - - - - - - -keboola.http_client API documentation - - - - - - - - - - - -
-
-
-

Package keboola.http_client

-
-
-
- -Expand source code - -
from .http import HttpClient  # noqa
-
-
-
-

Sub-modules

-
-
keboola.http_client.http
-
-
-
-
-
-
-
-
-
-
-
-
- -
- - + + + + + + +keboola.http_client API documentation + + + + + + + + + + + +
+ + +
+ + \ No newline at end of file diff --git a/setup.py b/setup.py index 72b8c44..a2bf01f 100644 --- a/setup.py +++ b/setup.py @@ -5,16 +5,16 @@ project_urls = { 'Documentation': 'https://htmlpreview.github.io/?https://raw.githubusercontent.com/keboola/' - 'python-http-client/main/docs/api-html/http_client/http.html' + 'python-http-client/main/docs/html/keboola/http_client/index.html' } setuptools.setup( name="keboola.http_client", - version="1.0.0", + version="1.0.1", author="Keboola KDS Team", project_urls=project_urls, setup_requires=['pytest-runner', 'flake8'], - tests_require=['pytest'], + tests_require=['pytest', 'responses'], install_requires=[ 'requests' ], diff --git a/src/keboola/http_client/auth.py b/src/keboola/http_client/auth.py new file mode 100644 index 0000000..b2d8fd2 --- /dev/null +++ b/src/keboola/http_client/auth.py @@ -0,0 +1,98 @@ +import inspect +from abc import ABC, abstractmethod +from typing import Callable, Union, Dict + +from requests.auth import AuthBase, HTTPBasicAuth + + +class AuthBuilderError(Exception): + pass + + +class AuthMethodBase(ABC): + """ + Base class to implement the authentication method. To mark secret constructor parameters prefix them with secret__ + e.g. __init__(self, username, secret__password) + """ + + @abstractmethod + def login(self): + """ + Perform steps to login and returns requests.aut.AuthBase callable that modifies the request. + + """ + pass + + +class AuthMethodBuilder: + SECRET_PREFIX = "secret__" + + @classmethod + def build(cls, method_name: str, **parameters): + """ + + Args: + method_name: + **parameters: dictionary of named parameters. + Note that parameters prefixed # will be converted to prefix secret__. e.g. #password -> secret__password + argument in the AuthMethod + + Returns: + + """ + supported_actions = cls.get_methods() + + if method_name not in list(supported_actions.keys()): + raise AuthBuilderError(f'{method_name} is not supported auth method, ' + f'supported values are: [{list(supported_actions.keys())}]') + parameters = cls._convert_secret_parameters(supported_actions[method_name], **parameters) + cls._validate_method_arguments(supported_actions[method_name], **parameters) + + return supported_actions[method_name](**parameters) + + @staticmethod + def _validate_method_arguments(method: object, **args): + + arguments = [p for p in inspect.signature(method.__init__).parameters if p != 'self'] + missing_arguments = [] + for p in arguments: + if p not in args: + missing_arguments.append(p.replace(AuthMethodBuilder.SECRET_PREFIX, '#')) + if missing_arguments: + raise AuthBuilderError(f'Some arguments of method {method.__name__} are missing: {missing_arguments}') + + @staticmethod + def _convert_secret_parameters(method: object, **parameters): + new_parameters = {} + for p in parameters: + new_parameters[p.replace('#', AuthMethodBuilder.SECRET_PREFIX)] = parameters[p] + return new_parameters + + @staticmethod + def get_methods() -> Dict[str, Callable]: + supported_actions = {} + for c in AuthMethodBase.__subclasses__(): + supported_actions[c.__name__] = c + return supported_actions + + @classmethod + def get_supported_methods(cls): + return list(cls.get_methods().keys()) + + +# ########### SUPPORTED AUTHENTICATION METHODS + +class BasicHttp(AuthMethodBase): + + def __init__(self, username, secret__password): + self.username = username + self.password = secret__password + + def login(self) -> Union[AuthBase, Callable]: + return HTTPBasicAuth(username=self.username, password=self.password) + + def __eq__(self, other): + return all([ + self.username == getattr(other, 'username', None), + self.password == getattr(other, 'password', None) + ]) diff --git a/src/keboola/http_client/http.py b/src/keboola/http_client/http.py index 8f9e1b8..01266f7 100644 --- a/src/keboola/http_client/http.py +++ b/src/keboola/http_client/http.py @@ -8,6 +8,8 @@ from requests.adapters import HTTPAdapter from requests.packages.urllib3.util.retry import Retry +from keboola.http_client.auth import AuthMethodBase + Cookie = Union[Dict[str, str], CookieJar] METHOD_RETRY_WHITELIST = ('GET', 'POST', 'PATCH', 'UPDATE', 'PUT', 'DELETE') @@ -45,7 +47,7 @@ class HttpClient: def __init__(self, base_url: str, max_retries: int = 10, backoff_factor: float = 0.3, status_forcelist: Tuple[int, ...] = (500, 502, 504), default_http_header: Dict = None, - auth_header: Dict = None, auth: Tuple = None, default_params: Dict = None, + auth_header: Dict = None, auth_method: AuthMethodBase = None, default_params: Dict = None, allowed_methods: Tuple = METHOD_RETRY_WHITELIST): """ Create an endpoint. @@ -62,10 +64,11 @@ def __init__(self, base_url: str, max_retries: int = 10, backoff_factor: float = }``` auth_header: Auth header to be sent with each request eg. `{'Authorization': 'Bearer ' + token}` - auth: Default Authentication tuple or object to attach to (from requests.Session().auth). - eg. auth = (user, password) default_params: default parameters to be sent with each request eg. `{'param':'value'}` allowed_methods (tuple): Set of upper-cased HTTP method verbs that we should retry on. + auth_method: AuthMethodBase: requests.aut.AuthBase callable that modifies the request to add + authentication. login() method needs to be called to perform the authentication. All subsequent + request will be authenticated. """ if base_url is None: raise ValueError("Base URL is required.") @@ -74,11 +77,21 @@ def __init__(self, base_url: str, max_retries: int = 10, backoff_factor: float = self.max_retries = max_retries self.backoff_factor = backoff_factor self.status_forcelist = status_forcelist - self._auth = auth self._auth_header = auth_header if auth_header else {} self._default_header = default_http_header if default_http_header else {} self._default_params = default_params self.allowed_methods = allowed_methods + self._auth_method = auth_method + self._auth = None + + def login(self): + """ + Perform login based on auth method + + """ + # perform login + if self._auth_method: + self._auth = self._auth_method.login() def _requests_retry_session(self, session=None): session = session or requests.Session() diff --git a/tests/test_auth.py b/tests/test_auth.py new file mode 100644 index 0000000..44e4aae --- /dev/null +++ b/tests/test_auth.py @@ -0,0 +1,52 @@ +import base64 +import unittest + +import responses + +from keboola.http_client.auth import AuthMethodBuilder, AuthBuilderError, BasicHttp +from keboola.http_client.http import HttpClient + + +class TestConfiguration(unittest.TestCase): + + def test_convert_private(self): + params = {'#password': 'test'} + new_args = AuthMethodBuilder._convert_secret_parameters(BasicHttp, **params) + self.assertDictEqual(new_args, {'secret__password': 'test'}) + + def test_invalid_method_params_fail(self): + params = {'#password': 'test'} + with self.assertRaises(AuthBuilderError): + AuthMethodBuilder.build('BasicHttp', **params) + + def test_invalid_method_fail(self): + with self.assertRaises(AuthBuilderError): + AuthMethodBuilder.build('INVALID', **{}) + + def test_valid_method_params_pass(self): + params = {'username': "usr", '#password': 'test'} + expected = BasicHttp(username='usr', secret__password='test') + auth_method = AuthMethodBuilder.build('BasicHttp', **params) + self.assertEqual(expected, auth_method) + + +class TestAuthorisation(unittest.TestCase): + + @responses.activate + def test_basic_auth(self): + auth_method = BasicHttp('user', 'password') + + client = HttpClient(base_url="http://functional/", auth_method=auth_method) + client.login() + + # expected + token = base64.b64encode('user:password'.encode('utf-8')).decode('utf-8') + responses.add( + responses.GET, + url="http://functional/test", + match=[responses.matchers.header_matcher({"Authorization": f"Basic {token}"})], + json={'status': 'success'} + + ) + + client.get('test') From ea4bd27b3aa7ad7bff0c79631dce207430c42507 Mon Sep 17 00:00:00 2001 From: David Esner Date: Fri, 5 Nov 2021 10:51:24 +0100 Subject: [PATCH 2/2] UPDATE workflow, test requirements --- .github/workflows/deploy.yml | 1 + .github/workflows/deploy_to_test.yml | 1 + .github/workflows/push_dev.yml | 1 + test_requirements.txt | 1 + 4 files changed, 4 insertions(+) create mode 100644 test_requirements.txt diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ae74d2e..7032603 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -21,6 +21,7 @@ jobs: pip install setuptools wheel twine pip install flake8 pytest pip install -r requirements.txt + pip install -r test_requirements.txt - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names diff --git a/.github/workflows/deploy_to_test.yml b/.github/workflows/deploy_to_test.yml index 0a61c7f..068773f 100644 --- a/.github/workflows/deploy_to_test.yml +++ b/.github/workflows/deploy_to_test.yml @@ -22,6 +22,7 @@ jobs: pip install setuptools wheel twine pip install flake8 pytest pip install -r requirements.txt + pip install -r test_requirements.txt - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names diff --git a/.github/workflows/push_dev.yml b/.github/workflows/push_dev.yml index 6ff22ce..80ade15 100644 --- a/.github/workflows/push_dev.yml +++ b/.github/workflows/push_dev.yml @@ -21,6 +21,7 @@ jobs: python -m pip install --upgrade pip pip install flake8 pytest pip install -r requirements.txt + pip install -r test_requirements.txt - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names diff --git a/test_requirements.txt b/test_requirements.txt new file mode 100644 index 0000000..3b5f741 --- /dev/null +++ b/test_requirements.txt @@ -0,0 +1 @@ +responses \ No newline at end of file