コード例 #1
0
ファイル: manifest.py プロジェクト: shalevy1/parsec-cloud
    class SCHEMA_CLS(BaseSignedDataSchema):
        type = fields.EnumCheckedConstant(ManifestType.WORKSPACE_MANIFEST,
                                          required=True)
        id = EntryIDField(required=True)
        # Version 0 means the data is not synchronized
        version = fields.Integer(required=True, validate=validate.Range(min=0))
        created = fields.DateTime(required=True)
        updated = fields.DateTime(required=True)
        children = fields.FrozenMap(
            EntryNameField(validate=validate.Length(min=1, max=256)),
            EntryIDField(required=True),
            required=True,
        )

        @pre_load
        def fix_legacy(self, data: Dict[str, T]) -> Dict[str, T]:
            # Compatibility with versions <= 1.14
            if data["author"] is None:
                data["author"] = LOCAL_AUTHOR_LEGACY_PLACEHOLDER
            return data

        @post_load
        def make_obj(self, data: Dict[str, Any]) -> "WorkspaceManifest":
            data.pop("type")
            return WorkspaceManifest(**data)
コード例 #2
0
ファイル: manifest.py プロジェクト: shalevy1/parsec-cloud
    class SCHEMA_CLS(BaseSchema):
        name = EntryNameField(validate=validate.Length(min=1, max=256),
                              required=True)
        id = EntryIDField(required=True)
        key = fields.SecretKey(required=True)
        encryption_revision = fields.Int(required=True,
                                         validate=validate.Range(min=0))
        encrypted_on = fields.DateTime(required=True)
        role_cached_on = fields.DateTime(required=True)
        role = RealmRoleField(required=True, allow_none=True)

        @post_load
        def make_obj(self, data: Dict[str, Any]) -> "WorkspaceEntry":
            return WorkspaceEntry(**data)
コード例 #3
0
    class SCHEMA_CLS(BaseSignedDataSchema):
        type = fields.CheckedConstant("workspace_manifest", required=True)
        id = EntryIDField(required=True)
        # Version 0 means the data is not synchronized (hence author sould be None)
        version = fields.Integer(required=True, validate=validate.Range(min=0))
        created = fields.DateTime(required=True)
        updated = fields.DateTime(required=True)
        children = fields.FrozenMap(
            EntryNameField(validate=validate.Length(min=1, max=256)),
            EntryIDField(required=True),
            required=True,
        )

        @post_load
        def make_obj(self, data):
            data.pop("type")
            return WorkspaceManifest(**data)
コード例 #4
0
ファイル: events.py プロジェクト: stjordanis/parsec-cloud
class EventsPingedRepSchema(BaseRepSchema):
    event = fields.EnumCheckedConstant(APIEvent.PINGED, required=True)
    ping = fields.String(validate=validate.Length(max=64), required=True)
コード例 #5
0
class EventsPingedRepSchema(BaseRepSchema):
    status = fields.CheckedConstant("ok", required=True)
    event = fields.CheckedConstant("pinged", required=True)
    ping = fields.String(validate=validate.Length(max=64), required=True)
コード例 #6
0
from parsec.serde import UnknownCheckedSchema, fields, validate
from parsec.api.protocole.base import BaseReqSchema, BaseRepSchema, CmdSerializer

__all__ = (
    "vlob_group_check_serializer",
    "vlob_create_serializer",
    "vlob_read_serializer",
    "vlob_update_serializer",
)

_validate_trust_seed = validate.Length(max=32)
_validate_version = validate.Range(min=1)


class CheckEntrySchema(UnknownCheckedSchema):
    id = fields.UUID(required=True)
    rts = fields.String(required=True, validate=_validate_trust_seed)
    version = fields.Integer(required=True, validate=validate.Range(min=0))


class ChangedEntrySchema(UnknownCheckedSchema):
    id = fields.UUID(required=True)
    version = fields.Integer(required=True)


class VlobGroupCheckReqSchema(BaseReqSchema):
    to_check = fields.List(fields.Nested(CheckEntrySchema), required=True)


class VlobGroupCheckRepSchema(BaseRepSchema):
    changed = fields.List(fields.Nested(ChangedEntrySchema), required=True)
コード例 #7
0
ファイル: events.py プロジェクト: touilleWoman/parsec-cloud
class EventsSubscribeReqSchema(BaseReqSchema):
    pinged = fields.List(fields.String(validate=validate.Length(max=64)),
                         missing=None)
    beacon_updated = fields.List(fields.UUID(), missing=None)
    message_received = fields.Boolean(missing=None)