Skip to content

sift_client.transport.rest_transport

Transport layer for REST communication.

This module provides a simple wrapper around sift_py/rest.py for making REST API calls.

CLASS DESCRIPTION
RestClient

A client wrapper for REST APIs.

RestConfig

Configuration for REST API clients.

ATTRIBUTE DESCRIPTION
logger

logger module-attribute

logger = getLogger(__name__)

RestClient

RestClient(config: RestConfig)

A client wrapper for REST APIs.

This class provides a wrapper around sift_py/rest.py for making REST API calls. It handles authentication, retries, and error mapping.

Initialize the REST client.

PARAMETER DESCRIPTION
config

The REST client configuration.

TYPE: RestConfig

METHOD DESCRIPTION
close

Close the REST client session.

delete

Execute a DELETE request.

get

Execute a GET request.

patch

Execute a PATCH request.

post

Execute a POST request.

put

Execute a PUT request.

ATTRIBUTE DESCRIPTION
base_url

Get the base URL of the REST client.

TYPE: str

base_url property

base_url: str

Get the base URL of the REST client.

RETURNS DESCRIPTION
str

The base URL string.

close

close() -> None

Close the REST client session.

delete

delete(
    endpoint: str, headers: dict | None = None, **kwargs
) -> Response

Execute a DELETE request.

PARAMETER DESCRIPTION
endpoint

The API endpoint to call.

TYPE: str

headers

Additional headers to include in the request.

TYPE: dict | None DEFAULT: None

**kwargs

Additional arguments to pass to the request.

DEFAULT: {}

RETURNS DESCRIPTION
Response

The HTTP response.

get

get(
    endpoint: str, headers: dict | None = None, **kwargs
) -> Response

Execute a GET request.

PARAMETER DESCRIPTION
endpoint

The API endpoint to call.

TYPE: str

headers

Additional headers to include in the request.

TYPE: dict | None DEFAULT: None

**kwargs

Additional arguments to pass to the request.

DEFAULT: {}

RETURNS DESCRIPTION
Response

The HTTP response.

patch

patch(
    endpoint: str,
    headers: dict | None = None,
    data=None,
    **kwargs,
) -> Response

Execute a PATCH request.

PARAMETER DESCRIPTION
endpoint

The API endpoint to call.

TYPE: str

headers

Additional headers to include in the request.

TYPE: dict | None DEFAULT: None

data

The data to send in the request body.

DEFAULT: None

**kwargs

Additional arguments to pass to the request.

DEFAULT: {}

RETURNS DESCRIPTION
Response

The HTTP response.

post

post(
    endpoint: str,
    headers: dict | None = None,
    data=None,
    **kwargs,
) -> Response

Execute a POST request.

PARAMETER DESCRIPTION
endpoint

The API endpoint to call.

TYPE: str

headers

Additional headers to include in the request.

TYPE: dict | None DEFAULT: None

data

The data to send in the request body.

DEFAULT: None

**kwargs

Additional arguments to pass to the request.

DEFAULT: {}

RETURNS DESCRIPTION
Response

The HTTP response.

put

put(
    endpoint: str,
    headers: dict | None = None,
    data=None,
    **kwargs,
) -> Response

Execute a PUT request.

PARAMETER DESCRIPTION
endpoint

The API endpoint to call.

TYPE: str

headers

Additional headers to include in the request.

TYPE: dict | None DEFAULT: None

data

The data to send in the request body.

DEFAULT: None

**kwargs

Additional arguments to pass to the request.

DEFAULT: {}

RETURNS DESCRIPTION
Response

The HTTP response.

RestConfig

RestConfig(
    base_url: str,
    api_key: str,
    use_ssl: bool = True,
    cert_via_openssl: bool = False,
    retry: Retry = _DEFAULT_REST_RETRY,
)

Configuration for REST API clients.

Initialize the REST configuration.

PARAMETER DESCRIPTION
base_url

The base URL of the API.

TYPE: str

api_key

The API key for authentication.

TYPE: str

use_ssl

Whether to use HTTPS.

TYPE: bool DEFAULT: True

cert_via_openssl

Whether to use OpenSSL for SSL/TLS.

TYPE: bool DEFAULT: False

retry

The retry configuration for requests.

TYPE: Retry DEFAULT: _DEFAULT_REST_RETRY

ATTRIBUTE DESCRIPTION
api_key

base_url

cert_via_openssl

retry

use_ssl

api_key instance-attribute

api_key = api_key

base_url instance-attribute

base_url = base_url

cert_via_openssl instance-attribute

cert_via_openssl = cert_via_openssl

retry instance-attribute

retry = retry

use_ssl instance-attribute

use_ssl = use_ssl