Skip to content

Http Client

HTTP client for connector operations with retry and authentication.

Classes

ConnectorResponse

ConnectorResponse(status_code: int, headers: Dict[str, str], value: Optional[T])

Bases: Generic[T]

Represents a response from a connector operation.

Initialize a ConnectorResponse.

Parameters:

Name Type Description Default
status_code int

The HTTP status code.

required
headers Dict[str, str]

The response headers.

required
value Optional[T]

The response value.

required

Attributes

is_success_status_code property
is_success_status_code: bool

Check if the response indicates success.

ConnectorHttpClient

ConnectorHttpClient(token_provider: TokenProvider, options: ConnectorClientOptions)

HTTP client for connector operations with retry and authentication.

Initialize a ConnectorHttpClient.

Parameters:

Name Type Description Default
token_provider TokenProvider

The token provider for authentication.

required
options ConnectorClientOptions

The client options.

required

Methods:

close async
close()

Close the HTTP session and token provider.

send_async async
send_async(method: str, url: str, scopes: Optional[List[str]] = None, body: Optional[Any] = None, content_type: Optional[str] = None) -> _ResponseSnapshot

Send an HTTP request with authentication and retry.

Parameters:

Name Type Description Default
method str

The HTTP method. GET, HEAD, OPTIONS, and TRACE use configured retries by default. Other methods require the explicit per-client retry_unsafe_http_methods opt-in to retry.

required
url str

The request URL.

required
scopes Optional[List[str]]

The authentication scopes. Defaults to API Hub scopes.

None
body Optional[Any]

Optional request body. Raw bytes and bytearray values are sent as-is; all other values are JSON-serialized.

None
content_type Optional[str]

Optional Content-Type header value. Defaults to application/octet-stream for raw binary bodies and application/json otherwise. This value does not change how the body is serialized.

None

Returns:

Type Description
_ResponseSnapshot

The HTTP response.

get_async async
get_async(request_uri: str, scopes: Optional[List[str]] = None) -> Any

Send a GET request.

Parameters:

Name Type Description Default
request_uri str

The request URI.

required
scopes Optional[List[str]]

Optional authentication scopes.

None

Returns:

Type Description
Any

The deserialized response.

post_async async
post_async(request_uri: str, body: Any, scopes: Optional[List[str]] = None) -> Any

Send a POST request with JSON body.

Parameters:

Name Type Description Default
request_uri str

The request URI.

required
body Any

The request body.

required
scopes Optional[List[str]]

Optional authentication scopes.

None

Returns:

Type Description
Any

The deserialized response.