Skip to main content

orvanta_api/apis/
agent_workers_api.rs

1/*
2 * Orvanta API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 6.5.0
7 * Contact: contact@orvanta.cloud
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 [`blacklist_agent_token`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum BlacklistAgentTokenError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`create_agent_token`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CreateAgentTokenError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_agent_workspace_licence`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetAgentWorkspaceLicenceError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`get_min_version`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetMinVersionError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`list_blacklisted_agent_tokens`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ListBlacklistedAgentTokensError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`remove_blacklist_agent_token`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum RemoveBlacklistAgentTokenError {
57    UnknownValue(serde_json::Value),
58}
59
60
61pub async fn blacklist_agent_token(configuration: &configuration::Configuration, blacklist_agent_token_request: models::BlacklistAgentTokenRequest) -> Result<(), Error<BlacklistAgentTokenError>> {
62    let local_var_configuration = configuration;
63
64    let local_var_client = &local_var_configuration.client;
65
66    let local_var_uri_str = format!("{}/agent_workers/blacklist_token", local_var_configuration.base_path);
67    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
68
69    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
70        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
71    }
72    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
73        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
74    };
75    local_var_req_builder = local_var_req_builder.json(&blacklist_agent_token_request);
76
77    let local_var_req = local_var_req_builder.build()?;
78    let local_var_resp = local_var_client.execute(local_var_req).await?;
79
80    let local_var_status = local_var_resp.status();
81    let local_var_content = local_var_resp.text().await?;
82
83    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
84        Ok(())
85    } else {
86        let local_var_entity: Option<BlacklistAgentTokenError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
87        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
88        Err(Error::ResponseError(local_var_error))
89    }
90}
91
92pub async fn create_agent_token(configuration: &configuration::Configuration, create_agent_token_request: models::CreateAgentTokenRequest) -> Result<String, Error<CreateAgentTokenError>> {
93    let local_var_configuration = configuration;
94
95    let local_var_client = &local_var_configuration.client;
96
97    let local_var_uri_str = format!("{}/agent_workers/create_agent_token", local_var_configuration.base_path);
98    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
99
100    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
101        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
102    }
103    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
104        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
105    };
106    local_var_req_builder = local_var_req_builder.json(&create_agent_token_request);
107
108    let local_var_req = local_var_req_builder.build()?;
109    let local_var_resp = local_var_client.execute(local_var_req).await?;
110
111    let local_var_status = local_var_resp.status();
112    let local_var_content = local_var_resp.text().await?;
113
114    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
115        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
116    } else {
117        let local_var_entity: Option<CreateAgentTokenError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
118        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
119        Err(Error::ResponseError(local_var_error))
120    }
121}
122
123/// Agent-token authenticated. The instance's licence mode and, in managed mode, the signed licence token of the one workspace the agent token is bound to. The agent re-verifies the token before using it.
124pub async fn get_agent_workspace_licence(configuration: &configuration::Configuration, ) -> Result<models::GetAgentWorkspaceLicence200Response, Error<GetAgentWorkspaceLicenceError>> {
125    let local_var_configuration = configuration;
126
127    let local_var_client = &local_var_configuration.client;
128
129    let local_var_uri_str = format!("{}/agent_workers/licence", local_var_configuration.base_path);
130    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
131
132    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
133        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
134    }
135    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
136        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
137    };
138
139    let local_var_req = local_var_req_builder.build()?;
140    let local_var_resp = local_var_client.execute(local_var_req).await?;
141
142    let local_var_status = local_var_resp.status();
143    let local_var_content = local_var_resp.text().await?;
144
145    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
146        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
147    } else {
148        let local_var_entity: Option<GetAgentWorkspaceLicenceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
149        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
150        Err(Error::ResponseError(local_var_error))
151    }
152}
153
154pub async fn get_min_version(configuration: &configuration::Configuration, ) -> Result<String, Error<GetMinVersionError>> {
155    let local_var_configuration = configuration;
156
157    let local_var_client = &local_var_configuration.client;
158
159    let local_var_uri_str = format!("{}/agent_workers/get_min_version", local_var_configuration.base_path);
160    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
161
162    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
163        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
164    }
165    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
166        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
167    };
168
169    let local_var_req = local_var_req_builder.build()?;
170    let local_var_resp = local_var_client.execute(local_var_req).await?;
171
172    let local_var_status = local_var_resp.status();
173    let local_var_content = local_var_resp.text().await?;
174
175    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
176        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
177    } else {
178        let local_var_entity: Option<GetMinVersionError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
179        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
180        Err(Error::ResponseError(local_var_error))
181    }
182}
183
184pub async fn list_blacklisted_agent_tokens(configuration: &configuration::Configuration, include_expired: Option<bool>) -> Result<Vec<models::ListBlacklistedAgentTokens200ResponseInner>, Error<ListBlacklistedAgentTokensError>> {
185    let local_var_configuration = configuration;
186
187    let local_var_client = &local_var_configuration.client;
188
189    let local_var_uri_str = format!("{}/agent_workers/list_blacklisted_tokens", local_var_configuration.base_path);
190    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
191
192    if let Some(ref local_var_str) = include_expired {
193        local_var_req_builder = local_var_req_builder.query(&[("include_expired", &local_var_str.to_string())]);
194    }
195    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
196        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
197    }
198    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
199        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
200    };
201
202    let local_var_req = local_var_req_builder.build()?;
203    let local_var_resp = local_var_client.execute(local_var_req).await?;
204
205    let local_var_status = local_var_resp.status();
206    let local_var_content = local_var_resp.text().await?;
207
208    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
209        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
210    } else {
211        let local_var_entity: Option<ListBlacklistedAgentTokensError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
212        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
213        Err(Error::ResponseError(local_var_error))
214    }
215}
216
217pub async fn remove_blacklist_agent_token(configuration: &configuration::Configuration, remove_blacklist_agent_token_request: models::RemoveBlacklistAgentTokenRequest) -> Result<(), Error<RemoveBlacklistAgentTokenError>> {
218    let local_var_configuration = configuration;
219
220    let local_var_client = &local_var_configuration.client;
221
222    let local_var_uri_str = format!("{}/agent_workers/remove_blacklist_token", local_var_configuration.base_path);
223    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
224
225    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
226        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
227    }
228    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
229        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
230    };
231    local_var_req_builder = local_var_req_builder.json(&remove_blacklist_agent_token_request);
232
233    let local_var_req = local_var_req_builder.build()?;
234    let local_var_resp = local_var_client.execute(local_var_req).await?;
235
236    let local_var_status = local_var_resp.status();
237    let local_var_content = local_var_resp.text().await?;
238
239    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
240        Ok(())
241    } else {
242        let local_var_entity: Option<RemoveBlacklistAgentTokenError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
243        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
244        Err(Error::ResponseError(local_var_error))
245    }
246}
247