ory_client/apis/
jwk_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.17.2
7 * Contact: support@ory.sh
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`create_json_web_key_set`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateJsonWebKeySetError {
22    DefaultResponse(models::ErrorOAuth2),
23    UnknownValue(serde_json::Value),
24}
25
26/// struct for typed errors of method [`delete_json_web_key`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum DeleteJsonWebKeyError {
30    DefaultResponse(models::ErrorOAuth2),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`delete_json_web_key_set`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum DeleteJsonWebKeySetError {
38    DefaultResponse(models::ErrorOAuth2),
39    UnknownValue(serde_json::Value),
40}
41
42/// struct for typed errors of method [`get_json_web_key`]
43#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum GetJsonWebKeyError {
46    DefaultResponse(models::ErrorOAuth2),
47    UnknownValue(serde_json::Value),
48}
49
50/// struct for typed errors of method [`get_json_web_key_set`]
51#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum GetJsonWebKeySetError {
54    DefaultResponse(models::ErrorOAuth2),
55    UnknownValue(serde_json::Value),
56}
57
58/// struct for typed errors of method [`set_json_web_key`]
59#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum SetJsonWebKeyError {
62    DefaultResponse(models::ErrorOAuth2),
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method [`set_json_web_key_set`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum SetJsonWebKeySetError {
70    DefaultResponse(models::ErrorOAuth2),
71    UnknownValue(serde_json::Value),
72}
73
74
75/// This endpoint is capable of generating JSON Web Key Sets for you. There a different strategies available, such as symmetric cryptographic keys (HS256, HS512) and asymetric cryptographic keys (RS256, ECDSA). If the specified JSON Web Key Set does not exist, it will be created.  A JSON Web Key (JWK) is a JavaScript Object Notation (JSON) data structure that represents a cryptographic key. A JWK Set is a JSON data structure that represents a set of JWKs. A JSON Web Key is identified by its set and key id. ORY Hydra uses this functionality to store cryptographic keys used for TLS and JSON Web Tokens (such as OpenID Connect ID tokens), and allows storing user-defined keys as well.
76pub async fn create_json_web_key_set(configuration: &configuration::Configuration, set: &str, create_json_web_key_set: models::CreateJsonWebKeySet) -> Result<models::JsonWebKeySet, Error<CreateJsonWebKeySetError>> {
77    let local_var_configuration = configuration;
78
79    let local_var_client = &local_var_configuration.client;
80
81    let local_var_uri_str = format!("{}/admin/keys/{set}", local_var_configuration.base_path, set=crate::apis::urlencode(set));
82    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
83
84    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
85        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
86    }
87    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
88        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
89    };
90    local_var_req_builder = local_var_req_builder.json(&create_json_web_key_set);
91
92    let local_var_req = local_var_req_builder.build()?;
93    let local_var_resp = local_var_client.execute(local_var_req).await?;
94
95    let local_var_status = local_var_resp.status();
96    let local_var_content = local_var_resp.text().await?;
97
98    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
99        serde_json::from_str(&local_var_content).map_err(Error::from)
100    } else {
101        let local_var_entity: Option<CreateJsonWebKeySetError> = serde_json::from_str(&local_var_content).ok();
102        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
103        Err(Error::ResponseError(local_var_error))
104    }
105}
106
107/// Use this endpoint to delete a single JSON Web Key.  A JSON Web Key (JWK) is a JavaScript Object Notation (JSON) data structure that represents a cryptographic key. A JWK Set is a JSON data structure that represents a set of JWKs. A JSON Web Key is identified by its set and key id. ORY Hydra uses this functionality to store cryptographic keys used for TLS and JSON Web Tokens (such as OpenID Connect ID tokens), and allows storing user-defined keys as well.
108pub async fn delete_json_web_key(configuration: &configuration::Configuration, set: &str, kid: &str) -> Result<(), Error<DeleteJsonWebKeyError>> {
109    let local_var_configuration = configuration;
110
111    let local_var_client = &local_var_configuration.client;
112
113    let local_var_uri_str = format!("{}/admin/keys/{set}/{kid}", local_var_configuration.base_path, set=crate::apis::urlencode(set), kid=crate::apis::urlencode(kid));
114    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
115
116    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
117        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
118    }
119    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
120        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
121    };
122
123    let local_var_req = local_var_req_builder.build()?;
124    let local_var_resp = local_var_client.execute(local_var_req).await?;
125
126    let local_var_status = local_var_resp.status();
127    let local_var_content = local_var_resp.text().await?;
128
129    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
130        Ok(())
131    } else {
132        let local_var_entity: Option<DeleteJsonWebKeyError> = serde_json::from_str(&local_var_content).ok();
133        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
134        Err(Error::ResponseError(local_var_error))
135    }
136}
137
138/// Use this endpoint to delete a complete JSON Web Key Set and all the keys in that set.  A JSON Web Key (JWK) is a JavaScript Object Notation (JSON) data structure that represents a cryptographic key. A JWK Set is a JSON data structure that represents a set of JWKs. A JSON Web Key is identified by its set and key id. ORY Hydra uses this functionality to store cryptographic keys used for TLS and JSON Web Tokens (such as OpenID Connect ID tokens), and allows storing user-defined keys as well.
139pub async fn delete_json_web_key_set(configuration: &configuration::Configuration, set: &str) -> Result<(), Error<DeleteJsonWebKeySetError>> {
140    let local_var_configuration = configuration;
141
142    let local_var_client = &local_var_configuration.client;
143
144    let local_var_uri_str = format!("{}/admin/keys/{set}", local_var_configuration.base_path, set=crate::apis::urlencode(set));
145    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
146
147    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
148        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
149    }
150    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
151        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
152    };
153
154    let local_var_req = local_var_req_builder.build()?;
155    let local_var_resp = local_var_client.execute(local_var_req).await?;
156
157    let local_var_status = local_var_resp.status();
158    let local_var_content = local_var_resp.text().await?;
159
160    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
161        Ok(())
162    } else {
163        let local_var_entity: Option<DeleteJsonWebKeySetError> = serde_json::from_str(&local_var_content).ok();
164        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
165        Err(Error::ResponseError(local_var_error))
166    }
167}
168
169/// This endpoint returns a singular JSON Web Key contained in a set. It is identified by the set and the specific key ID (kid).
170pub async fn get_json_web_key(configuration: &configuration::Configuration, set: &str, kid: &str) -> Result<models::JsonWebKeySet, Error<GetJsonWebKeyError>> {
171    let local_var_configuration = configuration;
172
173    let local_var_client = &local_var_configuration.client;
174
175    let local_var_uri_str = format!("{}/admin/keys/{set}/{kid}", local_var_configuration.base_path, set=crate::apis::urlencode(set), kid=crate::apis::urlencode(kid));
176    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
177
178    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
179        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
180    }
181    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
182        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
183    };
184
185    let local_var_req = local_var_req_builder.build()?;
186    let local_var_resp = local_var_client.execute(local_var_req).await?;
187
188    let local_var_status = local_var_resp.status();
189    let local_var_content = local_var_resp.text().await?;
190
191    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
192        serde_json::from_str(&local_var_content).map_err(Error::from)
193    } else {
194        let local_var_entity: Option<GetJsonWebKeyError> = serde_json::from_str(&local_var_content).ok();
195        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
196        Err(Error::ResponseError(local_var_error))
197    }
198}
199
200/// This endpoint can be used to retrieve JWK Sets stored in ORY Hydra.  A JSON Web Key (JWK) is a JavaScript Object Notation (JSON) data structure that represents a cryptographic key. A JWK Set is a JSON data structure that represents a set of JWKs. A JSON Web Key is identified by its set and key id. ORY Hydra uses this functionality to store cryptographic keys used for TLS and JSON Web Tokens (such as OpenID Connect ID tokens), and allows storing user-defined keys as well.
201pub async fn get_json_web_key_set(configuration: &configuration::Configuration, set: &str) -> Result<models::JsonWebKeySet, Error<GetJsonWebKeySetError>> {
202    let local_var_configuration = configuration;
203
204    let local_var_client = &local_var_configuration.client;
205
206    let local_var_uri_str = format!("{}/admin/keys/{set}", local_var_configuration.base_path, set=crate::apis::urlencode(set));
207    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
208
209    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
210        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
211    }
212    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
213        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
214    };
215
216    let local_var_req = local_var_req_builder.build()?;
217    let local_var_resp = local_var_client.execute(local_var_req).await?;
218
219    let local_var_status = local_var_resp.status();
220    let local_var_content = local_var_resp.text().await?;
221
222    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
223        serde_json::from_str(&local_var_content).map_err(Error::from)
224    } else {
225        let local_var_entity: Option<GetJsonWebKeySetError> = serde_json::from_str(&local_var_content).ok();
226        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
227        Err(Error::ResponseError(local_var_error))
228    }
229}
230
231/// Use this method if you do not want to let Hydra generate the JWKs for you, but instead save your own.  A JSON Web Key (JWK) is a JavaScript Object Notation (JSON) data structure that represents a cryptographic key. A JWK Set is a JSON data structure that represents a set of JWKs. A JSON Web Key is identified by its set and key id. ORY Hydra uses this functionality to store cryptographic keys used for TLS and JSON Web Tokens (such as OpenID Connect ID tokens), and allows storing user-defined keys as well.
232pub async fn set_json_web_key(configuration: &configuration::Configuration, set: &str, kid: &str, json_web_key: Option<models::JsonWebKey>) -> Result<models::JsonWebKey, Error<SetJsonWebKeyError>> {
233    let local_var_configuration = configuration;
234
235    let local_var_client = &local_var_configuration.client;
236
237    let local_var_uri_str = format!("{}/admin/keys/{set}/{kid}", local_var_configuration.base_path, set=crate::apis::urlencode(set), kid=crate::apis::urlencode(kid));
238    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
239
240    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
241        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
242    }
243    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
244        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
245    };
246    local_var_req_builder = local_var_req_builder.json(&json_web_key);
247
248    let local_var_req = local_var_req_builder.build()?;
249    let local_var_resp = local_var_client.execute(local_var_req).await?;
250
251    let local_var_status = local_var_resp.status();
252    let local_var_content = local_var_resp.text().await?;
253
254    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
255        serde_json::from_str(&local_var_content).map_err(Error::from)
256    } else {
257        let local_var_entity: Option<SetJsonWebKeyError> = serde_json::from_str(&local_var_content).ok();
258        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
259        Err(Error::ResponseError(local_var_error))
260    }
261}
262
263/// Use this method if you do not want to let Hydra generate the JWKs for you, but instead save your own.  A JSON Web Key (JWK) is a JavaScript Object Notation (JSON) data structure that represents a cryptographic key. A JWK Set is a JSON data structure that represents a set of JWKs. A JSON Web Key is identified by its set and key id. ORY Hydra uses this functionality to store cryptographic keys used for TLS and JSON Web Tokens (such as OpenID Connect ID tokens), and allows storing user-defined keys as well.
264pub async fn set_json_web_key_set(configuration: &configuration::Configuration, set: &str, json_web_key_set: Option<models::JsonWebKeySet>) -> Result<models::JsonWebKeySet, Error<SetJsonWebKeySetError>> {
265    let local_var_configuration = configuration;
266
267    let local_var_client = &local_var_configuration.client;
268
269    let local_var_uri_str = format!("{}/admin/keys/{set}", local_var_configuration.base_path, set=crate::apis::urlencode(set));
270    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
271
272    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
273        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
274    }
275    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
276        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
277    };
278    local_var_req_builder = local_var_req_builder.json(&json_web_key_set);
279
280    let local_var_req = local_var_req_builder.build()?;
281    let local_var_resp = local_var_client.execute(local_var_req).await?;
282
283    let local_var_status = local_var_resp.status();
284    let local_var_content = local_var_resp.text().await?;
285
286    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
287        serde_json::from_str(&local_var_content).map_err(Error::from)
288    } else {
289        let local_var_entity: Option<SetJsonWebKeySetError> = serde_json::from_str(&local_var_content).ok();
290        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
291        Err(Error::ResponseError(local_var_error))
292    }
293}
294