1use reqwest;
12use serde::{Deserialize, Serialize};
13
14use super::{configuration, Error};
15use crate::{apis::ResponseContent, models};
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum OrganizationsOrganizationIdServiceAccountsGetError {
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum OrganizationsOrganizationIdServiceAccountsPostError {
28 UnknownValue(serde_json::Value),
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum ServiceAccountsDeletePostError {
35 UnknownValue(serde_json::Value),
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum ServiceAccountsIdAccessTokensGetError {
42 UnknownValue(serde_json::Value),
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum ServiceAccountsIdAccessTokensPostError {
49 UnknownValue(serde_json::Value),
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum ServiceAccountsIdAccessTokensRevokePostError {
56 UnknownValue(serde_json::Value),
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum ServiceAccountsIdGetError {
63 UnknownValue(serde_json::Value),
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum ServiceAccountsIdPutError {
70 UnknownValue(serde_json::Value),
71}
72
73pub async fn organizations_organization_id_service_accounts_get(
74 configuration: &configuration::Configuration,
75 organization_id: uuid::Uuid,
76 include_access_to_secrets: Option<bool>,
77) -> Result<
78 models::ServiceAccountSecretsDetailsResponseModelListResponseModel,
79 Error<OrganizationsOrganizationIdServiceAccountsGetError>,
80> {
81 let local_var_configuration = configuration;
82
83 let local_var_client = &local_var_configuration.client;
84
85 let local_var_uri_str = format!(
86 "{}/organizations/{organizationId}/service-accounts",
87 local_var_configuration.base_path,
88 organizationId = crate::apis::urlencode(organization_id.to_string())
89 );
90 let mut local_var_req_builder =
91 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
92
93 if let Some(ref local_var_str) = include_access_to_secrets {
94 local_var_req_builder =
95 local_var_req_builder.query(&[("includeAccessToSecrets", &local_var_str.to_string())]);
96 }
97 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
98 local_var_req_builder =
99 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
100 }
101 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
102 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
103 };
104
105 let local_var_req = local_var_req_builder.build()?;
106 let local_var_resp = local_var_client.execute(local_var_req).await?;
107
108 let local_var_status = local_var_resp.status();
109 let local_var_content = local_var_resp.text().await?;
110
111 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
112 serde_json::from_str(&local_var_content).map_err(Error::from)
113 } else {
114 let local_var_entity: Option<OrganizationsOrganizationIdServiceAccountsGetError> =
115 serde_json::from_str(&local_var_content).ok();
116 let local_var_error = ResponseContent {
117 status: local_var_status,
118 content: local_var_content,
119 entity: local_var_entity,
120 };
121 Err(Error::ResponseError(local_var_error))
122 }
123}
124
125pub async fn organizations_organization_id_service_accounts_post(
126 configuration: &configuration::Configuration,
127 organization_id: uuid::Uuid,
128 service_account_create_request_model: Option<models::ServiceAccountCreateRequestModel>,
129) -> Result<
130 models::ServiceAccountResponseModel,
131 Error<OrganizationsOrganizationIdServiceAccountsPostError>,
132> {
133 let local_var_configuration = configuration;
134
135 let local_var_client = &local_var_configuration.client;
136
137 let local_var_uri_str = format!(
138 "{}/organizations/{organizationId}/service-accounts",
139 local_var_configuration.base_path,
140 organizationId = crate::apis::urlencode(organization_id.to_string())
141 );
142 let mut local_var_req_builder =
143 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
144
145 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
146 local_var_req_builder =
147 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
148 }
149 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
150 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
151 };
152 local_var_req_builder = local_var_req_builder.json(&service_account_create_request_model);
153
154 let local_var_req = local_var_req_builder.build()?;
155 let local_var_resp = local_var_client.execute(local_var_req).await?;
156
157 let local_var_status = local_var_resp.status();
158 let local_var_content = local_var_resp.text().await?;
159
160 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
161 serde_json::from_str(&local_var_content).map_err(Error::from)
162 } else {
163 let local_var_entity: Option<OrganizationsOrganizationIdServiceAccountsPostError> =
164 serde_json::from_str(&local_var_content).ok();
165 let local_var_error = ResponseContent {
166 status: local_var_status,
167 content: local_var_content,
168 entity: local_var_entity,
169 };
170 Err(Error::ResponseError(local_var_error))
171 }
172}
173
174pub async fn service_accounts_delete_post(
175 configuration: &configuration::Configuration,
176 uuid_colon_colon_uuid: Option<Vec<uuid::Uuid>>,
177) -> Result<models::BulkDeleteResponseModelListResponseModel, Error<ServiceAccountsDeletePostError>>
178{
179 let local_var_configuration = configuration;
180
181 let local_var_client = &local_var_configuration.client;
182
183 let local_var_uri_str = format!(
184 "{}/service-accounts/delete",
185 local_var_configuration.base_path
186 );
187 let mut local_var_req_builder =
188 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
189
190 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
191 local_var_req_builder =
192 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
193 }
194 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
195 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
196 };
197 local_var_req_builder = local_var_req_builder.json(&uuid_colon_colon_uuid);
198
199 let local_var_req = local_var_req_builder.build()?;
200 let local_var_resp = local_var_client.execute(local_var_req).await?;
201
202 let local_var_status = local_var_resp.status();
203 let local_var_content = local_var_resp.text().await?;
204
205 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
206 serde_json::from_str(&local_var_content).map_err(Error::from)
207 } else {
208 let local_var_entity: Option<ServiceAccountsDeletePostError> =
209 serde_json::from_str(&local_var_content).ok();
210 let local_var_error = ResponseContent {
211 status: local_var_status,
212 content: local_var_content,
213 entity: local_var_entity,
214 };
215 Err(Error::ResponseError(local_var_error))
216 }
217}
218
219pub async fn service_accounts_id_access_tokens_get(
220 configuration: &configuration::Configuration,
221 id: uuid::Uuid,
222) -> Result<
223 models::AccessTokenResponseModelListResponseModel,
224 Error<ServiceAccountsIdAccessTokensGetError>,
225> {
226 let local_var_configuration = configuration;
227
228 let local_var_client = &local_var_configuration.client;
229
230 let local_var_uri_str = format!(
231 "{}/service-accounts/{id}/access-tokens",
232 local_var_configuration.base_path,
233 id = crate::apis::urlencode(id.to_string())
234 );
235 let mut local_var_req_builder =
236 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
237
238 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
239 local_var_req_builder =
240 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
241 }
242 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
243 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
244 };
245
246 let local_var_req = local_var_req_builder.build()?;
247 let local_var_resp = local_var_client.execute(local_var_req).await?;
248
249 let local_var_status = local_var_resp.status();
250 let local_var_content = local_var_resp.text().await?;
251
252 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
253 serde_json::from_str(&local_var_content).map_err(Error::from)
254 } else {
255 let local_var_entity: Option<ServiceAccountsIdAccessTokensGetError> =
256 serde_json::from_str(&local_var_content).ok();
257 let local_var_error = ResponseContent {
258 status: local_var_status,
259 content: local_var_content,
260 entity: local_var_entity,
261 };
262 Err(Error::ResponseError(local_var_error))
263 }
264}
265
266pub async fn service_accounts_id_access_tokens_post(
267 configuration: &configuration::Configuration,
268 id: uuid::Uuid,
269 access_token_create_request_model: Option<models::AccessTokenCreateRequestModel>,
270) -> Result<models::AccessTokenCreationResponseModel, Error<ServiceAccountsIdAccessTokensPostError>>
271{
272 let local_var_configuration = configuration;
273
274 let local_var_client = &local_var_configuration.client;
275
276 let local_var_uri_str = format!(
277 "{}/service-accounts/{id}/access-tokens",
278 local_var_configuration.base_path,
279 id = crate::apis::urlencode(id.to_string())
280 );
281 let mut local_var_req_builder =
282 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
283
284 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
285 local_var_req_builder =
286 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
287 }
288 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
289 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
290 };
291 local_var_req_builder = local_var_req_builder.json(&access_token_create_request_model);
292
293 let local_var_req = local_var_req_builder.build()?;
294 let local_var_resp = local_var_client.execute(local_var_req).await?;
295
296 let local_var_status = local_var_resp.status();
297 let local_var_content = local_var_resp.text().await?;
298
299 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
300 serde_json::from_str(&local_var_content).map_err(Error::from)
301 } else {
302 let local_var_entity: Option<ServiceAccountsIdAccessTokensPostError> =
303 serde_json::from_str(&local_var_content).ok();
304 let local_var_error = ResponseContent {
305 status: local_var_status,
306 content: local_var_content,
307 entity: local_var_entity,
308 };
309 Err(Error::ResponseError(local_var_error))
310 }
311}
312
313pub async fn service_accounts_id_access_tokens_revoke_post(
314 configuration: &configuration::Configuration,
315 id: uuid::Uuid,
316 revoke_access_tokens_request: Option<models::RevokeAccessTokensRequest>,
317) -> Result<(), Error<ServiceAccountsIdAccessTokensRevokePostError>> {
318 let local_var_configuration = configuration;
319
320 let local_var_client = &local_var_configuration.client;
321
322 let local_var_uri_str = format!(
323 "{}/service-accounts/{id}/access-tokens/revoke",
324 local_var_configuration.base_path,
325 id = crate::apis::urlencode(id.to_string())
326 );
327 let mut local_var_req_builder =
328 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
329
330 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
331 local_var_req_builder =
332 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
333 }
334 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
335 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
336 };
337 local_var_req_builder = local_var_req_builder.json(&revoke_access_tokens_request);
338
339 let local_var_req = local_var_req_builder.build()?;
340 let local_var_resp = local_var_client.execute(local_var_req).await?;
341
342 let local_var_status = local_var_resp.status();
343 let local_var_content = local_var_resp.text().await?;
344
345 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
346 Ok(())
347 } else {
348 let local_var_entity: Option<ServiceAccountsIdAccessTokensRevokePostError> =
349 serde_json::from_str(&local_var_content).ok();
350 let local_var_error = ResponseContent {
351 status: local_var_status,
352 content: local_var_content,
353 entity: local_var_entity,
354 };
355 Err(Error::ResponseError(local_var_error))
356 }
357}
358
359pub async fn service_accounts_id_get(
360 configuration: &configuration::Configuration,
361 id: uuid::Uuid,
362) -> Result<models::ServiceAccountResponseModel, Error<ServiceAccountsIdGetError>> {
363 let local_var_configuration = configuration;
364
365 let local_var_client = &local_var_configuration.client;
366
367 let local_var_uri_str = format!(
368 "{}/service-accounts/{id}",
369 local_var_configuration.base_path,
370 id = crate::apis::urlencode(id.to_string())
371 );
372 let mut local_var_req_builder =
373 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
374
375 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
376 local_var_req_builder =
377 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
378 }
379 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
380 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
381 };
382
383 let local_var_req = local_var_req_builder.build()?;
384 let local_var_resp = local_var_client.execute(local_var_req).await?;
385
386 let local_var_status = local_var_resp.status();
387 let local_var_content = local_var_resp.text().await?;
388
389 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
390 serde_json::from_str(&local_var_content).map_err(Error::from)
391 } else {
392 let local_var_entity: Option<ServiceAccountsIdGetError> =
393 serde_json::from_str(&local_var_content).ok();
394 let local_var_error = ResponseContent {
395 status: local_var_status,
396 content: local_var_content,
397 entity: local_var_entity,
398 };
399 Err(Error::ResponseError(local_var_error))
400 }
401}
402
403pub async fn service_accounts_id_put(
404 configuration: &configuration::Configuration,
405 id: uuid::Uuid,
406 service_account_update_request_model: Option<models::ServiceAccountUpdateRequestModel>,
407) -> Result<models::ServiceAccountResponseModel, Error<ServiceAccountsIdPutError>> {
408 let local_var_configuration = configuration;
409
410 let local_var_client = &local_var_configuration.client;
411
412 let local_var_uri_str = format!(
413 "{}/service-accounts/{id}",
414 local_var_configuration.base_path,
415 id = crate::apis::urlencode(id.to_string())
416 );
417 let mut local_var_req_builder =
418 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
419
420 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
421 local_var_req_builder =
422 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
423 }
424 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
425 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
426 };
427 local_var_req_builder = local_var_req_builder.json(&service_account_update_request_model);
428
429 let local_var_req = local_var_req_builder.build()?;
430 let local_var_resp = local_var_client.execute(local_var_req).await?;
431
432 let local_var_status = local_var_resp.status();
433 let local_var_content = local_var_resp.text().await?;
434
435 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
436 serde_json::from_str(&local_var_content).map_err(Error::from)
437 } else {
438 let local_var_entity: Option<ServiceAccountsIdPutError> =
439 serde_json::from_str(&local_var_content).ok();
440 let local_var_error = ResponseContent {
441 status: local_var_status,
442 content: local_var_content,
443 entity: local_var_entity,
444 };
445 Err(Error::ResponseError(local_var_error))
446 }
447}