class SCHEMA_CLS(BaseSchema): organization_addr = BackendOrganizationAddrField(required=True) device_id = DeviceIDField(required=True) device_label = fields.String(allow_none=True, missing=None) human_handle = HumanHandleField(allow_none=True, missing=None) signing_key = fields.SigningKey(required=True) private_key = fields.PrivateKey(required=True) # `profile` replaces `is_admin` field (which is still required for backward # compatibility), hence `None` is not allowed is_admin = fields.Boolean(required=True) profile = UserProfileField(allow_none=False) user_manifest_id = EntryIDField(required=True) user_manifest_key = fields.SecretKey(required=True) local_symkey = fields.SecretKey(required=True) @post_load def make_obj(self, data): # Handle legacy `is_admin` field default_profile = UserProfile.ADMIN if data.pop( "is_admin") else UserProfile.STANDARD try: profile = data["profile"] except KeyError: data["profile"] = default_profile else: if default_profile == UserProfile.ADMIN and profile != UserProfile.ADMIN: raise ValidationError( "Fields `profile` and `is_admin` have incompatible values" ) return LocalDevice(**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(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): organization_addr = BackendOrganizationAddrField(required=True) device_id = DeviceIDField(required=True) signing_key = fields.SigningKey(required=True) private_key = fields.PrivateKey(required=True) is_admin = fields.Boolean(required=True) user_manifest_id = EntryIDField(required=True) user_manifest_key = fields.SecretKey(required=True) local_symkey = fields.SecretKey(required=True) human_handle = HumanHandleField(allow_none=True, missing=None) @post_load def make_obj(self, data): return LocalDevice(**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 PendingDeviceKeys(BaseSchema): type = fields.CheckedConstant("requested_device_keys", required=True) private_key = fields.PrivateKey(required=True) signing_key = fields.SigningKey(required=True)
class DeviceClaimAnswerSchema(UnknownCheckedSchema): type = fields.CheckedConstant("device_claim_answer", required=True) private_key = fields.PrivateKey(required=True) user_manifest_access = fields.Nested(ManifestAccessSchema, required=True)