Revision 264a13f7 kamaki/clients/cyclades/rest_api.py

b/kamaki/clients/cyclades/rest_api.py
44 44
        path = path4url('servers', server_id, 'stats')
45 45
        return self.get(path, success=success, **kwargs)
46 46

  
47
    def networks_get(
48
            self,
49
            network_id='',
50
            command='',
51
            success=(200, 203),
52
            **kwargs):
53
        """GET base_url/networks[/network_id][/command] request
54

  
55
        :param network_id: integer (str or int)
56

  
57
        :param command: (str) 'detail' or ''
58

  
59
        :param success: success code or list or tuple of accepted success
60
            codes. if server response code is not in this list, a ClientError
61
            raises
62

  
63
        :returns: request response
64
        """
65
        path = path4url('networks', network_id, command)
66
        return self.get(path, success=success, **kwargs)
67

  
68
    def networks_delete(
69
            self,
70
            network_id='',
71
            command='',
72
            success=204,
73
            **kwargs):
74
        """DEL ETE base_url/networks[/network_id][/command] request
75

  
76
        :param network_id: integer (str or int)
77

  
78
        :param command: (str) 'detail' or ''
79

  
80
        :param success: success code or list or tuple of accepted success
81
            codes. if server response code is not in this list, a ClientError
82
            raises
83

  
84
        :returns: request response
85
        """
86
        path = path4url('networks', network_id, command)
87
        return self.delete(path, success=success, **kwargs)
88

  
89
    def networks_post(
90
            self,
91
            network_id='',
92
            command='',
93
            json_data=None,
94
            success=202,
95
            **kwargs):
96
        """POST base_url/servers[/server_id]/[command] request
97

  
98
        :param network_id: integer (str or int)
99

  
100
        :param command: (str) 'detail' or ''
101

  
102
        :param json_data: (dict) will be send as data
103

  
104
        :param success: success code or list or tuple of accepted success
105
            codes. if server response code is not in this list, a ClientError
106
            raises
107

  
108
        :returns: request response
109
        """
110
        data = json_data
111
        if json_data is not None:
112
            data = json.dumps(json_data)
113
            self.set_header('Content-Type', 'application/json')
114
            self.set_header('Content-Length', len(data))
115

  
116
        path = path4url('networks', network_id, command)
117
        return self.post(path, data=data, success=success, **kwargs)
118

  
119
    def networks_put(
120
            self,
121
            network_id='',
122
            command='',
123
            json_data=None,
124
            success=204,
125
            **kwargs):
126
        """PUT base_url/servers[/server_id]/[command] request
127

  
128
        :param network_id: integer (str or int)
129

  
130
        :param command: (str) 'detail' or ''
131

  
132
        :param json_data: (dict) will be send as data
133

  
134
        :param success: success code or list or tuple of accepted success
135
            codes. if server response code is not in this list, a ClientError
136
            raises
137

  
138
        :returns: request response
139
        """
140
        data = json_data
141
        if json_data is not None:
142
            data = json.dumps(json_data)
143
            self.set_header('Content-Type', 'application/json')
144
            self.set_header('Content-Length', len(data))
145

  
146
        path = path4url('networks', network_id, command)
147
        return self.put(path, data=data, success=success, **kwargs)
47
    # def networks_get(
48
    #         self,
49
    #         network_id='',
50
    #         command='',
51
    #         success=(200, 203),
52
    #         **kwargs):
53
    #     """GET base_url/networks[/network_id][/command] request
54

  
55
    #     :param network_id: integer (str or int)
56

  
57
    #     :param command: (str) 'detail' or ''
58

  
59
    #     :param success: success code or list or tuple of accepted success
60
    #         codes. if server response code is not in this list, a ClientError
61
    #         raises
62

  
63
    #     :returns: request response
64
    #     """
65
    #     path = path4url('networks', network_id, command)
66
    #     return self.get(path, success=success, **kwargs)
67

  
68
    # def networks_delete(
69
    #         self,
70
    #         network_id='',
71
    #         command='',
72
    #         success=204,
73
    #         **kwargs):
74
    #     """DEL ETE base_url/networks[/network_id][/command] request
75

  
76
    #     :param network_id: integer (str or int)
77

  
78
    #     :param command: (str) 'detail' or ''
79

  
80
    #     :param success: success code or list or tuple of accepted success
81
    #         codes. if server response code is not in this list, a ClientError
82
    #         raises
83

  
84
    #     :returns: request response
85
    #     """
86
    #     path = path4url('networks', network_id, command)
87
    #     return self.delete(path, success=success, **kwargs)
88

  
89
    # def networks_post(
90
    #         self,
91
    #         network_id='',
92
    #         command='',
93
    #         json_data=None,
94
    #         success=202,
95
    #         **kwargs):
96
    #     """POST base_url/servers[/server_id]/[command] request
97

  
98
    #     :param network_id: integer (str or int)
99

  
100
    #     :param command: (str) 'detail' or ''
101

  
102
    #     :param json_data: (dict) will be send as data
103

  
104
    #     :param success: success code or list or tuple of accepted success
105
    #         codes. if server response code is not in this list, a ClientError
106
    #         raises
107

  
108
    #     :returns: request response
109
    #     """
110
    #     data = json_data
111
    #     if json_data is not None:
112
    #         data = json.dumps(json_data)
113
    #         self.set_header('Content-Type', 'application/json')
114
    #         self.set_header('Content-Length', len(data))
115

  
116
    #     path = path4url('networks', network_id, command)
117
    #     return self.post(path, data=data, success=success, **kwargs)
118

  
119
    # def networks_put(
120
    #         self,
121
    #         network_id='',
122
    #         command='',
123
    #         json_data=None,
124
    #         success=204,
125
    #         **kwargs):
126
    #     """PUT base_url/servers[/server_id]/[command] request
127

  
128
    #     :param network_id: integer (str or int)
129

  
130
    #     :param command: (str) 'detail' or ''
131

  
132
    #     :param json_data: (dict) will be send as data
133

  
134
    #     :param success: success code or list or tuple of accepted success
135
    #         codes. if server response code is not in this list, a ClientError
136
    #         raises
137

  
138
    #     :returns: request response
139
    #     """
140
    #     data = json_data
141
    #     if json_data is not None:
142
    #         data = json.dumps(json_data)
143
    #         self.set_header('Content-Type', 'application/json')
144
    #         self.set_header('Content-Length', len(data))
145

  
146
    #     path = path4url('networks', network_id, command)
147
    #     return self.put(path, data=data, success=success, **kwargs)

Also available in: Unified diff