Beispiel #1
0
class TableBlockSchema(WorksheetBlockSchema):
    mode = fields.Constant(BlockModes.table_block)
    bundles_spec = fields.Nested(BundlesSpecSchema, required=True)
    status = fields.Nested(FetchStatusSchema, required=True)

    header = fields.List(fields.String(), required=True)
    rows = fields.List(fields.Dict(), required=True)
Beispiel #2
0
class RecordsBlockSchema(BundleBlockSchema):
    mode = fields.Constant(BlockModes.record_block)
    bundles_spec = fields.Nested(BundlesSpecSchema, required=True)
    status = fields.Nested(FetchStatusSchema, required=True)

    header = fields.Constant(('key', 'value'))
    rows = fields.Nested(RecordsRowSchema, many=True, required=True)
Beispiel #3
0
class GraphBlockSchema(BundleBlockSchema):
    mode = fields.Constant(BlockModes.graph_block)
    bundles_spec = fields.Nested(BundlesSpecSchema, required=True)
    status = fields.Nested(FetchStatusSchema, required=True)

    trajectories = fields.Nested(GraphTrajectorySchema, many=True, required=True)
    max_lines = fields.Integer()
    xlabel = fields.String()
    ylabel = fields.String()
Beispiel #4
0
class BundleBlockSchema(WorksheetBlockSchema):
    """
    Parent schema for blocks that load data from a single bundle.
    Stores state relevant to fetching information from bundle.
    """

    bundles_spec = fields.Nested(BundlesSpecSchema, required=True)
    target_genpath = fields.String(required=True)
    status = fields.Nested(FetchStatusSchema, required=True)
Beispiel #5
0
class TableBlockSchema(WorksheetBlockSchema):
    mode = fields.Constant(BlockModes.table_block)
    bundles_spec = fields.Nested(BundlesSpecSchema, required=True)
    status = fields.Nested(FetchStatusSchema, required=True)

    header = fields.List(fields.String(), required=True)
    rows = fields.List(fields.Dict(), required=True)
    sort_keys = fields.List(fields.Integer())
    first_bundle_source_index = fields.Integer(
    )  # index for the first bundle in source
    using_schemas = fields.List(fields.String())
Beispiel #6
0
class RecordsBlockSchema(BundleBlockSchema):
    mode = fields.Constant(BlockModes.record_block)
    bundles_spec = fields.Nested(BundlesSpecSchema, required=True)
    status = fields.Nested(FetchStatusSchema, required=True)

    header = fields.Constant(('key', 'value'))
    rows = fields.Nested(RecordsRowSchema, many=True, required=True)
    sort_keys = fields.List(fields.Integer())
    first_bundle_source_index = fields.Integer(
    )  # index for the first bundle in source
    using_schemas = fields.List(fields.String())
class BookSerializer(Schema):
    id = fields.String()
    title = fields.String()
    description = fields.String()
    published_date = fields.String()
    isbn = fields.String()
    image_url = fields.String()
    authors = fields.Nested(AuthorSerializer(), many=True)
    genres = fields.Nested(GenreSerializer(), many=True)

    class Meta:
        type_ = 'book'
Beispiel #8
0
class AuthSchema(Schema):
    id = fields.String(dump_only=True)
    identity = fields.Nested(IdentitySchema)

    class Meta:
        type_ = 'auth'
        strict = True
Beispiel #9
0
class PasswordAuthSchema(Schema):
    id = fields.String(dump_only=True)
    user = fields.Nested(UserAuthSchema)

    class Meta:
        type_ = 'password'
        strict = True
Beispiel #10
0
class BundleSchema(Schema):
    id = fields.String(validate=validate_uuid, attribute='uuid')
    uuid = fields.String(attribute='uuid')  # for backwards compatibility
    bundle_type = fields.String(
        validate=validate.OneOf({bsc.BUNDLE_TYPE
                                 for bsc in BUNDLE_SUBCLASSES}))
    command = fields.String(allow_none=True)
    data_hash = fields.String()
    state = fields.String()
    owner = fields.Relationship(include_resource_linkage=True,
                                type_='users',
                                attribute='owner_id')
    is_anonymous = fields.Bool()
    metadata = fields.Dict()
    dependencies = fields.Nested(BundleDependencySchema, many=True)
    children = fields.Relationship(include_resource_linkage=True,
                                   type_='bundles',
                                   id_field='uuid',
                                   many=True)
    group_permissions = fields.Relationship(include_resource_linkage=True,
                                            type_='bundle-permissions',
                                            id_field='id',
                                            many=True)
    host_worksheets = fields.Relationship(include_resource_linkage=True,
                                          type_='worksheets',
                                          id_field='uuid',
                                          many=True)
    args = fields.String()

    # Bundle permission of the authenticated user for convenience, read-only
    permission = fields.Integer()
    permission_spec = PermissionSpec(attribute='permission')

    class Meta:
        type_ = 'bundles'
