flexmeasures.api.common.schemas.users

Classes

class flexmeasures.api.common.schemas.users.AccountIdField(*, strict: bool = False, **kwargs)

Field that represents an account ID. It deserializes from the account id to an account instance.

_deserialize(account_id: str, attr, obj, **kwargs) Account

Deserialize value. Concrete Field classes 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.

  • kwargs – Field-specific keyword arguments.

Raises:

ValidationError – In case of formatting or validation failure.

Returns:

The deserialized value.

Changed in version 2.0.0: Added attr and data parameters.

Changed in version 3.0.0: Added **kwargs to signature.

_serialize(account: Account, attr, data, **kwargs) int

Return a string if self.as_string=True, otherwise return this field’s num_type.

classmethod load_current()

Use this with the load_default arg to __init__ if you want the current user’s account by default.

class flexmeasures.api.common.schemas.users.UserIdField(*args, **kwargs)

Field that represents a user ID. It deserializes from the user id to a user instance.

__init__(*args, **kwargs)
_deserialize(user_id: int, attr, obj, **kwargs) User

Deserialize value. Concrete Field classes 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.

  • kwargs – Field-specific keyword arguments.

Raises:

ValidationError – In case of formatting or validation failure.

Returns:

The deserialized value.

Changed in version 2.0.0: Added attr and data parameters.

Changed in version 3.0.0: Added **kwargs to signature.

_serialize(user: User, attr, data, **kwargs) int

Return a string if self.as_string=True, otherwise return this field’s num_type.