Revision a2ef112e kamaki/clients/compute_rest_api.py
b/kamaki/clients/compute_rest_api.py | ||
---|---|---|
119 | 119 |
|
120 | 120 |
path = path4url('servers', server_id, command) |
121 | 121 |
return self.put(path, data=data, success=success, **kwargs) |
122 |
|
|
123 |
def flavors_get(self, flavor_id='', command='', success=200, **kwargs): |
|
124 |
"""GET base_url[/flavor_id][/command] |
|
125 |
|
|
126 |
:param flavor_id: integer (str or int) |
|
127 |
|
|
128 |
:param command: flavor service command |
|
129 |
|
|
130 |
:param success: success code or list or tupple of accepted success |
|
131 |
codes. if server response code is not in this list, a ClientError |
|
132 |
raises |
|
133 |
|
|
134 |
:returns: request response |
|
135 |
""" |
|
136 |
path = path4url('flavors', flavor_id, command) |
|
137 |
return self.get(path, success=success, **kwargs) |
|
138 |
|
|
139 |
def images_get(self, image_id='', command='', success=200, **kwargs): |
|
140 |
"""GET base_url[/image_id][/command] |
|
141 |
|
|
142 |
:param image_id: string |
|
143 |
|
|
144 |
:param command: image server command |
|
145 |
|
|
146 |
:param success: success code or list or tupple of accepted success |
|
147 |
codes. if server response code is not in this list, a ClientError |
|
148 |
raises |
|
149 |
|
|
150 |
:returns: request response |
|
151 |
""" |
|
152 |
path = path4url('images', image_id, command) |
|
153 |
return self.get(path, success=success, **kwargs) |
|
154 |
|
|
155 |
def images_delete(self, image_id='', command='', success=204, **kwargs): |
|
156 |
"""DELETE base_url[/image_id][/command] |
|
157 |
|
|
158 |
:param image_id: string |
|
159 |
|
|
160 |
:param command: image server command |
|
161 |
|
|
162 |
:param success: success code or list or tuple of accepted success |
|
163 |
codes. if server response code is not in this list, a ClientError |
|
164 |
raises |
|
165 |
|
|
166 |
:returns: request response |
|
167 |
""" |
|
168 |
path = path4url('images', image_id, command) |
|
169 |
return self.delete(path, success=success, **kwargs) |
|
170 |
|
|
171 |
def images_post(self, |
|
172 |
image_id='', command='', json_data=None, success=201, **kwargs): |
|
173 |
"""POST base_url/images[/image_id]/[command] request |
|
174 |
|
|
175 |
:param image_id: string |
|
176 |
|
|
177 |
:param command: image server command |
|
178 |
|
|
179 |
:param json_data: (dict) will be send as data |
|
180 |
|
|
181 |
:param success: success code or list or tuple of accepted success |
|
182 |
codes. if server response code is not in this list, a ClientError |
|
183 |
raises |
|
184 |
|
|
185 |
:returns: request response |
|
186 |
""" |
|
187 |
data = json_data |
|
188 |
if json_data is not None: |
|
189 |
data = json.dumps(json_data) |
|
190 |
self.set_header('Content-Type', 'application/json') |
|
191 |
self.set_header('Content-Length', len(data)) |
|
192 |
|
|
193 |
path = path4url('images', image_id, command) |
|
194 |
return self.post(path, data=data, success=success, **kwargs) |
|
195 |
|
|
196 |
def images_put(self, |
|
197 |
image_id='', command='', json_data=None, success=201, **kwargs): |
|
198 |
"""PUT base_url/images[/image_id]/[command] request |
|
199 |
|
|
200 |
:param image_id: string |
|
201 |
|
|
202 |
:param command: image server command |
|
203 |
|
|
204 |
:param json_data: (dict) will be send as data |
|
205 |
|
|
206 |
:param success: success code or list or tuple of accepted success |
|
207 |
codes. if server response code is not in this list, a ClientError |
|
208 |
raises |
|
209 |
|
|
210 |
:returns: request response |
|
211 |
""" |
|
212 |
data = json_data |
|
213 |
if json_data is not None: |
|
214 |
data = json.dumps(json_data) |
|
215 |
self.set_header('Content-Type', 'application/json') |
|
216 |
self.set_header('Content-Length', len(data)) |
|
217 |
|
|
218 |
path = path4url('images', image_id, command) |
|
219 |
return self.put(path, data=data, success=success, **kwargs) |
Also available in: Unified diff