blob: d0e85f8e1a8a10c46d66cff6ee544dad19c296bd [file] [log] [blame]
Oleksiy Petrenkocaad2032018-04-20 14:42:46 +03001from neutronv2.common import send, get_by_name_or_uuid
2try:
3 from urllib.parse import urlencode
4except ImportError:
5 from urllib import urlencode
6
7RESOURCE_LIST_KEY = 'networks'
8
9
10@send('get')
11def network_list(**kwargs):
12 url = '/networks?{}'.format(urlencode(kwargs))
13 return url, {}
14
15
16@get_by_name_or_uuid(network_list, RESOURCE_LIST_KEY)
17@send('get')
18def network_get_details(network_id, **kwargs):
19 url = '/networks/{}?{}'.format(network_id, urlencode(kwargs))
20 return url, {}
21
22
23@get_by_name_or_uuid(network_list, RESOURCE_LIST_KEY)
24@send('put')
25def network_update(network_id, **kwargs):
26 url = '/networks/{}'.format(network_id)
27 json = {
28 'network': kwargs,
29 }
30 return url, {'json': json}
31
32
33@get_by_name_or_uuid(network_list, RESOURCE_LIST_KEY)
34@send('delete')
35def network_delete(network_id, **kwargs):
36 url = '/networks/{}'.format(network_id)
37 return url, {}
38
39
40@send('post')
41def network_create(**kwargs):
42 url = '/networks'
43 json = {
44 'network': kwargs,
45 }
46 return url, {'json': json}
47
48
49@send('post')
50def network_bulk_create(networks, **kwargs):
51 url = '/networks'
52 json = {
53 'networks': networks,
54 }
55 return url, {'json': json}