示例#1
0
class HumanFindReqSchema(BaseReqSchema):
    query = fields.String(required=True, allow_none=True)
    omit_revoked = fields.Boolean(required=True)
    omit_non_human = fields.Boolean(required=True)
    # First page is 1
    page = fields.Int(required=True, validate=lambda n: n > 0)
    per_page = fields.Integer(required=True, validate=lambda n: 0 < n <= 100)
示例#2
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
示例#3
0
    class SCHEMA_CLS(BaseSchema):
        type = fields.EnumCheckedConstant(
            LocalManifestType.LOCAL_WORKSPACE_MANIFEST, required=True)
        base = fields.Nested(_PyWorkspaceManifest.SCHEMA_CLS, required=True)
        need_sync = fields.Boolean(required=True)
        updated = fields.DateTime(required=True)
        children = fields.FrozenMap(EntryNameField(),
                                    EntryIDField(),
                                    required=True)
        # Added in Parsec v1.15
        # Confined entries are entries that are meant to stay locally and not be added
        # to the uploaded remote manifest when synchronizing. The criteria for being
        # confined is to have a filename that matched the "prevent sync" pattern at the time of
        # the last change (or when a new filter was successfully applied)
        local_confinement_points = fields.FrozenSet(EntryIDField(),
                                                    allow_none=False,
                                                    required=False,
                                                    missing=frozenset())
        # Added in Parsec v1.15
        # Filtered entries are entries present in the base manifest that are not exposed
        # locally. We keep track of them to remember that those entries have not been
        # deleted locally and hence should be restored when crafting the remote manifest
        # to upload.
        remote_confinement_points = fields.FrozenSet(EntryIDField(),
                                                     allow_none=False,
                                                     required=False,
                                                     missing=frozenset())
        # Added in Parsec v1.15
        # Speculative placeholders are created when we want to access a workspace
        # but didn't retrieve manifest data from backend yet. This implies:
        # - non-placeholders cannot be speculative
        # - the only non-speculative placeholder is the placeholder initialized
        #   during the initial workspace creation
        # This speculative information is useful during merge to understand if
        # a data is not present in the placeholder compared with a remote because:
        # a) the data is not locally known (speculative is True)
        # b) the data is known, but has been locally removed (speculative is False)
        # Prevented to be `required=True` by backward compatibility
        speculative = fields.Boolean(allow_none=False,
                                     required=False,
                                     missing=False)

        @post_load
        def make_obj(self, data):
            # TODO: Ensure non-placeholder cannot be marked speculative
            assert data["speculative"] is False or data["base"].version == 0
            # TODO: Should this assert be in remote workspace manifest definition instead ?
            # TODO: but in theory remote workspace manifest should assert version > 0 !
            assert data["base"].version != 0 or not data["base"].children
            data.pop("type")
            return LocalWorkspaceManifest(**data)
示例#4
0
class UserSchema(UnknownCheckedSchema):
    user_id = fields.String(required=True)
    is_admin = fields.Boolean(required=True)
    created_on = fields.DateTime(required=True)

    certified_user = fields.Bytes(required=True)
    user_certifier = fields.DeviceID(allow_none=True)

    devices = fields.Map(fields.DeviceName(),
                         fields.Nested(DeviceSchema),
                         required=True)
示例#5
0
    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)
示例#6
0
    class SCHEMA_CLS(BaseSchema):
        type = fields.EnumCheckedConstant(
            LocalManifestType.LOCAL_USER_MANIFEST, required=True)
        base = fields.Nested(_PyUserManifest.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(
            _PyWorkspaceEntry.SCHEMA_CLS),
                                       required=True)
        # Added in Parsec v1.15
        # Speculative placeholders are created when we want to access the
        # user manifest but didn't retrieve it from backend yet. This implies:
        # - non-placeholders cannot be speculative
        # - the only non-speculative placeholder is the placeholder initialized
        #   during the initial user claim (by opposition of subsequent device
        #   claims on the same user)
        # This speculative information is useful during merge to understand if
        # a data is not present in the placeholder compared with a remote because:
        # a) the data is not locally known (speculative is True)
        # b) the data is known, but has been locally removed (speculative is False)
        # Prevented to be `required=True` by backward compatibility
        speculative = fields.Boolean(allow_none=False,
                                     required=False,
                                     missing=False)

        @post_load
        def make_obj(self, data):
            data.pop("type")
            # TODO: Ensure non-placeholder cannot be marked speculative
            assert data["speculative"] is False or data["base"].version == 0
            # TODO: Should this assert be in remote workspace manifest definition instead ?
            # TODO: but in theory remote workspace manifest should assert version > 0 !
            assert data["base"].version != 0 or not data["base"].workspaces
            return LocalUserManifest(**data)
示例#7
0
class InviteNewDeviceReqSchema(BaseReqSchema):
    type = fields.EnumCheckedConstant(InvitationType.DEVICE, required=True)
    send_email = fields.Boolean(required=True)
示例#8
0
class InviteNewUserReqSchema(BaseReqSchema):
    type = fields.EnumCheckedConstant(InvitationType.USER, required=True)
    claimer_email = fields.String(required=True)
    send_email = fields.Boolean(required=True)
示例#9
0
class RealmStatusRepSchema(BaseRepSchema):
    in_maintenance = fields.Boolean(required=True)
    maintenance_type = MaintenanceTypeField(allow_none=True)
    maintenance_started_on = fields.DateTime(required=True, allow_none=True)
    maintenance_started_by = DeviceIDField(required=True, allow_none=True)
    encryption_revision = fields.Integer(required=True)
示例#10
0
class UserCreateReqSchema(BaseReqSchema):
    certified_user = fields.Bytes(required=True)
    certified_device = fields.Bytes(required=True)
    is_admin = fields.Boolean(missing=False)