flexmeasures.data.schemas.account
Classes
- class flexmeasures.data.schemas.account.AccountIdField(*, strict: bool = False, as_string: bool = False, **kwargs: Unpack[_BaseFieldKwargs])
Field that deserializes to an Account and serializes back to an integer.
- class flexmeasures.data.schemas.account.AccountIdOrListField(*, load_default: ~typing.Any = <marshmallow.missing>, dump_default: ~typing.Any = <marshmallow.missing>, data_key: str | None = None, attribute: str | None = None, validate: ~typing.Callable[[~typing.Any], ~typing.Any] | ~typing.Iterable[~typing.Callable[[~typing.Any], ~typing.Any]] | None = None, required: bool = False, allow_none: bool | None = None, load_only: bool = False, dump_only: bool = False, error_messages: dict[str, str] | None = None, metadata: ~typing.Mapping[str, ~typing.Any] | None = None)
Field that accepts a single account ID or a non-empty list of account IDs.
Both
42and[42, 99]are accepted. Always deserializes to a list ofAccountinstances.The field is intentionally expressed as a union of
integerandarray[integer]rather than always requiring a list, so that future OpenAPI generation can emit aoneOfschema for it.- _deserialize(value: Any, attr, data, **kwargs) list[Account]
Deserialize value. Concrete
Fieldclasses should implement this method.- Parameters:
value – The value to be deserialized.
attr – The attribute/key in data to be deserialized.
data – The raw input data passed to the Schema.load <marshmallow.Schema.load>.
kwargs – Field-specific keyword arguments.
- Raises:
ValidationError – In case of formatting or validation failure.
- Returns:
The deserialized value.
Changed in version 3.0.0: Added
**kwargsto signature.
- _serialize(value: Any, attr, obj, **kwargs)
Serializes
valueto a basic Python datatype. Noop by default. ConcreteFieldclasses should implement this method.Example:
class TitleCase(Field): def _serialize(self, value, attr, obj, **kwargs): if not value: return "" return str(value).title()
- Parameters:
value – The value to be serialized.
attr – The attribute or key on the object to be serialized.
obj – The object the value was pulled from.
kwargs – Field-specific keyword arguments.
- Returns:
The serialized value
- class flexmeasures.data.schemas.account.AccountRoleSchema(*args, **kwargs)
AccountRole schema, with validations.
- class Meta
- model
alias of
AccountRole
- opts: LoadInstanceMixin.Opts = <flask_marshmallow.sqla.SQLAlchemySchemaOpts object>