Module licenseware.common.serializers.features_schema
Expand source code
from marshmallow import Schema, fields
from licenseware.common.validators import validate_uuid4
class FeaturesSchema(Schema):
tenant_id = fields.String(required=True, validate=validate_uuid4)
name = fields.String(required=True)
app_id = fields.String(required=False, allow_none=True)
description = fields.String(required=False, allow_none=True)
access_levels = fields.List(fields.String, required=False, allow_none=True)
monthly_quota = fields.Integer(required=False, allow_none=True)
activated = fields.Boolean(required=False, allow_none=True)
feature_id = fields.String(required=False, allow_none=True)
feature_path = fields.String(required=False, allow_none=True)
Classes
class FeaturesSchema (*, only: Union[Sequence[str], Set[str], None] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict[~KT, ~VT]] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)
-
Base schema class with which to define custom schemas.
Example usage:
.. code-block:: python
import datetime as dt from dataclasses import dataclass from marshmallow import Schema, fields @dataclass class Album: title: str release_date: dt.date class AlbumSchema(Schema): title = fields.Str() release_date = fields.Date() album = Album("Beggars Banquet", dt.date(1968, 12, 6)) schema = AlbumSchema() data = schema.dump(album) data # {'release_date': '1968-12-06', 'title': 'Beggars Banquet'}
:param only: Whitelist of the declared fields to select when instantiating the Schema. If None, all fields are used. Nested fields can be represented with dot delimiters. :param exclude: Blacklist of the declared fields to exclude when instantiating the Schema. If a field appears in both
only
andexclude
, it is not used. Nested fields can be represented with dot delimiters. :param many: Should be set toTrue
ifobj
is a collection so that the object will be serialized to a list. :param context: Optional context passed to :class:fields.Method
and :class:fields.Function
fields. :param load_only: Fields to skip during serialization (write-only fields) :param dump_only: Fields to skip during deserialization (read-only fields) :param partial: Whether to ignore missing fields and not require any fields declared. Propagates down toNested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields. :param unknown: Whether to exclude, include, or raise an error for unknown fields in the data. UseEXCLUDE
,INCLUDE
orRAISE
.Changed in version: 3.0.0
prefix
parameter removed.Changed in version: 2.0.0
__validators__
,__preprocessors__
, and__data_handlers__
are removed in favor ofmarshmallow.decorators.validates_schema
,marshmallow.decorators.pre_load
andmarshmallow.decorators.post_dump
.__accessor__
and__error_handler__
are deprecated. Implement thehandle_error
andget_attribute
methods instead.Expand source code
class FeaturesSchema(Schema): tenant_id = fields.String(required=True, validate=validate_uuid4) name = fields.String(required=True) app_id = fields.String(required=False, allow_none=True) description = fields.String(required=False, allow_none=True) access_levels = fields.List(fields.String, required=False, allow_none=True) monthly_quota = fields.Integer(required=False, allow_none=True) activated = fields.Boolean(required=False, allow_none=True) feature_id = fields.String(required=False, allow_none=True) feature_path = fields.String(required=False, allow_none=True)
Ancestors
- marshmallow.schema.Schema
- marshmallow.base.SchemaABC
Class variables
var access_levels
var activated
var app_id
var description
var feature_id
var feature_path
var monthly_quota
var name
var opts
var tenant_id