Beispiel #11
0
class NotificationSchema(Schema):
    """
    API Schema for Notification Model
    """

    class Meta:
        """
        Meta class for Notification API schema
        """

        type_ = 'notification'
        self_view = 'v1.notification_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)
    created_at = fields.DateTime(dump_only=True)
    is_read = fields.Boolean()
    content = fields.Nested(NotificationContentSchema)
    user = Relationship(
        self_view='v1.notification_user',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.user_detail',
        related_view_kwargs={'notification_id': '<id>'},
        schema='UserSchema',
        type_='user',
    )
Beispiel #12
0
class TrendInputSchema(BaseSchema):
    """
    Schema for the request for trend data (not the response)
    """
    fields = JsonString(invert=True)
    filter = FilterReference()
    outliers = f.Nested(OutlierSchema, missing=outlier.OutlierDetector)
Beispiel #13
0
class RouteInputSchema(JSONAPISchema):
    id = fields.UUID()
    origin = fields.Nested(GeoJSONSchema, required=True)
    origin_name = fields.String(required=True)
    destination = fields.Nested(GeoJSONSchema, required=True)
    destination_name = fields.String(required=True)
    waypoints = fields.List(fields.Float)
    waypoints_names = fields.List(fields.String)
    polyline = fields.Nested(GeoJSONSchema, required=True)
    bounds = fields.Dict()
    created = fields.DateTime(allow_none=True)

    class Meta:
        type_ = 'routes'
        strict = True
        inflect = dasherize
Beispiel #14
0
class MoviesSchema(Schema):
    id = fields.Integer(dump_only=True)
    title = fields.String()
    year = fields.Integer()
    rated = fields.String()
    released = fields.String()
    runtime = fields.String()
    genre = fields.String()
    director = fields.String()
    writer = fields.String()
    casts = fields.String()
    plot = fields.String()
    language = fields.String()
    country = fields.String()
    awards = fields.String()
    poster = fields.String()
    rating = fields.Float()
    votes = fields.String()
    imdbid = fields.String()
    kind = fields.String()
    boxoffice = fields.String()
    production = fields.String()
    website = fields.String()

    actors = fields.Nested(ActorsSchema, many=True, only=('id', 'name'))

    class Meta:
        type_ = 'movie'
        ordered = True
Beispiel #15
0
    class PersonSchema(Schema):
        class Meta:
            type_ = 'person'
            self_view = 'api.person_detail'
            self_view_kwargs = {'person_id': '<id>'}

        id = fields.Integer(as_string=True, attribute='person_id')
        name = fields.Str(required=True)
        birth_date = fields.DateTime()
        computers = Relationship(related_view='api.computer_list',
                                 related_view_kwargs={'person_id': '<person_id>'},
                                 schema='ComputerSchema',
                                 type_='computer',
                                 many=True)

        tags = fields.Nested(person_tag_schema, many=True)
        single_tag = fields.Nested(person_single_tag_schema)
Beispiel #16
0
class IdentitySchema(Schema):
    id = fields.String(dump_only=True)
    methods = fields.List(fields.String())
    password = fields.Nested(PasswordAuthSchema)

    class Meta:
        type_ = 'identity'
        strict = True
Beispiel #17
0
class VideoStreamSchema(Schema):
    class Meta:
        type_ = 'video-stream'
        self_view = 'v1.video_stream_detail'
        self_view_kwargs = {'id': '<id>'}
        inflect = dasherize

    id = fields.Str(dump_only=True)
    name = fields.Str(required=True)
    url = fields.Url(required=True)
    password = fields.Str(required=False, allow_none=True)
    bg_img_url = fields.Str(required=False, allow_none=True)
    additional_information = fields.Str(required=False, allow_none=True)
    extra = fields.Nested(VideoStreamExtraSchema, allow_none=True)
    rooms = Relationship(
        many=True,
        self_view='v1.video_stream_rooms',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.microlocation_list',
        related_view_kwargs={'video_stream_id': '<id>'},
        schema='MicrolocationSchema',
        type_='microlocation',
    )
    event = Relationship(
        self_view='v1.video_stream_event',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.event_detail',
        related_view_kwargs={'video_stream_id': '<id>'},
        schema='EventSchemaPublic',
        type_='event',
    )
    video_channel = Relationship(
        attribute='channel',
        self_view='v1.video_stream_channel',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.video_channel_detail',
        related_view_kwargs={'video_stream_id': '<id>'},
        schema='VideoChannelSchemaPublic',
        type_='video-channel',
    )
    video_recordings = Relationship(
        many=True,
        self_view='v1.video_stream_recordings',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.video_recording_list',
        related_view_kwargs={'video_stream_id': '<id>'},
        schema='VideoRecordingSchema',
        type_='video-recording',
    )
    moderators = Relationship(
        many=True,
        self_view='v1.video_stream_moderators',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.video_stream_moderator_list',
        related_view_kwargs={'video_stream_id': '<id>'},
        schema='VideoStreamModeratorSchema',
        type_='video-stream-moderator',
    )
Beispiel #18
0
class BaseObject(Schema):
    class Meta:
        type_ = "object"

    id = fields.Integer()
    created_at = fields.DateTime()
    owner = fields.Nested(BaseUser)
    belongs_to_id = fields.Integer()  # don't leak
    type = fields.String(attribute="discriminator")
