sindri_openapi/apis/
authorization_api.rs

1/*
2 * Sindri Labs API
3 *
4 *  ## About [Sindri Labs](https://www.sindri.app/)' API simplifies the developer experience to enable fast and scalable zero-knowledge proof generation. Front-End Dashboard: [https://sindri.app/login](https://sindri.app/login) ## Documentation The [Sindri Documentation](https://sindri.app/docs) contains everything you need to get started! ## Sindri Resources The [sindri-resources GitHub repo](https://github.com/Sindri-Labs/sindri-resources) contains contains resources and sample data for the Sindri API. ## Using this Page This is a standard [OpenAPI (Swagger)](https://swagger.io/specification/) API documentation page. It provides detailed documentation for each endpoint. This page enables easy prototyping via the \"Try it out\" feature! Since all Sindri endpoints require a valid API Key, in order to use the \"Try it out\" feature for any endpoint in this documentation you must first obtain an API key. Do this in one of two ways: 1. Enter your username and password in the `/api/apikey/generate` endpoint of the **Authorization** section below. Use the API key returned in the `access` field of the response. 2. Obtain an API key from the Sindri Dashboard team \"Account Settings\". After obtaining your API key, authorize your page session by entering your API Key in the `SindriAPIKeyBearerAuth` section, reached by clicking \"Authorize\" below. Proving Backend Version: v1.2.17
5 *
6 * The version of the OpenAPI document: v1.17.28
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{Deserialize, Serialize};
15
16/// struct for typed errors of method [`apikey_delete`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum ApikeyDeleteError {
20    Status404(models::ApiKeyDoesNotExistResponse),
21    Status500(models::SindriInternalErrorResponse),
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`apikey_generate`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ApikeyGenerateError {
29    Status400(models::SindriValueErrorResponse),
30    Status403(models::ApiKeyErrorResponse),
31    Status401(models::ApiKeyErrorResponse),
32    UnknownValue(serde_json::Value),
33}
34
35/// struct for typed errors of method [`apikey_generate_with_auth`]
36#[derive(Debug, Clone, Serialize, Deserialize)]
37#[serde(untagged)]
38pub enum ApikeyGenerateWithAuthError {
39    Status400(models::SindriValueErrorResponse),
40    UnknownValue(serde_json::Value),
41}
42
43/// struct for typed errors of method [`apikey_list`]
44#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum ApikeyListError {
47    Status500(models::SindriInternalErrorResponse),
48    UnknownValue(serde_json::Value),
49}
50
51/// Delete a specific API key.
52pub async fn apikey_delete(
53    configuration: &configuration::Configuration,
54    apikey_id: Option<&str>,
55) -> Result<models::ActionResponse, Error<ApikeyDeleteError>> {
56    // add a prefix to parameters to efficiently prevent name collisions
57    let p_apikey_id = apikey_id;
58
59    let uri_str = format!(
60        "{}/api/v1/apikey/{apikey_id}/delete",
61        configuration.base_path,
62        apikey_id = crate::apis::urlencode(p_apikey_id.unwrap())
63    );
64    let mut req_builder = configuration
65        .client
66        .request(reqwest::Method::DELETE, &uri_str);
67
68    if let Some(ref user_agent) = configuration.user_agent {
69        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
70    }
71    if let Some(ref token) = configuration.bearer_access_token {
72        req_builder = req_builder.bearer_auth(token.to_owned());
73    };
74    if let Some(ref token) = configuration.bearer_access_token {
75        req_builder = req_builder.bearer_auth(token.to_owned());
76    };
77
78    let req = req_builder.build()?;
79    let resp = configuration.client.execute(req).await?;
80
81    let status = resp.status();
82
83    if !status.is_client_error() && !status.is_server_error() {
84        let content = resp.text().await?;
85        serde_json::from_str(&content).map_err(Error::from)
86    } else {
87        let content = resp.text().await?;
88        let entity: Option<ApikeyDeleteError> = serde_json::from_str(&content).ok();
89        Err(Error::ResponseError(ResponseContent {
90            status,
91            content,
92            entity,
93        }))
94    }
95}
96
97/// Generates a long-term API Key from your account's username and password.
98pub async fn apikey_generate(
99    configuration: &configuration::Configuration,
100    obtain_apikey_input: models::ObtainApikeyInput,
101    sindri_team_id: Option<&str>,
102) -> Result<models::ApiKeyResponse, Error<ApikeyGenerateError>> {
103    // add a prefix to parameters to efficiently prevent name collisions
104    let p_obtain_apikey_input = obtain_apikey_input;
105    let p_sindri_team_id = sindri_team_id;
106
107    let uri_str = format!("{}/api/apikey/generate", configuration.base_path);
108    let mut req_builder = configuration
109        .client
110        .request(reqwest::Method::POST, &uri_str);
111
112    if let Some(ref user_agent) = configuration.user_agent {
113        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
114    }
115    if let Some(param_value) = p_sindri_team_id {
116        req_builder = req_builder.header("Sindri-Team-Id", param_value.to_string());
117    }
118    req_builder = req_builder.json(&p_obtain_apikey_input);
119
120    let req = req_builder.build()?;
121    let resp = configuration.client.execute(req).await?;
122
123    let status = resp.status();
124
125    if !status.is_client_error() && !status.is_server_error() {
126        let content = resp.text().await?;
127        serde_json::from_str(&content).map_err(Error::from)
128    } else {
129        let content = resp.text().await?;
130        let entity: Option<ApikeyGenerateError> = serde_json::from_str(&content).ok();
131        Err(Error::ResponseError(ResponseContent {
132            status,
133            content,
134            entity,
135        }))
136    }
137}
138
139/// Generate an API key for the requesting team.
140pub async fn apikey_generate_with_auth(
141    configuration: &configuration::Configuration,
142    name: Option<&str>,
143) -> Result<models::ApiKeyResponse, Error<ApikeyGenerateWithAuthError>> {
144    // add a prefix to parameters to efficiently prevent name collisions
145    let p_name = name;
146
147    let uri_str = format!("{}/api/v1/apikey/generate", configuration.base_path);
148    let mut req_builder = configuration
149        .client
150        .request(reqwest::Method::POST, &uri_str);
151
152    if let Some(ref param_value) = p_name {
153        req_builder = req_builder.query(&[("name", &param_value.to_string())]);
154    }
155    if let Some(ref user_agent) = configuration.user_agent {
156        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
157    }
158    if let Some(ref token) = configuration.bearer_access_token {
159        req_builder = req_builder.bearer_auth(token.to_owned());
160    };
161    if let Some(ref token) = configuration.bearer_access_token {
162        req_builder = req_builder.bearer_auth(token.to_owned());
163    };
164
165    let req = req_builder.build()?;
166    let resp = configuration.client.execute(req).await?;
167
168    let status = resp.status();
169
170    if !status.is_client_error() && !status.is_server_error() {
171        let content = resp.text().await?;
172        serde_json::from_str(&content).map_err(Error::from)
173    } else {
174        let content = resp.text().await?;
175        let entity: Option<ApikeyGenerateWithAuthError> = serde_json::from_str(&content).ok();
176        Err(Error::ResponseError(ResponseContent {
177            status,
178            content,
179            entity,
180        }))
181    }
182}
183
184/// List API keys for the requesting team.
185pub async fn apikey_list(
186    configuration: &configuration::Configuration,
187) -> Result<Vec<models::ApiKeyResponse>, Error<ApikeyListError>> {
188    let uri_str = format!("{}/api/v1/apikey/list", configuration.base_path);
189    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
190
191    if let Some(ref user_agent) = configuration.user_agent {
192        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
193    }
194    if let Some(ref token) = configuration.bearer_access_token {
195        req_builder = req_builder.bearer_auth(token.to_owned());
196    };
197    if let Some(ref token) = configuration.bearer_access_token {
198        req_builder = req_builder.bearer_auth(token.to_owned());
199    };
200
201    let req = req_builder.build()?;
202    let resp = configuration.client.execute(req).await?;
203
204    let status = resp.status();
205
206    if !status.is_client_error() && !status.is_server_error() {
207        let content = resp.text().await?;
208        serde_json::from_str(&content).map_err(Error::from)
209    } else {
210        let content = resp.text().await?;
211        let entity: Option<ApikeyListError> = serde_json::from_str(&content).ok();
212        Err(Error::ResponseError(ResponseContent {
213            status,
214            content,
215            entity,
216        }))
217    }
218}