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 AdminBatchCreateImportedApiKeysError {
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 AdminImportApiKeyError {
70 DefaultResponse(models::Status),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum AdminIssueApiKeyError {
78 DefaultResponse(models::Status),
79 UnknownValue(serde_json::Value),
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum AdminListImportedApiKeysError {
86 DefaultResponse(models::Status),
87 UnknownValue(serde_json::Value),
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum AdminListIssuedApiKeysError {
94 DefaultResponse(models::Status),
95 UnknownValue(serde_json::Value),
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum AdminRevokeImportedApiKeyError {
102 DefaultResponse(models::Status),
103 UnknownValue(serde_json::Value),
104}
105
106#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum AdminRevokeIssuedApiKeyError {
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 GetJwksError {
150 DefaultResponse(models::Status),
151 UnknownValue(serde_json::Value),
152}
153
154#[derive(Debug, Clone, Serialize, Deserialize)]
156#[serde(untagged)]
157pub enum RevokeApiKeyError {
158 DefaultResponse(models::Status),
159 UnknownValue(serde_json::Value),
160}
161
162
163pub async fn admin_batch_create_imported_api_keys(configuration: &configuration::Configuration, batch_create_imported_api_keys_request: models::BatchCreateImportedApiKeysRequest) -> Result<models::BatchCreateImportedApiKeysResponse, Error<AdminBatchCreateImportedApiKeysError>> {
165 let p_body_batch_create_imported_api_keys_request = batch_create_imported_api_keys_request;
167
168 let uri_str = format!("{}/v2alpha1/admin/importedApiKeys:batchCreate", configuration.base_path);
169 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
170
171 if let Some(ref user_agent) = configuration.user_agent {
172 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
173 }
174 if let Some(ref token) = configuration.bearer_access_token {
175 req_builder = req_builder.bearer_auth(token.to_owned());
176 };
177 req_builder = req_builder.json(&p_body_batch_create_imported_api_keys_request);
178
179 let req = req_builder.build()?;
180 let resp = configuration.client.execute(req).await?;
181
182 let status = resp.status();
183 let content_type = resp
184 .headers()
185 .get("content-type")
186 .and_then(|v| v.to_str().ok())
187 .unwrap_or("application/octet-stream");
188 let content_type = super::ContentType::from(content_type);
189
190 if !status.is_client_error() && !status.is_server_error() {
191 let content = resp.text().await?;
192 match content_type {
193 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
194 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BatchCreateImportedApiKeysResponse`"))),
195 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::BatchCreateImportedApiKeysResponse`")))),
196 }
197 } else {
198 let content = resp.text().await?;
199 let entity: Option<AdminBatchCreateImportedApiKeysError> = serde_json::from_str(&content).ok();
200 Err(Error::ResponseError(ResponseContent { status, content, entity }))
201 }
202}
203
204pub 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>> {
206 let p_body_batch_verify_api_keys_request = batch_verify_api_keys_request;
208 let p_header_cache_control = cache_control;
209 let p_header_pragma = pragma;
210
211 let uri_str = format!("{}/v2alpha1/admin/apiKeys:batchVerify", configuration.base_path);
212 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
213
214 if let Some(ref user_agent) = configuration.user_agent {
215 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
216 }
217 if let Some(param_value) = p_header_cache_control {
218 req_builder = req_builder.header("Cache-Control", param_value.to_string());
219 }
220 if let Some(param_value) = p_header_pragma {
221 req_builder = req_builder.header("Pragma", param_value.to_string());
222 }
223 if let Some(ref token) = configuration.bearer_access_token {
224 req_builder = req_builder.bearer_auth(token.to_owned());
225 };
226 req_builder = req_builder.json(&p_body_batch_verify_api_keys_request);
227
228 let req = req_builder.build()?;
229 let resp = configuration.client.execute(req).await?;
230
231 let status = resp.status();
232 let content_type = resp
233 .headers()
234 .get("content-type")
235 .and_then(|v| v.to_str().ok())
236 .unwrap_or("application/octet-stream");
237 let content_type = super::ContentType::from(content_type);
238
239 if !status.is_client_error() && !status.is_server_error() {
240 let content = resp.text().await?;
241 match content_type {
242 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
243 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BatchVerifyApiKeysResponse`"))),
244 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`")))),
245 }
246 } else {
247 let content = resp.text().await?;
248 let entity: Option<AdminBatchVerifyApiKeysError> = serde_json::from_str(&content).ok();
249 Err(Error::ResponseError(ResponseContent { status, content, entity }))
250 }
251}
252
253pub async fn admin_delete_imported_api_key(configuration: &configuration::Configuration, key_id: &str) -> Result<serde_json::Value, Error<AdminDeleteImportedApiKeyError>> {
255 let p_path_key_id = key_id;
257
258 let uri_str = format!("{}/v2alpha1/admin/importedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
259 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
260
261 if let Some(ref user_agent) = configuration.user_agent {
262 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
263 }
264 if let Some(ref token) = configuration.bearer_access_token {
265 req_builder = req_builder.bearer_auth(token.to_owned());
266 };
267
268 let req = req_builder.build()?;
269 let resp = configuration.client.execute(req).await?;
270
271 let status = resp.status();
272 let content_type = resp
273 .headers()
274 .get("content-type")
275 .and_then(|v| v.to_str().ok())
276 .unwrap_or("application/octet-stream");
277 let content_type = super::ContentType::from(content_type);
278
279 if !status.is_client_error() && !status.is_server_error() {
280 let content = resp.text().await?;
281 match content_type {
282 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
283 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
284 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`")))),
285 }
286 } else {
287 let content = resp.text().await?;
288 let entity: Option<AdminDeleteImportedApiKeyError> = serde_json::from_str(&content).ok();
289 Err(Error::ResponseError(ResponseContent { status, content, entity }))
290 }
291}
292
293pub async fn admin_derive_token(configuration: &configuration::Configuration, derive_token_request: models::DeriveTokenRequest) -> Result<models::DeriveTokenResponse, Error<AdminDeriveTokenError>> {
295 let p_body_derive_token_request = derive_token_request;
297
298 let uri_str = format!("{}/v2alpha1/admin/apiKeys:derive", configuration.base_path);
299 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
300
301 if let Some(ref user_agent) = configuration.user_agent {
302 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
303 }
304 if let Some(ref token) = configuration.bearer_access_token {
305 req_builder = req_builder.bearer_auth(token.to_owned());
306 };
307 req_builder = req_builder.json(&p_body_derive_token_request);
308
309 let req = req_builder.build()?;
310 let resp = configuration.client.execute(req).await?;
311
312 let status = resp.status();
313 let content_type = resp
314 .headers()
315 .get("content-type")
316 .and_then(|v| v.to_str().ok())
317 .unwrap_or("application/octet-stream");
318 let content_type = super::ContentType::from(content_type);
319
320 if !status.is_client_error() && !status.is_server_error() {
321 let content = resp.text().await?;
322 match content_type {
323 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
324 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeriveTokenResponse`"))),
325 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`")))),
326 }
327 } else {
328 let content = resp.text().await?;
329 let entity: Option<AdminDeriveTokenError> = serde_json::from_str(&content).ok();
330 Err(Error::ResponseError(ResponseContent { status, content, entity }))
331 }
332}
333
334pub async fn admin_get_imported_api_key(configuration: &configuration::Configuration, key_id: &str) -> Result<models::ImportedApiKey, Error<AdminGetImportedApiKeyError>> {
336 let p_path_key_id = key_id;
338
339 let uri_str = format!("{}/v2alpha1/admin/importedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
340 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
341
342 if let Some(ref user_agent) = configuration.user_agent {
343 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
344 }
345 if let Some(ref token) = configuration.bearer_access_token {
346 req_builder = req_builder.bearer_auth(token.to_owned());
347 };
348
349 let req = req_builder.build()?;
350 let resp = configuration.client.execute(req).await?;
351
352 let status = resp.status();
353 let content_type = resp
354 .headers()
355 .get("content-type")
356 .and_then(|v| v.to_str().ok())
357 .unwrap_or("application/octet-stream");
358 let content_type = super::ContentType::from(content_type);
359
360 if !status.is_client_error() && !status.is_server_error() {
361 let content = resp.text().await?;
362 match content_type {
363 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
364 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ImportedApiKey`"))),
365 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`")))),
366 }
367 } else {
368 let content = resp.text().await?;
369 let entity: Option<AdminGetImportedApiKeyError> = serde_json::from_str(&content).ok();
370 Err(Error::ResponseError(ResponseContent { status, content, entity }))
371 }
372}
373
374pub async fn admin_get_issued_api_key(configuration: &configuration::Configuration, key_id: &str) -> Result<models::IssuedApiKey, Error<AdminGetIssuedApiKeyError>> {
376 let p_path_key_id = key_id;
378
379 let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
380 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
381
382 if let Some(ref user_agent) = configuration.user_agent {
383 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
384 }
385 if let Some(ref token) = configuration.bearer_access_token {
386 req_builder = req_builder.bearer_auth(token.to_owned());
387 };
388
389 let req = req_builder.build()?;
390 let resp = configuration.client.execute(req).await?;
391
392 let status = resp.status();
393 let content_type = resp
394 .headers()
395 .get("content-type")
396 .and_then(|v| v.to_str().ok())
397 .unwrap_or("application/octet-stream");
398 let content_type = super::ContentType::from(content_type);
399
400 if !status.is_client_error() && !status.is_server_error() {
401 let content = resp.text().await?;
402 match content_type {
403 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
404 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IssuedApiKey`"))),
405 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`")))),
406 }
407 } else {
408 let content = resp.text().await?;
409 let entity: Option<AdminGetIssuedApiKeyError> = serde_json::from_str(&content).ok();
410 Err(Error::ResponseError(ResponseContent { status, content, entity }))
411 }
412}
413
414pub async fn admin_import_api_key(configuration: &configuration::Configuration, import_api_key_request: models::ImportApiKeyRequest) -> Result<models::ImportedApiKey, Error<AdminImportApiKeyError>> {
416 let p_body_import_api_key_request = import_api_key_request;
418
419 let uri_str = format!("{}/v2alpha1/admin/importedApiKeys", configuration.base_path);
420 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
421
422 if let Some(ref user_agent) = configuration.user_agent {
423 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
424 }
425 if let Some(ref token) = configuration.bearer_access_token {
426 req_builder = req_builder.bearer_auth(token.to_owned());
427 };
428 req_builder = req_builder.json(&p_body_import_api_key_request);
429
430 let req = req_builder.build()?;
431 let resp = configuration.client.execute(req).await?;
432
433 let status = resp.status();
434 let content_type = resp
435 .headers()
436 .get("content-type")
437 .and_then(|v| v.to_str().ok())
438 .unwrap_or("application/octet-stream");
439 let content_type = super::ContentType::from(content_type);
440
441 if !status.is_client_error() && !status.is_server_error() {
442 let content = resp.text().await?;
443 match content_type {
444 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
445 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ImportedApiKey`"))),
446 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`")))),
447 }
448 } else {
449 let content = resp.text().await?;
450 let entity: Option<AdminImportApiKeyError> = serde_json::from_str(&content).ok();
451 Err(Error::ResponseError(ResponseContent { status, content, entity }))
452 }
453}
454
455pub async fn admin_issue_api_key(configuration: &configuration::Configuration, issue_api_key_request: models::IssueApiKeyRequest) -> Result<models::IssueApiKeyResponse, Error<AdminIssueApiKeyError>> {
457 let p_body_issue_api_key_request = issue_api_key_request;
459
460 let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys", configuration.base_path);
461 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
462
463 if let Some(ref user_agent) = configuration.user_agent {
464 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
465 }
466 if let Some(ref token) = configuration.bearer_access_token {
467 req_builder = req_builder.bearer_auth(token.to_owned());
468 };
469 req_builder = req_builder.json(&p_body_issue_api_key_request);
470
471 let req = req_builder.build()?;
472 let resp = configuration.client.execute(req).await?;
473
474 let status = resp.status();
475 let content_type = resp
476 .headers()
477 .get("content-type")
478 .and_then(|v| v.to_str().ok())
479 .unwrap_or("application/octet-stream");
480 let content_type = super::ContentType::from(content_type);
481
482 if !status.is_client_error() && !status.is_server_error() {
483 let content = resp.text().await?;
484 match content_type {
485 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
486 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IssueApiKeyResponse`"))),
487 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`")))),
488 }
489 } else {
490 let content = resp.text().await?;
491 let entity: Option<AdminIssueApiKeyError> = serde_json::from_str(&content).ok();
492 Err(Error::ResponseError(ResponseContent { status, content, entity }))
493 }
494}
495
496pub 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>> {
498 let p_query_page_size = page_size;
500 let p_query_page_token = page_token;
501 let p_query_filter = filter;
502
503 let uri_str = format!("{}/v2alpha1/admin/importedApiKeys", configuration.base_path);
504 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
505
506 if let Some(ref param_value) = p_query_page_size {
507 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
508 }
509 if let Some(ref param_value) = p_query_page_token {
510 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
511 }
512 if let Some(ref param_value) = p_query_filter {
513 req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
514 }
515 if let Some(ref user_agent) = configuration.user_agent {
516 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
517 }
518 if let Some(ref token) = configuration.bearer_access_token {
519 req_builder = req_builder.bearer_auth(token.to_owned());
520 };
521
522 let req = req_builder.build()?;
523 let resp = configuration.client.execute(req).await?;
524
525 let status = resp.status();
526 let content_type = resp
527 .headers()
528 .get("content-type")
529 .and_then(|v| v.to_str().ok())
530 .unwrap_or("application/octet-stream");
531 let content_type = super::ContentType::from(content_type);
532
533 if !status.is_client_error() && !status.is_server_error() {
534 let content = resp.text().await?;
535 match content_type {
536 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
537 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListImportedApiKeysResponse`"))),
538 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`")))),
539 }
540 } else {
541 let content = resp.text().await?;
542 let entity: Option<AdminListImportedApiKeysError> = serde_json::from_str(&content).ok();
543 Err(Error::ResponseError(ResponseContent { status, content, entity }))
544 }
545}
546
547pub 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>> {
549 let p_query_page_size = page_size;
551 let p_query_page_token = page_token;
552 let p_query_filter = filter;
553
554 let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys", configuration.base_path);
555 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
556
557 if let Some(ref param_value) = p_query_page_size {
558 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
559 }
560 if let Some(ref param_value) = p_query_page_token {
561 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
562 }
563 if let Some(ref param_value) = p_query_filter {
564 req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
565 }
566 if let Some(ref user_agent) = configuration.user_agent {
567 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
568 }
569 if let Some(ref token) = configuration.bearer_access_token {
570 req_builder = req_builder.bearer_auth(token.to_owned());
571 };
572
573 let req = req_builder.build()?;
574 let resp = configuration.client.execute(req).await?;
575
576 let status = resp.status();
577 let content_type = resp
578 .headers()
579 .get("content-type")
580 .and_then(|v| v.to_str().ok())
581 .unwrap_or("application/octet-stream");
582 let content_type = super::ContentType::from(content_type);
583
584 if !status.is_client_error() && !status.is_server_error() {
585 let content = resp.text().await?;
586 match content_type {
587 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
588 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListIssuedApiKeysResponse`"))),
589 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`")))),
590 }
591 } else {
592 let content = resp.text().await?;
593 let entity: Option<AdminListIssuedApiKeysError> = serde_json::from_str(&content).ok();
594 Err(Error::ResponseError(ResponseContent { status, content, entity }))
595 }
596}
597
598pub async fn admin_revoke_imported_api_key(configuration: &configuration::Configuration, key_id: &str, admin_revoke_imported_api_key_body: models::AdminRevokeImportedApiKeyBody) -> Result<serde_json::Value, Error<AdminRevokeImportedApiKeyError>> {
600 let p_path_key_id = key_id;
602 let p_body_admin_revoke_imported_api_key_body = admin_revoke_imported_api_key_body;
603
604 let uri_str = format!("{}/v2alpha1/admin/importedApiKeys/{key_id}:revoke", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
605 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
606
607 if let Some(ref user_agent) = configuration.user_agent {
608 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
609 }
610 if let Some(ref token) = configuration.bearer_access_token {
611 req_builder = req_builder.bearer_auth(token.to_owned());
612 };
613 req_builder = req_builder.json(&p_body_admin_revoke_imported_api_key_body);
614
615 let req = req_builder.build()?;
616 let resp = configuration.client.execute(req).await?;
617
618 let status = resp.status();
619 let content_type = resp
620 .headers()
621 .get("content-type")
622 .and_then(|v| v.to_str().ok())
623 .unwrap_or("application/octet-stream");
624 let content_type = super::ContentType::from(content_type);
625
626 if !status.is_client_error() && !status.is_server_error() {
627 let content = resp.text().await?;
628 match content_type {
629 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
630 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
631 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`")))),
632 }
633 } else {
634 let content = resp.text().await?;
635 let entity: Option<AdminRevokeImportedApiKeyError> = serde_json::from_str(&content).ok();
636 Err(Error::ResponseError(ResponseContent { status, content, entity }))
637 }
638}
639
640pub async fn admin_revoke_issued_api_key(configuration: &configuration::Configuration, key_id: &str, admin_revoke_issued_api_key_body: models::AdminRevokeIssuedApiKeyBody) -> Result<serde_json::Value, Error<AdminRevokeIssuedApiKeyError>> {
642 let p_path_key_id = key_id;
644 let p_body_admin_revoke_issued_api_key_body = admin_revoke_issued_api_key_body;
645
646 let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys/{key_id}:revoke", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
647 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
648
649 if let Some(ref user_agent) = configuration.user_agent {
650 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
651 }
652 if let Some(ref token) = configuration.bearer_access_token {
653 req_builder = req_builder.bearer_auth(token.to_owned());
654 };
655 req_builder = req_builder.json(&p_body_admin_revoke_issued_api_key_body);
656
657 let req = req_builder.build()?;
658 let resp = configuration.client.execute(req).await?;
659
660 let status = resp.status();
661 let content_type = resp
662 .headers()
663 .get("content-type")
664 .and_then(|v| v.to_str().ok())
665 .unwrap_or("application/octet-stream");
666 let content_type = super::ContentType::from(content_type);
667
668 if !status.is_client_error() && !status.is_server_error() {
669 let content = resp.text().await?;
670 match content_type {
671 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
672 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
673 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`")))),
674 }
675 } else {
676 let content = resp.text().await?;
677 let entity: Option<AdminRevokeIssuedApiKeyError> = serde_json::from_str(&content).ok();
678 Err(Error::ResponseError(ResponseContent { status, content, entity }))
679 }
680}
681
682pub 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>> {
684 let p_path_key_id = key_id;
686 let p_body_admin_rotate_issued_api_key_body = admin_rotate_issued_api_key_body;
687
688 let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys/{key_id}:rotate", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
689 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
690
691 if let Some(ref user_agent) = configuration.user_agent {
692 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
693 }
694 if let Some(ref token) = configuration.bearer_access_token {
695 req_builder = req_builder.bearer_auth(token.to_owned());
696 };
697 req_builder = req_builder.json(&p_body_admin_rotate_issued_api_key_body);
698
699 let req = req_builder.build()?;
700 let resp = configuration.client.execute(req).await?;
701
702 let status = resp.status();
703 let content_type = resp
704 .headers()
705 .get("content-type")
706 .and_then(|v| v.to_str().ok())
707 .unwrap_or("application/octet-stream");
708 let content_type = super::ContentType::from(content_type);
709
710 if !status.is_client_error() && !status.is_server_error() {
711 let content = resp.text().await?;
712 match content_type {
713 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
714 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RotateIssuedApiKeyResponse`"))),
715 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`")))),
716 }
717 } else {
718 let content = resp.text().await?;
719 let entity: Option<AdminRotateIssuedApiKeyError> = serde_json::from_str(&content).ok();
720 Err(Error::ResponseError(ResponseContent { status, content, entity }))
721 }
722}
723
724pub 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>> {
726 let p_path_key_id = key_id;
728 let p_body_admin_update_imported_api_key_request = admin_update_imported_api_key_request;
729 let p_query_update_mask = update_mask;
730
731 let uri_str = format!("{}/v2alpha1/admin/importedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
732 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
733
734 if let Some(ref param_value) = p_query_update_mask {
735 req_builder = req_builder.query(&[("update_mask", ¶m_value.to_string())]);
736 }
737 if let Some(ref user_agent) = configuration.user_agent {
738 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
739 }
740 if let Some(ref token) = configuration.bearer_access_token {
741 req_builder = req_builder.bearer_auth(token.to_owned());
742 };
743 req_builder = req_builder.json(&p_body_admin_update_imported_api_key_request);
744
745 let req = req_builder.build()?;
746 let resp = configuration.client.execute(req).await?;
747
748 let status = resp.status();
749 let content_type = resp
750 .headers()
751 .get("content-type")
752 .and_then(|v| v.to_str().ok())
753 .unwrap_or("application/octet-stream");
754 let content_type = super::ContentType::from(content_type);
755
756 if !status.is_client_error() && !status.is_server_error() {
757 let content = resp.text().await?;
758 match content_type {
759 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
760 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ImportedApiKey`"))),
761 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`")))),
762 }
763 } else {
764 let content = resp.text().await?;
765 let entity: Option<AdminUpdateImportedApiKeyError> = serde_json::from_str(&content).ok();
766 Err(Error::ResponseError(ResponseContent { status, content, entity }))
767 }
768}
769
770pub 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>> {
772 let p_path_key_id = key_id;
774 let p_body_admin_update_issued_api_key_request = admin_update_issued_api_key_request;
775 let p_query_update_mask = update_mask;
776
777 let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
778 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
779
780 if let Some(ref param_value) = p_query_update_mask {
781 req_builder = req_builder.query(&[("update_mask", ¶m_value.to_string())]);
782 }
783 if let Some(ref user_agent) = configuration.user_agent {
784 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
785 }
786 if let Some(ref token) = configuration.bearer_access_token {
787 req_builder = req_builder.bearer_auth(token.to_owned());
788 };
789 req_builder = req_builder.json(&p_body_admin_update_issued_api_key_request);
790
791 let req = req_builder.build()?;
792 let resp = configuration.client.execute(req).await?;
793
794 let status = resp.status();
795 let content_type = resp
796 .headers()
797 .get("content-type")
798 .and_then(|v| v.to_str().ok())
799 .unwrap_or("application/octet-stream");
800 let content_type = super::ContentType::from(content_type);
801
802 if !status.is_client_error() && !status.is_server_error() {
803 let content = resp.text().await?;
804 match content_type {
805 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
806 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IssuedApiKey`"))),
807 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`")))),
808 }
809 } else {
810 let content = resp.text().await?;
811 let entity: Option<AdminUpdateIssuedApiKeyError> = serde_json::from_str(&content).ok();
812 Err(Error::ResponseError(ResponseContent { status, content, entity }))
813 }
814}
815
816pub 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>> {
818 let p_body_verify_api_key_request = verify_api_key_request;
820 let p_header_cache_control = cache_control;
821 let p_header_pragma = pragma;
822
823 let uri_str = format!("{}/v2alpha1/admin/apiKeys:verify", configuration.base_path);
824 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
825
826 if let Some(ref user_agent) = configuration.user_agent {
827 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
828 }
829 if let Some(param_value) = p_header_cache_control {
830 req_builder = req_builder.header("Cache-Control", param_value.to_string());
831 }
832 if let Some(param_value) = p_header_pragma {
833 req_builder = req_builder.header("Pragma", param_value.to_string());
834 }
835 if let Some(ref token) = configuration.bearer_access_token {
836 req_builder = req_builder.bearer_auth(token.to_owned());
837 };
838 req_builder = req_builder.json(&p_body_verify_api_key_request);
839
840 let req = req_builder.build()?;
841 let resp = configuration.client.execute(req).await?;
842
843 let status = resp.status();
844 let content_type = resp
845 .headers()
846 .get("content-type")
847 .and_then(|v| v.to_str().ok())
848 .unwrap_or("application/octet-stream");
849 let content_type = super::ContentType::from(content_type);
850
851 if !status.is_client_error() && !status.is_server_error() {
852 let content = resp.text().await?;
853 match content_type {
854 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
855 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerifyApiKeyResponse`"))),
856 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`")))),
857 }
858 } else {
859 let content = resp.text().await?;
860 let entity: Option<AdminVerifyApiKeyError> = serde_json::from_str(&content).ok();
861 Err(Error::ResponseError(ResponseContent { status, content, entity }))
862 }
863}
864
865pub async fn get_jwks(configuration: &configuration::Configuration, ) -> Result<models::GetJwksResponse, Error<GetJwksError>> {
867
868 let uri_str = format!("{}/v2alpha1/derivedKeys/jwks.json", configuration.base_path);
869 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
870
871 if let Some(ref user_agent) = configuration.user_agent {
872 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
873 }
874
875 let req = req_builder.build()?;
876 let resp = configuration.client.execute(req).await?;
877
878 let status = resp.status();
879 let content_type = resp
880 .headers()
881 .get("content-type")
882 .and_then(|v| v.to_str().ok())
883 .unwrap_or("application/octet-stream");
884 let content_type = super::ContentType::from(content_type);
885
886 if !status.is_client_error() && !status.is_server_error() {
887 let content = resp.text().await?;
888 match content_type {
889 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
890 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetJwksResponse`"))),
891 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`")))),
892 }
893 } else {
894 let content = resp.text().await?;
895 let entity: Option<GetJwksError> = serde_json::from_str(&content).ok();
896 Err(Error::ResponseError(ResponseContent { status, content, entity }))
897 }
898}
899
900pub async fn revoke_api_key(configuration: &configuration::Configuration, self_revoke_api_key_request: models::SelfRevokeApiKeyRequest) -> Result<serde_json::Value, Error<RevokeApiKeyError>> {
902 let p_body_self_revoke_api_key_request = self_revoke_api_key_request;
904
905 let uri_str = format!("{}/v2alpha1/apiKeys:selfRevoke", configuration.base_path);
906 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
907
908 if let Some(ref user_agent) = configuration.user_agent {
909 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
910 }
911 req_builder = req_builder.json(&p_body_self_revoke_api_key_request);
912
913 let req = req_builder.build()?;
914 let resp = configuration.client.execute(req).await?;
915
916 let status = resp.status();
917 let content_type = resp
918 .headers()
919 .get("content-type")
920 .and_then(|v| v.to_str().ok())
921 .unwrap_or("application/octet-stream");
922 let content_type = super::ContentType::from(content_type);
923
924 if !status.is_client_error() && !status.is_server_error() {
925 let content = resp.text().await?;
926 match content_type {
927 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
928 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
929 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`")))),
930 }
931 } else {
932 let content = resp.text().await?;
933 let entity: Option<RevokeApiKeyError> = serde_json::from_str(&content).ok();
934 Err(Error::ResponseError(ResponseContent { status, content, entity }))
935 }
936}
937