-
Notifications
You must be signed in to change notification settings - Fork 0
229 make admin #235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
229 make admin #235
Changes from 1 commit
4d129a9
bcd2564
68f4961
47e21af
d6f5ad5
da5024f
67ce20b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,10 @@ | |
|
|
||
| from time_tracker_api.api import common_fields, api, NullableString | ||
|
|
||
| faker = Faker() | ||
| from utils.azure_users import AzureConnection | ||
|
|
||
|
|
||
| azure_connection = AzureConnection() | ||
|
|
||
| ns = api.namespace('users', description='Namespace of the API for users') | ||
|
|
||
|
|
@@ -17,34 +20,34 @@ | |
| title='Name', | ||
| max_length=50, | ||
| description='Name of the user', | ||
| example=faker.word(['Marcelo', 'Sandro']), | ||
| example=Faker().word(['Marcelo', 'Sandro']), | ||
| ), | ||
| 'email': fields.String( | ||
| title="User's Email", | ||
| max_length=50, | ||
| description='Email of the user that belongs to the tenant', | ||
| example=faker.email(), | ||
| example=Faker().email(), | ||
| ), | ||
| 'role': NullableString( | ||
| title="User's Role", | ||
| max_length=50, | ||
| description='Role assigned to the user by the tenant', | ||
| example=faker.word(['time-tracker-admin']), | ||
| example=Faker().word(['time-tracker-admin']), | ||
| ), | ||
| }, | ||
| ) | ||
|
|
||
| user_response_fields.update(common_fields) | ||
|
|
||
| user_input_fields = ns.model( | ||
| 'UserInput', | ||
| user_role_input_fields = ns.model( | ||
| 'UserRoleInput', | ||
| { | ||
| 'role': NullableString( | ||
| title="User's Role", | ||
| required=True, | ||
| max_length=50, | ||
| description='Role assigned to the user by the tenant', | ||
| example=faker.word(['time-tracker-admin']), | ||
| example=Faker().word(['time-tracker-admin']), | ||
| ), | ||
| }, | ||
| ) | ||
|
|
@@ -56,26 +59,33 @@ class Users(Resource): | |
| @ns.marshal_list_with(user_response_fields) | ||
| def get(self): | ||
| """List all users""" | ||
| from utils.azure_users import AzureConnection | ||
|
|
||
| azure_connection = AzureConnection() | ||
| return azure_connection.users() | ||
|
|
||
|
|
||
| @ns.route('/<string:id>/roles') | ||
| @ns.response(HTTPStatus.NOT_FOUND, 'User not found') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. User not found? I would say it is better to say |
||
| @ns.response(HTTPStatus.UNPROCESSABLE_ENTITY, 'The id has an invalid format') | ||
| @ns.param('id', 'The user identifier') | ||
| class UserRole(Resource): | ||
| @ns.doc('update_user_role') | ||
| @ns.expect(user_input_fields) | ||
| class UserRoles(Resource): | ||
| @ns.doc('create_user_role') | ||
| @ns.expect(user_role_input_fields) | ||
| @ns.response( | ||
| HTTPStatus.BAD_REQUEST, 'Invalid format or structure of the user' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Invalid format or structure of the user? Is not this for roles? |
||
| ) | ||
| @ns.marshal_with(user_response_fields) | ||
Angeluz-07 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def put(self, id): | ||
| """Update user's role""" | ||
| from utils.azure_users import AzureConnection | ||
|
|
||
| azure_connection = AzureConnection() | ||
| def post(self, id): | ||
| """Create user's role""" | ||
| return azure_connection.update_user_role(id, ns.payload['role']) | ||
|
|
||
|
|
||
| @ns.route('/<string:user_id>/roles/<string:role_id>') | ||
| @ns.response(HTTPStatus.NOT_FOUND, 'User not found') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. User not found? IMO, it is better to say |
||
| @ns.response(HTTPStatus.UNPROCESSABLE_ENTITY, 'The id has an invalid format') | ||
| @ns.param('user_id', 'The user identifier') | ||
| @ns.param('role_id', 'The role name identifier') | ||
| class UserRole(Resource): | ||
| @ns.doc('delete_user_role') | ||
| @ns.marshal_with(user_response_fields) | ||
| def delete(self, user_id, role_id): | ||
| """Delete user's role""" | ||
| return azure_connection.update_user_role(user_id, role=None) | ||
Uh oh!
There was an error while loading. Please reload this page.