air_sdk.air_model#
Attributes#
Classes#
Helper class that provides a standard way to create an ABC using |
|
AirModel mixin for lazily resolving the instance. |
|
Mixin used to allow AirModel subclasses to have an unimplemented API. |
|
Mixin class for defining common endpoint methods. |
|
Mixin class for defining common endpoint methods. |
Functions#
|
Get a unique mapping for assignment of metadata on special BaseModel fields. |
Module Contents#
- air_sdk.air_model.T#
- air_sdk.air_model.TAirModel#
- air_sdk.air_model.TAirModel_co#
- air_sdk.air_model.TParentAirModel_co#
- air_sdk.air_model.TSupportedPrimitive#
- air_sdk.air_model.SpecialField#
- air_sdk.air_model.DataDict#
- air_sdk.air_model._generate_special_field() SpecialField[source]#
Get a unique mapping for assignment of metadata on special BaseModel fields.
- class air_sdk.air_model.AirModel[source]#
-
Helper class that provides a standard way to create an ABC using inheritance.
- _api: dataclasses.InitVar#
- FIELD_FOREIGN_KEY: ClassVar[SpecialField]#
- FIELD_LAZY: ClassVar[SpecialField]#
- __post_init__(_api: air_sdk.AirApi) None[source]#
- property __pk__: PrimaryKey#
Returns current model’s primary key for API-related actions.
- clear_cached_property(property_name: str) None[source]#
Clear a cached property to force re-computation on next access.
- Parameters:
property_name – Name of the cached property to clear
Example
>>> simulation.clear_cached_property('ztp_script') >>> # Next access will re-query the API >>> print(simulation.ztp_script)
- __setitem__(key: str, value: Any) None[source]#
Enable dictionary-style assignment to fields: obj[‘field_name’] = value
- __refresh__(refreshed_obj: BaseModel | None = None) None[source]#
Refreshed the instances data from the backend.
- Raises:
NotImplementedError - When the model's API does not implement get. –
- classmethod get_model_api() Type[BaseEndpointAPI[TAirModel_co]][source]#
- Abstractmethod:
Returns the respective AirModelAPI type for this model.
- class air_sdk.air_model.ForeignKeyMixin(primary_key: uuid.UUID, _api: air_sdk.AirApi)[source]#
Bases:
Generic[TAirModel_co]AirModel mixin for lazily resolving the instance.
- __fk__#
- __fk_resolved__ = False#
- __api__#
- property __pk__: PrimaryKey#
- class air_sdk.air_model.ApiNotImplementedMixin[source]#
Mixin used to allow AirModel subclasses to have an unimplemented API.
- class air_sdk.air_model.EndpointMethodMixin[source]#
Mixin class for defining common endpoint methods.
This is used to prevent with the intention of raising a NotImplementedError instead of an AttributeError when specific endpoint methods are not implemented in the SDK or API.
- class air_sdk.air_model.BaseEndpointAPI(
- api: air_sdk.AirApi,
- default_filters: dict[str, Any] | None = None,
Bases:
EndpointMethodMixin,Generic[TAirModel_co]Mixin class for defining common endpoint methods.
This is used to prevent with the intention of raising a NotImplementedError instead of an AttributeError when specific endpoint methods are not implemented in the SDK or API.
- model: Type[TAirModel_co]#
- __api__#
- default_filters#
- property model_cls_type_hints: DataDict#
- property model_cls_fields: Tuple[dataclasses.Field[Any], Ellipsis]#
- load_model(data: DataDict) TAirModel_co[source]#
Construct a new model instance, validate data, and set the API Client.
- get_defaults_for_missing_fields(
- dc_fields: list[dataclasses.Field[Any]],
Get default values for fields missing from API response.
- parse_provided_fields(
- dc_fields: list[dataclasses.Field[Any]],
- data: DataDict,
- parse_field(
- hint: Type[T],
- metadata: Mapping[Any, Any],
- provided_value: Any,
- context: str,
Parse the provided value based on the type hint of the value.
This allows us to perform type checking of provided values and assists in the implementation of our FIELD_FOREIGN_KEY and FIELD_LAZY fields.
If parsing fails (e.g., due to API type changes), falls back to returning the raw value to prevent crashes.
- handle_list_field( ) list[T][source]#
Provided data argument is validated to be an actual list. Each item in data list is then validated against the target type and parsed individually.
- handle_optional_field(
- hint: Type[T | None],
- metadata: Mapping[Any, Any],
- provided_value: Any,
- handle_air_model_field(
- hint: Type[TAirModel_co],
- metadata: Mapping[Any, Any],
- provided_value: Any,
AirModel fields are validated as follows: - Foreign key fields are reserved for on-demand loading - Otherwise, field is parsed as a regular BaseModel
- handle_datetime_field(provided_value: Any) datetime.datetime[source]#