enconnect.utils package#

Subpackages#

Submodules#

enconnect.utils.dummy module#

Functions and routines associated with Enasis Network Remote Connect.

This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.

enconnect.utils.dummy.dumlog(**kwargs: Any) None[source]#

Capture and drop messages for would be provided logger.

Parameters:

kwargs – Keyword arguments which would be passed.

enconnect.utils.http module#

Functions and routines associated with Enasis Network Remote Connect.

This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.

class enconnect.utils.http.HTTPClient(timeout: int = 30, headers: dict[str, str] | None = None, verify: SSLContext | str | bool = True, capem: str | None = None, httpauth: tuple[str, str] | None = None, retry: int = 3, backoff: float = 3.0, states: set[int] = {429})[source]#

Bases: object

Interact with the upstream server in blocking or async.

Parameters:
  • timeout – Timeout waiting for the server response.

  • headers – Optional headers to include in requests.

  • verify – Require valid certificate from the server.

  • capem – Optional path to the certificate authority.

  • httpauth – Optional information for authentication.

  • retry – How many attempts are made with the server.

  • backoff – Backoff backoff if encountered retries.

  • states – Which states will be retried with backoff.

property backoff: float#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property capem: str | None#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property client_async: AsyncClient#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property client_block: Client#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property headers: dict[str, str] | None#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property httpauth: tuple[str, str] | None#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

async request_async(method: Literal['delete', 'get', 'post', 'patch', 'put'], location: str, params: dict[str, Any] | None = None, json: dict[str, Any] | None = None, *, data: dict[str, Any] | None = None, files: dict[str, Any] | None = None, timeout: int | None = None, headers: dict[str, str] | None = None, httpauth: tuple[str, str] | None = None) Response[source]#

Return the response for upstream request to the server.

Parameters:
  • method – Method for operation with the API server.

  • location – Location with path for server request.

  • params – Optional parameters included in request.

  • json – Optional JSON payload included in request.

  • data – Optional dict payload included in request.

  • files – Optional file payload included in request.

  • timeout – Timeout waiting for the server response.

  • headers – Optional headers to include in requests.

  • httpauth – Optional information for authentication.

Returns:

Response from upstream request to the server.

request_block(method: Literal['delete', 'get', 'post', 'patch', 'put'], location: str, params: dict[str, Any] | None = None, json: dict[str, Any] | None = None, *, data: dict[str, Any] | None = None, files: dict[str, Any] | None = None, timeout: int | None = None, headers: dict[str, str] | None = None, httpauth: tuple[str, str] | None = None) Response[source]#

Return the response for upstream request to the server.

Parameters:
  • method – Method for operation with the API server.

  • location – Location with path for server request.

  • params – Optional parameters included in request.

  • json – Optional JSON payload included in request.

  • data – Optional dict payload included in request.

  • files – Optional file payload included in request.

  • timeout – Timeout waiting for the server response.

  • headers – Optional headers to include in requests.

  • httpauth – Optional information for authentication.

Returns:

Response from upstream request to the server.

property retry: int#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property states: set[int]#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

async stream_async(method: Literal['delete', 'get', 'post', 'patch', 'put'], location: str, params: dict[str, Any] | None = None, json: dict[str, Any] | None = None, *, data: dict[str, Any] | None = None, timeout: int | None = None, headers: dict[str, str] | None = None, httpauth: tuple[str, str] | None = None) AsyncIterator[str][source]#

Return the response for upstream request to the server.

Parameters:
  • method – Method for operation with the API server.

  • location – Location with path for server request.

  • params – Optional parameters included in request.

  • json – Optional JSON payload included in request.

  • data – Optional dict payload included in request.

  • timeout – Timeout waiting for the server response.

  • headers – Optional headers to include in requests.

  • httpauth – Optional information for authentication.

Returns:

Response from upstream request to the server.

stream_block(method: Literal['delete', 'get', 'post', 'patch', 'put'], location: str, params: dict[str, Any] | None = None, json: dict[str, Any] | None = None, *, data: dict[str, Any] | None = None, timeout: int | None = None, headers: dict[str, str] | None = None, httpauth: tuple[str, str] | None = None) Iterator[str][source]#

Return the response for upstream request to the server.

Parameters:
  • method – Method for operation with the API server.

  • location – Location with path for server request.

  • params – Optional parameters included in request.

  • json – Optional JSON payload included in request.

  • data – Optional dict payload included in request.

  • timeout – Timeout waiting for the server response.

  • headers – Optional headers to include in requests.

  • httpauth – Optional information for authentication.

Returns:

