Skip to main content

exoscale_rs/apis/
instance_api.rs

1/*
2 * Exoscale API
3 *
4 * Infrastructure automation API, allowing programmatic access to all Exoscale products and services.
5 *
6 * The version of the OpenAPI document: 2.0.0
7 * Contact: support@exoscale.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11use reqwest;
12use serde::{Deserialize, Serialize};
13use crate::{models, utils,apis::ResponseContent};
14use super::{Error, configuration};
15
16
17/// struct for typed errors of method [`add_instance_protection`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum AddInstanceProtectionError {
21    UnknownValue(serde_json::Value),
22}
23
24
25/// struct for typed errors of method [`create_instance`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CreateInstanceError {
29    UnknownValue(serde_json::Value),
30}
31
32
33/// struct for typed errors of method [`create_snapshot`]
34#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum CreateSnapshotError {
37    UnknownValue(serde_json::Value),
38}
39
40
41/// struct for typed errors of method [`delete_instance`]
42#[derive(Debug, Clone, Serialize, Deserialize)]
43#[serde(untagged)]
44pub enum DeleteInstanceError {
45    UnknownValue(serde_json::Value),
46}
47
48
49/// struct for typed errors of method [`enable_tpm`]
50#[derive(Debug, Clone, Serialize, Deserialize)]
51#[serde(untagged)]
52pub enum EnableTpmError {
53    UnknownValue(serde_json::Value),
54}
55
56
57/// struct for typed errors of method [`get_console_proxy_url`]
58#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(untagged)]
60pub enum GetConsoleProxyUrlError {
61    UnknownValue(serde_json::Value),
62}
63
64
65/// struct for typed errors of method [`get_instance`]
66#[derive(Debug, Clone, Serialize, Deserialize)]
67#[serde(untagged)]
68pub enum GetInstanceError {
69    UnknownValue(serde_json::Value),
70}
71
72
73/// struct for typed errors of method [`list_instances`]
74#[derive(Debug, Clone, Serialize, Deserialize)]
75#[serde(untagged)]
76pub enum ListInstancesError {
77    UnknownValue(serde_json::Value),
78}
79
80
81/// struct for typed errors of method [`reboot_instance`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum RebootInstanceError {
85    UnknownValue(serde_json::Value),
86}
87
88
89/// struct for typed errors of method [`remove_instance_protection`]
90#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum RemoveInstanceProtectionError {
93    UnknownValue(serde_json::Value),
94}
95
96
97/// struct for typed errors of method [`reset_instance`]
98#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum ResetInstanceError {
101    UnknownValue(serde_json::Value),
102}
103
104
105/// struct for typed errors of method [`reset_instance_field`]
106#[derive(Debug, Clone, Serialize, Deserialize)]
107#[serde(untagged)]
108pub enum ResetInstanceFieldError {
109    UnknownValue(serde_json::Value),
110}
111
112
113/// struct for typed errors of method [`reset_instance_password`]
114#[derive(Debug, Clone, Serialize, Deserialize)]
115#[serde(untagged)]
116pub enum ResetInstancePasswordError {
117    UnknownValue(serde_json::Value),
118}
119
120
121/// struct for typed errors of method [`resize_instance_disk`]
122#[derive(Debug, Clone, Serialize, Deserialize)]
123#[serde(untagged)]
124pub enum ResizeInstanceDiskError {
125    UnknownValue(serde_json::Value),
126}
127
128
129/// struct for typed errors of method [`reveal_instance_password`]
130#[derive(Debug, Clone, Serialize, Deserialize)]
131#[serde(untagged)]
132pub enum RevealInstancePasswordError {
133    UnknownValue(serde_json::Value),
134}
135
136
137/// struct for typed errors of method [`revert_instance_to_snapshot`]
138#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum RevertInstanceToSnapshotError {
141    UnknownValue(serde_json::Value),
142}
143
144
145/// struct for typed errors of method [`scale_instance`]
146#[derive(Debug, Clone, Serialize, Deserialize)]
147#[serde(untagged)]
148pub enum ScaleInstanceError {
149    UnknownValue(serde_json::Value),
150}
151
152
153/// struct for typed errors of method [`start_instance`]
154#[derive(Debug, Clone, Serialize, Deserialize)]
155#[serde(untagged)]
156pub enum StartInstanceError {
157    UnknownValue(serde_json::Value),
158}
159
160
161/// struct for typed errors of method [`stop_instance`]
162#[derive(Debug, Clone, Serialize, Deserialize)]
163#[serde(untagged)]
164pub enum StopInstanceError {
165    UnknownValue(serde_json::Value),
166}
167
168
169/// struct for typed errors of method [`update_instance`]
170#[derive(Debug, Clone, Serialize, Deserialize)]
171#[serde(untagged)]
172pub enum UpdateInstanceError {
173    UnknownValue(serde_json::Value),
174}
175
176
177pub async fn add_instance_protection(configuration: &configuration::Configuration, id: String) -> Result<models::Operation, Error<AddInstanceProtectionError>> {
178    let local_var_id = id;
179
180    let mut path_params_map = std::collections::HashMap::new();
181                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
182
183    let query_params_vec: Vec<(&str, String)> = Vec::new();
184    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
185        let body_payload_option: Option<()> = None;
186
187    utils::execute_request(
188    configuration,
189    reqwest::Method::PUT,
190    "/instance/{id}:add-protection",
191    path_params_map,
192    query_params_option,
193    body_payload_option,
194    ).await
195}
196pub async fn create_instance(configuration: &configuration::Configuration, create_instance_request: models::CreateInstanceRequest) -> Result<models::Operation, Error<CreateInstanceError>> {
197    let local_var_create_instance_request = create_instance_request;
198
199    let path_params_map = std::collections::HashMap::new();
200
201    let query_params_vec: Vec<(&str, String)> = Vec::new();
202    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
203            let body_payload_option = Some(local_var_create_instance_request);
204
205    utils::execute_request(
206    configuration,
207    reqwest::Method::POST,
208    "/instance",
209    path_params_map,
210    query_params_option,
211    body_payload_option,
212    ).await
213}
214pub async fn create_snapshot(configuration: &configuration::Configuration, id: String) -> Result<models::Operation, Error<CreateSnapshotError>> {
215    let local_var_id = id;
216
217    let mut path_params_map = std::collections::HashMap::new();
218                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
219
220    let query_params_vec: Vec<(&str, String)> = Vec::new();
221    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
222        let body_payload_option: Option<()> = None;
223
224    utils::execute_request(
225    configuration,
226    reqwest::Method::POST,
227    "/instance/{id}:create-snapshot",
228    path_params_map,
229    query_params_option,
230    body_payload_option,
231    ).await
232}
233pub async fn delete_instance(configuration: &configuration::Configuration, id: String) -> Result<models::Operation, Error<DeleteInstanceError>> {
234    let local_var_id = id;
235
236    let mut path_params_map = std::collections::HashMap::new();
237                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
238
239    let query_params_vec: Vec<(&str, String)> = Vec::new();
240    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
241        let body_payload_option: Option<()> = None;
242
243    utils::execute_request(
244    configuration,
245    reqwest::Method::DELETE,
246    "/instance/{id}",
247    path_params_map,
248    query_params_option,
249    body_payload_option,
250    ).await
251}
252pub async fn enable_tpm(configuration: &configuration::Configuration, id: String) -> Result<models::Operation, Error<EnableTpmError>> {
253    let local_var_id = id;
254
255    let mut path_params_map = std::collections::HashMap::new();
256                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
257
258    let query_params_vec: Vec<(&str, String)> = Vec::new();
259    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
260        let body_payload_option: Option<()> = None;
261
262    utils::execute_request(
263    configuration,
264    reqwest::Method::POST,
265    "/instance/{id}:enable-tpm",
266    path_params_map,
267    query_params_option,
268    body_payload_option,
269    ).await
270}
271pub async fn get_console_proxy_url(configuration: &configuration::Configuration, id: String) -> Result<models::GetConsoleProxyUrl200Response, Error<GetConsoleProxyUrlError>> {
272    let local_var_id = id;
273
274    let mut path_params_map = std::collections::HashMap::new();
275                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
276
277    let query_params_vec: Vec<(&str, String)> = Vec::new();
278    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
279        let body_payload_option: Option<()> = None;
280
281    utils::execute_request(
282    configuration,
283    reqwest::Method::GET,
284    "/console/{id}",
285    path_params_map,
286    query_params_option,
287    body_payload_option,
288    ).await
289}
290pub async fn get_instance(configuration: &configuration::Configuration, id: String) -> Result<models::Instance, Error<GetInstanceError>> {
291    let local_var_id = id;
292
293    let mut path_params_map = std::collections::HashMap::new();
294                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
295
296    let query_params_vec: Vec<(&str, String)> = Vec::new();
297    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
298        let body_payload_option: Option<()> = None;
299
300    utils::execute_request(
301    configuration,
302    reqwest::Method::GET,
303    "/instance/{id}",
304    path_params_map,
305    query_params_option,
306    body_payload_option,
307    ).await
308}
309pub async fn list_instances(configuration: &configuration::Configuration, manager_id: Option<String>, manager_type: Option<&str>, ip_address: Option<&str>, labels: Option<&str>) -> Result<models::ListInstances200Response, Error<ListInstancesError>> {
310    let local_var_manager_id = manager_id;
311    let local_var_manager_type = manager_type;
312    let local_var_ip_address = ip_address;
313    let local_var_labels = labels;
314
315    let path_params_map = std::collections::HashMap::new();
316
317    let mut query_params_vec: Vec<(&str, String)> = Vec::new();
318                        if let Some(value) = &local_var_manager_id {
319                            query_params_vec.push(("manager-id", value.to_string()));
320                        }
321                        if let Some(value) = &local_var_manager_type {
322                            query_params_vec.push(("manager-type", value.to_string()));
323                        }
324                        if let Some(value) = &local_var_ip_address {
325                            query_params_vec.push(("ip-address", value.to_string()));
326                        }
327                        if let Some(value) = &local_var_labels {
328                            query_params_vec.push(("labels", value.to_string()));
329                        }
330    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
331        let body_payload_option: Option<()> = None;
332
333    utils::execute_request(
334    configuration,
335    reqwest::Method::GET,
336    "/instance",
337    path_params_map,
338    query_params_option,
339    body_payload_option,
340    ).await
341}
342pub async fn reboot_instance(configuration: &configuration::Configuration, id: String) -> Result<models::Operation, Error<RebootInstanceError>> {
343    let local_var_id = id;
344
345    let mut path_params_map = std::collections::HashMap::new();
346                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
347
348    let query_params_vec: Vec<(&str, String)> = Vec::new();
349    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
350        let body_payload_option: Option<()> = None;
351
352    utils::execute_request(
353    configuration,
354    reqwest::Method::PUT,
355    "/instance/{id}:reboot",
356    path_params_map,
357    query_params_option,
358    body_payload_option,
359    ).await
360}
361pub async fn remove_instance_protection(configuration: &configuration::Configuration, id: String) -> Result<models::Operation, Error<RemoveInstanceProtectionError>> {
362    let local_var_id = id;
363
364    let mut path_params_map = std::collections::HashMap::new();
365                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
366
367    let query_params_vec: Vec<(&str, String)> = Vec::new();
368    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
369        let body_payload_option: Option<()> = None;
370
371    utils::execute_request(
372    configuration,
373    reqwest::Method::PUT,
374    "/instance/{id}:remove-protection",
375    path_params_map,
376    query_params_option,
377    body_payload_option,
378    ).await
379}
380pub async fn reset_instance(configuration: &configuration::Configuration, id: String, reset_instance_request: models::ResetInstanceRequest) -> Result<models::Operation, Error<ResetInstanceError>> {
381    let local_var_id = id;
382    let local_var_reset_instance_request = reset_instance_request;
383
384    let mut path_params_map = std::collections::HashMap::new();
385                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
386
387    let query_params_vec: Vec<(&str, String)> = Vec::new();
388    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
389            let body_payload_option = Some(local_var_reset_instance_request);
390
391    utils::execute_request(
392    configuration,
393    reqwest::Method::PUT,
394    "/instance/{id}:reset",
395    path_params_map,
396    query_params_option,
397    body_payload_option,
398    ).await
399}
400pub async fn reset_instance_field(configuration: &configuration::Configuration, id: String, field: &str) -> Result<models::Operation, Error<ResetInstanceFieldError>> {
401    let local_var_id = id;
402    let local_var_field = field;
403
404    let mut path_params_map = std::collections::HashMap::new();
405                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
406                path_params_map.insert("field".to_string(), crate::apis::urlencode(local_var_field));
407
408    let query_params_vec: Vec<(&str, String)> = Vec::new();
409    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
410        let body_payload_option: Option<()> = None;
411
412    utils::execute_request(
413    configuration,
414    reqwest::Method::DELETE,
415    "/instance/{id}/{field}",
416    path_params_map,
417    query_params_option,
418    body_payload_option,
419    ).await
420}
421pub async fn reset_instance_password(configuration: &configuration::Configuration, id: String) -> Result<models::Operation, Error<ResetInstancePasswordError>> {
422    let local_var_id = id;
423
424    let mut path_params_map = std::collections::HashMap::new();
425                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
426
427    let query_params_vec: Vec<(&str, String)> = Vec::new();
428    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
429        let body_payload_option: Option<()> = None;
430
431    utils::execute_request(
432    configuration,
433    reqwest::Method::PUT,
434    "/instance/{id}:reset-password",
435    path_params_map,
436    query_params_option,
437    body_payload_option,
438    ).await
439}
440pub async fn resize_instance_disk(configuration: &configuration::Configuration, id: String, resize_instance_disk_request: models::ResizeInstanceDiskRequest) -> Result<models::Operation, Error<ResizeInstanceDiskError>> {
441    let local_var_id = id;
442    let local_var_resize_instance_disk_request = resize_instance_disk_request;
443
444    let mut path_params_map = std::collections::HashMap::new();
445                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
446
447    let query_params_vec: Vec<(&str, String)> = Vec::new();
448    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
449            let body_payload_option = Some(local_var_resize_instance_disk_request);
450
451    utils::execute_request(
452    configuration,
453    reqwest::Method::PUT,
454    "/instance/{id}:resize-disk",
455    path_params_map,
456    query_params_option,
457    body_payload_option,
458    ).await
459}
460pub async fn reveal_instance_password(configuration: &configuration::Configuration, id: String) -> Result<models::InstancePassword, Error<RevealInstancePasswordError>> {
461    let local_var_id = id;
462
463    let mut path_params_map = std::collections::HashMap::new();
464                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
465
466    let query_params_vec: Vec<(&str, String)> = Vec::new();
467    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
468        let body_payload_option: Option<()> = None;
469
470    utils::execute_request(
471    configuration,
472    reqwest::Method::GET,
473    "/instance/{id}:password",
474    path_params_map,
475    query_params_option,
476    body_payload_option,
477    ).await
478}
479pub async fn revert_instance_to_snapshot(configuration: &configuration::Configuration, instance_id: String, revert_instance_to_snapshot_request: models::RevertInstanceToSnapshotRequest) -> Result<models::Operation, Error<RevertInstanceToSnapshotError>> {
480    let local_var_instance_id = instance_id;
481    let local_var_revert_instance_to_snapshot_request = revert_instance_to_snapshot_request;
482
483    let mut path_params_map = std::collections::HashMap::new();
484                path_params_map.insert("instance_id".to_string(), crate::apis::urlencode(local_var_instance_id));
485
486    let query_params_vec: Vec<(&str, String)> = Vec::new();
487    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
488            let body_payload_option = Some(local_var_revert_instance_to_snapshot_request);
489
490    utils::execute_request(
491    configuration,
492    reqwest::Method::POST,
493    "/instance/{instance_id}:revert-snapshot",
494    path_params_map,
495    query_params_option,
496    body_payload_option,
497    ).await
498}
499pub async fn scale_instance(configuration: &configuration::Configuration, id: String, scale_instance_request: models::ScaleInstanceRequest) -> Result<models::Operation, Error<ScaleInstanceError>> {
500    let local_var_id = id;
501    let local_var_scale_instance_request = scale_instance_request;
502
503    let mut path_params_map = std::collections::HashMap::new();
504                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
505
506    let query_params_vec: Vec<(&str, String)> = Vec::new();
507    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
508            let body_payload_option = Some(local_var_scale_instance_request);
509
510    utils::execute_request(
511    configuration,
512    reqwest::Method::PUT,
513    "/instance/{id}:scale",
514    path_params_map,
515    query_params_option,
516    body_payload_option,
517    ).await
518}
519pub async fn start_instance(configuration: &configuration::Configuration, id: String, start_instance_request: models::StartInstanceRequest) -> Result<models::Operation, Error<StartInstanceError>> {
520    let local_var_id = id;
521    let local_var_start_instance_request = start_instance_request;
522
523    let mut path_params_map = std::collections::HashMap::new();
524                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
525
526    let query_params_vec: Vec<(&str, String)> = Vec::new();
527    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
528            let body_payload_option = Some(local_var_start_instance_request);
529
530    utils::execute_request(
531    configuration,
532    reqwest::Method::PUT,
533    "/instance/{id}:start",
534    path_params_map,
535    query_params_option,
536    body_payload_option,
537    ).await
538}
539pub async fn stop_instance(configuration: &configuration::Configuration, id: String) -> Result<models::Operation, Error<StopInstanceError>> {
540    let local_var_id = id;
541
542    let mut path_params_map = std::collections::HashMap::new();
543                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
544
545    let query_params_vec: Vec<(&str, String)> = Vec::new();
546    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
547        let body_payload_option: Option<()> = None;
548
549    utils::execute_request(
550    configuration,
551    reqwest::Method::PUT,
552    "/instance/{id}:stop",
553    path_params_map,
554    query_params_option,
555    body_payload_option,
556    ).await
557}
558pub async fn update_instance(configuration: &configuration::Configuration, id: String, update_instance_request: models::UpdateInstanceRequest) -> Result<models::Operation, Error<UpdateInstanceError>> {
559    let local_var_id = id;
560    let local_var_update_instance_request = update_instance_request;
561
562    let mut path_params_map = std::collections::HashMap::new();
563                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
564
565    let query_params_vec: Vec<(&str, String)> = Vec::new();
566    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
567            let body_payload_option = Some(local_var_update_instance_request);
568
569    utils::execute_request(
570    configuration,
571    reqwest::Method::PUT,
572    "/instance/{id}",
573    path_params_map,
574    query_params_option,
575    body_payload_option,
576    ).await
577}