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: 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]) -> "FileManifest": data.pop("type") return FileManifest(**data)
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)
class SCHEMA_CLS(BaseSignedDataSchema): type = fields.CheckedConstant("sharing.revoked", required=True) id = EntryIDField(required=True) @post_load def make_obj(self, data): data.pop("type") return SharingRevokedMessageContent(**data)
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)
class SCHEMA_CLS(BaseSignedDataSchema): type = fields.CheckedConstant("file_manifest", required=True) id = EntryIDField(required=True) parent = 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) 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) @post_load def make_obj(self, data): data.pop("type") return FileManifest(**data)
class SCHEMA_CLS(BaseSchema): type = fields.CheckedConstant("device_claim_answer", required=True) private_key = fields.PrivateKey(required=True) user_manifest_id = EntryIDField(required=True) user_manifest_key = fields.SecretKey(required=True) @post_load def make_obj(self, data): data.pop("type") return DeviceClaimAnswerContent(**data)
class SCHEMA_CLS(BaseSignedDataSchema): type = fields.EnumCheckedConstant(MessageContentType.SHARING_REVOKED, required=True) id = EntryIDField(required=True) @post_load def make_obj( # type: ignore[misc] self, data: Dict[str, Any]) -> "SharingRevokedMessageContent": data.pop("type") return SharingRevokedMessageContent(**data)
class SCHEMA_CLS(BaseSchema): type = fields.CheckedConstant("device_claim_answer", required=True) private_key = fields.PrivateKey(required=True) user_manifest_id = EntryIDField(required=True) user_manifest_key = fields.SecretKey(required=True) @post_load def make_obj( # type: ignore[misc] self, data: Dict[str, Any] ) -> "APIV1_DeviceClaimAnswerContent": data.pop("type") return APIV1_DeviceClaimAnswerContent(**data)
class SCHEMA_CLS(BaseSchema): name = EntryNameField(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)
class SCHEMA_CLS(BaseSchema): type = fields.CheckedConstant("invite_device_confirmation", required=True) device_id = DeviceIDField(required=True) device_label = fields.String(allow_none=True, missing=None) human_handle = HumanHandleField(allow_none=True, missing=None) profile = UserProfileField(required=True) private_key = fields.PrivateKey(required=True) user_manifest_id = EntryIDField(required=True) user_manifest_key = fields.SecretKey(required=True) root_verify_key = fields.VerifyKey(required=True) @post_load def make_obj(self, data): data.pop("type") return InviteDeviceConfirmation(**data)
class SCHEMA_CLS(BaseSignedDataSchema): type = fields.CheckedConstant("sharing.granted", required=True) name = fields.String(required=True) id = EntryIDField(required=True) encryption_revision = fields.Integer(required=True) encrypted_on = fields.DateTime(required=True) key = fields.SecretKey(required=True) # Don't include role given the only reliable way to get this information # is to fetch the realm role certificate from the backend. # Besides, we will also need the message sender's realm role certificate # to make sure he is an owner. @post_load def make_obj(self, data): data.pop("type") return SharingGrantedMessageContent(**data)
class SCHEMA_CLS(BaseSignedDataSchema): type = fields.CheckedConstant("user_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) last_processed_message = fields.Integer(required=True, validate=validate.Range(min=0)) workspaces = fields.List(fields.Nested(WorkspaceEntry.SCHEMA_CLS), required=True) @post_load def make_obj(self, data): data.pop("type") return UserManifest(**data)
class SCHEMA_CLS(OneOfSchema, BaseSignedDataSchema): type_field = "type" version = fields.Integer(required=True, validate=validate.Range(min=0)) id = EntryIDField(required=True) @property def type_schemas( self ) -> Dict[ManifestType, Type[OneOfSchema]]: # type: ignore[override] return { ManifestType.FILE_MANIFEST: FileManifest.SCHEMA_CLS, ManifestType.FOLDER_MANIFEST: FolderManifest.SCHEMA_CLS, ManifestType.WORKSPACE_MANIFEST: WorkspaceManifest.SCHEMA_CLS, ManifestType.USER_MANIFEST: UserManifest.SCHEMA_CLS, } def get_obj_type(self, obj: Dict[str, T]) -> T: return obj["type"]
class SCHEMA_CLS(BaseSignedDataSchema): type = fields.EnumCheckedConstant(MessageContentType.SHARING_GRANTED, required=True) name = EntryNameField(required=True) id = EntryIDField(required=True) encryption_revision = fields.Integer(required=True) encrypted_on = fields.DateTime(required=True) key = fields.SecretKey(required=True) # Don't include role given the only reliable way to get this information # is to fetch the realm role certificate from the backend. # Besides, we will also need the message sender's realm role certificate # to make sure he is an owner. @post_load def make_obj( # type: ignore[misc] self, data: Dict[str, Any]) -> "SharingGrantedMessageContent": data.pop("type") return SharingGrantedMessageContent(**data)
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: 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]) -> "UserManifest": data.pop("type") return UserManifest(**data)