aistore.sdk.request_client
aistore.sdk.request_client
Module Contents
Classes
Data
API
Internal client for making requests to an AIS cluster or a specific proxy (e.g. AuthN).
Parameters:
Endpoint to either the AIS cluster or a specific proxy (e.g. AuthN).
SessionManager for creating and accessing requests session.
Request timeout in seconds; a single float. for both connect/read timeouts (e.g., 5.0), a tuple for separate connect/read timeouts (e.g., (3.0, 10.0)), or None to disable timeout.
Authorization token.
Handler for processing HTTP responses. Defaults to AISResponseHandler.
Return the base URL.
Return the SessionManager used to create sessions for this client.
Return the timeout for requests.
Return the token for authorization.
Calculate the content length of data for HTTP requests.
Handles multiple data types including bytes, strings, and file-like objects.
Parameters:
The data whose length needs to be calculated. Can be:
- bytes or str: Direct length calculation
- File-like object with fileno(): Uses fstat for efficiency
- File-like object with seek(): Uses seek to determine size
- Other types: Returns None with a warning
Returns: Optional[int]
The content length in bytes, or None if it cannot be determined
Raises:
IOError: If file operations fail during content length calculation
Prepare the request parameters for the initial proxy request.
When data is present, the Content-Length header is calculated and set if possible, but the actual data is replaced with an empty byte string to avoid SSL EOF errors and improve efficiency.
Parameters:
Request headers to be sent
Additional request parameters including optional ‘data’
Returns: Dict[str, Any]
Dict containing the prepared request parameters for the proxy
Raises:
IOError: If file operations fail during content length calculation
Execute a request with manual redirect handling for HTTPS connections with data.
This method implements a two-phase request pattern:
- Send a request to the proxy to obtain the redirect URL
- Send the actual request with data to the redirected target
This workaround is necessary because the requests library does not properly
handle 307 redirects from TLS-enabled servers when data is present in the request,
resulting in SSL EOF errors: SSLEOFError(8, ‘EOF occurred in violation of protocol’)
When cluster authentication is enabled, the proxy requires the Content-Length header to compute the HMAC signature, but the actual data payload is not needed until the request reaches the target node.
Parameters:
HTTP method (e.g., ‘GET’, ‘POST’, ‘PUT’, ‘DELETE’)
Initial URL to the AIS proxy
HTTP headers to be sent with the request
Additional request parameters (e.g., data, params, timeout)
Returns: Response
The HTTP response from the final target server
Raises:
ValueError: If the proxy does not return a redirect or the redirect URL is missingTypeError: If data type is not supportedIOError: If file operations fail during content length calculation
Create a copy of the current RequestClient instance with an optional new base URL.
Parameters:
New base URL for the cloned client. Defaults to the existing base URL.
Returns: RequestClient
A new instance with the same settings but an optional different base URL.
Get the full URL to the path on the cluster with the given parameters.
Parameters:
Path on the cluster.
Query parameters to include.
Returns: str
URL including cluster base URL and parameters.
Return the smap.
Make a request with the request_client’s retry manager.
If the request is an HTTPS request with a payload (data), it uses _request_with_manual_redirect.
Otherwise, it makes a direct call using the current session manager with _make_session_request.
Parameters:
HTTP method (e.g. POST, GET, PUT, DELETE).
URL path to call.
Alternative endpoint for the AIS cluster (e.g. for connecting to a specific proxy).
Extra headers to be passed with the request. Content-Type and User-Agent will be overridden.
Optional keyword arguments to pass with the call to request.
Returns: Response
The HTTP response from the server.
Make a request and deserialize the response to a defined type.
Parameters:
HTTP method (e.g. POST, GET, PUT, DELETE).
URL path to call.
Resulting type to which the response should be deserialized.
Optional keyword arguments to pass with the call to request.
Returns: T
Parsed result of the call to the API, as res_model.