Beispiel #19
0
class BundlesSpecSchema(PlainSchema):
    uuid_spec_type = 'uuid_spec'

    spec_types = uuid_spec_type

    # Fields
    spec_type = fields.String(validate=validate.OneOf(set(spec_types)))
    bundle_infos = fields.List(fields.Dict())
    fetch_status = fields.Nested(FetchStatusSchema, required=True)
Beispiel #20
0
class FeaturedSchema(Schema):
    id = fields.Str(dump_only=True)
    title = fields.Str(dump_only=True)
    audio_url = fields.Str(dump_only=True)
    sort = fields.Str(dump_only=True)
    album = fields.Nested(AlbumSchema, dump_only=True)

    class Meta:
        type_ = "featured"
Beispiel #21
0
    class PersonSchema(Schema):
        class Meta:
            type_ = "person"
            self_view = "api.person_detail"
            self_view_kwargs = {"person_id": "<id>"}

        id = fields.Integer(as_string=True, attribute="person_id")
        name = fields.Str(required=True)
        birth_date = fields.DateTime()
        computers = Relationship(
            related_view="api.computer_list",
            related_view_kwargs={"person_id": "<person_id>"},
            schema="ComputerSchema",
            type_="computer",
            many=True,
        )

        tags = fields.Nested(person_tag_schema, many=True)
        single_tag = fields.Nested(person_single_tag_schema)
Beispiel #22
0
    class StringJsonAttributePersonSchema(Schema):
        class Meta:
            type_ = 'string_json_attribute_person'
            self_view = 'api.string_json_attribute_person_detail'
            self_view_kwargs = {'person_id': '<id>'}

        id = fields.Integer(as_string=True, attribute='person_id')
        name = fields.Str(required=True)
        birth_date = fields.DateTime()
        address = fields.Nested(address_schema, many=False)
Beispiel #23
0
class BundleImageBlockSchema(WorksheetBlockSchema):
    mode = fields.Constant(BlockModes.BUNDLE_IMAGE_MODE)
    path = fields.String()
    bundle = fields.Relationship(
        include_resource_linkage=True, type_='bundles', attribute='bundle_uuid', allow_none=True
    )
    max_lines = fields.Integer()

    status = fields.Nested(FetchStatusSchema)
    image_data = fields.String()
Beispiel #24
0
class RatingsSchema(Schema):
    id = fields.Integer(dump_only=True)
    user_id = fields.Integer(dump_only=True)
    movie_id = fields.Integer(dump_only=True)
    movie = fields.Nested(MoviesSchema, only=('id', 'title', 'poster', 'year'))
    ratings = fields.Float(dump_to='rating')

    class Meta:
        type_ = 'rating'
        ordered = True
Beispiel #25
0
class Placement(Schema):
    id = fields.String(required=True, dump_only=True, attribute='placement_id')
    name = fields.String()
    placement_period = fields.List(fields.Nested(PlacementPeriod))

    class Meta:
        type_ = 'placement'
        self_view = 'zelos'
        self_view_many = 'zelos'
        strict = True
Beispiel #26
0
class PlacementPeriod(Schema):
    id = fields.String(dump_only=True, attribute='placement_id')
    start = fields.String()
    end = fields.DateTime()
    cmp = fields.Int()
    delivery = fields.List(fields.Nested(Delivery))
    budget = fields.Int()

    class Meta:
        type_ = 'placement_period'
Beispiel #27
0
class TrendInputSchema(BaseSchema):
    """
    Schema for the request for trend data (not the response)
    """

    fields = JsonString(invert=True, required=True)
    filter = FilterReference()
    control_limits = f.Nested(ControlLimitSchema, required=True)
    center_line = f.String(validate=validate.OneOf(["mean", "median", "none"]),
                           required=True)
Beispiel #28
0
class BundleContentsBlockSchema(WorksheetBlockSchema):
    mode = fields.Constant(BlockModes.BUNDLE_CONTENTS_MODE)
    path = fields.String()
    bundle = fields.Relationship(
        include_resource_linkage=True, type_='bundles', attribute='bundle_uuid', allow_none=True
    )
    max_lines = fields.Integer()

    status = fields.Nested(FetchStatusSchema)
    files = fields.List(fields.String())
    lines = fields.List(fields.String())
Beispiel #29
0
class TokenSchema(Schema):
    id = fields.String(dump_only=True)
    methods = fields.String()
    audit_id = fields.String()
    user = fields.Nested(UserAuthSchema)
    issused_date = fields.DateTime()
    expires_date = fields.DateTime()

    class Meta:
        type_ = 'token'
        strict = True
Beispiel #30
0
    class StringJsonAttributePersonSchema(Schema):
        class Meta:
            type_ = "string_json_attribute_person"
            self_view = "api.string_json_attribute_person_detail"
            self_view_kwargs = {"person_id": "<id>"}

        id = fields.Integer(as_string=True, attribute="person_id")
        name = fields.Str(required=True)
        birth_date = fields.DateTime()
        address = fields.Nested(address_schema, many=False)
        tags = fields.List(fields.Dict())