StationControlClient#

Module: iqm.station_control.client.station_control_client

class StationControlClient(station_control_url, *, token=None, tokens_file=None, get_token_callback=None, client_signature=None)#

Bases: Serializable

Client implementation for station control service REST API.

Parameters:
  • station_control_url (str) – Remote station control service URL.

  • token (str | None) – Long-lived authentication token in plain text format. If token is given no other user authentication parameters should be given.

  • tokens_file (str | None) – Path to a tokens file used for authentication. If tokens_file is given no other user authentication parameters should be given.

  • get_token_callback (Callable[[], str] | None) – Callback function that returns an Authorization header containing a bearer token. If get_token_callback is given no other user authentication parameters should be given.

  • client_signature (str | None) – String that is added to the User-Agent header of requests sent to the server.

Attributes

version

Version of the Station Control API this client is using.

Methods

clean_query_parameters

deserialize

Reconstruct an instance from a dictionary payload.

deserialize_response

get_about

send_request

Send an HTTP request.

serialize

Serialize the object instance into a dictionary payload.

serialize_model

Serialize a Pydantic model into a JSON string.

serialize_query_params

Serialize query parameters, skipping None values and empty dictionaries.

serialize()#

Serialize the object instance into a dictionary payload.

Return type:

dict[str, Any]

classmethod deserialize(data)#

Reconstruct an instance from a dictionary payload.

Parameters:

data (dict[str, Any])

Return type:

StationControlClient

property version: str#

Version of the Station Control API this client is using.

serialize_query_params(params)#

Serialize query parameters, skipping None values and empty dictionaries.

Parameters:

params (dict[str, Any])

Return type:

dict[str, Any]

send_request(http_method, url_path, *, headers=None, params=None, json_data=None, octets=None, timeout=600)#

Send an HTTP request.

Parameters json_data and octets are mutually exclusive. The first non-None argument (in this order) will be used to construct the body of the request.

Parameters:
  • http_method (Callable[[...], Response]) – HTTP method to use for the request, any of requests.[post|get|put|head|delete|patch|options].

  • url_path (str) – URL for the request.

  • headers (dict[str, str] | None) – Additional HTTP headers for the request. Some may be overridden.

  • params (dict[str, Any] | None) – HTTP query parameters to store in the query string of the request URL.

  • json_data (str | None) – JSON string to store in the body, may contain arbitrary Unicode characters.

  • octets (bytes | None) – Pre-serialized binary data to store in the body.

  • timeout (int) – Timeout for the request in seconds.

Returns:

Response to the request.

Raises:

IQMError – Request was not successful.

Return type:

Response

static serialize_model(model)#

Serialize a Pydantic model into a JSON string.

All Pydantic models should be serialized using this method, to keep the client behavior uniform.

Parameters:

model (BaseModel) – Pydantic model to JSON-serialize.

Returns:

Corresponding JSON string, may contain arbitrary Unicode characters.

Return type:

str

Inheritance

Inheritance diagram of iqm.station_control.client.station_control_client.StationControlClient