def put(self, role_id): """ .. http:put:: /roles/1 Update a role **Example request**: .. sourcecode:: http PUT /roles/1 HTTP/1.1 Host: example.com Accept: application/json, text/javascript { "name": "role1", "description": "This is a new description" } **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript { "id": 1, "name": "role1", "description": "this is a new description" } :reqheader Authorization: OAuth token to authenticate :statuscode 200: no error :statuscode 403: unauthenticated """ permission = ViewRoleCredentialsPermission(role_id) if permission.can(): self.reqparse.add_argument('name', type=str, location='json', required=True) self.reqparse.add_argument('description', type=str, location='json') self.reqparse.add_argument('users', type=list, location='json') args = self.reqparse.parse_args() return service.update(role_id, args['name'], args.get('description'), args.get('users')) abort(403)
def put(self, role_id, data=None): """ .. http:put:: /roles/1 Update a role **Example request**: .. sourcecode:: http PUT /roles/1 HTTP/1.1 Host: example.com Accept: application/json, text/javascript Content-Type: application/json;charset=UTF-8 { "name": "role1", "description": "This is a new description" } **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript { "id": 1, "name": "role1", "description": "this is a new description" } :reqheader Authorization: OAuth token to authenticate :statuscode 200: no error :statuscode 403: unauthenticated """ permission = RoleMemberPermission(role_id) if permission.can(): return service.update( role_id, data["name"], data.get("description"), data.get("users") ) return dict(message="You are not authorized to modify this role."), 403
def put(self, role_id, data=None): """ .. http:put:: /roles/1 Update a role **Example request**: .. sourcecode:: http PUT /roles/1 HTTP/1.1 Host: example.com Accept: application/json, text/javascript { "name": "role1", "description": "This is a new description" } **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript { "id": 1, "name": "role1", "description": "this is a new description" } :reqheader Authorization: OAuth token to authenticate :statuscode 200: no error :statuscode 403: unauthenticated """ permission = ViewRoleCredentialsPermission(role_id) if permission.can(): return service.update(role_id, data['name'], data.get('description'), data.get('users')) abort(403)