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 | |
Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 4 | try: |
| 5 | from urllib.parse import urlencode |
| 6 | except ImportError: |
| 7 | from urllib import urlencode |
| 8 | |
| 9 | |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 10 | @get_by_name_or_uuid_multiple([('project', 'project_id')]) |
Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 11 | @send('get') |
| 12 | def project_get_details(project_id, **kwargs): |
| 13 | url = '/projects/{}?{}'.format(project_id, urlencode(kwargs)) |
| 14 | return url, None |
| 15 | |
| 16 | |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 17 | @get_by_name_or_uuid_multiple([('project', 'project_id')]) |
Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 18 | @send('patch') |
| 19 | def project_update(project_id, **kwargs): |
| 20 | url = '/projects/{}'.format(project_id) |
| 21 | json = { |
| 22 | 'project': kwargs, |
| 23 | } |
| 24 | return url, json |
| 25 | |
| 26 | |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 27 | @get_by_name_or_uuid_multiple([('project', 'project_id')]) |
Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 28 | @send('delete') |
| 29 | def project_delete(project_id, **kwargs): |
| 30 | url = '/projects/{}'.format(project_id) |
| 31 | return url, None |
| 32 | |
| 33 | |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 34 | @get_by_name_or_uuid_multiple([('domain', 'domain_id')]) |
Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 35 | @send('post') |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 36 | def project_create(domain_id, name,**kwargs): |
Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 37 | url = '/projects' |
| 38 | json = { |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 39 | 'project': { |
| 40 | 'name': name, |
| 41 | 'domain_id': domain_id, |
| 42 | } |
Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 43 | } |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 44 | json['project'].update(kwargs) |
Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 45 | return url, json |