Skip to main content

exoscale_rs/apis/
model_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 [`create_model`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum CreateModelError {
21    Status403(models::ErrorResponse),
22    UnknownValue(serde_json::Value),
23}
24
25
26/// struct for typed errors of method [`delete_model`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum DeleteModelError {
30    Status412(models::DeleteModelConflictResponse),
31    Status403(models::ErrorResponse),
32    Status404(models::ErrorResponse),
33    UnknownValue(serde_json::Value),
34}
35
36
37/// struct for typed errors of method [`get_model`]
38#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum GetModelError {
41    Status404(models::ErrorResponse),
42    UnknownValue(serde_json::Value),
43}
44
45
46/// struct for typed errors of method [`list_models`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ListModelsError {
50    UnknownValue(serde_json::Value),
51}
52
53
54pub async fn create_model(configuration: &configuration::Configuration, create_model_request: models::CreateModelRequest) -> Result<models::Operation, Error<CreateModelError>> {
55    let local_var_create_model_request = create_model_request;
56
57    let path_params_map = std::collections::HashMap::new();
58
59    let query_params_vec: Vec<(&str, String)> = Vec::new();
60    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
61            let body_payload_option = Some(local_var_create_model_request);
62
63    utils::execute_request(
64    configuration,
65    reqwest::Method::POST,
66    "/ai/model",
67    path_params_map,
68    query_params_option,
69    body_payload_option,
70    ).await
71}
72pub async fn delete_model(configuration: &configuration::Configuration, id: String) -> Result<models::Operation, Error<DeleteModelError>> {
73    let local_var_id = id;
74
75    let mut path_params_map = std::collections::HashMap::new();
76                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
77
78    let query_params_vec: Vec<(&str, String)> = Vec::new();
79    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
80        let body_payload_option: Option<()> = None;
81
82    utils::execute_request(
83    configuration,
84    reqwest::Method::DELETE,
85    "/ai/model/{id}",
86    path_params_map,
87    query_params_option,
88    body_payload_option,
89    ).await
90}
91pub async fn get_model(configuration: &configuration::Configuration, id: String) -> Result<models::GetModelResponse, Error<GetModelError>> {
92    let local_var_id = id;
93
94    let mut path_params_map = std::collections::HashMap::new();
95                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
96
97    let query_params_vec: Vec<(&str, String)> = Vec::new();
98    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
99        let body_payload_option: Option<()> = None;
100
101    utils::execute_request(
102    configuration,
103    reqwest::Method::GET,
104    "/ai/model/{id}",
105    path_params_map,
106    query_params_option,
107    body_payload_option,
108    ).await
109}
110pub async fn list_models(configuration: &configuration::Configuration, visibility: Option<&str>) -> Result<models::ListModelsResponse, Error<ListModelsError>> {
111    let local_var_visibility = visibility;
112
113    let path_params_map = std::collections::HashMap::new();
114
115    let mut query_params_vec: Vec<(&str, String)> = Vec::new();
116                        if let Some(value) = &local_var_visibility {
117                            query_params_vec.push(("visibility", value.to_string()));
118                        }
119    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
120        let body_payload_option: Option<()> = None;
121
122    utils::execute_request(
123    configuration,
124    reqwest::Method::GET,
125    "/ai/model",
126    path_params_map,
127    query_params_option,
128    body_payload_option,
129    ).await
130}