Skip to main content

ory_client/apis/
api_keys_api.rs

1/*
2 * Ory APIs
3 *
4 * # Introduction Documentation for all public and administrative Ory APIs. Administrative APIs can only be accessed with a valid Personal Access Token. Public APIs are mostly used in browsers.  ## SDKs This document describes the APIs available in the Ory Network. The APIs are available as SDKs for the following languages:  | Language       | Download SDK                                                     | Documentation                                                                        | | -------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------ | | Dart           | [pub.dev](https://pub.dev/packages/ory_client)                   | [README](https://github.com/ory/sdk/blob/master/clients/client/dart/README.md)       | | .NET           | [nuget.org](https://www.nuget.org/packages/Ory.Client/)          | [README](https://github.com/ory/sdk/blob/master/clients/client/dotnet/README.md)     | | Elixir         | [hex.pm](https://hex.pm/packages/ory_client)                     | [README](https://github.com/ory/sdk/blob/master/clients/client/elixir/README.md)     | | Go             | [github.com](https://github.com/ory/client-go)                   | [README](https://github.com/ory/sdk/blob/master/clients/client/go/README.md)         | | Java           | [maven.org](https://search.maven.org/artifact/sh.ory/ory-client) | [README](https://github.com/ory/sdk/blob/master/clients/client/java/README.md)       | | JavaScript     | [npmjs.com](https://www.npmjs.com/package/@ory/client)           | [README](https://github.com/ory/sdk/blob/master/clients/client/typescript/README.md) | | JavaScript (With fetch) | [npmjs.com](https://www.npmjs.com/package/@ory/client-fetch)           | [README](https://github.com/ory/sdk/blob/master/clients/client/typescript-fetch/README.md) |  | PHP            | [packagist.org](https://packagist.org/packages/ory/client)       | [README](https://github.com/ory/sdk/blob/master/clients/client/php/README.md)        | | Python         | [pypi.org](https://pypi.org/project/ory-client/)                 | [README](https://github.com/ory/sdk/blob/master/clients/client/python/README.md)     | | Ruby           | [rubygems.org](https://rubygems.org/gems/ory-client)             | [README](https://github.com/ory/sdk/blob/master/clients/client/ruby/README.md)       | | Rust           | [crates.io](https://crates.io/crates/ory-client)                 | [README](https://github.com/ory/sdk/blob/master/clients/client/rust/README.md)       | 
5 *
6 * The version of the OpenAPI document: v1.22.53
7 * Contact: support@ory.sh
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`admin_batch_create_imported_api_keys`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AdminBatchCreateImportedApiKeysError {
22    DefaultResponse(models::Status),
23    UnknownValue(serde_json::Value),
24}
25
26/// struct for typed errors of method [`admin_batch_verify_api_keys`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum AdminBatchVerifyApiKeysError {
30    DefaultResponse(models::Status),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`admin_delete_imported_api_key`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum AdminDeleteImportedApiKeyError {
38    DefaultResponse(models::Status),
39    UnknownValue(serde_json::Value),
40}
41
42/// struct for typed errors of method [`admin_derive_token`]
43#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum AdminDeriveTokenError {
46    DefaultResponse(models::Status),
47    UnknownValue(serde_json::Value),
48}
49
50/// struct for typed errors of method [`admin_get_imported_api_key`]
51#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum AdminGetImportedApiKeyError {
54    DefaultResponse(models::Status),
55    UnknownValue(serde_json::Value),
56}
57
58/// struct for typed errors of method [`admin_get_issued_api_key`]
59#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum AdminGetIssuedApiKeyError {
62    DefaultResponse(models::Status),
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method [`admin_import_api_key`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum AdminImportApiKeyError {
70    DefaultResponse(models::Status),
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`admin_issue_api_key`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum AdminIssueApiKeyError {
78    DefaultResponse(models::Status),
79    UnknownValue(serde_json::Value),
80}
81
82/// struct for typed errors of method [`admin_list_imported_api_keys`]
83#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum AdminListImportedApiKeysError {
86    DefaultResponse(models::Status),
87    UnknownValue(serde_json::Value),
88}
89
90/// struct for typed errors of method [`admin_list_issued_api_keys`]
91#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum AdminListIssuedApiKeysError {
94    DefaultResponse(models::Status),
95    UnknownValue(serde_json::Value),
96}
97
98/// struct for typed errors of method [`admin_revoke_imported_api_key`]
99#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum AdminRevokeImportedApiKeyError {
102    DefaultResponse(models::Status),
103    UnknownValue(serde_json::Value),
104}
105
106/// struct for typed errors of method [`admin_revoke_issued_api_key`]
107#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum AdminRevokeIssuedApiKeyError {
110    DefaultResponse(models::Status),
111    UnknownValue(serde_json::Value),
112}
113
114/// struct for typed errors of method [`admin_rotate_issued_api_key`]
115#[derive(Debug, Clone, Serialize, Deserialize)]
116#[serde(untagged)]
117pub enum AdminRotateIssuedApiKeyError {
118    DefaultResponse(models::Status),
119    UnknownValue(serde_json::Value),
120}
121
122/// struct for typed errors of method [`admin_update_imported_api_key`]
123#[derive(Debug, Clone, Serialize, Deserialize)]
124#[serde(untagged)]
125pub enum AdminUpdateImportedApiKeyError {
126    DefaultResponse(models::Status),
127    UnknownValue(serde_json::Value),
128}
129
130/// struct for typed errors of method [`admin_update_issued_api_key`]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum AdminUpdateIssuedApiKeyError {
134    DefaultResponse(models::Status),
135    UnknownValue(serde_json::Value),
136}
137
138/// struct for typed errors of method [`admin_verify_api_key`]
139#[derive(Debug, Clone, Serialize, Deserialize)]
140#[serde(untagged)]
141pub enum AdminVerifyApiKeyError {
142    DefaultResponse(models::Status),
143    UnknownValue(serde_json::Value),
144}
145
146/// struct for typed errors of method [`get_jwks`]
147#[derive(Debug, Clone, Serialize, Deserialize)]
148#[serde(untagged)]
149pub enum GetJwksError {
150    DefaultResponse(models::Status),
151    UnknownValue(serde_json::Value),
152}
153
154/// struct for typed errors of method [`revoke_api_key`]
155#[derive(Debug, Clone, Serialize, Deserialize)]
156#[serde(untagged)]
157pub enum RevokeApiKeyError {
158    DefaultResponse(models::Status),
159    UnknownValue(serde_json::Value),
160}
161
162
163/// Imports up to 1000 external API keys in one request. Returns per-item results. If at least one item succeeds, response is 200 OK. If all items fail, the endpoint returns a non-200 error.  ```http POST /v2alpha1/admin/importedApiKeys:batchCreate {   \"requests\": [     {\"raw_key\": \"sk_live_abc\", \"name\": \"Stripe key\", \"actor_id\": \"user_1\"},     {\"raw_key\": \"ghp_xyz\", \"name\": \"GitHub PAT\", \"actor_id\": \"user_2\"}   ] } ```
164pub 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    // add a prefix to parameters to efficiently prevent name collisions
166    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
204/// Verifies multiple credentials in a single request. Efficiently verifies up to 100 credentials in parallel. Each credential is verified independently; partial failures are returned. Admin access only.  Cache Control (HTTP Headers):   - Cache-Control: no-cache  - Bypasses cache read, forces fresh DB lookup   - Cache-Control: no-store  - Bypasses cache read AND write (never cached)   - Pragma: no-cache         - Same as Cache-Control: no-cache (HTTP/1.0)  The cache directive applies to every credential in the batch.  ```http POST /v2alpha1/admin/apiKeys:batchVerify {   \"requests\": [     {\"credential\": \"sk_live_abc123...\"},     {\"credential\": \"eyJhbGciOiJFZERTQSI...\"}   ] } ```
205pub 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    // add a prefix to parameters to efficiently prevent name collisions
207    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
253/// Permanently deletes an imported key (hard delete). The key is removed from the database. Use AdminRevokeImportedApiKey for soft deletion (recommended).  ```http DELETE /v2alpha1/admin/importedApiKeys/{key_id} ```
254pub async fn admin_delete_imported_api_key(configuration: &configuration::Configuration, key_id: &str) -> Result<(), Error<AdminDeleteImportedApiKeyError>> {
255    // add a prefix to parameters to efficiently prevent name collisions
256    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
273    if !status.is_client_error() && !status.is_server_error() {
274        Ok(())
275    } else {
276        let content = resp.text().await?;
277        let entity: Option<AdminDeleteImportedApiKeyError> = serde_json::from_str(&content).ok();
278        Err(Error::ResponseError(ResponseContent { status, content, entity }))
279    }
280}
281
282/// Mints a short-lived JWT or Macaroon token from an API key. Works with both issued and imported keys. The derived token inherits the permissions of the parent API key.  ```http POST /v2alpha1/admin/apiKeys:derive {   \"credential\": \"eyJhbGciOiJFZERTQSI...\",   \"ttl\": \"1h\" } ```
283pub async fn admin_derive_token(configuration: &configuration::Configuration, derive_token_request: models::DeriveTokenRequest) -> Result<models::DeriveTokenResponse, Error<AdminDeriveTokenError>> {
284    // add a prefix to parameters to efficiently prevent name collisions
285    let p_body_derive_token_request = derive_token_request;
286
287    let uri_str = format!("{}/v2alpha1/admin/apiKeys:derive", configuration.base_path);
288    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
289
290    if let Some(ref user_agent) = configuration.user_agent {
291        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
292    }
293    if let Some(ref token) = configuration.bearer_access_token {
294        req_builder = req_builder.bearer_auth(token.to_owned());
295    };
296    req_builder = req_builder.json(&p_body_derive_token_request);
297
298    let req = req_builder.build()?;
299    let resp = configuration.client.execute(req).await?;
300
301    let status = resp.status();
302    let content_type = resp
303        .headers()
304        .get("content-type")
305        .and_then(|v| v.to_str().ok())
306        .unwrap_or("application/octet-stream");
307    let content_type = super::ContentType::from(content_type);
308
309    if !status.is_client_error() && !status.is_server_error() {
310        let content = resp.text().await?;
311        match content_type {
312            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
313            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeriveTokenResponse`"))),
314            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`")))),
315        }
316    } else {
317        let content = resp.text().await?;
318        let entity: Option<AdminDeriveTokenError> = serde_json::from_str(&content).ok();
319        Err(Error::ResponseError(ResponseContent { status, content, entity }))
320    }
321}
322
323/// Retrieves details about a specific imported key. Returns metadata about the imported key. The original raw key is never returned.  ```http GET /v2alpha1/admin/importedApiKeys/{key_id} ```
324pub async fn admin_get_imported_api_key(configuration: &configuration::Configuration, key_id: &str) -> Result<models::ImportedApiKey, Error<AdminGetImportedApiKeyError>> {
325    // add a prefix to parameters to efficiently prevent name collisions
326    let p_path_key_id = key_id;
327
328    let uri_str = format!("{}/v2alpha1/admin/importedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
329    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
330
331    if let Some(ref user_agent) = configuration.user_agent {
332        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
333    }
334    if let Some(ref token) = configuration.bearer_access_token {
335        req_builder = req_builder.bearer_auth(token.to_owned());
336    };
337
338    let req = req_builder.build()?;
339    let resp = configuration.client.execute(req).await?;
340
341    let status = resp.status();
342    let content_type = resp
343        .headers()
344        .get("content-type")
345        .and_then(|v| v.to_str().ok())
346        .unwrap_or("application/octet-stream");
347    let content_type = super::ContentType::from(content_type);
348
349    if !status.is_client_error() && !status.is_server_error() {
350        let content = resp.text().await?;
351        match content_type {
352            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
353            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ImportedApiKey`"))),
354            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`")))),
355        }
356    } else {
357        let content = resp.text().await?;
358        let entity: Option<AdminGetImportedApiKeyError> = serde_json::from_str(&content).ok();
359        Err(Error::ResponseError(ResponseContent { status, content, entity }))
360    }
361}
362
363/// Retrieves details about a specific issued API key including its status, scopes, expiration, and usage statistics. The secret is never returned.  ```http GET /v2alpha1/admin/issuedApiKeys/01HQZX9VYQKJB8XQZQXQZQXQXQ ```
364pub async fn admin_get_issued_api_key(configuration: &configuration::Configuration, key_id: &str) -> Result<models::IssuedApiKey, Error<AdminGetIssuedApiKeyError>> {
365    // add a prefix to parameters to efficiently prevent name collisions
366    let p_path_key_id = key_id;
367
368    let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
369    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
370
371    if let Some(ref user_agent) = configuration.user_agent {
372        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
373    }
374    if let Some(ref token) = configuration.bearer_access_token {
375        req_builder = req_builder.bearer_auth(token.to_owned());
376    };
377
378    let req = req_builder.build()?;
379    let resp = configuration.client.execute(req).await?;
380
381    let status = resp.status();
382    let content_type = resp
383        .headers()
384        .get("content-type")
385        .and_then(|v| v.to_str().ok())
386        .unwrap_or("application/octet-stream");
387    let content_type = super::ContentType::from(content_type);
388
389    if !status.is_client_error() && !status.is_server_error() {
390        let content = resp.text().await?;
391        match content_type {
392            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
393            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IssuedApiKey`"))),
394            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`")))),
395        }
396    } else {
397        let content = resp.text().await?;
398        let entity: Option<AdminGetIssuedApiKeyError> = serde_json::from_str(&content).ok();
399        Err(Error::ResponseError(ResponseContent { status, content, entity }))
400    }
401}
402
403/// Imports an external API key into the system. Allows importing keys from legacy systems or external providers. The raw key is hashed and stored securely (HMAC). Imported keys support token derivation (JWT/Macaroon) like issued keys.  ```http POST /v2alpha1/admin/importedApiKeys {   \"raw_key\": \"imported-key-EXAMPLE-not-a-real-secret\",   \"name\": \"Example imported key\",   \"actor_id\": \"user_123\" } ```
404pub async fn admin_import_api_key(configuration: &configuration::Configuration, import_api_key_request: models::ImportApiKeyRequest) -> Result<models::ImportedApiKey, Error<AdminImportApiKeyError>> {
405    // add a prefix to parameters to efficiently prevent name collisions
406    let p_body_import_api_key_request = import_api_key_request;
407
408    let uri_str = format!("{}/v2alpha1/admin/importedApiKeys", configuration.base_path);
409    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
410
411    if let Some(ref user_agent) = configuration.user_agent {
412        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
413    }
414    if let Some(ref token) = configuration.bearer_access_token {
415        req_builder = req_builder.bearer_auth(token.to_owned());
416    };
417    req_builder = req_builder.json(&p_body_import_api_key_request);
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::ImportedApiKey`"))),
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::ImportedApiKey`")))),
436        }
437    } else {
438        let content = resp.text().await?;
439        let entity: Option<AdminImportApiKeyError> = serde_json::from_str(&content).ok();
440        Err(Error::ResponseError(ResponseContent { status, content, entity }))
441    }
442}
443
444/// Creates a new API key for a given actor. The secret is returned only once in the response and cannot be retrieved later. Keys can be scoped with specific permissions and have optional expiration.  ```http POST /v2alpha1/admin/issuedApiKeys {   \"name\": \"production-service\",   \"actor_id\": \"user_123\",   \"scopes\": [\"read\", \"write\"],   \"ttl\": \"8760h\" } ```
445pub async fn admin_issue_api_key(configuration: &configuration::Configuration, issue_api_key_request: models::IssueApiKeyRequest) -> Result<models::IssueApiKeyResponse, Error<AdminIssueApiKeyError>> {
446    // add a prefix to parameters to efficiently prevent name collisions
447    let p_body_issue_api_key_request = issue_api_key_request;
448
449    let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys", 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_issue_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::IssueApiKeyResponse`"))),
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::IssueApiKeyResponse`")))),
477        }
478    } else {
479        let content = resp.text().await?;
480        let entity: Option<AdminIssueApiKeyError> = serde_json::from_str(&content).ok();
481        Err(Error::ResponseError(ResponseContent { status, content, entity }))
482    }
483}
484
485/// Lists all imported keys with filtering. Returns imported keys only (not issued keys). Supports pagination and AIP-160 filter expressions.  ```http GET /v2alpha1/admin/importedApiKeys?page_size=50&filter=status%3DKEY_STATUS_ACTIVE ```
486pub 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>> {
487    // add a prefix to parameters to efficiently prevent name collisions
488    let p_query_page_size = page_size;
489    let p_query_page_token = page_token;
490    let p_query_filter = filter;
491
492    let uri_str = format!("{}/v2alpha1/admin/importedApiKeys", configuration.base_path);
493    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
494
495    if let Some(ref param_value) = p_query_page_size {
496        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
497    }
498    if let Some(ref param_value) = p_query_page_token {
499        req_builder = req_builder.query(&[("page_token", &param_value.to_string())]);
500    }
501    if let Some(ref param_value) = p_query_filter {
502        req_builder = req_builder.query(&[("filter", &param_value.to_string())]);
503    }
504    if let Some(ref user_agent) = configuration.user_agent {
505        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
506    }
507    if let Some(ref token) = configuration.bearer_access_token {
508        req_builder = req_builder.bearer_auth(token.to_owned());
509    };
510
511    let req = req_builder.build()?;
512    let resp = configuration.client.execute(req).await?;
513
514    let status = resp.status();
515    let content_type = resp
516        .headers()
517        .get("content-type")
518        .and_then(|v| v.to_str().ok())
519        .unwrap_or("application/octet-stream");
520    let content_type = super::ContentType::from(content_type);
521
522    if !status.is_client_error() && !status.is_server_error() {
523        let content = resp.text().await?;
524        match content_type {
525            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
526            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListImportedApiKeysResponse`"))),
527            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`")))),
528        }
529    } else {
530        let content = resp.text().await?;
531        let entity: Option<AdminListImportedApiKeysError> = serde_json::from_str(&content).ok();
532        Err(Error::ResponseError(ResponseContent { status, content, entity }))
533    }
534}
535
536/// Lists issued API keys with optional filtering. Supports cursor-based pagination and AIP-160 filter expressions. Returns only issued (generated) API keys; use ListImportedApiKeys for imported keys.  ```http GET /v2alpha1/admin/issuedApiKeys?page_size=50&filter=actor_id%3D%22user_123%22 ```
537pub 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>> {
538    // add a prefix to parameters to efficiently prevent name collisions
539    let p_query_page_size = page_size;
540    let p_query_page_token = page_token;
541    let p_query_filter = filter;
542
543    let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys", configuration.base_path);
544    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
545
546    if let Some(ref param_value) = p_query_page_size {
547        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
548    }
549    if let Some(ref param_value) = p_query_page_token {
550        req_builder = req_builder.query(&[("page_token", &param_value.to_string())]);
551    }
552    if let Some(ref param_value) = p_query_filter {
553        req_builder = req_builder.query(&[("filter", &param_value.to_string())]);
554    }
555    if let Some(ref user_agent) = configuration.user_agent {
556        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
557    }
558    if let Some(ref token) = configuration.bearer_access_token {
559        req_builder = req_builder.bearer_auth(token.to_owned());
560    };
561
562    let req = req_builder.build()?;
563    let resp = configuration.client.execute(req).await?;
564
565    let status = resp.status();
566    let content_type = resp
567        .headers()
568        .get("content-type")
569        .and_then(|v| v.to_str().ok())
570        .unwrap_or("application/octet-stream");
571    let content_type = super::ContentType::from(content_type);
572
573    if !status.is_client_error() && !status.is_server_error() {
574        let content = resp.text().await?;
575        match content_type {
576            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
577            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListIssuedApiKeysResponse`"))),
578            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`")))),
579        }
580    } else {
581        let content = resp.text().await?;
582        let entity: Option<AdminListIssuedApiKeysError> = serde_json::from_str(&content).ok();
583        Err(Error::ResponseError(ResponseContent { status, content, entity }))
584    }
585}
586
587/// Immediately revokes an imported API key. Once revoked, the key can no longer be used for authentication. This operation is irreversible. Revoked keys are retained for audit purposes.  ```http POST /v2alpha1/admin/importedApiKeys/9a3f051b2c7e8d4f1a6b9c0e5f2d8a3b:revoke {   \"reason\": \"REVOCATION_REASON_KEY_COMPROMISE\" } ```
588pub async fn admin_revoke_imported_api_key(configuration: &configuration::Configuration, key_id: &str, admin_revoke_imported_api_key_body: models::AdminRevokeImportedApiKeyBody) -> Result<(), Error<AdminRevokeImportedApiKeyError>> {
589    // add a prefix to parameters to efficiently prevent name collisions
590    let p_path_key_id = key_id;
591    let p_body_admin_revoke_imported_api_key_body = admin_revoke_imported_api_key_body;
592
593    let uri_str = format!("{}/v2alpha1/admin/importedApiKeys/{key_id}:revoke", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
594    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
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    req_builder = req_builder.json(&p_body_admin_revoke_imported_api_key_body);
603
604    let req = req_builder.build()?;
605    let resp = configuration.client.execute(req).await?;
606
607    let status = resp.status();
608
609    if !status.is_client_error() && !status.is_server_error() {
610        Ok(())
611    } else {
612        let content = resp.text().await?;
613        let entity: Option<AdminRevokeImportedApiKeyError> = serde_json::from_str(&content).ok();
614        Err(Error::ResponseError(ResponseContent { status, content, entity }))
615    }
616}
617
618/// Immediately revokes an issued API key. Once revoked, the key can no longer be used for authentication. This operation is irreversible. Revoked keys are retained for audit purposes.  ```http POST /v2alpha1/admin/issuedApiKeys/01HQZX9VYQKJB8XQZQXQZQXQXQ:revoke {   \"reason\": \"REVOCATION_REASON_KEY_COMPROMISE\" } ```
619pub async fn admin_revoke_issued_api_key(configuration: &configuration::Configuration, key_id: &str, admin_revoke_issued_api_key_body: models::AdminRevokeIssuedApiKeyBody) -> Result<(), Error<AdminRevokeIssuedApiKeyError>> {
620    // add a prefix to parameters to efficiently prevent name collisions
621    let p_path_key_id = key_id;
622    let p_body_admin_revoke_issued_api_key_body = admin_revoke_issued_api_key_body;
623
624    let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys/{key_id}:revoke", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
625    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
626
627    if let Some(ref user_agent) = configuration.user_agent {
628        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
629    }
630    if let Some(ref token) = configuration.bearer_access_token {
631        req_builder = req_builder.bearer_auth(token.to_owned());
632    };
633    req_builder = req_builder.json(&p_body_admin_revoke_issued_api_key_body);
634
635    let req = req_builder.build()?;
636    let resp = configuration.client.execute(req).await?;
637
638    let status = resp.status();
639
640    if !status.is_client_error() && !status.is_server_error() {
641        Ok(())
642    } else {
643        let content = resp.text().await?;
644        let entity: Option<AdminRevokeIssuedApiKeyError> = serde_json::from_str(&content).ok();
645        Err(Error::ResponseError(ResponseContent { status, content, entity }))
646    }
647}
648
649/// Generates a new secret for an issued API key. Creates a new API key with a new key_id and secret, and immediately revokes the old key. This is the recommended way to update scopes, metadata, or rotate credentials.  For zero-downtime rotation, use this workflow instead:   1. IssueApiKey with new credentials   2. Deploy new secret to all services   3. Verify new secret works everywhere   4. AdminRevokeIssuedApiKey to remove the old key  ```http POST /v2alpha1/admin/issuedApiKeys/01HQZX9VYQKJB8XQZQXQZQXQXQ:rotate {   \"scopes\": [\"read\"] } ```
650pub 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>> {
651    // add a prefix to parameters to efficiently prevent name collisions
652    let p_path_key_id = key_id;
653    let p_body_admin_rotate_issued_api_key_body = admin_rotate_issued_api_key_body;
654
655    let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys/{key_id}:rotate", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
656    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
657
658    if let Some(ref user_agent) = configuration.user_agent {
659        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
660    }
661    if let Some(ref token) = configuration.bearer_access_token {
662        req_builder = req_builder.bearer_auth(token.to_owned());
663    };
664    req_builder = req_builder.json(&p_body_admin_rotate_issued_api_key_body);
665
666    let req = req_builder.build()?;
667    let resp = configuration.client.execute(req).await?;
668
669    let status = resp.status();
670    let content_type = resp
671        .headers()
672        .get("content-type")
673        .and_then(|v| v.to_str().ok())
674        .unwrap_or("application/octet-stream");
675    let content_type = super::ContentType::from(content_type);
676
677    if !status.is_client_error() && !status.is_server_error() {
678        let content = resp.text().await?;
679        match content_type {
680            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
681            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RotateIssuedApiKeyResponse`"))),
682            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`")))),
683        }
684    } else {
685        let content = resp.text().await?;
686        let entity: Option<AdminRotateIssuedApiKeyError> = serde_json::from_str(&content).ok();
687        Err(Error::ResponseError(ResponseContent { status, content, entity }))
688    }
689}
690
691/// Updates metadata, scopes, or rate limits of an imported key. Supports partial updates via the update_mask query parameter (AIP-134). Omitting update_mask is equivalent to a mask of every populated field in the body. To clear a field to its zero value, list it explicitly in update_mask and leave it unset (or empty) in the body.  ```http PATCH /v2alpha1/admin/importedApiKeys/{key_id}?update_mask=name {   \"imported_api_key\": {     \"key_id\": \"{key_id}\",     \"name\": \"New name\"   } } ```
692pub 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>> {
693    // add a prefix to parameters to efficiently prevent name collisions
694    let p_path_key_id = key_id;
695    let p_body_admin_update_imported_api_key_request = admin_update_imported_api_key_request;
696    let p_query_update_mask = update_mask;
697
698    let uri_str = format!("{}/v2alpha1/admin/importedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
699    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
700
701    if let Some(ref param_value) = p_query_update_mask {
702        req_builder = req_builder.query(&[("update_mask", &param_value.to_string())]);
703    }
704    if let Some(ref user_agent) = configuration.user_agent {
705        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
706    }
707    if let Some(ref token) = configuration.bearer_access_token {
708        req_builder = req_builder.bearer_auth(token.to_owned());
709    };
710    req_builder = req_builder.json(&p_body_admin_update_imported_api_key_request);
711
712    let req = req_builder.build()?;
713    let resp = configuration.client.execute(req).await?;
714
715    let status = resp.status();
716    let content_type = resp
717        .headers()
718        .get("content-type")
719        .and_then(|v| v.to_str().ok())
720        .unwrap_or("application/octet-stream");
721    let content_type = super::ContentType::from(content_type);
722
723    if !status.is_client_error() && !status.is_server_error() {
724        let content = resp.text().await?;
725        match content_type {
726            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
727            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ImportedApiKey`"))),
728            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`")))),
729        }
730    } else {
731        let content = resp.text().await?;
732        let entity: Option<AdminUpdateImportedApiKeyError> = serde_json::from_str(&content).ok();
733        Err(Error::ResponseError(ResponseContent { status, content, entity }))
734    }
735}
736
737/// Updates metadata, scopes, or rate limits of an issued key without rotating the secret. Use RotateIssuedApiKey to change the secret.  Follows AIP-134: the request body is the IssuedApiKey resource itself, and the update_mask query parameter names the subset of fields to apply. Omitting update_mask is equivalent to a mask of every populated field in the body. To clear a field to its zero value, list it explicitly in update_mask and leave it unset (or empty) in the body.  ```http PATCH /v2alpha1/admin/issuedApiKeys/01HQZX9VYQKJB8XQZQXQZQXQXQ?update_mask=scopes {   \"issued_api_key\": {     \"key_id\": \"01HQZX9VYQKJB8XQZQXQZQXQXQ\",     \"scopes\": [\"read\"]   } } ```
738pub 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>> {
739    // add a prefix to parameters to efficiently prevent name collisions
740    let p_path_key_id = key_id;
741    let p_body_admin_update_issued_api_key_request = admin_update_issued_api_key_request;
742    let p_query_update_mask = update_mask;
743
744    let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
745    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
746
747    if let Some(ref param_value) = p_query_update_mask {
748        req_builder = req_builder.query(&[("update_mask", &param_value.to_string())]);
749    }
750    if let Some(ref user_agent) = configuration.user_agent {
751        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
752    }
753    if let Some(ref token) = configuration.bearer_access_token {
754        req_builder = req_builder.bearer_auth(token.to_owned());
755    };
756    req_builder = req_builder.json(&p_body_admin_update_issued_api_key_request);
757
758    let req = req_builder.build()?;
759    let resp = configuration.client.execute(req).await?;
760
761    let status = resp.status();
762    let content_type = resp
763        .headers()
764        .get("content-type")
765        .and_then(|v| v.to_str().ok())
766        .unwrap_or("application/octet-stream");
767    let content_type = super::ContentType::from(content_type);
768
769    if !status.is_client_error() && !status.is_server_error() {
770        let content = resp.text().await?;
771        match content_type {
772            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
773            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IssuedApiKey`"))),
774            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`")))),
775        }
776    } else {
777        let content = resp.text().await?;
778        let entity: Option<AdminUpdateIssuedApiKeyError> = serde_json::from_str(&content).ok();
779        Err(Error::ResponseError(ResponseContent { status, content, entity }))
780    }
781}
782
783/// Verifies a single API key or derived token. Validates the credential's signature, expiration, and revocation status. Works with any credential type (issued keys, imported keys, JWT, macaroon). The verification result includes decoded claims and metadata — admin access only.  Cache Control (HTTP Headers):   - Cache-Control: no-cache  - Bypasses cache read, forces fresh DB lookup   - Cache-Control: no-store  - Bypasses cache read AND write (never cached)   - Pragma: no-cache         - Same as Cache-Control: no-cache (HTTP/1.0)  ```http POST /v2alpha1/admin/apiKeys:verify {   \"credential\": \"sk_live_abc123...\" } ```
784pub 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>> {
785    // add a prefix to parameters to efficiently prevent name collisions
786    let p_body_verify_api_key_request = verify_api_key_request;
787    let p_header_cache_control = cache_control;
788    let p_header_pragma = pragma;
789
790    let uri_str = format!("{}/v2alpha1/admin/apiKeys:verify", configuration.base_path);
791    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
792
793    if let Some(ref user_agent) = configuration.user_agent {
794        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
795    }
796    if let Some(param_value) = p_header_cache_control {
797        req_builder = req_builder.header("Cache-Control", param_value.to_string());
798    }
799    if let Some(param_value) = p_header_pragma {
800        req_builder = req_builder.header("Pragma", param_value.to_string());
801    }
802    if let Some(ref token) = configuration.bearer_access_token {
803        req_builder = req_builder.bearer_auth(token.to_owned());
804    };
805    req_builder = req_builder.json(&p_body_verify_api_key_request);
806
807    let req = req_builder.build()?;
808    let resp = configuration.client.execute(req).await?;
809
810    let status = resp.status();
811    let content_type = resp
812        .headers()
813        .get("content-type")
814        .and_then(|v| v.to_str().ok())
815        .unwrap_or("application/octet-stream");
816    let content_type = super::ContentType::from(content_type);
817
818    if !status.is_client_error() && !status.is_server_error() {
819        let content = resp.text().await?;
820        match content_type {
821            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
822            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerifyApiKeyResponse`"))),
823            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`")))),
824        }
825    } else {
826        let content = resp.text().await?;
827        let entity: Option<AdminVerifyApiKeyError> = serde_json::from_str(&content).ok();
828        Err(Error::ResponseError(ResponseContent { status, content, entity }))
829    }
830}
831
832/// Returns the JSON Web Key Set for token verification. Provides the public keys needed to verify JWT tokens issued by this service. Keys are loaded from configuration (file://, https://, or base64:// URIs). Follows the JWKS standard (RFC 7517).  ```http GET /v2alpha1/derivedKeys/jwks.json ```
833pub async fn get_jwks(configuration: &configuration::Configuration, ) -> Result<models::GetJwksResponse, Error<GetJwksError>> {
834
835    let uri_str = format!("{}/v2alpha1/derivedKeys/jwks.json", configuration.base_path);
836    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
837
838    if let Some(ref user_agent) = configuration.user_agent {
839        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
840    }
841
842    let req = req_builder.build()?;
843    let resp = configuration.client.execute(req).await?;
844
845    let status = resp.status();
846    let content_type = resp
847        .headers()
848        .get("content-type")
849        .and_then(|v| v.to_str().ok())
850        .unwrap_or("application/octet-stream");
851    let content_type = super::ContentType::from(content_type);
852
853    if !status.is_client_error() && !status.is_server_error() {
854        let content = resp.text().await?;
855        match content_type {
856            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
857            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetJwksResponse`"))),
858            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`")))),
859        }
860    } else {
861        let content = resp.text().await?;
862        let entity: Option<GetJwksError> = serde_json::from_str(&content).ok();
863        Err(Error::ResponseError(ResponseContent { status, content, entity }))
864    }
865}
866
867/// Proof-of-possession variant of revocation. The `Self*` prefix on the request/response messages disambiguates from the admin variants (`AdminRevokeIssuedApiKey` / `AdminRevokeImportedApiKey`).  Allows an API key holder to revoke their own key. The caller must provide the full API key secret as proof of possession. Supports issued API keys and imported keys. JWT and macaroon tokens cannot be self-revoked (they are stateless).  The PRIVILEGE_WITHDRAWN reason is not allowed for self-revocation (admin-only).  ```http POST /v2alpha1/apiKeys:selfRevoke {   \"credential\": \"sk_live_abc123...\",   \"reason\": \"REVOCATION_REASON_KEY_COMPROMISE\" } ```
868pub async fn revoke_api_key(configuration: &configuration::Configuration, self_revoke_api_key_request: models::SelfRevokeApiKeyRequest) -> Result<serde_json::Value, Error<RevokeApiKeyError>> {
869    // add a prefix to parameters to efficiently prevent name collisions
870    let p_body_self_revoke_api_key_request = self_revoke_api_key_request;
871
872    let uri_str = format!("{}/v2alpha1/apiKeys:selfRevoke", configuration.base_path);
873    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
874
875    if let Some(ref user_agent) = configuration.user_agent {
876        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
877    }
878    req_builder = req_builder.json(&p_body_self_revoke_api_key_request);
879
880    let req = req_builder.build()?;
881    let resp = configuration.client.execute(req).await?;
882
883    let status = resp.status();
884    let content_type = resp
885        .headers()
886        .get("content-type")
887        .and_then(|v| v.to_str().ok())
888        .unwrap_or("application/octet-stream");
889    let content_type = super::ContentType::from(content_type);
890
891    if !status.is_client_error() && !status.is_server_error() {
892        let content = resp.text().await?;
893        match content_type {
894            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
895            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
896            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`")))),
897        }
898    } else {
899        let content = resp.text().await?;
900        let entity: Option<RevokeApiKeyError> = serde_json::from_str(&content).ok();
901        Err(Error::ResponseError(ResponseContent { status, content, entity }))
902    }
903}
904