Response from upstream request to the server.

property timeout: int#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property verify: SSLContext | str | bool#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

Module contents#

Functions and routines associated with Enasis Network Remote Connect.

This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.

class enconnect.utils.HTTPClient(timeout: int = 30, headers: dict[str, str] | None = None, verify: SSLContext | str | bool = True, capem: str | None = None, httpauth: tuple[str, str] | None = None, retry: int = 3, backoff: float = 3.0, states: set[int] = {429})[source]#

Bases: object

Interact with the upstream server in blocking or async.

Parameters:
  • timeout – Timeout waiting for the server response.

  • headers – Optional headers to include in requests.

  • verify – Require valid certificate from the server.

  • capem – Optional path to the certificate authority.

  • httpauth – Optional information for authentication.

  • retry – How many attempts are made with the server.

  • backoff – Backoff backoff if encountered retries.

  • states – Which states will be retried with backoff.

property backoff: float#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property capem: str | None#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property client_async: AsyncClient#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property client_block: Client#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property headers: dict[str, str] | None#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property httpauth: tuple[str, str] | None#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

async request_async(method: Literal['delete', 'get', 'post', 'patch', 'put'], location: str, params: dict[str, Any] | None = None, json: dict[str, Any] | None = None, *, data: dict[str, Any] | None = None, files: dict[str, Any] | None = None, timeout: int | None = None, headers: dict[str, str] | None = None, httpauth: tuple[str, str] | None = None) Response[source]#

Return the response for upstream request to the server.

Parameters:
  • method – Method for operation with the API server.

  • location – Location with path for server request.

  • params – Optional parameters included in request.

  • json – Optional JSON payload included in request.

  • data – Optional dict payload included in request.

  • files – Optional file payload included in request.

  • timeout – Timeout waiting for the server response.

  • headers – Optional headers to include in requests.

  • httpauth – Optional information for authentication.

Returns:

Response from upstream request to the server.

request_block(method: Literal['delete', 'get', 'post', 'patch', 'put'], location: str, params: dict[str, Any] | None = None, json: dict[str, Any] | None = None, *, data: dict[str, Any] | None = None, files: dict[str, Any] | None = None, timeout: int | None = None, headers: dict[str, str] | None = None, httpauth: tuple[str, str] | None = None) Response[source]#

Return the response for upstream request to the server.

Parameters:
  • method – Method for operation with the API server.

  • location – Location with path for server request.

  • params – Optional parameters included in request.

  • json – Optional JSON payload included in request.

  • data – Optional dict payload included in request.

  • files – Optional file payload included in request.

  • timeout – Timeout waiting for the server response.

  • headers – Optional headers to include in requests.

  • httpauth – Optional information for authentication.

Returns:

Response from upstream request to the server.

property retry: int#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property states: set[int]#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

async stream_async(method: Literal['delete', 'get', 'post', 'patch', 'put'], location: str, params: dict[str, Any] | None = None, json: dict[str, Any] | None = None, *, data: dict[str, Any] | None = None, timeout: int | None = None, headers: dict[str, str] | None = None, httpauth: tuple[str, str] | None = None) AsyncIterator[str][source]#

Return the response for upstream request to the server.

Parameters:
  • method – Method for operation with the API server.

  • location – Location with path for server request.

  • params – Optional parameters included in request.

  • json – Optional JSON payload included in request.

  • data – Optional dict payload included in request.

  • timeout – Timeout waiting for the server response.

  • headers – Optional headers to include in requests.

  • httpauth – Optional information for authentication.

Returns:

Response from upstream request to the server.

stream_block(method: Literal['delete', 'get', 'post', 'patch', 'put'], location: str, params: dict[str, Any] | None = None, json: dict[str, Any] | None = None, *, data: dict[str, Any] | None = None, timeout: int | None = None, headers: dict[str, str] | None = None, httpauth: tuple[str, str] | None = None) Iterator[str][source]#

Return the response for upstream request to the server.

Parameters:
  • method – Method for operation with the API server.

  • location – Location with path for server request.

  • params – Optional parameters included in request.

  • json – Optional JSON payload included in request.

  • data – Optional dict payload included in request.

  • timeout – Timeout waiting for the server response.

  • headers – Optional headers to include in requests.

  • httpauth – Optional information for authentication.

Returns:

Response from upstream request to the server.

property timeout: int#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property verify: SSLContext | str | bool#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

enconnect.utils.dumlog(**kwargs: Any) None[source]#

Capture and drop messages for would be provided logger.

Parameters:

kwargs – Keyword arguments which would be passed.