Esempio n. 1
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)
Esempio n. 2
0
class OrganizationStatsRepSchema(BaseSchema):
    data_size = fields.Integer(required=True)
    metadata_size = fields.Integer(required=True)
    realms = fields.Integer(required=True)
    users = fields.Integer(required=True)
    active_users = fields.Integer(required=True)
    users_per_profile_detail = fields.List(
        fields.Nested(UsersPerProfileDetailItemSchema), required=True)
Esempio n. 3
0
class ApiReleaseSchema(BaseSchema):
    draft = fields.Boolean(missing=False)
    prerelease = fields.Boolean(missing=False)
    tag_name = fields.String(required=True)
    assets = fields.List(fields.Nested(ApiReleaseAssetSchema), missing=[])

    @post_load
    def add_version_field(self, data):
        try:
            data["version"] = Version(data["tag_name"])
        except ValueError:
            data["version"] = None
        return data
Esempio n. 4
0
    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)
Esempio n. 5
0
class HandshakeChallengeSchema(BaseSchema):
    handshake = fields.CheckedConstant("challenge", required=True)
    challenge = fields.Bytes(required=True)
    supported_api_versions = fields.List(ApiVersionField(), required=True)
    # Those fields have been added to API version 2.4 (Parsec 2.7.0)
    # They are provided to the client in order to allow them to detect whether
    # their system clock is out of sync and let them close the connection.
    # They will be missing for older backend so they cannot be strictly required.
    # TODO: This backward compatibility should be removed once Parsec < 2.4 support is dropped
    ballpark_client_early_offset = fields.Float(required=False, allow_none=False)
    ballpark_client_late_offset = fields.Float(required=False, allow_none=False)
    backend_timestamp = fields.DateTime(required=False, allow_none=False)

    @post_load
    def make_obj(self, data: Dict[str, Any]) -> Dict[str, Any]:  # type: ignore[misc]
        # Cannot use `missing=None` with `allow_none=False`
        data.setdefault("ballpark_client_early_offset", None)
        data.setdefault("ballpark_client_late_offset", None)
        data.setdefault("backend_timestamp", None)
        return data
Esempio n. 6
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: 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)
Esempio n. 7
0
class APIV1_UserFindRepSchema(BaseRepSchema):
    results = fields.List(UserIDField())
    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)
Esempio n. 8
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)
Esempio n. 9
0
class TrustchainSchema(BaseSchema):
    devices = fields.List(fields.Bytes(required=True))
    users = fields.List(fields.Bytes(required=True))
    revoked_users = fields.List(fields.Bytes(required=True))
Esempio n. 10
0
class VlobGroupCheckRepSchema(BaseRepSchema):
    changed = fields.List(fields.Nested(ChangedEntrySchema), required=True)
Esempio n. 11
0
class MessageGetRepSchema(BaseRepSchema):
    messages = fields.List(fields.Nested(MessageSchema), required=True)
Esempio n. 12
0
class InviteListRepSchema(BaseRepSchema):
    invitations = fields.List(fields.Nested(InviteListItemSchema),
                              required=True)
Esempio n. 13
0
class VlobMaintenanceSaveReencryptionBatchReqSchema(BaseReqSchema):
    realm_id = fields.UUID(required=True)
    encryption_revision = fields.Integer(required=True)
    batch = fields.List(fields.Nested(ReencryptionBatchEntrySchema), required=True)
Esempio n. 14
0
class VlobMaintenanceGetReencryptionBatchRepSchema(BaseRepSchema):
    batch = fields.List(fields.Nested(ReencryptionBatchEntrySchema), required=True)
Esempio n. 15
0
class RealmGetRoleCertificatesRepSchema(BaseRepSchema):
    certificates = fields.List(fields.Bytes(required=True), required=True)
Esempio n. 16
0
class BeaconReadRepSchema(BaseRepSchema):
    items = fields.List(fields.Nested(BeaconItemSchema), required=True)
Esempio n. 17
0
class FindUserRepSchema(BaseRepSchema):
    results = fields.List(fields.UserID())
    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)
Esempio n. 18
0
class PkiEnrollmentListRepSchema(BaseRepSchema):
    enrollments = fields.List(fields.Nested(PkiEnrollmentListItemSchema),
                              required=True)
Esempio n. 19
0
class HandshakeChallengeSchema(BaseSchema):
    handshake = fields.CheckedConstant("challenge", required=True)
    challenge = fields.Bytes(required=True)
    supported_api_versions = fields.List(ApiVersionField(), required=True)
Esempio n. 20
0
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)
Esempio n. 21
0
class ApiReleasesSchema(BaseSchema):
    releases = fields.List(fields.Nested(ApiReleaseSchema), missing=[])
Esempio n. 22
0
class VlobGroupCheckReqSchema(BaseReqSchema):
    to_check = fields.List(fields.Nested(CheckEntrySchema), required=True)