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 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 AdminRevokeApiKeyError {
102 DefaultResponse(models::Status),
103 UnknownValue(serde_json::Value),
104}
105
106#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum AdminRotateIssuedApiKeyError {
110 DefaultResponse(models::Status),
111 UnknownValue(serde_json::Value),
112}
113
114#[derive(Debug, Clone, Serialize, Deserialize)]
116#[serde(untagged)]
117pub enum AdminUpdateImportedApiKeyError {
118 DefaultResponse(models::Status),
119 UnknownValue(serde_json::Value),
120}
121
122#[derive(Debug, Clone, Serialize, Deserialize)]
124#[serde(untagged)]
125pub enum AdminUpdateIssuedApiKeyError {
126 DefaultResponse(models::Status),
127 UnknownValue(serde_json::Value),
128}
129
130#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum AdminVerifyApiKeyError {
134 DefaultResponse(models::Status),
135 UnknownValue(serde_json::Value),
136}
137
138#[derive(Debug, Clone, Serialize, Deserialize)]
140#[serde(untagged)]
141pub enum GetJwksError {
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_import_api_key(configuration: &configuration::Configuration, import_api_key_request: models::ImportApiKeyRequest) -> Result<models::ImportedApiKey, Error<AdminImportApiKeyError>> {
408 let p_body_import_api_key_request = import_api_key_request;
410
411 let uri_str = format!("{}/v2alpha1/admin/importedApiKeys", configuration.base_path);
412 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
413
414 if let Some(ref user_agent) = configuration.user_agent {
415 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
416 }
417 if let Some(ref token) = configuration.bearer_access_token {
418 req_builder = req_builder.bearer_auth(token.to_owned());
419 };
420 req_builder = req_builder.json(&p_body_import_api_key_request);
421
422 let req = req_builder.build()?;
423 let resp = configuration.client.execute(req).await?;
424
425 let status = resp.status();
426 let content_type = resp
427 .headers()
428 .get("content-type")
429 .and_then(|v| v.to_str().ok())
430 .unwrap_or("application/octet-stream");
431 let content_type = super::ContentType::from(content_type);
432
433 if !status.is_client_error() && !status.is_server_error() {
434 let content = resp.text().await?;
435 match content_type {
436 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
437 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ImportedApiKey`"))),
438 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`")))),
439 }
440 } else {
441 let content = resp.text().await?;
442 let entity: Option<AdminImportApiKeyError> = serde_json::from_str(&content).ok();
443 Err(Error::ResponseError(ResponseContent { status, content, entity }))
444 }
445}
446
447pub async fn admin_issue_api_key(configuration: &configuration::Configuration, issue_api_key_request: models::IssueApiKeyRequest) -> Result<models::IssueApiKeyResponse, Error<AdminIssueApiKeyError>> {
449 let p_body_issue_api_key_request = issue_api_key_request;
451
452 let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys", configuration.base_path);
453 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
454
455 if let Some(ref user_agent) = configuration.user_agent {
456 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
457 }
458 if let Some(ref token) = configuration.bearer_access_token {
459 req_builder = req_builder.bearer_auth(token.to_owned());
460 };
461 req_builder = req_builder.json(&p_body_issue_api_key_request);
462
463 let req = req_builder.build()?;
464 let resp = configuration.client.execute(req).await?;
465
466 let status = resp.status();
467 let content_type = resp
468 .headers()
469 .get("content-type")
470 .and_then(|v| v.to_str().ok())
471 .unwrap_or("application/octet-stream");
472 let content_type = super::ContentType::from(content_type);
473
474 if !status.is_client_error() && !status.is_server_error() {
475 let content = resp.text().await?;
476 match content_type {
477 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
478 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IssueApiKeyResponse`"))),
479 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`")))),
480 }
481 } else {
482 let content = resp.text().await?;
483 let entity: Option<AdminIssueApiKeyError> = serde_json::from_str(&content).ok();
484 Err(Error::ResponseError(ResponseContent { status, content, entity }))
485 }
486}
487
488pub 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>> {
490 let p_query_page_size = page_size;
492 let p_query_page_token = page_token;
493 let p_query_filter = filter;
494
495 let uri_str = format!("{}/v2alpha1/admin/importedApiKeys", configuration.base_path);
496 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
497
498 if let Some(ref param_value) = p_query_page_size {
499 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
500 }
501 if let Some(ref param_value) = p_query_page_token {
502 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
503 }
504 if let Some(ref param_value) = p_query_filter {
505 req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
506 }
507 if let Some(ref user_agent) = configuration.user_agent {
508 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
509 }
510 if let Some(ref token) = configuration.bearer_access_token {
511 req_builder = req_builder.bearer_auth(token.to_owned());
512 };
513
514 let req = req_builder.build()?;
515 let resp = configuration.client.execute(req).await?;
516
517 let status = resp.status();
518 let content_type = resp
519 .headers()
520 .get("content-type")
521 .and_then(|v| v.to_str().ok())
522 .unwrap_or("application/octet-stream");
523 let content_type = super::ContentType::from(content_type);
524
525 if !status.is_client_error() && !status.is_server_error() {
526 let content = resp.text().await?;
527 match content_type {
528 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
529 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListImportedApiKeysResponse`"))),
530 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`")))),
531 }
532 } else {
533 let content = resp.text().await?;
534 let entity: Option<AdminListImportedApiKeysError> = serde_json::from_str(&content).ok();
535 Err(Error::ResponseError(ResponseContent { status, content, entity }))
536 }
537}
538
539pub 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>> {
541 let p_query_page_size = page_size;
543 let p_query_page_token = page_token;
544 let p_query_filter = filter;
545
546 let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys", configuration.base_path);
547 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
548
549 if let Some(ref param_value) = p_query_page_size {
550 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
551 }
552 if let Some(ref param_value) = p_query_page_token {
553 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
554 }
555 if let Some(ref param_value) = p_query_filter {
556 req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
557 }
558 if let Some(ref user_agent) = configuration.user_agent {
559 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
560 }
561 if let Some(ref token) = configuration.bearer_access_token {
562 req_builder = req_builder.bearer_auth(token.to_owned());
563 };
564
565 let req = req_builder.build()?;
566 let resp = configuration.client.execute(req).await?;
567
568 let status = resp.status();
569 let content_type = resp
570 .headers()
571 .get("content-type")
572 .and_then(|v| v.to_str().ok())
573 .unwrap_or("application/octet-stream");
574 let content_type = super::ContentType::from(content_type);
575
576 if !status.is_client_error() && !status.is_server_error() {
577 let content = resp.text().await?;
578 match content_type {
579 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
580 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListIssuedApiKeysResponse`"))),
581 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`")))),
582 }
583 } else {
584 let content = resp.text().await?;
585 let entity: Option<AdminListIssuedApiKeysError> = serde_json::from_str(&content).ok();
586 Err(Error::ResponseError(ResponseContent { status, content, entity }))
587 }
588}
589
590pub 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>> {
592 let p_path_key_id = key_id;
594 let p_body_admin_revoke_api_key_body = admin_revoke_api_key_body;
595
596 let uri_str = format!("{}/v2alpha1/admin/apiKeys/{key_id}:revoke", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
597 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
598
599 if let Some(ref user_agent) = configuration.user_agent {
600 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
601 }
602 if let Some(ref token) = configuration.bearer_access_token {
603 req_builder = req_builder.bearer_auth(token.to_owned());
604 };
605 req_builder = req_builder.json(&p_body_admin_revoke_api_key_body);
606
607 let req = req_builder.build()?;
608 let resp = configuration.client.execute(req).await?;
609
610 let status = resp.status();
611 let content_type = resp
612 .headers()
613 .get("content-type")
614 .and_then(|v| v.to_str().ok())
615 .unwrap_or("application/octet-stream");
616 let content_type = super::ContentType::from(content_type);
617
618 if !status.is_client_error() && !status.is_server_error() {
619 let content = resp.text().await?;
620 match content_type {
621 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
622 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
623 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`")))),
624 }
625 } else {
626 let content = resp.text().await?;
627 let entity: Option<AdminRevokeApiKeyError> = serde_json::from_str(&content).ok();
628 Err(Error::ResponseError(ResponseContent { status, content, entity }))
629 }
630}
631
632pub 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>> {
634 let p_path_key_id = key_id;
636 let p_body_admin_rotate_issued_api_key_body = admin_rotate_issued_api_key_body;
637
638 let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys/{key_id}:rotate", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
639 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
640
641 if let Some(ref user_agent) = configuration.user_agent {
642 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
643 }
644 if let Some(ref token) = configuration.bearer_access_token {
645 req_builder = req_builder.bearer_auth(token.to_owned());
646 };
647 req_builder = req_builder.json(&p_body_admin_rotate_issued_api_key_body);
648
649 let req = req_builder.build()?;
650 let resp = configuration.client.execute(req).await?;
651
652 let status = resp.status();
653 let content_type = resp
654 .headers()
655 .get("content-type")
656 .and_then(|v| v.to_str().ok())
657 .unwrap_or("application/octet-stream");
658 let content_type = super::ContentType::from(content_type);
659
660 if !status.is_client_error() && !status.is_server_error() {
661 let content = resp.text().await?;
662 match content_type {
663 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
664 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RotateIssuedApiKeyResponse`"))),
665 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`")))),
666 }
667 } else {
668 let content = resp.text().await?;
669 let entity: Option<AdminRotateIssuedApiKeyError> = serde_json::from_str(&content).ok();
670 Err(Error::ResponseError(ResponseContent { status, content, entity }))
671 }
672}
673
674pub 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>> {
676 let p_path_key_id = key_id;
678 let p_body_admin_update_imported_api_key_request = admin_update_imported_api_key_request;
679 let p_query_update_mask = update_mask;
680
681 let uri_str = format!("{}/v2alpha1/admin/importedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
682 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
683
684 if let Some(ref param_value) = p_query_update_mask {
685 req_builder = req_builder.query(&[("update_mask", ¶m_value.to_string())]);
686 }
687 if let Some(ref user_agent) = configuration.user_agent {
688 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
689 }
690 if let Some(ref token) = configuration.bearer_access_token {
691 req_builder = req_builder.bearer_auth(token.to_owned());
692 };
693 req_builder = req_builder.json(&p_body_admin_update_imported_api_key_request);
694
695 let req = req_builder.build()?;
696 let resp = configuration.client.execute(req).await?;
697
698 let status = resp.status();
699 let content_type = resp
700 .headers()
701 .get("content-type")
702 .and_then(|v| v.to_str().ok())
703 .unwrap_or("application/octet-stream");
704 let content_type = super::ContentType::from(content_type);
705
706 if !status.is_client_error() && !status.is_server_error() {
707 let content = resp.text().await?;
708 match content_type {
709 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
710 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ImportedApiKey`"))),
711 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`")))),
712 }
713 } else {
714 let content = resp.text().await?;
715 let entity: Option<AdminUpdateImportedApiKeyError> = serde_json::from_str(&content).ok();
716 Err(Error::ResponseError(ResponseContent { status, content, entity }))
717 }
718}
719
720pub 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>> {
722 let p_path_key_id = key_id;
724 let p_body_admin_update_issued_api_key_request = admin_update_issued_api_key_request;
725 let p_query_update_mask = update_mask;
726
727 let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
728 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
729
730 if let Some(ref param_value) = p_query_update_mask {
731 req_builder = req_builder.query(&[("update_mask", ¶m_value.to_string())]);
732 }
733 if let Some(ref user_agent) = configuration.user_agent {
734 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
735 }
736 if let Some(ref token) = configuration.bearer_access_token {
737 req_builder = req_builder.bearer_auth(token.to_owned());
738 };
739 req_builder = req_builder.json(&p_body_admin_update_issued_api_key_request);
740
741 let req = req_builder.build()?;
742 let resp = configuration.client.execute(req).await?;
743
744 let status = resp.status();
745 let content_type = resp
746 .headers()
747 .get("content-type")
748 .and_then(|v| v.to_str().ok())
749 .unwrap_or("application/octet-stream");
750 let content_type = super::ContentType::from(content_type);
751
752 if !status.is_client_error() && !status.is_server_error() {
753 let content = resp.text().await?;
754 match content_type {
755 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
756 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IssuedApiKey`"))),
757 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`")))),
758 }
759 } else {
760 let content = resp.text().await?;
761 let entity: Option<AdminUpdateIssuedApiKeyError> = serde_json::from_str(&content).ok();
762 Err(Error::ResponseError(ResponseContent { status, content, entity }))
763 }
764}
765
766pub 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>> {
768 let p_body_verify_api_key_request = verify_api_key_request;
770 let p_header_cache_control = cache_control;
771 let p_header_pragma = pragma;
772
773 let uri_str = format!("{}/v2alpha1/admin/apiKeys:verify", configuration.base_path);
774 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
775
776 if let Some(ref user_agent) = configuration.user_agent {
777 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
778 }
779 if let Some(param_value) = p_header_cache_control {
780 req_builder = req_builder.header("Cache-Control", param_value.to_string());
781 }
782 if let Some(param_value) = p_header_pragma {
783 req_builder = req_builder.header("Pragma", param_value.to_string());
784 }
785 if let Some(ref token) = configuration.bearer_access_token {
786 req_builder = req_builder.bearer_auth(token.to_owned());
787 };
788 req_builder = req_builder.json(&p_body_verify_api_key_request);
789
790 let req = req_builder.build()?;
791 let resp = configuration.client.execute(req).await?;
792
793 let status = resp.status();
794 let content_type = resp
795 .headers()
796 .get("content-type")
797 .and_then(|v| v.to_str().ok())
798 .unwrap_or("application/octet-stream");
799 let content_type = super::ContentType::from(content_type);
800
801 if !status.is_client_error() && !status.is_server_error() {
802 let content = resp.text().await?;
803 match content_type {
804 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
805 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerifyApiKeyResponse`"))),
806 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`")))),
807 }
808 } else {
809 let content = resp.text().await?;
810 let entity: Option<AdminVerifyApiKeyError> = serde_json::from_str(&content).ok();
811 Err(Error::ResponseError(ResponseContent { status, content, entity }))
812 }
813}
814
815pub async fn get_jwks(configuration: &configuration::Configuration, ) -> Result<models::GetJwksResponse, Error<GetJwksError>> {
817
818 let uri_str = format!("{}/v2alpha1/derivedKeys/jwks.json", configuration.base_path);
819 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
820
821 if let Some(ref user_agent) = configuration.user_agent {
822 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
823 }
824
825 let req = req_builder.build()?;
826 let resp = configuration.client.execute(req).await?;
827
828 let status = resp.status();
829 let content_type = resp
830 .headers()
831 .get("content-type")
832 .and_then(|v| v.to_str().ok())
833 .unwrap_or("application/octet-stream");
834 let content_type = super::ContentType::from(content_type);
835
836 if !status.is_client_error() && !status.is_server_error() {
837 let content = resp.text().await?;
838 match content_type {
839 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
840 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetJwksResponse`"))),
841 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`")))),
842 }
843 } else {
844 let content = resp.text().await?;
845 let entity: Option<GetJwksError> = serde_json::from_str(&content).ok();
846 Err(Error::ResponseError(ResponseContent { status, content, entity }))
847 }
848}
849
850pub async fn revoke_api_key(configuration: &configuration::Configuration, self_revoke_api_key_request: models::SelfRevokeApiKeyRequest) -> Result<serde_json::Value, Error<RevokeApiKeyError>> {
852 let p_body_self_revoke_api_key_request = self_revoke_api_key_request;
854
855 let uri_str = format!("{}/v2alpha1/apiKeys:selfRevoke", configuration.base_path);
856 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
857
858 if let Some(ref user_agent) = configuration.user_agent {
859 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
860 }
861 req_builder = req_builder.json(&p_body_self_revoke_api_key_request);
862
863 let req = req_builder.build()?;
864 let resp = configuration.client.execute(req).await?;
865
866 let status = resp.status();
867 let content_type = resp
868 .headers()
869 .get("content-type")
870 .and_then(|v| v.to_str().ok())
871 .unwrap_or("application/octet-stream");
872 let content_type = super::ContentType::from(content_type);
873
874 if !status.is_client_error() && !status.is_server_error() {
875 let content = resp.text().await?;
876 match content_type {
877 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
878 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
879 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`")))),
880 }
881 } else {
882 let content = resp.text().await?;
883 let entity: Option<RevokeApiKeyError> = serde_json::from_str(&content).ok();
884 Err(Error::ResponseError(ResponseContent { status, content, entity }))
885 }
886}
887