Exemple #1
0
class UserSerializer(serpy.Serializer):
    authorizations = MethodField(schema_type=AuthorizationSerializer(), display_none=False)
    shape_scope = Field(schema_type=list, description='The scope shape on data to search')
    shape = Field(schema_type=str, display_none=False, description='GeoJSON of the shape of the user')
    type = Field(schema_type=str)
    billing_plan = MethodField(schema_type=BillingPlanSerializer(), display_none=False)
    end_point = MethodField(schema_type=EndPointSerializer(), display_none=False)
    coord = MethodField(display_none=False, description='Default coord of user')
    context = MethodField(schema_type=ContextSerializer(), display_none=False)
    block_until = DateTimeDbField(schema_type=DateTimeDictField, display_none=False)

    def get_end_point(self, obj):
        if obj.end_point:
            return EndPointSerializer(obj.end_point, display_none=False).data
        return None

    def get_billing_plan(self, obj):
        if obj.billing_plan:
            return BillingPlanSerializer(obj.billing_plan, display_none=False).data
        return None

    def get_context(self, obj):
        return ContextSerializer(obj, is_utc=True, display_none=False).data

    def get_authorizations(self, obj):
        if obj.authorizations:
            return [AuthorizationSerializer(auto, display_none=False).data for auto in obj.authorizations]
        return None

    def get_coord(self, obj):
        if obj.default_coord:
            default_coord = obj.default_coord.split(";")
            if len(default_coord) == 2:
                return {"lon": default_coord[0], "lat": default_coord[1]}
        return None
Exemple #2
0
class TechnicalStatusSerializer(NullableDictSerializer):
    regions = status.CommonStatusSerializer(many=True, display_none=False)
    jormungandr_version = Field(schema_type=str, display_none=True)
    bss_providers = status.BssProviderSerializer(many=True, display_none=False)
    context = MethodField(schema_type=ContextSerializer(), display_none=False)
    warnings = base.BetaEndpointsSerializer()
    redis = status.RedisStatusSerializer(display_none=False)
    configuration_database = Field(schema_type=str, display_none=False)

    def get_context(self, obj):
        return ContextSerializer(obj, is_utc=True, display_none=False).data
Exemple #3
0
class CoverageSerializer(NullableDictSerializer):
    id = Field(attr="region_id",
               schema_type=str,
               display_none=True,
               description='Identifier of the coverage')
    start_production_date = Field(
        schema_type=str,
        description='Beginning of the production period. '
        'We only have data on this production period',
    )
    end_production_date = Field(
        schema_type=str,
        description='End of the production period. '
        'We only have data on this production period',
    )
    last_load_at = LambdaField(
        method=lambda _, o: CoverageDateTimeField('last_load_at').to_value(o),
        description='Datetime of the last data loading',
        schema_type=str,
    )
    name = Field(schema_type=str,
                 display_none=True,
                 description='Name of the coverage')
    status = Field(schema_type=str)
    shape = Field(schema_type=str,
                  display_none=True,
                  description='GeoJSON of the shape of the coverage')
    error = CoverageErrorSerializer(display_none=False)
    dataset_created_at = Field(schema_type=str,
                               description='Creation date of the dataset')
Exemple #4
0
    class JsonchemaSupportedType(serpy.Serializer):
        jsonschemaStrField = StrField(required=False)
        jsonschemaBoolField = BoolField(required=True, display_none=True)
        jsonschemaFloatField = FloatField(required=True, display_none=True)
        jsonschemaIntField = IntField()
        jsonschemaField = Field(schema_type=int)
        jsonschemaMethodField = MethodField(schema_type=str)
        lambda_schema = LambdaField(method=lambda **kw: None, schema_type=Custom())
        list_lambda_schema = LambdaField(method=lambda **kw: None,
                                         schema_type=Custom(many=True))

        def get_jsonschemaMethodField(self, obj):
            pass
Exemple #5
0
class SwaggerParamSerializer(serpy.Serializer):
    description = Field()
    location = Field(label='in')
    name = StrField()
    required = Field()
    type = StrField()
    default = StrField()
    enum = Field()
    minimum = Field()
    maximum = Field()
    format = Field()
    collectionFormat = Field(attr='collection_format')
    items = LambdaField(
        method=lambda _, obj: SwaggerParamSerializer(obj.items).data if obj.items else None, display_none=False
    )
Exemple #6
0
class CalendarExceptionSerializer(PbNestedSerializer):
    datetime = Field(attr='date', schema_type=DateType)
    type = EnumField()
Exemple #7
0
class CalendarPeriodSerializer(PbNestedSerializer):
    begin = Field(schema_type=DateType)
    end = Field(schema_type=DateType)
Exemple #8
0
class ValidityPatternSerializer(PbNestedSerializer):
    beginning_date = Field(schema_type=DateType)
    days = Field(schema_type=str)
Exemple #9
0
class ExceptionSerializer(serpy.Serializer):
    type = jsonschema.Field(schema_type=str)
    id = jsonschema.Field(schema_type=str, display_none=True)
    date = Field(attr='date', schema_type=DateTimeType)
Exemple #10
0
class CoverageErrorSerializer(NullableDictSerializer):
    code = Field(schema_type=str)
    value = Field(schema_type=str)
Exemple #11
0
class EndPointSerializer(serpy.Serializer):
    name = Field(schema_type=str)
    default = Field(schema_type=bool)
Exemple #12
0
class BillingPlanSerializer(serpy.Serializer):
    name = Field(schema_type=str)
    max_request_count = Field(schema_type=int)
    max_object_count = Field(schema_type=int)
    default = Field(schema_type=bool)