Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 1 | from keystonev3.common import send |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 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 | |
| 9 | @send('get') |
| 10 | def endpoint_get_details(endpoint_id, **kwargs): |
| 11 | url = '/endpoints/{}?{}'.format(endpoint_id, urlencode(kwargs)) |
| 12 | return url, None |
| 13 | |
| 14 | |
| 15 | @send('patch') |
| 16 | def endpoint_update(endpoint_id, **kwargs): |
| 17 | url = '/endpoints/{}'.format(endpoint_id) |
| 18 | json = { |
| 19 | 'endpoint': kwargs, |
| 20 | } |
| 21 | return url, json |
| 22 | |
| 23 | |
| 24 | @send('delete') |
| 25 | def endpoint_delete(endpoint_id, **kwargs): |
| 26 | url = '/endpoints/{}'.format(endpoint_id) |
| 27 | return url, None |
| 28 | |
| 29 | |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 30 | @get_by_name_or_uuid_multiple([('service', 'service_id')]) |
Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 31 | @send('post') |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 32 | def endpoint_create(service_id, url, interface, **kwargs): |
| 33 | api_url = '/endpoints' |
Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 34 | json = { |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 35 | 'endpoint': { |
| 36 | 'service_id': service_id, |
| 37 | 'url': url, |
| 38 | 'interface': interface, |
| 39 | } |
Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 40 | } |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 41 | json['endpoint'].update(kwargs) |
| 42 | return api_url, json |