Beispiel #1
0
class serviceOperationSchema(ModelSchema):
    service_name = fields.String()
    version = fields.String()
    service_operator_event = fields.Nested(OperationSchema, many=True)

    class Meta:
        model = serviceOperation
Beispiel #2
0
class OperationSchema(ModelSchema):
    operator_time = fields.DateTime()
    operator_user = fields.String()
    operator_type = fields.String()
    operator_object = fields.String()

    class Meta:
        model = Operation
class AuthSchema(SourceSchema):
    psk = fields.String(required=True)

    def handle_error(self, error, data):
        if 'psk' in error.field_names:
            error.status_code = 401
        raise error
class GetMeasurementsSchema(ModelSchema):
    latitude_upper_bound = fields.Float(required=True)
    latitude_lower_bound = fields.Float(required=True)
    longitude_lower_bound = fields.Float(required=True)
    longitude_upper_bound = fields.Float(required=True)
    min_location_age = fields.Integer(validate=validate.Range(min=0))
    max_location_age = fields.Integer(validate=validate.Range(min=0))
    min_location_accuracy = fields.Float(validate=validate.Range(min=0))
    max_location_accuracy = fields.Float(validate=validate.Range(min=0))
    measurement_fields = fields.String()

    @validates_schema
    def validate_coordinates(self, data):
        if data['latitude_upper_bound'] < data['latitude_lower_bound']:
            raise ValidationError(
                "latitude_upper_bound must be greater than latitude_lower_bound."
            )
        if data['longitude_lower_bound'] > data['longitude_upper_bound']:
            raise ValidationError(
                "longitude_lower_bound must be smaller than longitude_upper_bound."
            )

        if ('min_location_age' in data and 'max_location_age' in data
                and data['min_location_age'] > data['max_location_age']):
            raise ValidationError(
                "min_location_age must be smaller than max_location_age.")

        if ('min_location_accuracy' in data and 'max_location_accuracy' in data
                and
                data['min_location_accuracy'] > data['max_location_accuracy']):
            raise ValidationError(
                "min_location_accuracy must be smaller than max_location_accuracy."
            )
Beispiel #5
0
 class DocSchemaRefAsString(Schema):
     id = fields.String()
     ref = fields.Reference('ReferenceDoc')
class GetMeasurementSchema(ModelSchema):
    measurement_fields = fields.String()