1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AdminBatchImportApiKeysError {
22 DefaultResponse(models::Status),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum AdminBatchVerifyApiKeysError {
30 DefaultResponse(models::Status),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum AdminDeleteImportedApiKeyError {
38 DefaultResponse(models::Status),
39 UnknownValue(serde_json::Value),
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum AdminDeriveTokenError {
46 DefaultResponse(models::Status),
47 UnknownValue(serde_json::Value),
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum AdminGetImportedApiKeyError {
54 DefaultResponse(models::Status),
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum AdminGetIssuedApiKeyError {
62 DefaultResponse(models::Status),
63 UnknownValue(serde_json::Value),
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum AdminGetJwksError {
70 DefaultResponse(models::Status),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum AdminImportApiKeyError {
78 DefaultResponse(models::Status),
79 UnknownValue(serde_json::Value),
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum AdminIssueApiKeyError {
86 DefaultResponse(models::Status),
87 UnknownValue(serde_json::Value),
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum AdminListImportedApiKeysError {
94 DefaultResponse(models::Status),
95 UnknownValue(serde_json::Value),
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum AdminListIssuedApiKeysError {
102 DefaultResponse(models::Status),
103 UnknownValue(serde_json::Value),
104}
105
106#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum AdminRevokeApiKeyError {
110 DefaultResponse(models::Status),
111 UnknownValue(serde_json::Value),
112}
113
114#[derive(Debug, Clone, Serialize, Deserialize)]
116#[serde(untagged)]
117pub enum AdminRotateIssuedApiKeyError {
118 DefaultResponse(models::Status),
119 UnknownValue(serde_json::Value),
120}
121
122#[derive(Debug, Clone, Serialize, Deserialize)]
124#[serde(untagged)]
125pub enum AdminUpdateImportedApiKeyError {
126 DefaultResponse(models::Status),
127 UnknownValue(serde_json::Value),
128}
129
130#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum AdminUpdateIssuedApiKeyError {
134 DefaultResponse(models::Status),
135 UnknownValue(serde_json::Value),
136}
137
138#[derive(Debug, Clone, Serialize, Deserialize)]
140#[serde(untagged)]
141pub enum AdminVerifyApiKeyError {
142 DefaultResponse(models::Status),
143 UnknownValue(serde_json::Value),
144}
145
146#[derive(Debug, Clone, Serialize, Deserialize)]
148#[serde(untagged)]
149pub enum RevokeApiKeyError {
150 DefaultResponse(models::Status),
151 UnknownValue(serde_json::Value),
152}
153
154
155pub async fn admin_batch_import_api_keys(configuration: &configuration::Configuration, batch_import_api_keys_request: models::BatchImportApiKeysRequest) -> Result<models::BatchImportApiKeysResponse, Error<AdminBatchImportApiKeysError>> {
157 let p_body_batch_import_api_keys_request = batch_import_api_keys_request;
159
160 let uri_str = format!("{}/v2alpha1/admin/importedApiKeys:batchImport", configuration.base_path);
161 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
162
163 if let Some(ref user_agent) = configuration.user_agent {
164 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
165 }
166 if let Some(ref token) = configuration.bearer_access_token {
167 req_builder = req_builder.bearer_auth(token.to_owned());
168 };
169 req_builder = req_builder.json(&p_body_batch_import_api_keys_request);
170
171 let req = req_builder.build()?;
172 let resp = configuration.client.execute(req).await?;
173
174 let status = resp.status();
175 let content_type = resp
176 .headers()
177 .get("content-type")
178 .and_then(|v| v.to_str().ok())
179 .unwrap_or("application/octet-stream");
180 let content_type = super::ContentType::from(content_type);
181
182 if !status.is_client_error() && !status.is_server_error() {
183 let content = resp.text().await?;
184 match content_type {
185 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
186 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BatchImportApiKeysResponse`"))),
187 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BatchImportApiKeysResponse`")))),
188 }
189 } else {
190 let content = resp.text().await?;
191 let entity: Option<AdminBatchImportApiKeysError> = serde_json::from_str(&content).ok();
192 Err(Error::ResponseError(ResponseContent { status, content, entity }))
193 }
194}
195
196pub async fn admin_batch_verify_api_keys(configuration: &configuration::Configuration, batch_verify_api_keys_request: models::BatchVerifyApiKeysRequest, cache_control: Option<&str>, pragma: Option<&str>) -> Result<models::BatchVerifyApiKeysResponse, Error<AdminBatchVerifyApiKeysError>> {
198 let p_body_batch_verify_api_keys_request = batch_verify_api_keys_request;
200 let p_header_cache_control = cache_control;
201 let p_header_pragma = pragma;
202
203 let uri_str = format!("{}/v2alpha1/admin/apiKeys:batchVerify", configuration.base_path);
204 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
205
206 if let Some(ref user_agent) = configuration.user_agent {
207 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
208 }
209 if let Some(param_value) = p_header_cache_control {
210 req_builder = req_builder.header("Cache-Control", param_value.to_string());
211 }
212 if let Some(param_value) = p_header_pragma {
213 req_builder = req_builder.header("Pragma", param_value.to_string());
214 }
215 if let Some(ref token) = configuration.bearer_access_token {
216 req_builder = req_builder.bearer_auth(token.to_owned());
217 };
218 req_builder = req_builder.json(&p_body_batch_verify_api_keys_request);
219
220 let req = req_builder.build()?;
221 let resp = configuration.client.execute(req).await?;
222
223 let status = resp.status();
224 let content_type = resp
225 .headers()
226 .get("content-type")
227 .and_then(|v| v.to_str().ok())
228 .unwrap_or("application/octet-stream");
229 let content_type = super::ContentType::from(content_type);
230
231 if !status.is_client_error() && !status.is_server_error() {
232 let content = resp.text().await?;
233 match content_type {
234 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
235 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BatchVerifyApiKeysResponse`"))),
236 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BatchVerifyApiKeysResponse`")))),
237 }
238 } else {
239 let content = resp.text().await?;
240 let entity: Option<AdminBatchVerifyApiKeysError> = serde_json::from_str(&content).ok();
241 Err(Error::ResponseError(ResponseContent { status, content, entity }))
242 }
243}
244
245pub async fn admin_delete_imported_api_key(configuration: &configuration::Configuration, key_id: &str) -> Result<serde_json::Value, Error<AdminDeleteImportedApiKeyError>> {
247 let p_path_key_id = key_id;
249
250 let uri_str = format!("{}/v2alpha1/admin/importedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
251 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
252
253 if let Some(ref user_agent) = configuration.user_agent {
254 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
255 }
256 if let Some(ref token) = configuration.bearer_access_token {
257 req_builder = req_builder.bearer_auth(token.to_owned());
258 };
259
260 let req = req_builder.build()?;
261 let resp = configuration.client.execute(req).await?;
262
263 let status = resp.status();
264 let content_type = resp
265 .headers()
266 .get("content-type")
267 .and_then(|v| v.to_str().ok())
268 .unwrap_or("application/octet-stream");
269 let content_type = super::ContentType::from(content_type);
270
271 if !status.is_client_error() && !status.is_server_error() {
272 let content = resp.text().await?;
273 match content_type {
274 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
275 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
276 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
277 }
278 } else {
279 let content = resp.text().await?;
280 let entity: Option<AdminDeleteImportedApiKeyError> = serde_json::from_str(&content).ok();
281 Err(Error::ResponseError(ResponseContent { status, content, entity }))
282 }
283}
284
285pub async fn admin_derive_token(configuration: &configuration::Configuration, derive_token_request: models::DeriveTokenRequest) -> Result<models::DeriveTokenResponse, Error<AdminDeriveTokenError>> {
287 let p_body_derive_token_request = derive_token_request;
289
290 let uri_str = format!("{}/v2alpha1/admin/apiKeys:derive", configuration.base_path);
291 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
292
293 if let Some(ref user_agent) = configuration.user_agent {
294 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
295 }
296 if let Some(ref token) = configuration.bearer_access_token {
297 req_builder = req_builder.bearer_auth(token.to_owned());
298 };
299 req_builder = req_builder.json(&p_body_derive_token_request);
300
301 let req = req_builder.build()?;
302 let resp = configuration.client.execute(req).await?;
303
304 let status = resp.status();
305 let content_type = resp
306 .headers()
307 .get("content-type")
308 .and_then(|v| v.to_str().ok())
309 .unwrap_or("application/octet-stream");
310 let content_type = super::ContentType::from(content_type);
311
312 if !status.is_client_error() && !status.is_server_error() {
313 let content = resp.text().await?;
314 match content_type {
315 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
316 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeriveTokenResponse`"))),
317 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeriveTokenResponse`")))),
318 }
319 } else {
320 let content = resp.text().await?;
321 let entity: Option<AdminDeriveTokenError> = serde_json::from_str(&content).ok();
322 Err(Error::ResponseError(ResponseContent { status, content, entity }))
323 }
324}
325
326pub async fn admin_get_imported_api_key(configuration: &configuration::Configuration, key_id: &str) -> Result<models::ImportedApiKey, Error<AdminGetImportedApiKeyError>> {
328 let p_path_key_id = key_id;
330
331 let uri_str = format!("{}/v2alpha1/admin/importedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
332 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
333
334 if let Some(ref user_agent) = configuration.user_agent {
335 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
336 }
337 if let Some(ref token) = configuration.bearer_access_token {
338 req_builder = req_builder.bearer_auth(token.to_owned());
339 };
340
341 let req = req_builder.build()?;
342 let resp = configuration.client.execute(req).await?;
343
344 let status = resp.status();
345 let content_type = resp
346 .headers()
347 .get("content-type")
348 .and_then(|v| v.to_str().ok())
349 .unwrap_or("application/octet-stream");
350 let content_type = super::ContentType::from(content_type);
351
352 if !status.is_client_error() && !status.is_server_error() {
353 let content = resp.text().await?;
354 match content_type {
355 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
356 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ImportedApiKey`"))),
357 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ImportedApiKey`")))),
358 }
359 } else {
360 let content = resp.text().await?;
361 let entity: Option<AdminGetImportedApiKeyError> = serde_json::from_str(&content).ok();
362 Err(Error::ResponseError(ResponseContent { status, content, entity }))
363 }
364}
365
366pub async fn admin_get_issued_api_key(configuration: &configuration::Configuration, key_id: &str) -> Result<models::IssuedApiKey, Error<AdminGetIssuedApiKeyError>> {
368 let p_path_key_id = key_id;
370
371 let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
372 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
373
374 if let Some(ref user_agent) = configuration.user_agent {
375 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
376 }
377 if let Some(ref token) = configuration.bearer_access_token {
378 req_builder = req_builder.bearer_auth(token.to_owned());
379 };
380
381 let req = req_builder.build()?;
382 let resp = configuration.client.execute(req).await?;
383
384 let status = resp.status();
385 let content_type = resp
386 .headers()
387 .get("content-type")
388 .and_then(|v| v.to_str().ok())
389 .unwrap_or("application/octet-stream");
390 let content_type = super::ContentType::from(content_type);
391
392 if !status.is_client_error() && !status.is_server_error() {
393 let content = resp.text().await?;
394 match content_type {
395 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
396 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IssuedApiKey`"))),
397 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IssuedApiKey`")))),
398 }
399 } else {
400 let content = resp.text().await?;
401 let entity: Option<AdminGetIssuedApiKeyError> = serde_json::from_str(&content).ok();
402 Err(Error::ResponseError(ResponseContent { status, content, entity }))
403 }
404}
405
406pub async fn admin_get_jwks(configuration: &configuration::Configuration, ) -> Result<models::GetJwksResponse, Error<AdminGetJwksError>> {
408
409 let uri_str = format!("{}/v2alpha1/admin/derivedKeys/jwks.json", configuration.base_path);
410 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
411
412 if let Some(ref user_agent) = configuration.user_agent {
413 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
414 }
415 if let Some(ref token) = configuration.bearer_access_token {
416 req_builder = req_builder.bearer_auth(token.to_owned());
417 };
418
419 let req = req_builder.build()?;
420 let resp = configuration.client.execute(req).await?;
421
422 let status = resp.status();
423 let content_type = resp
424 .headers()
425 .get("content-type")
426 .and_then(|v| v.to_str().ok())
427 .unwrap_or("application/octet-stream");
428 let content_type = super::ContentType::from(content_type);
429
430 if !status.is_client_error() && !status.is_server_error() {
431 let content = resp.text().await?;
432 match content_type {
433 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
434 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetJwksResponse`"))),
435 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetJwksResponse`")))),
436 }
437 } else {
438 let content = resp.text().await?;
439 let entity: Option<AdminGetJwksError> = serde_json::from_str(&content).ok();
440 Err(Error::ResponseError(ResponseContent { status, content, entity }))
441 }
442}
443
444pub async fn admin_import_api_key(configuration: &configuration::Configuration, import_api_key_request: models::ImportApiKeyRequest) -> Result<models::ImportedApiKey, Error<AdminImportApiKeyError>> {
446 let p_body_import_api_key_request = import_api_key_request;
448
449 let uri_str = format!("{}/v2alpha1/admin/importedApiKeys", configuration.base_path);
450 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
451
452 if let Some(ref user_agent) = configuration.user_agent {
453 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
454 }
455 if let Some(ref token) = configuration.bearer_access_token {
456 req_builder = req_builder.bearer_auth(token.to_owned());
457 };
458 req_builder = req_builder.json(&p_body_import_api_key_request);
459
460 let req = req_builder.build()?;
461 let resp = configuration.client.execute(req).await?;
462
463 let status = resp.status();
464 let content_type = resp
465 .headers()
466 .get("content-type")
467 .and_then(|v| v.to_str().ok())
468 .unwrap_or("application/octet-stream");
469 let content_type = super::ContentType::from(content_type);
470
471 if !status.is_client_error() && !status.is_server_error() {
472 let content = resp.text().await?;
473 match content_type {
474 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
475 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ImportedApiKey`"))),
476 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ImportedApiKey`")))),
477 }
478 } else {
479 let content = resp.text().await?;
480 let entity: Option<AdminImportApiKeyError> = serde_json::from_str(&content).ok();
481 Err(Error::ResponseError(ResponseContent { status, content, entity }))
482 }
483}
484
485pub async fn admin_issue_api_key(configuration: &configuration::Configuration, issue_api_key_request: models::IssueApiKeyRequest) -> Result<models::IssueApiKeyResponse, Error<AdminIssueApiKeyError>> {
487 let p_body_issue_api_key_request = issue_api_key_request;
489
490 let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys", configuration.base_path);
491 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
492
493 if let Some(ref user_agent) = configuration.user_agent {
494 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
495 }
496 if let Some(ref token) = configuration.bearer_access_token {
497 req_builder = req_builder.bearer_auth(token.to_owned());
498 };
499 req_builder = req_builder.json(&p_body_issue_api_key_request);
500
501 let req = req_builder.build()?;
502 let resp = configuration.client.execute(req).await?;
503
504 let status = resp.status();
505 let content_type = resp
506 .headers()
507 .get("content-type")
508 .and_then(|v| v.to_str().ok())
509 .unwrap_or("application/octet-stream");
510 let content_type = super::ContentType::from(content_type);
511
512 if !status.is_client_error() && !status.is_server_error() {
513 let content = resp.text().await?;
514 match content_type {
515 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
516 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IssueApiKeyResponse`"))),
517 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IssueApiKeyResponse`")))),
518 }
519 } else {
520 let content = resp.text().await?;
521 let entity: Option<AdminIssueApiKeyError> = serde_json::from_str(&content).ok();
522 Err(Error::ResponseError(ResponseContent { status, content, entity }))
523 }
524}
525
526pub async fn admin_list_imported_api_keys(configuration: &configuration::Configuration, page_size: Option<i32>, page_token: Option<&str>, filter: Option<&str>) -> Result<models::ListImportedApiKeysResponse, Error<AdminListImportedApiKeysError>> {
528 let p_query_page_size = page_size;
530 let p_query_page_token = page_token;
531 let p_query_filter = filter;
532
533 let uri_str = format!("{}/v2alpha1/admin/importedApiKeys", configuration.base_path);
534 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
535
536 if let Some(ref param_value) = p_query_page_size {
537 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
538 }
539 if let Some(ref param_value) = p_query_page_token {
540 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
541 }
542 if let Some(ref param_value) = p_query_filter {
543 req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
544 }
545 if let Some(ref user_agent) = configuration.user_agent {
546 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
547 }
548 if let Some(ref token) = configuration.bearer_access_token {
549 req_builder = req_builder.bearer_auth(token.to_owned());
550 };
551
552 let req = req_builder.build()?;
553 let resp = configuration.client.execute(req).await?;
554
555 let status = resp.status();
556 let content_type = resp
557 .headers()
558 .get("content-type")
559 .and_then(|v| v.to_str().ok())
560 .unwrap_or("application/octet-stream");
561 let content_type = super::ContentType::from(content_type);
562
563 if !status.is_client_error() && !status.is_server_error() {
564 let content = resp.text().await?;
565 match content_type {
566 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
567 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListImportedApiKeysResponse`"))),
568 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListImportedApiKeysResponse`")))),
569 }
570 } else {
571 let content = resp.text().await?;
572 let entity: Option<AdminListImportedApiKeysError> = serde_json::from_str(&content).ok();
573 Err(Error::ResponseError(ResponseContent { status, content, entity }))
574 }
575}
576
577pub async fn admin_list_issued_api_keys(configuration: &configuration::Configuration, page_size: Option<i32>, page_token: Option<&str>, filter: Option<&str>) -> Result<models::ListIssuedApiKeysResponse, Error<AdminListIssuedApiKeysError>> {
579 let p_query_page_size = page_size;
581 let p_query_page_token = page_token;
582 let p_query_filter = filter;
583
584 let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys", configuration.base_path);
585 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
586
587 if let Some(ref param_value) = p_query_page_size {
588 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
589 }
590 if let Some(ref param_value) = p_query_page_token {
591 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
592 }
593 if let Some(ref param_value) = p_query_filter {
594 req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
595 }
596 if let Some(ref user_agent) = configuration.user_agent {
597 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
598 }
599 if let Some(ref token) = configuration.bearer_access_token {
600 req_builder = req_builder.bearer_auth(token.to_owned());
601 };
602
603 let req = req_builder.build()?;
604 let resp = configuration.client.execute(req).await?;
605
606 let status = resp.status();
607 let content_type = resp
608 .headers()
609 .get("content-type")
610 .and_then(|v| v.to_str().ok())
611 .unwrap_or("application/octet-stream");
612 let content_type = super::ContentType::from(content_type);
613
614 if !status.is_client_error() && !status.is_server_error() {
615 let content = resp.text().await?;
616 match content_type {
617 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
618 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListIssuedApiKeysResponse`"))),
619 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListIssuedApiKeysResponse`")))),
620 }
621 } else {
622 let content = resp.text().await?;
623 let entity: Option<AdminListIssuedApiKeysError> = serde_json::from_str(&content).ok();
624 Err(Error::ResponseError(ResponseContent { status, content, entity }))
625 }
626}
627
628pub async fn admin_revoke_api_key(configuration: &configuration::Configuration, key_id: &str, admin_revoke_api_key_body: models::AdminRevokeApiKeyBody) -> Result<serde_json::Value, Error<AdminRevokeApiKeyError>> {
630 let p_path_key_id = key_id;
632 let p_body_admin_revoke_api_key_body = admin_revoke_api_key_body;
633
634 let uri_str = format!("{}/v2alpha1/admin/apiKeys/{key_id}:revoke", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
635 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
636
637 if let Some(ref user_agent) = configuration.user_agent {
638 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
639 }
640 if let Some(ref token) = configuration.bearer_access_token {
641 req_builder = req_builder.bearer_auth(token.to_owned());
642 };
643 req_builder = req_builder.json(&p_body_admin_revoke_api_key_body);
644
645 let req = req_builder.build()?;
646 let resp = configuration.client.execute(req).await?;
647
648 let status = resp.status();
649 let content_type = resp
650 .headers()
651 .get("content-type")
652 .and_then(|v| v.to_str().ok())
653 .unwrap_or("application/octet-stream");
654 let content_type = super::ContentType::from(content_type);
655
656 if !status.is_client_error() && !status.is_server_error() {
657 let content = resp.text().await?;
658 match content_type {
659 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
660 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
661 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
662 }
663 } else {
664 let content = resp.text().await?;
665 let entity: Option<AdminRevokeApiKeyError> = serde_json::from_str(&content).ok();
666 Err(Error::ResponseError(ResponseContent { status, content, entity }))
667 }
668}
669
670pub async fn admin_rotate_issued_api_key(configuration: &configuration::Configuration, key_id: &str, admin_rotate_issued_api_key_body: models::AdminRotateIssuedApiKeyBody) -> Result<models::RotateIssuedApiKeyResponse, Error<AdminRotateIssuedApiKeyError>> {
672 let p_path_key_id = key_id;
674 let p_body_admin_rotate_issued_api_key_body = admin_rotate_issued_api_key_body;
675
676 let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys/{key_id}:rotate", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
677 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
678
679 if let Some(ref user_agent) = configuration.user_agent {
680 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
681 }
682 if let Some(ref token) = configuration.bearer_access_token {
683 req_builder = req_builder.bearer_auth(token.to_owned());
684 };
685 req_builder = req_builder.json(&p_body_admin_rotate_issued_api_key_body);
686
687 let req = req_builder.build()?;
688 let resp = configuration.client.execute(req).await?;
689
690 let status = resp.status();
691 let content_type = resp
692 .headers()
693 .get("content-type")
694 .and_then(|v| v.to_str().ok())
695 .unwrap_or("application/octet-stream");
696 let content_type = super::ContentType::from(content_type);
697
698 if !status.is_client_error() && !status.is_server_error() {
699 let content = resp.text().await?;
700 match content_type {
701 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
702 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RotateIssuedApiKeyResponse`"))),
703 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RotateIssuedApiKeyResponse`")))),
704 }
705 } else {
706 let content = resp.text().await?;
707 let entity: Option<AdminRotateIssuedApiKeyError> = serde_json::from_str(&content).ok();
708 Err(Error::ResponseError(ResponseContent { status, content, entity }))
709 }
710}
711
712pub async fn admin_update_imported_api_key(configuration: &configuration::Configuration, key_id: &str, admin_update_imported_api_key_request: models::AdminUpdateImportedApiKeyRequest, update_mask: Option<&str>) -> Result<models::ImportedApiKey, Error<AdminUpdateImportedApiKeyError>> {
714 let p_path_key_id = key_id;
716 let p_body_admin_update_imported_api_key_request = admin_update_imported_api_key_request;
717 let p_query_update_mask = update_mask;
718
719 let uri_str = format!("{}/v2alpha1/admin/importedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
720 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
721
722 if let Some(ref param_value) = p_query_update_mask {
723 req_builder = req_builder.query(&[("update_mask", ¶m_value.to_string())]);
724 }
725 if let Some(ref user_agent) = configuration.user_agent {
726 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
727 }
728 if let Some(ref token) = configuration.bearer_access_token {
729 req_builder = req_builder.bearer_auth(token.to_owned());
730 };
731 req_builder = req_builder.json(&p_body_admin_update_imported_api_key_request);
732
733 let req = req_builder.build()?;
734 let resp = configuration.client.execute(req).await?;
735
736 let status = resp.status();
737 let content_type = resp
738 .headers()
739 .get("content-type")
740 .and_then(|v| v.to_str().ok())
741 .unwrap_or("application/octet-stream");
742 let content_type = super::ContentType::from(content_type);
743
744 if !status.is_client_error() && !status.is_server_error() {
745 let content = resp.text().await?;
746 match content_type {
747 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
748 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ImportedApiKey`"))),
749 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ImportedApiKey`")))),
750 }
751 } else {
752 let content = resp.text().await?;
753 let entity: Option<AdminUpdateImportedApiKeyError> = serde_json::from_str(&content).ok();
754 Err(Error::ResponseError(ResponseContent { status, content, entity }))
755 }
756}
757
758pub async fn admin_update_issued_api_key(configuration: &configuration::Configuration, key_id: &str, admin_update_issued_api_key_request: models::AdminUpdateIssuedApiKeyRequest, update_mask: Option<&str>) -> Result<models::IssuedApiKey, Error<AdminUpdateIssuedApiKeyError>> {
760 let p_path_key_id = key_id;
762 let p_body_admin_update_issued_api_key_request = admin_update_issued_api_key_request;
763 let p_query_update_mask = update_mask;
764
765 let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
766 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
767
768 if let Some(ref param_value) = p_query_update_mask {
769 req_builder = req_builder.query(&[("update_mask", ¶m_value.to_string())]);
770 }
771 if let Some(ref user_agent) = configuration.user_agent {
772 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
773 }
774 if let Some(ref token) = configuration.bearer_access_token {
775 req_builder = req_builder.bearer_auth(token.to_owned());
776 };
777 req_builder = req_builder.json(&p_body_admin_update_issued_api_key_request);
778
779 let req = req_builder.build()?;
780 let resp = configuration.client.execute(req).await?;
781
782 let status = resp.status();
783 let content_type = resp
784 .headers()
785 .get("content-type")
786 .and_then(|v| v.to_str().ok())
787 .unwrap_or("application/octet-stream");
788 let content_type = super::ContentType::from(content_type);
789
790 if !status.is_client_error() && !status.is_server_error() {
791 let content = resp.text().await?;
792 match content_type {
793 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
794 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IssuedApiKey`"))),
795 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IssuedApiKey`")))),
796 }
797 } else {
798 let content = resp.text().await?;
799 let entity: Option<AdminUpdateIssuedApiKeyError> = serde_json::from_str(&content).ok();
800 Err(Error::ResponseError(ResponseContent { status, content, entity }))
801 }
802}
803
804pub async fn admin_verify_api_key(configuration: &configuration::Configuration, verify_api_key_request: models::VerifyApiKeyRequest, cache_control: Option<&str>, pragma: Option<&str>) -> Result<models::VerifyApiKeyResponse, Error<AdminVerifyApiKeyError>> {
806 let p_body_verify_api_key_request = verify_api_key_request;
808 let p_header_cache_control = cache_control;
809 let p_header_pragma = pragma;
810
811 let uri_str = format!("{}/v2alpha1/admin/apiKeys:verify", configuration.base_path);
812 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
813
814 if let Some(ref user_agent) = configuration.user_agent {
815 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
816 }
817 if let Some(param_value) = p_header_cache_control {
818 req_builder = req_builder.header("Cache-Control", param_value.to_string());
819 }
820 if let Some(param_value) = p_header_pragma {
821 req_builder = req_builder.header("Pragma", param_value.to_string());
822 }
823 if let Some(ref token) = configuration.bearer_access_token {
824 req_builder = req_builder.bearer_auth(token.to_owned());
825 };
826 req_builder = req_builder.json(&p_body_verify_api_key_request);
827
828 let req = req_builder.build()?;
829 let resp = configuration.client.execute(req).await?;
830
831 let status = resp.status();
832 let content_type = resp
833 .headers()
834 .get("content-type")
835 .and_then(|v| v.to_str().ok())
836 .unwrap_or("application/octet-stream");
837 let content_type = super::ContentType::from(content_type);
838
839 if !status.is_client_error() && !status.is_server_error() {
840 let content = resp.text().await?;
841 match content_type {
842 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
843 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerifyApiKeyResponse`"))),
844 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VerifyApiKeyResponse`")))),
845 }
846 } else {
847 let content = resp.text().await?;
848 let entity: Option<AdminVerifyApiKeyError> = serde_json::from_str(&content).ok();
849 Err(Error::ResponseError(ResponseContent { status, content, entity }))
850 }
851}
852
853pub async fn revoke_api_key(configuration: &configuration::Configuration, self_revoke_api_key_request: models::SelfRevokeApiKeyRequest) -> Result<serde_json::Value, Error<RevokeApiKeyError>> {
855 let p_body_self_revoke_api_key_request = self_revoke_api_key_request;
857
858 let uri_str = format!("{}/v2alpha1/apiKeys:selfRevoke", configuration.base_path);
859 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
860
861 if let Some(ref user_agent) = configuration.user_agent {
862 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
863 }
864 req_builder = req_builder.json(&p_body_self_revoke_api_key_request);
865
866 let req = req_builder.build()?;
867 let resp = configuration.client.execute(req).await?;
868
869 let status = resp.status();
870 let content_type = resp
871 .headers()
872 .get("content-type")
873 .and_then(|v| v.to_str().ok())
874 .unwrap_or("application/octet-stream");
875 let content_type = super::ContentType::from(content_type);
876
877 if !status.is_client_error() && !status.is_server_error() {
878 let content = resp.text().await?;
879 match content_type {
880 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
881 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
882 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
883 }
884 } else {
885 let content = resp.text().await?;
886 let entity: Option<RevokeApiKeyError> = serde_json::from_str(&content).ok();
887 Err(Error::ResponseError(ResponseContent { status, content, entity }))
888 }
889}
890