Vladyslav Drok | cb8d0fb | 2018-06-27 19:28:14 +0300 | [diff] [blame] | 1 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 | # not use this file except in compliance with the License. You may obtain |
| 3 | # a copy of the License at |
| 4 | # |
| 5 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | # |
| 7 | # Unless required by applicable law or agreed to in writing, software |
| 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | # License for the specific language governing permissions and limitations |
| 11 | # under the License. |
| 12 | |
| 13 | import common |
| 14 | |
| 15 | # Function alias to not shadow built-ins |
| 16 | __func_alias__ = { |
| 17 | 'list_': 'list' |
| 18 | } |
| 19 | |
| 20 | |
| 21 | @common.function_descriptor('delete', 'Project quota') |
| 22 | @common.send('get') |
| 23 | def delete(project_id, user_id=None, **kwargs): |
| 24 | """List quotas of a project (and user)""" |
| 25 | url = '/os-quota-sets/%s' % project_id |
| 26 | if user_id: |
| 27 | url = '%s?user_id=%s' % (url, user_id) |
| 28 | return url, {} |
| 29 | |
| 30 | |
| 31 | @common.function_descriptor('find', 'Project quota', 'quota_set') |
| 32 | @common.send('get') |
| 33 | def list_(project_id, user_id=None, **kwargs): |
| 34 | """List quotas of a project (and user)""" |
| 35 | url = '/os-quota-sets/%s' % project_id |
| 36 | if user_id: |
| 37 | url = '%s?user_id=%s' % (url, user_id) |
| 38 | return url, {} |
| 39 | |
| 40 | |
| 41 | @common.function_descriptor('update', 'Project quota', 'quota_set') |
| 42 | @common.send('put') |
| 43 | def update(project_id, user_id=None, **kwargs): |
| 44 | """Update quota of the specified project (and user)""" |
| 45 | url = '/os-quota-sets/%s' % project_id |
| 46 | if user_id: |
| 47 | url = '%s?user_id=%s' % (url, user_id) |
| 48 | return url, {'json': {'quota_set': kwargs}} |