1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum AddGroupSecretError {
20 Status400(models::RespError),
21 Status401(models::RespError),
22 Status403(models::RespError),
23 Status404(models::RespError),
24 Status500(models::RespError),
25 UnknownValue(serde_json::Value),
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum GetGroupSecretError {
32 Status400(models::RespError),
33 Status401(models::RespError),
34 Status403(models::RespError),
35 Status404(models::RespError),
36 Status500(models::RespError),
37 UnknownValue(serde_json::Value),
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum ListGroupSecretsError {
44 Status400(models::RespError),
45 Status401(models::RespError),
46 Status403(models::RespError),
47 Status404(models::RespError),
48 Status500(models::RespError),
49 UnknownValue(serde_json::Value),
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum RemoveGroupSecretError {
56 Status401(models::RespError),
57 Status403(models::RespError),
58 Status404(models::RespError),
59 UnknownValue(serde_json::Value),
60}
61
62pub async fn add_group_secret(
64 configuration: &configuration::Configuration,
65 group_id: &str,
66 req_group_secret: models::ReqGroupSecret,
67) -> Result<models::RespGroupSecret, Error<AddGroupSecretError>> {
68 let p_path_group_id = group_id;
70 let p_body_req_group_secret = req_group_secret;
71
72 let uri_str = format!(
73 "{}/v3/workflows/groups/{group_id}/secrets",
74 configuration.base_path,
75 group_id = crate::apis::urlencode(p_path_group_id)
76 );
77 let mut req_builder = configuration
78 .client
79 .request(reqwest::Method::POST, &uri_str);
80
81 if let Some(ref user_agent) = configuration.user_agent {
82 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
83 }
84 if let Some(ref apikey) = configuration.api_key {
85 let key = apikey.key.clone();
86 let value = match apikey.prefix {
87 Some(ref prefix) => format!("{} {}", prefix, key),
88 None => key,
89 };
90 req_builder = req_builder.header("X-TAPIS-TOKEN", value);
91 };
92 req_builder = req_builder.json(&p_body_req_group_secret);
93
94 let req = req_builder.build()?;
95 let resp = configuration.client.execute(req).await?;
96
97 let status = resp.status();
98 let content_type = resp
99 .headers()
100 .get("content-type")
101 .and_then(|v| v.to_str().ok())
102 .unwrap_or("application/octet-stream");
103 let content_type = super::ContentType::from(content_type);
104
105 if !status.is_client_error() && !status.is_server_error() {
106 let content = resp.text().await?;
107 match content_type {
108 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
109 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespGroupSecret`"))),
110 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespGroupSecret`")))),
111 }
112 } else {
113 let content = resp.text().await?;
114 let entity: Option<AddGroupSecretError> = serde_json::from_str(&content).ok();
115 Err(Error::ResponseError(ResponseContent {
116 status,
117 content,
118 entity,
119 }))
120 }
121}
122
123pub async fn get_group_secret(
125 configuration: &configuration::Configuration,
126 group_id: &str,
127 group_secret_id: &str,
128) -> Result<models::RespGroupSecret, Error<GetGroupSecretError>> {
129 let p_path_group_id = group_id;
131 let p_path_group_secret_id = group_secret_id;
132
133 let uri_str = format!(
134 "{}/v3/workflows/groups/{group_id}/secrets/{group_secret_id}",
135 configuration.base_path,
136 group_id = crate::apis::urlencode(p_path_group_id),
137 group_secret_id = crate::apis::urlencode(p_path_group_secret_id)
138 );
139 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
140
141 if let Some(ref user_agent) = configuration.user_agent {
142 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
143 }
144 if let Some(ref apikey) = configuration.api_key {
145 let key = apikey.key.clone();
146 let value = match apikey.prefix {
147 Some(ref prefix) => format!("{} {}", prefix, key),
148 None => key,
149 };
150 req_builder = req_builder.header("X-TAPIS-TOKEN", value);
151 };
152
153 let req = req_builder.build()?;
154 let resp = configuration.client.execute(req).await?;
155
156 let status = resp.status();
157 let content_type = resp
158 .headers()
159 .get("content-type")
160 .and_then(|v| v.to_str().ok())
161 .unwrap_or("application/octet-stream");
162 let content_type = super::ContentType::from(content_type);
163
164 if !status.is_client_error() && !status.is_server_error() {
165 let content = resp.text().await?;
166 match content_type {
167 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
168 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespGroupSecret`"))),
169 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespGroupSecret`")))),
170 }
171 } else {
172 let content = resp.text().await?;
173 let entity: Option<GetGroupSecretError> = serde_json::from_str(&content).ok();
174 Err(Error::ResponseError(ResponseContent {
175 status,
176 content,
177 entity,
178 }))
179 }
180}
181
182pub async fn list_group_secrets(
184 configuration: &configuration::Configuration,
185 group_id: &str,
186) -> Result<models::RespGroupSecretList, Error<ListGroupSecretsError>> {
187 let p_path_group_id = group_id;
189
190 let uri_str = format!(
191 "{}/v3/workflows/groups/{group_id}/secrets",
192 configuration.base_path,
193 group_id = crate::apis::urlencode(p_path_group_id)
194 );
195 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
196
197 if let Some(ref user_agent) = configuration.user_agent {
198 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
199 }
200 if let Some(ref apikey) = configuration.api_key {
201 let key = apikey.key.clone();
202 let value = match apikey.prefix {
203 Some(ref prefix) => format!("{} {}", prefix, key),
204 None => key,
205 };
206 req_builder = req_builder.header("X-TAPIS-TOKEN", value);
207 };
208
209 let req = req_builder.build()?;
210 let resp = configuration.client.execute(req).await?;
211
212 let status = resp.status();
213 let content_type = resp
214 .headers()
215 .get("content-type")
216 .and_then(|v| v.to_str().ok())
217 .unwrap_or("application/octet-stream");
218 let content_type = super::ContentType::from(content_type);
219
220 if !status.is_client_error() && !status.is_server_error() {
221 let content = resp.text().await?;
222 match content_type {
223 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
224 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespGroupSecretList`"))),
225 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespGroupSecretList`")))),
226 }
227 } else {
228 let content = resp.text().await?;
229 let entity: Option<ListGroupSecretsError> = serde_json::from_str(&content).ok();
230 Err(Error::ResponseError(ResponseContent {
231 status,
232 content,
233 entity,
234 }))
235 }
236}
237
238pub async fn remove_group_secret(
240 configuration: &configuration::Configuration,
241 group_id: &str,
242 group_secret_id: &str,
243) -> Result<models::RespBase, Error<RemoveGroupSecretError>> {
244 let p_path_group_id = group_id;
246 let p_path_group_secret_id = group_secret_id;
247
248 let uri_str = format!(
249 "{}/v3/workflows/groups/{group_id}/secrets/{group_secret_id}",
250 configuration.base_path,
251 group_id = crate::apis::urlencode(p_path_group_id),
252 group_secret_id = crate::apis::urlencode(p_path_group_secret_id)
253 );
254 let mut req_builder = configuration
255 .client
256 .request(reqwest::Method::DELETE, &uri_str);
257
258 if let Some(ref user_agent) = configuration.user_agent {
259 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
260 }
261 if let Some(ref apikey) = configuration.api_key {
262 let key = apikey.key.clone();
263 let value = match apikey.prefix {
264 Some(ref prefix) => format!("{} {}", prefix, key),
265 None => key,
266 };
267 req_builder = req_builder.header("X-TAPIS-TOKEN", value);
268 };
269
270 let req = req_builder.build()?;
271 let resp = configuration.client.execute(req).await?;
272
273 let status = resp.status();
274 let content_type = resp
275 .headers()
276 .get("content-type")
277 .and_then(|v| v.to_str().ok())
278 .unwrap_or("application/octet-stream");
279 let content_type = super::ContentType::from(content_type);
280
281 if !status.is_client_error() && !status.is_server_error() {
282 let content = resp.text().await?;
283 match content_type {
284 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
285 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RespBase`"))),
286 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RespBase`")))),
287 }
288 } else {
289 let content = resp.text().await?;
290 let entity: Option<RemoveGroupSecretError> = serde_json::from_str(&content).ok();
291 Err(Error::ResponseError(ResponseContent {
292 status,
293 content,
294 entity,
295 }))
296 }
297}