pystclient.clients¶
STC client module for managing STC API interactions.
Functions
|
Persist an OAuth2 token to disk for reuse across sessions. |
Read a previously cached OAuth2 token from disk. |
|
|
Parse an HTTP response into a single STC model instance. |
|
Parse an HTTP response into a list of STC model instances. |
|
Decode and validate a JWT access token against the STC API requirements. |
Classes
|
Base client providing shared session and response-parsing utilities. |
|
Handle authentication. |
|
Client for accessing simulation result data from the STC platform. |
|
Client for managing FMU models in the STC platform. |
|
Client for managing STC projects and their associated configurations. |
STC Python client. |
|
|
Iterator that pages through simulation measurement results in configurable time steps. |
|
Client for creating, controlling, and monitoring simulators on the STC platform. |
- pystclient.clients.cache_token(token: dict[str, str] | OAuth2Token) None¶
Persist an OAuth2 token to disk for reuse across sessions.
The token is stored as a JSON file in the STC client home directory, allowing subsequent client instantiations to skip the interactive authentication flow.
- Parameters:
token – The OAuth2 token to cache
- pystclient.clients.read_token() dict[str, str] | None¶
Read a previously cached OAuth2 token from disk.
Looks for a token file in the STC client home directory. If no token file exists, returns
Noneso the caller can fall back to interactive authentication.- Returns:
The deserialized token dictionary, or
Noneif no cached token is available
- pystclient.clients.to_model(resp: Response, model: type[STCModel], mapping: Callable[[dict[Any, Any]], dict[Any, Any]] | None = None) STCModel¶
Parse an HTTP response into a single STC model instance.
Validates that the response has a JSON body with a 2xx status code, optionally transforms the raw JSON with a mapping function, then constructs and returns the specified model.
- Parameters:
resp – The HTTP response to parse
model – The model class to instantiate from the response data
mapping – An optional function to transform the raw JSON before model construction
- Returns:
The constructed model instance
- Raises:
APIResponseError – If the response status is not OK or is not JSON
- pystclient.clients.to_models(resp: Response, model: type[STCModel], mapping: Callable[[Any], list[dict[Any, Any]]] | None = None) list[STCModel]¶
Parse an HTTP response into a list of STC model instances.
Validates that the response has a JSON body with a 2xx status code, optionally transforms the raw JSON with a mapping function, then constructs a model instance for each item in the resulting list.
- Parameters:
resp – The HTTP response to parse
model – The model class to instantiate for each item
mapping – An optional function to extract a list of dicts from the raw JSON
- Returns:
A list of constructed model instances
- Raises:
APIResponseError – If the response status is not OK or is not JSON
- pystclient.clients.validate_token(access_token: str, key: KeySet, nonce: str | None = None) Token¶
Decode and validate a JWT access token against the STC API requirements.
Verifies that the token’s audience and authorized-party claims match the configured API and client IDs. Optionally validates a nonce to guard against replay attacks.
- Parameters:
access_token – The raw JWT access token string
key – The public key set used to verify the token signature
nonce – A nonce value to validate against the token’s
nonceclaim, by default None
- Returns:
The decoded JWT token with validated claims
- Raises:
InvalidClaimError – If any required claim fails validation