sites.sdk.common.http package

Submodules

sites.sdk.common.http.client module

class sites.sdk.common.http.client.HTTPClient(authenticator: AuthorizationBuilder | None = None)[source]

Arguments to instantiate a HTTPClient:

Param:

authenticator: Authenticator - the authenticator to use on requests

get_authenticator() AuthorizationBuilder | None[source]

Returns the current authenticator

:return an instance of Authenticator

make_request(request: Request, authenticator: AuthorizationBuilder | None = None) Response[source]

Handles requests with a retry strategy

Param:

request: Request - the prepared request object

Param:

authenticator: Authenticator - optional - the authenticator to use on this particular request, otherwise will use the global one

sites.sdk.common.http.utils module

exception sites.sdk.common.http.utils.ApiCallException[source]

Parent Exception to wrap API calls

exception sites.sdk.common.http.utils.ChecksumMismatchError[source]

Raised when a downloaded file’s checksum does not match the server-reported digest.

class sites.sdk.common.http.utils.HTTPMethod[source]

Represents the HTTP Methods

DELETE = 'DELETE'
GET = 'GET'
HEAD = 'HEAD'
POST = 'POST'
PUT = 'PUT'
sites.sdk.common.http.utils.ensure_json_response(response: Response, error_message: str) Dict[str, Any][source]

Parse the response into JSON; raise ApiCallException if the body was not JSON.

sites.sdk.common.http.utils.http_success(response: Response) bool[source]

returns true if response is >=200 and <300

sites.sdk.common.http.utils.parse_repr_digest(header_value: str | None) str | None[source]

Extract the base64-encoded SHA-256 digest from an RFC 9530 Repr-Digest header.

Parameters:

header_value – raw Repr-Digest header value, e.g. sha-256=:RK/0qy18MlBS...:

Returns:

the base64-encoded digest string, or None if not present or not parseable

sites.sdk.common.http.utils.parse_response(response: Response) Dict[str, Any] | bytes[source]

Returns JSON if the response is JSON otherwise the response body plain text in bytes

sites.sdk.common.http.utils.raise_exception_mapper(response: Response, error_message: str) None[source]