blob: 9f378d57420c2d697d3f1457affbc9571efb3672 [file] [log] [blame]
Vasyl Saienko4eda4f22018-04-26 19:30:39 +03001from keystonev3.common import send
Oleksiy Petrenkoe03e2c72018-08-10 13:24:32 +03002from keystonev3.arg_converter import get_by_name_or_uuid_multiple
Vasyl Saienko4eda4f22018-04-26 19:30:39 +03003try:
4 from urllib.parse import urlencode
5except ImportError:
6 from urllib import urlencode
7
8
9@send('get')
10def endpoint_get_details(endpoint_id, **kwargs):
11 url = '/endpoints/{}?{}'.format(endpoint_id, urlencode(kwargs))
12 return url, None
13
14
15@send('patch')
16def 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')
25def endpoint_delete(endpoint_id, **kwargs):
26 url = '/endpoints/{}'.format(endpoint_id)
27 return url, None
28
29
Oleksiy Petrenkoe03e2c72018-08-10 13:24:32 +030030@get_by_name_or_uuid_multiple([('service', 'service_id')])
Vasyl Saienko4eda4f22018-04-26 19:30:39 +030031@send('post')
Oleksiy Petrenkoe03e2c72018-08-10 13:24:32 +030032def endpoint_create(service_id, url, interface, **kwargs):
33 api_url = '/endpoints'
Vasyl Saienko4eda4f22018-04-26 19:30:39 +030034 json = {
Oleksiy Petrenkoe03e2c72018-08-10 13:24:32 +030035 'endpoint': {
36 'service_id': service_id,
37 'url': url,
38 'interface': interface,
39 }
Vasyl Saienko4eda4f22018-04-26 19:30:39 +030040 }
Oleksiy Petrenkoe03e2c72018-08-10 13:24:32 +030041 json['endpoint'].update(kwargs)
42 return api_url, json