Beispiel #1
0
    class SCHEMA_CLS(BaseSignedDataSchema):
        type = fields.EnumCheckedConstant(ManifestType.FILE_MANIFEST,
                                          required=True)
        id = EntryIDField(required=True)
        parent = 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)
        size = fields.Integer(required=True, validate=validate.Range(min=0))
        blocksize = fields.Integer(required=True,
                                   validate=validate.Range(min=8))
        blocks = fields.FrozenList(fields.Nested(BlockAccess.SCHEMA_CLS),
                                   required=True)

        @pre_load
        def fix_legacy(self, data):
            # 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):
            data.pop("type")
            return FileManifest(**data)
Beispiel #2
0
    class SCHEMA_CLS(BaseSchema):
        type = fields.EnumCheckedConstant(
            LocalManifestType.LOCAL_USER_MANIFEST, required=True)
        base = fields.Nested(RemoteUserManifest.SCHEMA_CLS, required=True)
        need_sync = fields.Boolean(required=True)
        updated = fields.DateTime(required=True)
        last_processed_message = fields.Integer(required=True,
                                                validate=validate.Range(min=0))
        workspaces = fields.FrozenList(fields.Nested(
            WorkspaceEntry.SCHEMA_CLS),
                                       required=True)

        @post_load
        def make_obj(self, data):
            data.pop("type")
            return LocalUserManifest(**data)
Beispiel #3
0
    class SCHEMA_CLS(BaseSchema):
        type = fields.EnumCheckedConstant(
            LocalManifestType.LOCAL_FILE_MANIFEST, required=True)
        base = fields.Nested(RemoteFileManifest.SCHEMA_CLS, required=True)
        need_sync = fields.Boolean(required=True)
        updated = fields.DateTime(required=True)
        size = fields.Integer(required=True, validate=validate.Range(min=0))
        blocksize = fields.Integer(required=True,
                                   validate=validate.Range(min=8))
        blocks = fields.FrozenList(fields.FrozenList(
            fields.Nested(Chunk.SCHEMA_CLS)),
                                   required=True)

        @post_load
        def make_obj(self, data):
            data.pop("type")
            return LocalFileManifest(**data)
Beispiel #4
0
    class SCHEMA_CLS(BaseSchema):
        id = ChunkIDField(required=True)
        start = fields.Integer(required=True, validate=validate.Range(min=0))
        stop = fields.Integer(required=True, validate=validate.Range(min=1))
        raw_offset = fields.Integer(required=True,
                                    validate=validate.Range(min=0))
        raw_size = fields.Integer(required=True,
                                  validate=validate.Range(min=1))
        access = fields.Nested(BlockAccess.SCHEMA_CLS,
                               required=True,
                               allow_none=True)

        @post_load
        def make_obj(self, data):
            return Chunk(**data)
Beispiel #5
0
    class SCHEMA_CLS(BaseSchema):
        type = fields.EnumCheckedConstant(
            LocalManifestType.LOCAL_FOLDER_MANIFEST, required=True)
        base = fields.Nested(RemoteFolderManifest.SCHEMA_CLS, required=True)
        need_sync = fields.Boolean(required=True)
        updated = fields.DateTime(required=True)
        children = fields.FrozenMap(EntryNameField(),
                                    EntryIDField(required=True),
                                    required=True)
        confined_entries = fields.FrozenSet(EntryIDField(required=True))
        filtered_entries = fields.FrozenSet(EntryIDField(required=True))

        @post_load
        def make_obj(self, data):
            data.pop("type")
            data.setdefault("confined_entries", frozenset())
            data.setdefault("filtered_entries", frozenset())
            return LocalFolderManifest(**data)
Beispiel #6
0
    class SCHEMA_CLS(OneOfSchema, BaseSchema):
        type_field = "type"
        base = fields.Nested(BaseRemoteManifest.SCHEMA_CLS, required=True)
        need_sync = fields.Boolean(required=True)
        updated = fields.DateTime(required=True)

        @property
        def type_schemas(self):
            return {
                LocalManifestType.LOCAL_FILE_MANIFEST:
                LocalFileManifest.SCHEMA_CLS,
                LocalManifestType.LOCAL_FOLDER_MANIFEST:
                LocalFolderManifest.SCHEMA_CLS,
                LocalManifestType.LOCAL_WORKSPACE_MANIFEST:
                LocalWorkspaceManifest.SCHEMA_CLS,
                LocalManifestType.LOCAL_USER_MANIFEST:
                LocalUserManifest.SCHEMA_CLS,
            }

        def get_obj_type(self, obj):
            return obj["type"]
Beispiel #7
0
    class SCHEMA_CLS(BaseSignedDataSchema):
        type = fields.EnumCheckedConstant(ManifestType.USER_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)
        last_processed_message = fields.Integer(required=True,
                                                validate=validate.Range(min=0))
        workspaces = fields.List(fields.Nested(WorkspaceEntry.SCHEMA_CLS),
                                 required=True)

        @pre_load
        def fix_legacy(self, data):
            # 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):
            data.pop("type")
            return UserManifest(**data)
Beispiel #8
0
class VlobMaintenanceSaveReencryptionBatchReqSchema(BaseReqSchema):
    realm_id = fields.UUID(required=True)
    encryption_revision = fields.Integer(required=True)
    batch = fields.List(fields.Nested(ReencryptionBatchEntrySchema), required=True)
Beispiel #9
0
class VlobMaintenanceGetReencryptionBatchRepSchema(BaseRepSchema):
    batch = fields.List(fields.Nested(ReencryptionBatchEntrySchema), required=True)
Beispiel #10
0
class APIV1_UserGetInvitationCreatorRepSchema(BaseRepSchema):
    device_certificate = fields.Bytes(required=True)
    user_certificate = fields.Bytes(required=True)
    trustchain = fields.Nested(TrustchainSchema, required=True)
Beispiel #11
0
class UserGetRepSchema(BaseRepSchema):
    user_certificate = fields.Bytes(required=True)
    revoked_user_certificate = fields.Bytes(required=True, allow_none=True)
    device_certificates = fields.List(fields.Bytes(required=True), required=True)

    trustchain = fields.Nested(TrustchainSchema, required=True)
Beispiel #12
0
class HumanFindRepSchema(BaseRepSchema):
    results = fields.List(fields.Nested(HumanFindResultItemSchema, required=True))
    page = fields.Int(validate=lambda n: n > 0)
    per_page = fields.Integer(validate=lambda n: 0 < n <= 100)
    total = fields.Int(validate=lambda n: n >= 0)
Beispiel #13
0
class MessageGetRepSchema(BaseRepSchema):
    messages = fields.List(fields.Nested(MessageSchema), required=True)
Beispiel #14
0
class InviteListRepSchema(BaseRepSchema):
    invitations = fields.List(fields.Nested(InviteListItemSchema),
                              required=True)