flexmeasures.api.common.schemas.users

Classes

class flexmeasures.api.common.schemas.users.AccountAPIQuerySchema(*, only: Sequence[str] | AbstractSet[str] | None = None, exclude: Sequence[str] | AbstractSet[str] = (), many: bool | None = None, load_only: Sequence[str] | AbstractSet[str] = (), dump_only: Sequence[str] | AbstractSet[str] = (), partial: bool | Sequence[str] | AbstractSet[str] | None = None, unknown: Literal['exclude', 'include', 'raise'] | None = None)
class flexmeasures.api.common.schemas.users.AccountIdField(*, strict: bool = False, as_string: bool = False, **kwargs: Unpack[_BaseFieldKwargs])

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

_deserialize(value: Any, attr, data, **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 <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 **kwargs to signature.

_serialize(value: Account, attr, obj, **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(value: Any, attr, data, **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 <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 **kwargs to signature.

_serialize(value: User, attr, obj, **kwargs) int

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

convert(value, param, ctx, **kwargs)

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail() with a descriptive message.

Parameters:
  • value – The value to convert.

  • param – The parameter that is using this type to convert its value. May be None.

  • ctx – The current context that arrived at this value. May be None.