Oleksiy Petrenko | 5bfb8bc | 2018-08-23 15:08:17 +0300 | [diff] [blame] | 1 | from neutronv2.common import send |
| 2 | from neutronv2.arg_converter import get_by_name_or_uuid_multiple |
| 3 | |
Oleksiy Petrenko | caad203 | 2018-04-20 14:42:46 +0300 | [diff] [blame] | 4 | try: |
| 5 | from urllib.parse import urlencode |
| 6 | except ImportError: |
| 7 | from urllib import urlencode |
| 8 | |
Oleksiy Petrenko | caad203 | 2018-04-20 14:42:46 +0300 | [diff] [blame] | 9 | |
Oleksiy Petrenko | 5bfb8bc | 2018-08-23 15:08:17 +0300 | [diff] [blame] | 10 | @get_by_name_or_uuid_multiple([('network', 'network_id')]) |
Oleksiy Petrenko | caad203 | 2018-04-20 14:42:46 +0300 | [diff] [blame] | 11 | @send('get') |
| 12 | def network_get_details(network_id, **kwargs): |
| 13 | url = '/networks/{}?{}'.format(network_id, urlencode(kwargs)) |
| 14 | return url, {} |
| 15 | |
| 16 | |
Oleksiy Petrenko | 5bfb8bc | 2018-08-23 15:08:17 +0300 | [diff] [blame] | 17 | @get_by_name_or_uuid_multiple([('network', 'network_id')]) |
Oleksiy Petrenko | caad203 | 2018-04-20 14:42:46 +0300 | [diff] [blame] | 18 | @send('put') |
| 19 | def network_update(network_id, **kwargs): |
| 20 | url = '/networks/{}'.format(network_id) |
| 21 | json = { |
| 22 | 'network': kwargs, |
| 23 | } |
| 24 | return url, {'json': json} |
| 25 | |
| 26 | |
Oleksiy Petrenko | 5bfb8bc | 2018-08-23 15:08:17 +0300 | [diff] [blame] | 27 | @get_by_name_or_uuid_multiple([('network', 'network_id')]) |
Oleksiy Petrenko | caad203 | 2018-04-20 14:42:46 +0300 | [diff] [blame] | 28 | @send('delete') |
| 29 | def network_delete(network_id, **kwargs): |
| 30 | url = '/networks/{}'.format(network_id) |
| 31 | return url, {} |
| 32 | |
| 33 | |
| 34 | @send('post') |
| 35 | def network_create(**kwargs): |
| 36 | url = '/networks' |
| 37 | json = { |
| 38 | 'network': kwargs, |
| 39 | } |
| 40 | return url, {'json': json} |
| 41 | |
| 42 | |
| 43 | @send('post') |
| 44 | def network_bulk_create(networks, **kwargs): |
| 45 | url = '/networks' |
| 46 | json = { |
| 47 | 'networks': networks, |
| 48 | } |
| 49 | return url, {'json': json} |