Skip to main content

exoscale_rs/apis/
api_key_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_api_key`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum CreateApiKeyError {
21    UnknownValue(serde_json::Value),
22}
23
24
25/// struct for typed errors of method [`delete_api_key`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum DeleteApiKeyError {
29    UnknownValue(serde_json::Value),
30}
31
32
33/// struct for typed errors of method [`get_api_key`]
34#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum GetApiKeyError {
37    UnknownValue(serde_json::Value),
38}
39
40
41/// struct for typed errors of method [`list_api_keys`]
42#[derive(Debug, Clone, Serialize, Deserialize)]
43#[serde(untagged)]
44pub enum ListApiKeysError {
45    UnknownValue(serde_json::Value),
46}
47
48
49pub async fn create_api_key(configuration: &configuration::Configuration, create_api_key_request: models::CreateApiKeyRequest) -> Result<models::IamApiKeyCreated, Error<CreateApiKeyError>> {
50    let local_var_create_api_key_request = create_api_key_request;
51
52    let path_params_map = std::collections::HashMap::new();
53
54    let query_params_vec: Vec<(&str, String)> = Vec::new();
55    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
56            let body_payload_option = Some(local_var_create_api_key_request);
57
58    utils::execute_request(
59    configuration,
60    reqwest::Method::POST,
61    "/api-key",
62    path_params_map,
63    query_params_option,
64    body_payload_option,
65    ).await
66}
67pub async fn delete_api_key(configuration: &configuration::Configuration, id: &str) -> Result<models::Operation, Error<DeleteApiKeyError>> {
68    let local_var_id = id;
69
70    let mut path_params_map = std::collections::HashMap::new();
71                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
72
73    let query_params_vec: Vec<(&str, String)> = Vec::new();
74    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
75        let body_payload_option: Option<()> = None;
76
77    utils::execute_request(
78    configuration,
79    reqwest::Method::DELETE,
80    "/api-key/{id}",
81    path_params_map,
82    query_params_option,
83    body_payload_option,
84    ).await
85}
86pub async fn get_api_key(configuration: &configuration::Configuration, id: &str) -> Result<models::IamApiKey, Error<GetApiKeyError>> {
87    let local_var_id = id;
88
89    let mut path_params_map = std::collections::HashMap::new();
90                path_params_map.insert("id".to_string(), crate::apis::urlencode(local_var_id));
91
92    let query_params_vec: Vec<(&str, String)> = Vec::new();
93    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
94        let body_payload_option: Option<()> = None;
95
96    utils::execute_request(
97    configuration,
98    reqwest::Method::GET,
99    "/api-key/{id}",
100    path_params_map,
101    query_params_option,
102    body_payload_option,
103    ).await
104}
105pub async fn list_api_keys(configuration: &configuration::Configuration, ) -> Result<models::ListApiKeys200Response, Error<ListApiKeysError>> {
106
107    let path_params_map = std::collections::HashMap::new();
108
109    let query_params_vec: Vec<(&str, String)> = Vec::new();
110    let query_params_option = if query_params_vec.is_empty() { None } else { Some(query_params_vec.as_slice())};
111        let body_payload_option: Option<()> = None;
112
113    utils::execute_request(
114    configuration,
115    reqwest::Method::GET,
116    "/api-key",
117    path_params_map,
118    query_params_option,
119    body_payload_option,
120    ).await
121}