1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum BackendVersionError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetBrandNameError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetEntitlementsError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetLicenseIdError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetOpenApiYamlError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetWorkspaceEntitlementsError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ListFeaturesError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum ListWorkspaceFeaturesError {
71 UnknownValue(serde_json::Value),
72}
73
74
75pub async fn backend_version(configuration: &configuration::Configuration, ) -> Result<String, Error<BackendVersionError>> {
76 let local_var_configuration = configuration;
77
78 let local_var_client = &local_var_configuration.client;
79
80 let local_var_uri_str = format!("{}/version", local_var_configuration.base_path);
81 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
82
83 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
84 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
85 }
86 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
87 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
88 };
89
90 let local_var_req = local_var_req_builder.build()?;
91 let local_var_resp = local_var_client.execute(local_var_req).await?;
92
93 let local_var_status = local_var_resp.status();
94 let local_var_content = local_var_resp.text().await?;
95
96 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
97 crate::from_str_patched(&local_var_content).map_err(Error::from)
98 } else {
99 let local_var_entity: Option<BackendVersionError> = crate::from_str_patched(&local_var_content).ok();
100 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
101 Err(Error::ResponseError(local_var_error))
102 }
103}
104
105pub async fn get_brand_name(configuration: &configuration::Configuration, ) -> Result<String, Error<GetBrandNameError>> {
107 let local_var_configuration = configuration;
108
109 let local_var_client = &local_var_configuration.client;
110
111 let local_var_uri_str = format!("{}/brand_name", local_var_configuration.base_path);
112 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
113
114 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
115 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
116 }
117 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
118 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
119 };
120
121 let local_var_req = local_var_req_builder.build()?;
122 let local_var_resp = local_var_client.execute(local_var_req).await?;
123
124 let local_var_status = local_var_resp.status();
125 let local_var_content = local_var_resp.text().await?;
126
127 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
128 crate::from_str_patched(&local_var_content).map_err(Error::from)
129 } else {
130 let local_var_entity: Option<GetBrandNameError> = crate::from_str_patched(&local_var_content).ok();
131 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
132 Err(Error::ResponseError(local_var_error))
133 }
134}
135
136pub async fn get_entitlements(configuration: &configuration::Configuration, ) -> Result<models::GetEntitlements200Response, Error<GetEntitlementsError>> {
137 let local_var_configuration = configuration;
138
139 let local_var_client = &local_var_configuration.client;
140
141 let local_var_uri_str = format!("{}/entitlements", local_var_configuration.base_path);
142 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
143
144 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
145 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
146 }
147 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
148 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
149 };
150
151 let local_var_req = local_var_req_builder.build()?;
152 let local_var_resp = local_var_client.execute(local_var_req).await?;
153
154 let local_var_status = local_var_resp.status();
155 let local_var_content = local_var_resp.text().await?;
156
157 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
158 crate::from_str_patched(&local_var_content).map_err(Error::from)
159 } else {
160 let local_var_entity: Option<GetEntitlementsError> = crate::from_str_patched(&local_var_content).ok();
161 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
162 Err(Error::ResponseError(local_var_error))
163 }
164}
165
166pub async fn get_license_id(configuration: &configuration::Configuration, ) -> Result<String, Error<GetLicenseIdError>> {
167 let local_var_configuration = configuration;
168
169 let local_var_client = &local_var_configuration.client;
170
171 let local_var_uri_str = format!("{}/ee_license", local_var_configuration.base_path);
172 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
173
174 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
175 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
176 }
177 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
178 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
179 };
180
181 let local_var_req = local_var_req_builder.build()?;
182 let local_var_resp = local_var_client.execute(local_var_req).await?;
183
184 let local_var_status = local_var_resp.status();
185 let local_var_content = local_var_resp.text().await?;
186
187 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
188 crate::from_str_patched(&local_var_content).map_err(Error::from)
189 } else {
190 let local_var_entity: Option<GetLicenseIdError> = crate::from_str_patched(&local_var_content).ok();
191 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
192 Err(Error::ResponseError(local_var_error))
193 }
194}
195
196pub async fn get_open_api_yaml(configuration: &configuration::Configuration, ) -> Result<String, Error<GetOpenApiYamlError>> {
197 let local_var_configuration = configuration;
198
199 let local_var_client = &local_var_configuration.client;
200
201 let local_var_uri_str = format!("{}/openapi.yaml", local_var_configuration.base_path);
202 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
203
204 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
205 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
206 }
207 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
208 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
209 };
210
211 let local_var_req = local_var_req_builder.build()?;
212 let local_var_resp = local_var_client.execute(local_var_req).await?;
213
214 let local_var_status = local_var_resp.status();
215 let local_var_content = local_var_resp.text().await?;
216
217 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
218 crate::from_str_patched(&local_var_content).map_err(Error::from)
219 } else {
220 let local_var_entity: Option<GetOpenApiYamlError> = crate::from_str_patched(&local_var_content).ok();
221 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
222 Err(Error::ResponseError(local_var_error))
223 }
224}
225
226pub async fn get_workspace_entitlements(configuration: &configuration::Configuration, workspace: &str) -> Result<models::WorkspaceEntitlements, Error<GetWorkspaceEntitlementsError>> {
228 let local_var_configuration = configuration;
229
230 let local_var_client = &local_var_configuration.client;
231
232 let local_var_uri_str = format!("{}/w/{workspace}/entitlements", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
233 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
234
235 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
236 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
237 }
238 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
239 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
240 };
241
242 let local_var_req = local_var_req_builder.build()?;
243 let local_var_resp = local_var_client.execute(local_var_req).await?;
244
245 let local_var_status = local_var_resp.status();
246 let local_var_content = local_var_resp.text().await?;
247
248 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
249 crate::from_str_patched(&local_var_content).map_err(Error::from)
250 } else {
251 let local_var_entity: Option<GetWorkspaceEntitlementsError> = crate::from_str_patched(&local_var_content).ok();
252 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
253 Err(Error::ResponseError(local_var_error))
254 }
255}
256
257pub async fn list_features(configuration: &configuration::Configuration, ) -> Result<models::FeatureCatalogResponse, Error<ListFeaturesError>> {
258 let local_var_configuration = configuration;
259
260 let local_var_client = &local_var_configuration.client;
261
262 let local_var_uri_str = format!("{}/features", local_var_configuration.base_path);
263 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
264
265 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
266 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
267 }
268
269 let local_var_req = local_var_req_builder.build()?;
270 let local_var_resp = local_var_client.execute(local_var_req).await?;
271
272 let local_var_status = local_var_resp.status();
273 let local_var_content = local_var_resp.text().await?;
274
275 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
276 crate::from_str_patched(&local_var_content).map_err(Error::from)
277 } else {
278 let local_var_entity: Option<ListFeaturesError> = crate::from_str_patched(&local_var_content).ok();
279 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
280 Err(Error::ResponseError(local_var_error))
281 }
282}
283
284pub async fn list_workspace_features(configuration: &configuration::Configuration, workspace: &str) -> Result<models::FeatureCatalogResponse, Error<ListWorkspaceFeaturesError>> {
286 let local_var_configuration = configuration;
287
288 let local_var_client = &local_var_configuration.client;
289
290 let local_var_uri_str = format!("{}/w/{workspace}/features", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
291 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
292
293 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
294 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
295 }
296 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
297 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
298 };
299
300 let local_var_req = local_var_req_builder.build()?;
301 let local_var_resp = local_var_client.execute(local_var_req).await?;
302
303 let local_var_status = local_var_resp.status();
304 let local_var_content = local_var_resp.text().await?;
305
306 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
307 crate::from_str_patched(&local_var_content).map_err(Error::from)
308 } else {
309 let local_var_entity: Option<ListWorkspaceFeaturesError> = crate::from_str_patched(&local_var_content).ok();
310 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
311 Err(Error::ResponseError(local_var_error))
312 }
313}
314