Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame^] | 1 | from keystonev3.common import get_by_name_or_uuid, send |
| 2 | try: |
| 3 | from urllib.parse import urlencode |
| 4 | except ImportError: |
| 5 | from urllib import urlencode |
| 6 | |
| 7 | |
| 8 | @send('get') |
| 9 | def user_list(**kwargs): |
| 10 | url = '/users?{}'.format(urlencode(kwargs)) |
| 11 | return url, None |
| 12 | |
| 13 | |
| 14 | @get_by_name_or_uuid(user_list, 'users', 'user_id') |
| 15 | @send('get') |
| 16 | def user_get_details(user_id, **kwargs): |
| 17 | url = '/users/{}?{}'.format(user_id, urlencode(kwargs)) |
| 18 | return url, None |
| 19 | |
| 20 | |
| 21 | @get_by_name_or_uuid(user_list, 'users', 'user_id') |
| 22 | @send('patch') |
| 23 | def user_update(user_id, **kwargs): |
| 24 | url = '/users/{}'.format(user_id) |
| 25 | json = { |
| 26 | 'user': kwargs, |
| 27 | } |
| 28 | return url, json |
| 29 | |
| 30 | |
| 31 | @get_by_name_or_uuid(user_list, 'users', 'user_id') |
| 32 | @send('delete') |
| 33 | def user_delete(user_id, **kwargs): |
| 34 | url = '/users/{}'.format(user_id) |
| 35 | return url, None |
| 36 | |
| 37 | |
| 38 | @send('post') |
| 39 | def user_create(**kwargs): |
| 40 | url = '/users' |
| 41 | json = { |
| 42 | 'user': kwargs, |
| 43 | } |
| 44 | return url, json |