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 project_list(**kwargs): |
| 10 | url = '/projects?{}'.format(urlencode(kwargs)) |
| 11 | return url, None |
| 12 | |
| 13 | |
| 14 | @get_by_name_or_uuid(project_list, 'projects', 'project_id') |
| 15 | @send('get') |
| 16 | def project_get_details(project_id, **kwargs): |
| 17 | url = '/projects/{}?{}'.format(project_id, urlencode(kwargs)) |
| 18 | return url, None |
| 19 | |
| 20 | |
| 21 | @get_by_name_or_uuid(project_list, 'projects', 'project_id') |
| 22 | @send('patch') |
| 23 | def project_update(project_id, **kwargs): |
| 24 | url = '/projects/{}'.format(project_id) |
| 25 | json = { |
| 26 | 'project': kwargs, |
| 27 | } |
| 28 | return url, json |
| 29 | |
| 30 | |
| 31 | @get_by_name_or_uuid(project_list, 'projects', 'project_id') |
| 32 | @send('delete') |
| 33 | def project_delete(project_id, **kwargs): |
| 34 | url = '/projects/{}'.format(project_id) |
| 35 | return url, None |
| 36 | |
| 37 | |
| 38 | @send('post') |
| 39 | def project_create(**kwargs): |
| 40 | url = '/projects' |
| 41 | json = { |
| 42 | 'project': kwargs, |
| 43 | } |
| 44 | return url, json |