pulsar_admin_sdk/apis/
schemas_api.rs

1/*
2 * Pulsar Admin REST API
3 *
4 * This provides the REST API for admin operations
5 *
6 * The version of the OpenAPI document: v2
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`schemas_resource_delete_schema`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum SchemasResourceDeleteSchemaError {
22    Status401(),
23    Status403(),
24    Status404(),
25    Status412(),
26    Status500(),
27    UnknownValue(serde_json::Value),
28}
29
30/// struct for typed errors of method [`schemas_resource_get_all_schemas`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum SchemasResourceGetAllSchemasError {
34    Status401(),
35    Status403(),
36    Status404(),
37    Status412(),
38    Status500(),
39    UnknownValue(serde_json::Value),
40}
41
42/// struct for typed errors of method [`schemas_resource_get_schema`]
43#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum SchemasResourceGetSchemaError {
46    Status401(),
47    Status403(),
48    Status404(),
49    Status412(),
50    Status500(),
51    UnknownValue(serde_json::Value),
52}
53
54/// struct for typed errors of method [`schemas_resource_get_schema_0`]
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum SchemasResourceGetSchema0Error {
58    Status401(),
59    Status403(),
60    Status404(),
61    Status412(),
62    Status500(),
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method [`schemas_resource_get_version_by_schema`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum SchemasResourceGetVersionBySchemaError {
70    Status401(),
71    Status403(),
72    Status404(),
73    Status412(),
74    Status422(),
75    Status500(),
76    UnknownValue(serde_json::Value),
77}
78
79/// struct for typed errors of method [`schemas_resource_post_schema`]
80#[derive(Debug, Clone, Serialize, Deserialize)]
81#[serde(untagged)]
82pub enum SchemasResourcePostSchemaError {
83    Status401(),
84    Status403(),
85    Status404(),
86    Status409(),
87    Status412(),
88    Status422(),
89    Status500(),
90    UnknownValue(serde_json::Value),
91}
92
93/// struct for typed errors of method [`schemas_resource_test_compatibility`]
94#[derive(Debug, Clone, Serialize, Deserialize)]
95#[serde(untagged)]
96pub enum SchemasResourceTestCompatibilityError {
97    Status401(),
98    Status403(),
99    Status404(),
100    Status412(),
101    Status500(),
102    UnknownValue(serde_json::Value),
103}
104
105
106pub async fn schemas_resource_delete_schema(configuration: &configuration::Configuration, tenant: &str, namespace: &str, topic: &str, authoritative: Option<bool>, force: Option<bool>) -> Result<models::DeleteSchemaResponse, Error<SchemasResourceDeleteSchemaError>> {
107    let local_var_configuration = configuration;
108
109    let local_var_client = &local_var_configuration.client;
110
111    let local_var_uri_str = format!("{}/schemas/{tenant}/{namespace}/{topic}/schema", local_var_configuration.base_path, tenant=crate::apis::urlencode(tenant), namespace=crate::apis::urlencode(namespace), topic=crate::apis::urlencode(topic));
112    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
113
114    if let Some(ref local_var_str) = authoritative {
115        local_var_req_builder = local_var_req_builder.query(&[("authoritative", &local_var_str.to_string())]);
116    }
117    if let Some(ref local_var_str) = force {
118        local_var_req_builder = local_var_req_builder.query(&[("force", &local_var_str.to_string())]);
119    }
120    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
121        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
122    }
123    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
124        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
125    };
126
127    let local_var_req = local_var_req_builder.build()?;
128    let local_var_resp = local_var_client.execute(local_var_req).await?;
129
130    let local_var_status = local_var_resp.status();
131    let local_var_content = local_var_resp.text().await?;
132
133    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
134        serde_json::from_str(&local_var_content).map_err(Error::from)
135    } else {
136        let local_var_entity: Option<SchemasResourceDeleteSchemaError> = serde_json::from_str(&local_var_content).ok();
137        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
138        Err(Error::ResponseError(local_var_error))
139    }
140}
141
142pub async fn schemas_resource_get_all_schemas(configuration: &configuration::Configuration, tenant: &str, namespace: &str, topic: &str, authoritative: Option<bool>) -> Result<models::GetAllVersionsSchemaResponse, Error<SchemasResourceGetAllSchemasError>> {
143    let local_var_configuration = configuration;
144
145    let local_var_client = &local_var_configuration.client;
146
147    let local_var_uri_str = format!("{}/schemas/{tenant}/{namespace}/{topic}/schemas", local_var_configuration.base_path, tenant=crate::apis::urlencode(tenant), namespace=crate::apis::urlencode(namespace), topic=crate::apis::urlencode(topic));
148    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
149
150    if let Some(ref local_var_str) = authoritative {
151        local_var_req_builder = local_var_req_builder.query(&[("authoritative", &local_var_str.to_string())]);
152    }
153    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
154        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
155    }
156    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
157        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
158    };
159
160    let local_var_req = local_var_req_builder.build()?;
161    let local_var_resp = local_var_client.execute(local_var_req).await?;
162
163    let local_var_status = local_var_resp.status();
164    let local_var_content = local_var_resp.text().await?;
165
166    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
167        serde_json::from_str(&local_var_content).map_err(Error::from)
168    } else {
169        let local_var_entity: Option<SchemasResourceGetAllSchemasError> = serde_json::from_str(&local_var_content).ok();
170        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
171        Err(Error::ResponseError(local_var_error))
172    }
173}
174
175pub async fn schemas_resource_get_schema(configuration: &configuration::Configuration, tenant: &str, namespace: &str, topic: &str, authoritative: Option<bool>) -> Result<models::GetSchemaResponse, Error<SchemasResourceGetSchemaError>> {
176    let local_var_configuration = configuration;
177
178    let local_var_client = &local_var_configuration.client;
179
180    let local_var_uri_str = format!("{}/schemas/{tenant}/{namespace}/{topic}/schema", local_var_configuration.base_path, tenant=crate::apis::urlencode(tenant), namespace=crate::apis::urlencode(namespace), topic=crate::apis::urlencode(topic));
181    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
182
183    if let Some(ref local_var_str) = authoritative {
184        local_var_req_builder = local_var_req_builder.query(&[("authoritative", &local_var_str.to_string())]);
185    }
186    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
187        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
188    }
189    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
190        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
191    };
192
193    let local_var_req = local_var_req_builder.build()?;
194    let local_var_resp = local_var_client.execute(local_var_req).await?;
195
196    let local_var_status = local_var_resp.status();
197    let local_var_content = local_var_resp.text().await?;
198
199    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
200        serde_json::from_str(&local_var_content).map_err(Error::from)
201    } else {
202        let local_var_entity: Option<SchemasResourceGetSchemaError> = serde_json::from_str(&local_var_content).ok();
203        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
204        Err(Error::ResponseError(local_var_error))
205    }
206}
207
208pub async fn schemas_resource_get_schema_0(configuration: &configuration::Configuration, tenant: &str, namespace: &str, topic: &str, version: &str, authoritative: Option<bool>) -> Result<models::GetSchemaResponse, Error<SchemasResourceGetSchema0Error>> {
209    let local_var_configuration = configuration;
210
211    let local_var_client = &local_var_configuration.client;
212
213    let local_var_uri_str = format!("{}/schemas/{tenant}/{namespace}/{topic}/schema/{version}", local_var_configuration.base_path, tenant=crate::apis::urlencode(tenant), namespace=crate::apis::urlencode(namespace), topic=crate::apis::urlencode(topic), version=crate::apis::urlencode(version));
214    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
215
216    if let Some(ref local_var_str) = authoritative {
217        local_var_req_builder = local_var_req_builder.query(&[("authoritative", &local_var_str.to_string())]);
218    }
219    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
220        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
221    }
222    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
223        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
224    };
225
226    let local_var_req = local_var_req_builder.build()?;
227    let local_var_resp = local_var_client.execute(local_var_req).await?;
228
229    let local_var_status = local_var_resp.status();
230    let local_var_content = local_var_resp.text().await?;
231
232    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
233        serde_json::from_str(&local_var_content).map_err(Error::from)
234    } else {
235        let local_var_entity: Option<SchemasResourceGetSchema0Error> = serde_json::from_str(&local_var_content).ok();
236        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
237        Err(Error::ResponseError(local_var_error))
238    }
239}
240
241pub async fn schemas_resource_get_version_by_schema(configuration: &configuration::Configuration, tenant: &str, namespace: &str, topic: &str, authoritative: Option<bool>, body: Option<models::PostSchemaPayload>) -> Result<models::LongSchemaVersion, Error<SchemasResourceGetVersionBySchemaError>> {
242    let local_var_configuration = configuration;
243
244    let local_var_client = &local_var_configuration.client;
245
246    let local_var_uri_str = format!("{}/schemas/{tenant}/{namespace}/{topic}/version", local_var_configuration.base_path, tenant=crate::apis::urlencode(tenant), namespace=crate::apis::urlencode(namespace), topic=crate::apis::urlencode(topic));
247    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
248
249    if let Some(ref local_var_str) = authoritative {
250        local_var_req_builder = local_var_req_builder.query(&[("authoritative", &local_var_str.to_string())]);
251    }
252    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
253        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
254    }
255    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
256        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
257    };
258    local_var_req_builder = local_var_req_builder.json(&body);
259
260    let local_var_req = local_var_req_builder.build()?;
261    let local_var_resp = local_var_client.execute(local_var_req).await?;
262
263    let local_var_status = local_var_resp.status();
264    let local_var_content = local_var_resp.text().await?;
265
266    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
267        serde_json::from_str(&local_var_content).map_err(Error::from)
268    } else {
269        let local_var_entity: Option<SchemasResourceGetVersionBySchemaError> = serde_json::from_str(&local_var_content).ok();
270        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
271        Err(Error::ResponseError(local_var_error))
272    }
273}
274
275pub async fn schemas_resource_post_schema(configuration: &configuration::Configuration, tenant: &str, namespace: &str, topic: &str, authoritative: Option<bool>, body: Option<models::PostSchemaPayload>) -> Result<models::PostSchemaResponse, Error<SchemasResourcePostSchemaError>> {
276    let local_var_configuration = configuration;
277
278    let local_var_client = &local_var_configuration.client;
279
280    let local_var_uri_str = format!("{}/schemas/{tenant}/{namespace}/{topic}/schema", local_var_configuration.base_path, tenant=crate::apis::urlencode(tenant), namespace=crate::apis::urlencode(namespace), topic=crate::apis::urlencode(topic));
281    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
282
283    if let Some(ref local_var_str) = authoritative {
284        local_var_req_builder = local_var_req_builder.query(&[("authoritative", &local_var_str.to_string())]);
285    }
286    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
287        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
288    }
289    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
290        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
291    };
292    local_var_req_builder = local_var_req_builder.json(&body);
293
294    let local_var_req = local_var_req_builder.build()?;
295    let local_var_resp = local_var_client.execute(local_var_req).await?;
296
297    let local_var_status = local_var_resp.status();
298    let local_var_content = local_var_resp.text().await?;
299
300    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
301        serde_json::from_str(&local_var_content).map_err(Error::from)
302    } else {
303        let local_var_entity: Option<SchemasResourcePostSchemaError> = serde_json::from_str(&local_var_content).ok();
304        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
305        Err(Error::ResponseError(local_var_error))
306    }
307}
308
309pub async fn schemas_resource_test_compatibility(configuration: &configuration::Configuration, tenant: &str, namespace: &str, topic: &str, authoritative: Option<bool>, body: Option<models::PostSchemaPayload>) -> Result<models::IsCompatibilityResponse, Error<SchemasResourceTestCompatibilityError>> {
310    let local_var_configuration = configuration;
311
312    let local_var_client = &local_var_configuration.client;
313
314    let local_var_uri_str = format!("{}/schemas/{tenant}/{namespace}/{topic}/compatibility", local_var_configuration.base_path, tenant=crate::apis::urlencode(tenant), namespace=crate::apis::urlencode(namespace), topic=crate::apis::urlencode(topic));
315    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
316
317    if let Some(ref local_var_str) = authoritative {
318        local_var_req_builder = local_var_req_builder.query(&[("authoritative", &local_var_str.to_string())]);
319    }
320    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
321        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
322    }
323    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
324        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
325    };
326    local_var_req_builder = local_var_req_builder.json(&body);
327
328    let local_var_req = local_var_req_builder.build()?;
329    let local_var_resp = local_var_client.execute(local_var_req).await?;
330
331    let local_var_status = local_var_resp.status();
332    let local_var_content = local_var_resp.text().await?;
333
334    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
335        serde_json::from_str(&local_var_content).map_err(Error::from)
336    } else {
337        let local_var_entity: Option<SchemasResourceTestCompatibilityError> = serde_json::from_str(&local_var_content).ok();
338        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
339        Err(Error::ResponseError(local_var_error))
340    }
341}
342