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