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'
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'
class Post(Resource): id = fields.Integer() content = fields.String() class Meta: endpoint = '/user/{user_id}/post/{post_id}' endpoint_list = '/user/{user_id}/post'
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'
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'
class Profile(Resource): email = fields.String() age = fields.Integer()