Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 1 | from keystonev3.common import send |
| 2 | from keystonev3.arg_converter import get_by_name_or_uuid_multiple |
| 3 | try: |
| 4 | from urllib.parse import urlencode |
| 5 | except ImportError: |
| 6 | from urllib import urlencode |
| 7 | |
| 8 | |
| 9 | @get_by_name_or_uuid_multiple([('domain', 'domain_id')]) |
| 10 | @send('post') |
| 11 | def group_create(domain_id, name, **kwargs): |
| 12 | url = '/groups' |
| 13 | json = { |
| 14 | 'group':{ |
| 15 | 'name': name, |
| 16 | 'domain_id': domain_id, |
| 17 | } |
| 18 | } |
| 19 | json['group'].update(kwargs) |
| 20 | return url, json |
| 21 | |
| 22 | |
| 23 | @get_by_name_or_uuid_multiple([('group', 'group_id')]) |
| 24 | @send('get') |
| 25 | def group_get_details(group_id, **kwargs): |
| 26 | url = '/groups/{}'.format(group_id) |
| 27 | return url, None |
| 28 | |
| 29 | |
| 30 | @get_by_name_or_uuid_multiple([('group', 'group_id')]) |
| 31 | @send('patch') |
| 32 | def group_update(group_id, **kwargs): |
| 33 | url = '/groups/{}'.format(group_id) |
| 34 | json = { |
| 35 | 'group': kwargs, |
| 36 | } |
| 37 | return url, json |
| 38 | |
| 39 | |
| 40 | @get_by_name_or_uuid_multiple([('group', 'group_id')]) |
| 41 | @send('delete') |
| 42 | def group_delete(group_id, **kwargs): |
| 43 | url = '/groups/{}'.format(group_id) |
| 44 | return url, None |
| 45 | |
| 46 | @get_by_name_or_uuid_multiple([('group', 'group_id')]) |
| 47 | @send('get') |
| 48 | def group_user_list(group_id, **kwargs): |
| 49 | url = '/groups/{}?{}'.format(group_id, urlencode(kwargs)) |
| 50 | return url, None |
| 51 | |
| 52 | |
| 53 | @get_by_name_or_uuid_multiple([('group', 'group_id'), ('user', 'user_id')]) |
| 54 | @send('put') |
| 55 | def group_user_add(group_id, user_id, **kwargs): |
| 56 | url = '/groups/{}/users/{}'.format(group_id, user_id) |
| 57 | return url, None |
| 58 | |
| 59 | |
| 60 | @get_by_name_or_uuid_multiple([('group', 'group_id'), ('user', 'user_id')]) |
| 61 | @send('head') |
| 62 | def group_user_check(group_id, user_id, **kwargs): |
| 63 | url = '/groups/{}/users/{}'.format(group_id, user_id) |
| 64 | return url, None |
| 65 | |
| 66 | |
| 67 | @get_by_name_or_uuid_multiple([('group', 'group_id'), ('user', 'user_id')]) |
| 68 | @send('delete') |
| 69 | def group_user_remove(group_id, user_id, **kwargs): |
| 70 | url = '/groups/{}/users/{}'.format(group_id, user_id) |
| 71 | return url, None |