blob: 451880d9a00555761d26a82b0031396a46857f90 [file] [log] [blame]
Oleg Bondarev9250e612018-09-24 18:59:40 +04001from octaviav2.common import send
2from octaviav2.common import get_by_name_or_uuid
3
4try:
5 from urllib.parse import urlencode
6except ImportError:
7 from urllib import urlencode
8
9RESOURCE_LIST_KEY = 'loadbalancers'
10
11
12@send('get')
13def loadbalancer_list(**kwargs):
14 url = '/v2.0/lbaas/loadbalancers?{}'.format(urlencode(kwargs))
15 return url, {}
16
17@get_by_name_or_uuid(loadbalancer_list, RESOURCE_LIST_KEY)
18@send('get')
19def loadbalancer_get_details(loadbalancer_id, **kwargs):
20 url = '/v2.0/lbaas/loadbalancers/{}?{}'.format(loadbalancer_id, urlencode(kwargs))
21 return url, {}
22
23
24@get_by_name_or_uuid(loadbalancer_list, RESOURCE_LIST_KEY)
25@send('put')
26def loadbalancer_update(loadbalancer_id, **kwargs):
27 url = '/v2.0/lbaas/loadbalancers/{}'.format(loadbalancer_id)
28 json = {
29 'loadbalancer': kwargs,
30 }
31 return url, {'json': json}
32
33
34@get_by_name_or_uuid(loadbalancer_list, RESOURCE_LIST_KEY)
35@send('delete')
36def loadbalancer_delete(loadbalancer_id, **kwargs):
37 url = '/v2.0/lbaas/loadbalancers/{}'.format(loadbalancer_id)
38 return url, {}
39
40
41@send('post')
42def loadbalancer_create(**kwargs):
43 url = '/v2.0/lbaas/loadbalancers'
44 json = {
45 'loadbalancer': kwargs,
46 }
47 return url, {'json': json}