planetcasio.transport
– Client transport definition¶
- exception planetcasio.transport.UnexpectedRedirect(message: str | None = None, /, *, location: str | None = None)¶
Bases:
Exception
A 3xx status code was received while redirects were disabled.
- exception planetcasio.transport.FormNotFound(message: str | None = None, /)¶
Bases:
Exception
Form was not found with the given parameters.
- pydantic model planetcasio.transport.TransportConfig¶
Bases:
BaseModel
Transport configuration.
- Validators:
_validate
»all fields
- field auth: tuple[Username, Password] | None [Required]¶
Optional redentials.
- Validated by:
_validate
- field base_url: HttpUrl [Required]¶
Base URL.
- Validated by:
_validate
- class planetcasio.transport.Transport(*, session: ClientSession, config: TransportConfig)¶
Bases:
object
Client for interacting with Planète Casio.
- config: TransportConfig¶
Configuration.
- session: ClientSession¶
HTTP client session.
- classmethod context(config: TransportConfig, /) AsyncIterator[TransportType] ¶
Get a transport in a context.
- async authenticate() _AuthData ¶
Authenticate to the API.
- async check_auth() None ¶
Check that we have valid authentication data.
- Raises:
CredentialsRequired – Credentials have not been provided.
- async request_api(path: str, /, *, model: None = None, method: str | None = None, params: dict[str, str] | None = None, form_data: dict[str, str] | None = None) None ¶
- async request_api(path: str, /, *, model: type[APIResponseType], method: str | None = None, params: dict[str, str] | None = None, form_data: dict[str, str] | None = None) APIResponseType
Make an API request, and expect JSON to be returned.
- Parameters:
path – Path to the API endpoint.
method – Method to use with the API endpoint.
params – Query parameters to pass to the API endpoint.
form_data – Form data to post to the endpoint.
model – Expected response model.
- Returns:
API response, in the provided format.
- async request_html(path: str, /, *, params: dict[str, str] | None = None) Element ¶
Make a web interface request, and expect HTML to be returned.
- Parameters:
path – Path to the web interface endpoint.
query – Query parameters.
- Returns:
Parsed document.
- submit_form(path: str, values: dict[str, str] | None = None, /, *, form_path: str = '//form', params: dict[str, str] | None = None, files: dict[str, Path | str | tuple[str | Path, BytesIO | bytes | str]] | None = None) AsyncIterator[ClientResponse] ¶
Submit an HTML form present on the website.
- Parameters:
path – Path to the page containing the form to submit.
values – Values to add to the form.
form_path – XPath of the form to submit.
params – Query parameters to get the form.
files – File values to add to the form.
- class planetcasio.transport.BaseClient(config: TransportConfig, /)¶
Bases:
object
Holder for a transport, which creates the transport if need be.
- class planetcasio.transport.Feature(client: BaseClient, /)¶
Bases:
object
Object that makes use of a base client.
- client: BaseClient¶
Client to make use of.