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.48
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<serde_json::Value, 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    let content_type = resp
273        .headers()
274        .get("content-type")
275        .and_then(|v| v.to_str().ok())
276        .unwrap_or("application/octet-stream");
277    let content_type = super::ContentType::from(content_type);
278
279    if !status.is_client_error() && !status.is_server_error() {
280        let content = resp.text().await?;
281        match content_type {
282            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
283            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
284            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
285        }
286    } else {
287        let content = resp.text().await?;
288        let entity: Option<AdminDeleteImportedApiKeyError> = serde_json::from_str(&content).ok();
289        Err(Error::ResponseError(ResponseContent { status, content, entity }))
290    }
291}
292
293/// 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\" } ```
294pub async fn admin_derive_token(configuration: &configuration::Configuration, derive_token_request: models::DeriveTokenRequest) -> Result<models::DeriveTokenResponse, Error<AdminDeriveTokenError>> {
295    // add a prefix to parameters to efficiently prevent name collisions
296    let p_body_derive_token_request = derive_token_request;
297
298    let uri_str = format!("{}/v2alpha1/admin/apiKeys:derive", configuration.base_path);
299    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
300
301    if let Some(ref user_agent) = configuration.user_agent {
302        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
303    }
304    if let Some(ref token) = configuration.bearer_access_token {
305        req_builder = req_builder.bearer_auth(token.to_owned());
306    };
307    req_builder = req_builder.json(&p_body_derive_token_request);
308
309    let req = req_builder.build()?;
310    let resp = configuration.client.execute(req).await?;
311
312    let status = resp.status();
313    let content_type = resp
314        .headers()
315        .get("content-type")
316        .and_then(|v| v.to_str().ok())
317        .unwrap_or("application/octet-stream");
318    let content_type = super::ContentType::from(content_type);
319
320    if !status.is_client_error() && !status.is_server_error() {
321        let content = resp.text().await?;
322        match content_type {
323            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
324            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeriveTokenResponse`"))),
325            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeriveTokenResponse`")))),
326        }
327    } else {
328        let content = resp.text().await?;
329        let entity: Option<AdminDeriveTokenError> = serde_json::from_str(&content).ok();
330        Err(Error::ResponseError(ResponseContent { status, content, entity }))
331    }
332}
333
334/// 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} ```
335pub async fn admin_get_imported_api_key(configuration: &configuration::Configuration, key_id: &str) -> Result<models::ImportedApiKey, Error<AdminGetImportedApiKeyError>> {
336    // add a prefix to parameters to efficiently prevent name collisions
337    let p_path_key_id = key_id;
338
339    let uri_str = format!("{}/v2alpha1/admin/importedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
340    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
341
342    if let Some(ref user_agent) = configuration.user_agent {
343        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
344    }
345    if let Some(ref token) = configuration.bearer_access_token {
346        req_builder = req_builder.bearer_auth(token.to_owned());
347    };
348
349    let req = req_builder.build()?;
350    let resp = configuration.client.execute(req).await?;
351
352    let status = resp.status();
353    let content_type = resp
354        .headers()
355        .get("content-type")
356        .and_then(|v| v.to_str().ok())
357        .unwrap_or("application/octet-stream");
358    let content_type = super::ContentType::from(content_type);
359
360    if !status.is_client_error() && !status.is_server_error() {
361        let content = resp.text().await?;
362        match content_type {
363            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
364            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ImportedApiKey`"))),
365            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ImportedApiKey`")))),
366        }
367    } else {
368        let content = resp.text().await?;
369        let entity: Option<AdminGetImportedApiKeyError> = serde_json::from_str(&content).ok();
370        Err(Error::ResponseError(ResponseContent { status, content, entity }))
371    }
372}
373
374/// 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 ```
375pub async fn admin_get_issued_api_key(configuration: &configuration::Configuration, key_id: &str) -> Result<models::IssuedApiKey, Error<AdminGetIssuedApiKeyError>> {
376    // add a prefix to parameters to efficiently prevent name collisions
377    let p_path_key_id = key_id;
378
379    let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
380    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
381
382    if let Some(ref user_agent) = configuration.user_agent {
383        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
384    }
385    if let Some(ref token) = configuration.bearer_access_token {
386        req_builder = req_builder.bearer_auth(token.to_owned());
387    };
388
389    let req = req_builder.build()?;
390    let resp = configuration.client.execute(req).await?;
391
392    let status = resp.status();
393    let content_type = resp
394        .headers()
395        .get("content-type")
396        .and_then(|v| v.to_str().ok())
397        .unwrap_or("application/octet-stream");
398    let content_type = super::ContentType::from(content_type);
399
400    if !status.is_client_error() && !status.is_server_error() {
401        let content = resp.text().await?;
402        match content_type {
403            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
404            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IssuedApiKey`"))),
405            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IssuedApiKey`")))),
406        }
407    } else {
408        let content = resp.text().await?;
409        let entity: Option<AdminGetIssuedApiKeyError> = serde_json::from_str(&content).ok();
410        Err(Error::ResponseError(ResponseContent { status, content, entity }))
411    }
412}
413
414/// 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\": \"sk_live_abc123xyz\",   \"name\": \"Imported Stripe Key\",   \"actor_id\": \"user_123\" } ```
415pub async fn admin_import_api_key(configuration: &configuration::Configuration, import_api_key_request: models::ImportApiKeyRequest) -> Result<models::ImportedApiKey, Error<AdminImportApiKeyError>> {
416    // add a prefix to parameters to efficiently prevent name collisions
417    let p_body_import_api_key_request = import_api_key_request;
418
419    let uri_str = format!("{}/v2alpha1/admin/importedApiKeys", configuration.base_path);
420    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
421
422    if let Some(ref user_agent) = configuration.user_agent {
423        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
424    }
425    if let Some(ref token) = configuration.bearer_access_token {
426        req_builder = req_builder.bearer_auth(token.to_owned());
427    };
428    req_builder = req_builder.json(&p_body_import_api_key_request);
429
430    let req = req_builder.build()?;
431    let resp = configuration.client.execute(req).await?;
432
433    let status = resp.status();
434    let content_type = resp
435        .headers()
436        .get("content-type")
437        .and_then(|v| v.to_str().ok())
438        .unwrap_or("application/octet-stream");
439    let content_type = super::ContentType::from(content_type);
440
441    if !status.is_client_error() && !status.is_server_error() {
442        let content = resp.text().await?;
443        match content_type {
444            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
445            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ImportedApiKey`"))),
446            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ImportedApiKey`")))),
447        }
448    } else {
449        let content = resp.text().await?;
450        let entity: Option<AdminImportApiKeyError> = serde_json::from_str(&content).ok();
451        Err(Error::ResponseError(ResponseContent { status, content, entity }))
452    }
453}
454
455/// 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\" } ```
456pub async fn admin_issue_api_key(configuration: &configuration::Configuration, issue_api_key_request: models::IssueApiKeyRequest) -> Result<models::IssueApiKeyResponse, Error<AdminIssueApiKeyError>> {
457    // add a prefix to parameters to efficiently prevent name collisions
458    let p_body_issue_api_key_request = issue_api_key_request;
459
460    let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys", configuration.base_path);
461    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
462
463    if let Some(ref user_agent) = configuration.user_agent {
464        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
465    }
466    if let Some(ref token) = configuration.bearer_access_token {
467        req_builder = req_builder.bearer_auth(token.to_owned());
468    };
469    req_builder = req_builder.json(&p_body_issue_api_key_request);
470
471    let req = req_builder.build()?;
472    let resp = configuration.client.execute(req).await?;
473
474    let status = resp.status();
475    let content_type = resp
476        .headers()
477        .get("content-type")
478        .and_then(|v| v.to_str().ok())
479        .unwrap_or("application/octet-stream");
480    let content_type = super::ContentType::from(content_type);
481
482    if !status.is_client_error() && !status.is_server_error() {
483        let content = resp.text().await?;
484        match content_type {
485            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
486            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IssueApiKeyResponse`"))),
487            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IssueApiKeyResponse`")))),
488        }
489    } else {
490        let content = resp.text().await?;
491        let entity: Option<AdminIssueApiKeyError> = serde_json::from_str(&content).ok();
492        Err(Error::ResponseError(ResponseContent { status, content, entity }))
493    }
494}
495
496/// 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 ```
497pub async fn admin_list_imported_api_keys(configuration: &configuration::Configuration, page_size: Option<i32>, page_token: Option<&str>, filter: Option<&str>) -> Result<models::ListImportedApiKeysResponse, Error<AdminListImportedApiKeysError>> {
498    // add a prefix to parameters to efficiently prevent name collisions
499    let p_query_page_size = page_size;
500    let p_query_page_token = page_token;
501    let p_query_filter = filter;
502
503    let uri_str = format!("{}/v2alpha1/admin/importedApiKeys", configuration.base_path);
504    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
505
506    if let Some(ref param_value) = p_query_page_size {
507        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
508    }
509    if let Some(ref param_value) = p_query_page_token {
510        req_builder = req_builder.query(&[("page_token", &param_value.to_string())]);
511    }
512    if let Some(ref param_value) = p_query_filter {
513        req_builder = req_builder.query(&[("filter", &param_value.to_string())]);
514    }
515    if let Some(ref user_agent) = configuration.user_agent {
516        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
517    }
518    if let Some(ref token) = configuration.bearer_access_token {
519        req_builder = req_builder.bearer_auth(token.to_owned());
520    };
521
522    let req = req_builder.build()?;
523    let resp = configuration.client.execute(req).await?;
524
525    let status = resp.status();
526    let content_type = resp
527        .headers()
528        .get("content-type")
529        .and_then(|v| v.to_str().ok())
530        .unwrap_or("application/octet-stream");
531    let content_type = super::ContentType::from(content_type);
532
533    if !status.is_client_error() && !status.is_server_error() {
534        let content = resp.text().await?;
535        match content_type {
536            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
537            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListImportedApiKeysResponse`"))),
538            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListImportedApiKeysResponse`")))),
539        }
540    } else {
541        let content = resp.text().await?;
542        let entity: Option<AdminListImportedApiKeysError> = serde_json::from_str(&content).ok();
543        Err(Error::ResponseError(ResponseContent { status, content, entity }))
544    }
545}
546
547/// 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 ```
548pub async fn admin_list_issued_api_keys(configuration: &configuration::Configuration, page_size: Option<i32>, page_token: Option<&str>, filter: Option<&str>) -> Result<models::ListIssuedApiKeysResponse, Error<AdminListIssuedApiKeysError>> {
549    // add a prefix to parameters to efficiently prevent name collisions
550    let p_query_page_size = page_size;
551    let p_query_page_token = page_token;
552    let p_query_filter = filter;
553
554    let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys", configuration.base_path);
555    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
556
557    if let Some(ref param_value) = p_query_page_size {
558        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
559    }
560    if let Some(ref param_value) = p_query_page_token {
561        req_builder = req_builder.query(&[("page_token", &param_value.to_string())]);
562    }
563    if let Some(ref param_value) = p_query_filter {
564        req_builder = req_builder.query(&[("filter", &param_value.to_string())]);
565    }
566    if let Some(ref user_agent) = configuration.user_agent {
567        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
568    }
569    if let Some(ref token) = configuration.bearer_access_token {
570        req_builder = req_builder.bearer_auth(token.to_owned());
571    };
572
573    let req = req_builder.build()?;
574    let resp = configuration.client.execute(req).await?;
575
576    let status = resp.status();
577    let content_type = resp
578        .headers()
579        .get("content-type")
580        .and_then(|v| v.to_str().ok())
581        .unwrap_or("application/octet-stream");
582    let content_type = super::ContentType::from(content_type);
583
584    if !status.is_client_error() && !status.is_server_error() {
585        let content = resp.text().await?;
586        match content_type {
587            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
588            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListIssuedApiKeysResponse`"))),
589            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListIssuedApiKeysResponse`")))),
590        }
591    } else {
592        let content = resp.text().await?;
593        let entity: Option<AdminListIssuedApiKeysError> = serde_json::from_str(&content).ok();
594        Err(Error::ResponseError(ResponseContent { status, content, entity }))
595    }
596}
597
598/// 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\" } ```
599pub async fn admin_revoke_imported_api_key(configuration: &configuration::Configuration, key_id: &str, admin_revoke_imported_api_key_body: models::AdminRevokeImportedApiKeyBody) -> Result<serde_json::Value, Error<AdminRevokeImportedApiKeyError>> {
600    // add a prefix to parameters to efficiently prevent name collisions
601    let p_path_key_id = key_id;
602    let p_body_admin_revoke_imported_api_key_body = admin_revoke_imported_api_key_body;
603
604    let uri_str = format!("{}/v2alpha1/admin/importedApiKeys/{key_id}:revoke", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
605    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
606
607    if let Some(ref user_agent) = configuration.user_agent {
608        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
609    }
610    if let Some(ref token) = configuration.bearer_access_token {
611        req_builder = req_builder.bearer_auth(token.to_owned());
612    };
613    req_builder = req_builder.json(&p_body_admin_revoke_imported_api_key_body);
614
615    let req = req_builder.build()?;
616    let resp = configuration.client.execute(req).await?;
617
618    let status = resp.status();
619    let content_type = resp
620        .headers()
621        .get("content-type")
622        .and_then(|v| v.to_str().ok())
623        .unwrap_or("application/octet-stream");
624    let content_type = super::ContentType::from(content_type);
625
626    if !status.is_client_error() && !status.is_server_error() {
627        let content = resp.text().await?;
628        match content_type {
629            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
630            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
631            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
632        }
633    } else {
634        let content = resp.text().await?;
635        let entity: Option<AdminRevokeImportedApiKeyError> = serde_json::from_str(&content).ok();
636        Err(Error::ResponseError(ResponseContent { status, content, entity }))
637    }
638}
639
640/// 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\" } ```
641pub async fn admin_revoke_issued_api_key(configuration: &configuration::Configuration, key_id: &str, admin_revoke_issued_api_key_body: models::AdminRevokeIssuedApiKeyBody) -> Result<serde_json::Value, Error<AdminRevokeIssuedApiKeyError>> {
642    // add a prefix to parameters to efficiently prevent name collisions
643    let p_path_key_id = key_id;
644    let p_body_admin_revoke_issued_api_key_body = admin_revoke_issued_api_key_body;
645
646    let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys/{key_id}:revoke", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
647    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
648
649    if let Some(ref user_agent) = configuration.user_agent {
650        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
651    }
652    if let Some(ref token) = configuration.bearer_access_token {
653        req_builder = req_builder.bearer_auth(token.to_owned());
654    };
655    req_builder = req_builder.json(&p_body_admin_revoke_issued_api_key_body);
656
657    let req = req_builder.build()?;
658    let resp = configuration.client.execute(req).await?;
659
660    let status = resp.status();
661    let content_type = resp
662        .headers()
663        .get("content-type")
664        .and_then(|v| v.to_str().ok())
665        .unwrap_or("application/octet-stream");
666    let content_type = super::ContentType::from(content_type);
667
668    if !status.is_client_error() && !status.is_server_error() {
669        let content = resp.text().await?;
670        match content_type {
671            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
672            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
673            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
674        }
675    } else {
676        let content = resp.text().await?;
677        let entity: Option<AdminRevokeIssuedApiKeyError> = serde_json::from_str(&content).ok();
678        Err(Error::ResponseError(ResponseContent { status, content, entity }))
679    }
680}
681
682/// 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\"] } ```
683pub async fn admin_rotate_issued_api_key(configuration: &configuration::Configuration, key_id: &str, admin_rotate_issued_api_key_body: models::AdminRotateIssuedApiKeyBody) -> Result<models::RotateIssuedApiKeyResponse, Error<AdminRotateIssuedApiKeyError>> {
684    // add a prefix to parameters to efficiently prevent name collisions
685    let p_path_key_id = key_id;
686    let p_body_admin_rotate_issued_api_key_body = admin_rotate_issued_api_key_body;
687
688    let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys/{key_id}:rotate", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
689    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
690
691    if let Some(ref user_agent) = configuration.user_agent {
692        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
693    }
694    if let Some(ref token) = configuration.bearer_access_token {
695        req_builder = req_builder.bearer_auth(token.to_owned());
696    };
697    req_builder = req_builder.json(&p_body_admin_rotate_issued_api_key_body);
698
699    let req = req_builder.build()?;
700    let resp = configuration.client.execute(req).await?;
701
702    let status = resp.status();
703    let content_type = resp
704        .headers()
705        .get("content-type")
706        .and_then(|v| v.to_str().ok())
707        .unwrap_or("application/octet-stream");
708    let content_type = super::ContentType::from(content_type);
709
710    if !status.is_client_error() && !status.is_server_error() {
711        let content = resp.text().await?;
712        match content_type {
713            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
714            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RotateIssuedApiKeyResponse`"))),
715            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RotateIssuedApiKeyResponse`")))),
716        }
717    } else {
718        let content = resp.text().await?;
719        let entity: Option<AdminRotateIssuedApiKeyError> = serde_json::from_str(&content).ok();
720        Err(Error::ResponseError(ResponseContent { status, content, entity }))
721    }
722}
723
724/// 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\"   } } ```
725pub async fn admin_update_imported_api_key(configuration: &configuration::Configuration, key_id: &str, admin_update_imported_api_key_request: models::AdminUpdateImportedApiKeyRequest, update_mask: Option<&str>) -> Result<models::ImportedApiKey, Error<AdminUpdateImportedApiKeyError>> {
726    // add a prefix to parameters to efficiently prevent name collisions
727    let p_path_key_id = key_id;
728    let p_body_admin_update_imported_api_key_request = admin_update_imported_api_key_request;
729    let p_query_update_mask = update_mask;
730
731    let uri_str = format!("{}/v2alpha1/admin/importedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
732    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
733
734    if let Some(ref param_value) = p_query_update_mask {
735        req_builder = req_builder.query(&[("update_mask", &param_value.to_string())]);
736    }
737    if let Some(ref user_agent) = configuration.user_agent {
738        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
739    }
740    if let Some(ref token) = configuration.bearer_access_token {
741        req_builder = req_builder.bearer_auth(token.to_owned());
742    };
743    req_builder = req_builder.json(&p_body_admin_update_imported_api_key_request);
744
745    let req = req_builder.build()?;
746    let resp = configuration.client.execute(req).await?;
747
748    let status = resp.status();
749    let content_type = resp
750        .headers()
751        .get("content-type")
752        .and_then(|v| v.to_str().ok())
753        .unwrap_or("application/octet-stream");
754    let content_type = super::ContentType::from(content_type);
755
756    if !status.is_client_error() && !status.is_server_error() {
757        let content = resp.text().await?;
758        match content_type {
759            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
760            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ImportedApiKey`"))),
761            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ImportedApiKey`")))),
762        }
763    } else {
764        let content = resp.text().await?;
765        let entity: Option<AdminUpdateImportedApiKeyError> = serde_json::from_str(&content).ok();
766        Err(Error::ResponseError(ResponseContent { status, content, entity }))
767    }
768}
769
770/// 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\"]   } } ```
771pub async fn admin_update_issued_api_key(configuration: &configuration::Configuration, key_id: &str, admin_update_issued_api_key_request: models::AdminUpdateIssuedApiKeyRequest, update_mask: Option<&str>) -> Result<models::IssuedApiKey, Error<AdminUpdateIssuedApiKeyError>> {
772    // add a prefix to parameters to efficiently prevent name collisions
773    let p_path_key_id = key_id;
774    let p_body_admin_update_issued_api_key_request = admin_update_issued_api_key_request;
775    let p_query_update_mask = update_mask;
776
777    let uri_str = format!("{}/v2alpha1/admin/issuedApiKeys/{key_id}", configuration.base_path, key_id=crate::apis::urlencode(p_path_key_id));
778    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
779
780    if let Some(ref param_value) = p_query_update_mask {
781        req_builder = req_builder.query(&[("update_mask", &param_value.to_string())]);
782    }
783    if let Some(ref user_agent) = configuration.user_agent {
784        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
785    }
786    if let Some(ref token) = configuration.bearer_access_token {
787        req_builder = req_builder.bearer_auth(token.to_owned());
788    };
789    req_builder = req_builder.json(&p_body_admin_update_issued_api_key_request);
790
791    let req = req_builder.build()?;
792    let resp = configuration.client.execute(req).await?;
793
794    let status = resp.status();
795    let content_type = resp
796        .headers()
797        .get("content-type")
798        .and_then(|v| v.to_str().ok())
799        .unwrap_or("application/octet-stream");
800    let content_type = super::ContentType::from(content_type);
801
802    if !status.is_client_error() && !status.is_server_error() {
803        let content = resp.text().await?;
804        match content_type {
805            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
806            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IssuedApiKey`"))),
807            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IssuedApiKey`")))),
808        }
809    } else {
810        let content = resp.text().await?;
811        let entity: Option<AdminUpdateIssuedApiKeyError> = serde_json::from_str(&content).ok();
812        Err(Error::ResponseError(ResponseContent { status, content, entity }))
813    }
814}
815
816/// 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...\" } ```
817pub async fn admin_verify_api_key(configuration: &configuration::Configuration, verify_api_key_request: models::VerifyApiKeyRequest, cache_control: Option<&str>, pragma: Option<&str>) -> Result<models::VerifyApiKeyResponse, Error<AdminVerifyApiKeyError>> {
818    // add a prefix to parameters to efficiently prevent name collisions
819    let p_body_verify_api_key_request = verify_api_key_request;
820    let p_header_cache_control = cache_control;
821    let p_header_pragma = pragma;
822
823    let uri_str = format!("{}/v2alpha1/admin/apiKeys:verify", configuration.base_path);
824    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
825
826    if let Some(ref user_agent) = configuration.user_agent {
827        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
828    }
829    if let Some(param_value) = p_header_cache_control {
830        req_builder = req_builder.header("Cache-Control", param_value.to_string());
831    }
832    if let Some(param_value) = p_header_pragma {
833        req_builder = req_builder.header("Pragma", param_value.to_string());
834    }
835    if let Some(ref token) = configuration.bearer_access_token {
836        req_builder = req_builder.bearer_auth(token.to_owned());
837    };
838    req_builder = req_builder.json(&p_body_verify_api_key_request);
839
840    let req = req_builder.build()?;
841    let resp = configuration.client.execute(req).await?;
842
843    let status = resp.status();
844    let content_type = resp
845        .headers()
846        .get("content-type")
847        .and_then(|v| v.to_str().ok())
848        .unwrap_or("application/octet-stream");
849    let content_type = super::ContentType::from(content_type);
850
851    if !status.is_client_error() && !status.is_server_error() {
852        let content = resp.text().await?;
853        match content_type {
854            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
855            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerifyApiKeyResponse`"))),
856            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VerifyApiKeyResponse`")))),
857        }
858    } else {
859        let content = resp.text().await?;
860        let entity: Option<AdminVerifyApiKeyError> = serde_json::from_str(&content).ok();
861        Err(Error::ResponseError(ResponseContent { status, content, entity }))
862    }
863}
864
865/// 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 ```
866pub async fn get_jwks(configuration: &configuration::Configuration, ) -> Result<models::GetJwksResponse, Error<GetJwksError>> {
867
868    let uri_str = format!("{}/v2alpha1/derivedKeys/jwks.json", configuration.base_path);
869    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
870
871    if let Some(ref user_agent) = configuration.user_agent {
872        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
873    }
874
875    let req = req_builder.build()?;
876    let resp = configuration.client.execute(req).await?;
877
878    let status = resp.status();
879    let content_type = resp
880        .headers()
881        .get("content-type")
882        .and_then(|v| v.to_str().ok())
883        .unwrap_or("application/octet-stream");
884    let content_type = super::ContentType::from(content_type);
885
886    if !status.is_client_error() && !status.is_server_error() {
887        let content = resp.text().await?;
888        match content_type {
889            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
890            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetJwksResponse`"))),
891            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetJwksResponse`")))),
892        }
893    } else {
894        let content = resp.text().await?;
895        let entity: Option<GetJwksError> = serde_json::from_str(&content).ok();
896        Err(Error::ResponseError(ResponseContent { status, content, entity }))
897    }
898}
899
900/// 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\" } ```
901pub async fn revoke_api_key(configuration: &configuration::Configuration, self_revoke_api_key_request: models::SelfRevokeApiKeyRequest) -> Result<serde_json::Value, Error<RevokeApiKeyError>> {
902    // add a prefix to parameters to efficiently prevent name collisions
903    let p_body_self_revoke_api_key_request = self_revoke_api_key_request;
904
905    let uri_str = format!("{}/v2alpha1/apiKeys:selfRevoke", configuration.base_path);
906    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
907
908    if let Some(ref user_agent) = configuration.user_agent {
909        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
910    }
911    req_builder = req_builder.json(&p_body_self_revoke_api_key_request);
912
913    let req = req_builder.build()?;
914    let resp = configuration.client.execute(req).await?;
915
916    let status = resp.status();
917    let content_type = resp
918        .headers()
919        .get("content-type")
920        .and_then(|v| v.to_str().ok())
921        .unwrap_or("application/octet-stream");
922    let content_type = super::ContentType::from(content_type);
923
924    if !status.is_client_error() && !status.is_server_error() {
925        let content = resp.text().await?;
926        match content_type {
927            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
928            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
929            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
930        }
931    } else {
932        let content = resp.text().await?;
933        let entity: Option<RevokeApiKeyError> = serde_json::from_str(&content).ok();
934        Err(Error::ResponseError(ResponseContent { status, content, entity }))
935    }
936}
937