Revision 963bd664 kamaki/clients/network/rest_api.py

b/kamaki/clients/network/rest_api.py
31 31
# interpreted as representing official policies, either expressed
32 32
# or implied, of GRNET S.A.
33 33

  
34
from kamaki.clients import Client, ClientError
34
from kamaki.clients import Client
35 35
from kamaki.clients.utils import path4url
36 36
from json import dumps
37 37

  
......
39 39
class NetworkRestClient(Client):
40 40

  
41 41
    def networks_get(self, network_id=None, **kwargs):
42
        path = path4url('networks', network_id) if (
43
            network_id) else path4url('networks')
44
        return self.get(path, **kwargs)
42
        if network_id:
43
            return self.get(path4url('networks', network_id), **kwargs)
44
        return self.get(path4url('networks'), **kwargs)
45 45

  
46 46
    def networks_post(self, json_data=None, shared=None, **kwargs):
47 47
        path = path4url('networks')
48
        self.set_param(shared, bool(shared), iff=shared)
48
        self.set_param('shared', bool(shared), iff=shared)
49 49
        return self.post(
50 50
            path, data=dumps(json_data) if json_data else None, **kwargs)
51 51

  
......
56 56

  
57 57
        self.set_param(
58 58
            'admin_state_up', bool(admin_state_up), iff=admin_state_up)
59
        self.set_param(shared, bool(shared), iff=shared)
59
        self.set_param('shared', bool(shared), iff=shared)
60 60

  
61 61
        return self.put(
62 62
            path, data=dumps(json_data) if json_data else None, **kwargs)
......
64 64
    def networks_delete(self, network_id, **kwargs):
65 65
        return self.delete(path4url('networks', network_id), **kwargs)
66 66

  
67
    def subnets_get(self, json_data=None, subnet_id=None, **kwargs):
67
    def subnets_get(self, subnet_id=None, **kwargs):
68 68
        if subnet_id:
69 69
            return self.get(path4url('subnets', subnet_id), **kwargs)
70
        elif json_data:
71
            return self.get(
72
                path4url('subnets'), data=dumps(json_data), **kwargs)
73
        else:
74
            raise ClientError('No subnet_id or json_data in GET subnets')
70
        return self.get(path4url('subnets'), **kwargs)
75 71

  
76 72
    def subnets_post(self, **kwargs):
77 73
        return self.post(path4url('subnets'), **kwargs)
......
83 79
        return self.delete(path4url('subnets', subnet_id), **kwargs)
84 80

  
85 81
    def ports_get(self, port_id=None, **kwargs):
86
        path = path4url('ports', port_id) if port_id else path4url('ports')
87
        return self.get(path, **kwargs)
82
        if port_id:
83
            return self.get(path4url('ports', port_id), **kwargs)
84
        return self.get(path4url('ports'), **kwargs)
88 85

  
89 86
    def ports_post(
90 87
            self,
......
96 93
        self.set_param('fixed_ips', fixed_ips, iff=fixed_ips)
97 94
        self.set_param('security_groups', security_groups, iff=security_groups)
98 95
        data = dumps(json_data) if json_data else None
99
        self.post(path4url('ports'), data=data, **kwargs)
96
        return self.post(path4url('ports'), data=data, **kwargs)
100 97

  
101 98
    def ports_put(
102 99
            self, port_id,
......
108 105
        self.set_param('fixed_ips', fixed_ips, iff=fixed_ips)
109 106
        self.set_param('security_groups', security_groups, iff=security_groups)
110 107
        data = dumps(json_data) if json_data else None
111
        self.put(path4url('ports', port_id), data=data, **kwargs)
108
        return self.put(path4url('ports', port_id), data=data, **kwargs)
112 109

  
113 110
    def ports_delete(self, port_id, **kwargs):
114 111
        return self.delete(path4url('ports', port_id), **kwargs)

Also available in: Unified diff