43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
"""
|
|
.. module: lemur.roles.schemas
|
|
:platform: unix
|
|
:copyright: (c) 2015 by Netflix Inc., see AUTHORS for more
|
|
:license: Apache, see LICENSE for more details.
|
|
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
|
|
"""
|
|
from marshmallow import fields
|
|
from lemur.users.schemas import UserNestedOutputSchema
|
|
from lemur.authorities.schemas import AuthorityOutputSchema
|
|
from lemur.common.schema import LemurInputSchema, LemurOutputSchema
|
|
from lemur.schemas import AssociatedUserSchema, AssociatedAuthoritySchema
|
|
|
|
|
|
class RoleInputSchema(LemurInputSchema):
|
|
id = fields.Integer()
|
|
name = fields.String(required=True)
|
|
username = fields.String()
|
|
password = fields.String()
|
|
description = fields.String()
|
|
authorities = fields.Nested(AssociatedAuthoritySchema, many=True)
|
|
users = fields.Nested(AssociatedUserSchema, many=True)
|
|
|
|
|
|
class RoleOutputSchema(LemurOutputSchema):
|
|
id = fields.Integer()
|
|
name = fields.String()
|
|
description = fields.String()
|
|
authorities = fields.Nested(AuthorityOutputSchema, many=True)
|
|
users = fields.Nested(UserNestedOutputSchema, many=True)
|
|
|
|
|
|
class RoleNestedOutputSchema(LemurOutputSchema):
|
|
__envelope__ = False
|
|
id = fields.Integer()
|
|
name = fields.String()
|
|
description = fields.String()
|
|
|
|
|
|
role_input_schema = RoleInputSchema()
|
|
role_output_schema = RoleOutputSchema()
|
|
roles_output_schema = RoleOutputSchema(many=True)
|