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