provenaclient.utils.http_client

Created Date: Monday June 17th 2024 +1000 Author: Peter Baker —– Last Modified: Monday June 17th 2024 5:00:47 pm +1000 Modified By: Peter Baker —– Description: A HTTP client which wraps HTTPx async so that we can swap out a different http library later if needed. —– HISTORY: Date By Comments ———- — ———————————————————

Attributes

timeout

Classes

HttpClient

This class only contains static methods as it acts as an HTTP client and provides a layer over these static methods

Module Contents

provenaclient.utils.http_client.timeout
class provenaclient.utils.http_client.HttpClient[source]

This class only contains static methods as it acts as an HTTP client and provides a layer over these static methods and makes them easily identifiable within the codebase.

static make_get_request(url: str, params: dict[str, Any] | None = None, auth: provenaclient.auth.helpers.HttpxBearerAuth | None = None, headers: dict[str, Any] | None = None) httpx.Response[source]
Async:

Makes an asynchronous HTTP GET request to the specified URL using the provided parameters, authentication, and headers.

Parameters:
  • url (str) – The URL to which the GET request will be sent.

  • params (Optional[dict[str, Any]], optional) – A dictionary of the query parameters to be included in the GET request, by default None.

  • auth (Optional[HttpxBearerAuth], optional) – Authentication object (httpx bearer token only), to be included in the request headers, by default None.

  • headers (Optional[dict[str,Any]], optional) – A dictionary having additional HTTP headers to send with the GET request, by default None.

Returns:

The response from the server as an httpx.Response object.

Return type:

httpx.Response

static make_delete_request(url: str, auth: provenaclient.auth.helpers.HttpxBearerAuth, params: dict[str, Any] | None = None, headers: dict[str, Any] | None = None) httpx.Response[source]
Async:

Makes an asynchronous HTTP DELETE request to the specified URL using the provided parameters, authentication, and headers.

Parameters:
  • url (str) – The URL to which the DELETE request will be sent.

  • params (Optional[dict[str, Any]], optional) – A dictionary of the query parameters to be included in the GET request, by default None.

  • auth (Optional[HttpxBearerAuth], optional) – Authentication object (httpx bearer token only), to be included in the request headers, by default None.

  • headers (Optional[dict[str,Any]], optional) – A dictionary having additional HTTP headers to send with the GET request, by default None.

Returns:

The response from the server as an httpx.Response object.

Return type:

httpx.Response

static make_post_request(url: str, auth: provenaclient.auth.helpers.HttpxBearerAuth, params: dict[str, Any] | None = None, data: dict[str, Any] | None | List[dict[str, Any]] | None = None, files: dict[str, tuple[str, bytes, str]] | None = None, headers: dict[str, Any] | None = None) httpx.Response[source]
Async:

Makes an asynchronous HTTP POST request to the specified URL with the provided data, authentication, and headers.

Parameters:
  • url (str) – The URL to which the GET request will be sent.

  • params (Optional[dict[str, Any]], optional) – A dictionary of the query parameters to be included in the GET request, by default None.

  • auth (HttpxBearerAuth) – Authentication object (e.g., bearer token), which is required for the POST request.

  • data (Optional[dict[str,Any]], optional) – A dictionary of the data to be sent in the body of the POST request, by default None.

  • files (Optional[dict[str, tuple[str, bytes, str]]], optional) – A files request object containing the file content and the media type.

  • headers (Optional[dict[str, Any]], optional) – A dictionary representing additional HTTP headers to send with the POST request, by default None.

Returns:

The response from the server as an httpx.Response object.

Return type:

httpx.Response

static make_put_request(url: str, auth: provenaclient.auth.helpers.HttpxBearerAuth, params: dict[str, Any] | None = None, data: provenaclient.utils.helpers.JsonData | None = None, headers: dict[str, Any] | None = None) httpx.Response[source]
Async:

Makes an asynchronous HTTP put request to the specified URL with the provided data, authentication, and headers.

Parameters:
  • url (str) – The URL to which the GET request will be sent.

  • params (Optional[dict[str, Any]], optional) – A dictionary of the query parameters to be included in the GET request, by default None.

  • auth (HttpxBearerAuth) – Authentication object (e.g., bearer token), which is required for the put request.

  • data (Optional[dict[str,Any]], optional) – A dictionary of the data to be sent in the body of the put request, by default None.

  • headers (Optional[dict[str, Any]], optional) – A dictionary representing additional HTTP headers to send with the put request, by default None.

Returns:

The response from the server as an httpx.Response object.

Return type:

httpx.Response