Ejemplo n.º 1
0
class User(Resource):
    id = fields.Integer()
    login = fields.String()
    avatar_url = fields.String()
    location = fields.String()
    site_admin = fields.Boolean()

    class Meta:
        # Endpoint for getting a single specific user
        endpoint = '/users/{login}'
        # Endpoint for listing all users
        endpoint_list = '/users'
Ejemplo n.º 2
0
class Repository(Resource):
    id = fields.Integer()
    name = fields.String()
    full_name = fields.String()
    description = fields.String()
    owner = fields.Embedded(User)

    class Meta:
        # Endpoint for getting a single specific repository
        endpoint = '/repos/{full_name}'
        # Endpoint for listing all repositories
        endpoint_list = '/repositories'
Ejemplo n.º 3
0
class Post(Resource):
    id = fields.Integer()
    content = fields.String()

    class Meta:
        endpoint = '/user/{user_id}/post/{post_id}'
        endpoint_list = '/user/{user_id}/post'
Ejemplo n.º 4
0
class User(Resource):
    id = fields.Integer()
    name = fields.String()
    posts = fields.ManagedCollection(Post)
    profile = fields.Embedded(Profile)

    objects = Manager()
    with_posts = Manager(filter=lambda u: u.posts.count() > 0)

    class Meta:
        endpoint = '/user/{user_id}'
        endpoint_list = '/user'
Ejemplo n.º 5
0
class Scene(MonitorMixin, Resource):
    """
    Note that scene state is not available on this resource
    as scene state is write-only. See :class:`SceneStateChange` for details.
    """

    #: The ID given to the scene by the bridge (alphanumeric, Eg: `s123457`)
    id = fields.Integer(v.UnsignedInteger(), from_endpoint='id')
    #: An editable name given to the scene
    name = fields.String(v.Required())
    #: The Light resources effected by this scene
    lights = fields.ManagedIdListCollection(model=Light)
    #: Is this scene active?
    active = fields.Boolean()

    objects = SceneManager()

    class Meta:
        endpoint = '/scenes/{id}'
        endpoint_list = '/scenes'
Ejemplo n.º 6
0
class Profile(Resource):
    email = fields.String()
    age = fields.Integer()