Ann Taraday | 8204f72 | 2018-12-12 16:38:57 +0400 | [diff] [blame] | 1 | from neutronv2.common import send |
| 2 | from neutronv2.arg_converter import get_by_name_or_uuid_multiple |
| 3 | |
| 4 | try: |
| 5 | from urllib.parse import urlencode |
| 6 | except ImportError: |
| 7 | from urllib import urlencode |
| 8 | |
| 9 | |
| 10 | @get_by_name_or_uuid_multiple([('port', 'port_id')]) |
| 11 | @send('get') |
| 12 | def port_get_details(port_id, **kwargs): |
| 13 | url = '/ports/{}?{}'.format(port_id, urlencode(kwargs)) |
| 14 | return url, {} |
| 15 | |
| 16 | |
| 17 | @get_by_name_or_uuid_multiple([('port', 'port_id')]) |
| 18 | @send('put') |
| 19 | def port_update(port_id, **kwargs): |
| 20 | url = '/ports/{}'.format(port_id) |
| 21 | json = { |
| 22 | 'port': kwargs, |
| 23 | } |
| 24 | return url, {'json': json} |
| 25 | |
| 26 | |
| 27 | @get_by_name_or_uuid_multiple([('port', 'port_id')]) |
| 28 | @send('delete') |
| 29 | def port_delete(port_id, **kwargs): |
| 30 | url = '/port/{}'.format(port_id) |
| 31 | return url, {} |
| 32 | |
| 33 | |
| 34 | @send('post') |
| 35 | def port_create(**kwargs): |
| 36 | url = '/ports' |
| 37 | json = { |
| 38 | 'port': kwargs, |
| 39 | } |
| 40 | return url, {'json': json} |