snap_python.client module
- class snap_python.client.SnapClient(version: str = 'v2', snapd_socket_location: str = None, tcp_location: str = None, store_base_url: str = 'https://api.snapcraft.io', store_headers: dict[str, str] = None, prompt_for_authentication: bool = False)
Bases:
AbstractSnapsClient
Core class for interacting with the Snap Store and Snapd.
- get_changes_by_id(change_id: str) ChangesResponse
Asynchronously retrieves changes by their ID.
- Parameters:
change_id (str) – The ID of the change to retrieve.
- Returns:
The response object containing the changes.
- Return type:
- Raises:
httpx.HTTPStatusError – If the request results in an HTTP error.
- async get_changes_by_id_generator(change_id: str) AsyncGenerator[ChangesResponse, None]
Asynchronous generator to fetch changes by change ID.
This generator continuously requests changes from the server using the provided change ID and yields the response as a ChangesResponse object. It includes error handling for HTTP status errors and adds a small delay between requests to avoid overwhelming the server.
- Parameters:
change_id (str) – The ID of the change to fetch.
- Yields:
The response object containing the changes.
- Return type:
- Raises:
httpx.HTTPStatusError – If the request fails with an HTTP status error.
- async ping() Response
Reserved for human-readable content describing the service.
- Returns:
The response from the ping request.
- Return type:
httpx.Response
- request(method: str, endpoint: str, **kwargs) Response
Sends an HTTP request to the specified endpoint using the given method and parameters.
- Parameters:
method (str) – The HTTP method to use for the request (e.g., ‘GET’, ‘POST’).
endpoint (str) – The API endpoint to send the request to.
**kwargs – Additional keyword arguments to pass to the request.
- Returns:
The response object from the HTTP request.
- Return type:
httpx.Response
- Raises:
httpx.HTTPStatusError – If the response contains an HTTP status code indicating an error.
- request_raw(method: str, endpoint: str, **kwargs) Response
Sends an HTTP request using the specified method and endpoint.
- Parameters:
method (str) – The HTTP method to use for the request (e.g., ‘GET’, ‘POST’).
endpoint (str) – The endpoint URL to send the request to.
**kwargs – Additional keyword arguments to pass to the request.
- Returns:
The response object resulting from the HTTP request.
- Return type:
httpx.Response
- Raises:
httpx.HTTPStatusError – If the response contains an HTTP status code indicating an error.