hanzo_client/apis/
destination_api.rs1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteDestinationByPlatformError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetDestinationError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetDestinationByPlatformError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum PostDestinationByPlatformError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum PostDestinationByPlatformTestError {
50 UnknownValue(serde_json::Value),
51}
52
53
54pub async fn delete_destination_by_platform(configuration: &configuration::Configuration, platform: &str) -> Result<models::DestinationDisconnected, Error<DeleteDestinationByPlatformError>> {
56 let p_platform = platform;
58
59 let uri_str = format!("{}/v1/destination/{platform}", configuration.base_path, platform=crate::apis::urlencode(p_platform));
60 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
61
62 if let Some(ref user_agent) = configuration.user_agent {
63 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
64 }
65 if let Some(ref token) = configuration.bearer_access_token {
66 req_builder = req_builder.bearer_auth(token.to_owned());
67 };
68
69 let req = req_builder.build()?;
70 let resp = configuration.client.execute(req).await?;
71
72 let status = resp.status();
73 let content_type = resp
74 .headers()
75 .get("content-type")
76 .and_then(|v| v.to_str().ok())
77 .unwrap_or("application/octet-stream");
78 let content_type = super::ContentType::from(content_type);
79
80 if !status.is_client_error() && !status.is_server_error() {
81 let content = resp.text().await?;
82 match content_type {
83 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
84 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DestinationDisconnected`"))),
85 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DestinationDisconnected`")))),
86 }
87 } else {
88 let content = resp.text().await?;
89 let entity: Option<DeleteDestinationByPlatformError> = serde_json::from_str(&content).ok();
90 Err(Error::ResponseError(ResponseContent { status, content, entity }))
91 }
92}
93
94pub async fn get_destination(configuration: &configuration::Configuration, ) -> Result<models::DestinationList, Error<GetDestinationError>> {
96
97 let uri_str = format!("{}/v1/destination", configuration.base_path);
98 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
99
100 if let Some(ref user_agent) = configuration.user_agent {
101 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
102 }
103 if let Some(ref token) = configuration.bearer_access_token {
104 req_builder = req_builder.bearer_auth(token.to_owned());
105 };
106
107 let req = req_builder.build()?;
108 let resp = configuration.client.execute(req).await?;
109
110 let status = resp.status();
111 let content_type = resp
112 .headers()
113 .get("content-type")
114 .and_then(|v| v.to_str().ok())
115 .unwrap_or("application/octet-stream");
116 let content_type = super::ContentType::from(content_type);
117
118 if !status.is_client_error() && !status.is_server_error() {
119 let content = resp.text().await?;
120 match content_type {
121 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
122 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DestinationList`"))),
123 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DestinationList`")))),
124 }
125 } else {
126 let content = resp.text().await?;
127 let entity: Option<GetDestinationError> = serde_json::from_str(&content).ok();
128 Err(Error::ResponseError(ResponseContent { status, content, entity }))
129 }
130}
131
132pub async fn get_destination_by_platform(configuration: &configuration::Configuration, platform: &str) -> Result<models::DestinationStatus, Error<GetDestinationByPlatformError>> {
134 let p_platform = platform;
136
137 let uri_str = format!("{}/v1/destination/{platform}", configuration.base_path, platform=crate::apis::urlencode(p_platform));
138 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
139
140 if let Some(ref user_agent) = configuration.user_agent {
141 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
142 }
143 if let Some(ref token) = configuration.bearer_access_token {
144 req_builder = req_builder.bearer_auth(token.to_owned());
145 };
146
147 let req = req_builder.build()?;
148 let resp = configuration.client.execute(req).await?;
149
150 let status = resp.status();
151 let content_type = resp
152 .headers()
153 .get("content-type")
154 .and_then(|v| v.to_str().ok())
155 .unwrap_or("application/octet-stream");
156 let content_type = super::ContentType::from(content_type);
157
158 if !status.is_client_error() && !status.is_server_error() {
159 let content = resp.text().await?;
160 match content_type {
161 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
162 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DestinationStatus`"))),
163 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DestinationStatus`")))),
164 }
165 } else {
166 let content = resp.text().await?;
167 let entity: Option<GetDestinationByPlatformError> = serde_json::from_str(&content).ok();
168 Err(Error::ResponseError(ResponseContent { status, content, entity }))
169 }
170}
171
172pub async fn post_destination_by_platform(configuration: &configuration::Configuration, platform: &str, request_body: Option<std::collections::HashMap<String, serde_json::Value>>) -> Result<models::DestinationStatus, Error<PostDestinationByPlatformError>> {
174 let p_platform = platform;
176 let p_request_body = request_body;
177
178 let uri_str = format!("{}/v1/destination/{platform}", configuration.base_path, platform=crate::apis::urlencode(p_platform));
179 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
180
181 if let Some(ref user_agent) = configuration.user_agent {
182 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
183 }
184 if let Some(ref token) = configuration.bearer_access_token {
185 req_builder = req_builder.bearer_auth(token.to_owned());
186 };
187 req_builder = req_builder.json(&p_request_body);
188
189 let req = req_builder.build()?;
190 let resp = configuration.client.execute(req).await?;
191
192 let status = resp.status();
193 let content_type = resp
194 .headers()
195 .get("content-type")
196 .and_then(|v| v.to_str().ok())
197 .unwrap_or("application/octet-stream");
198 let content_type = super::ContentType::from(content_type);
199
200 if !status.is_client_error() && !status.is_server_error() {
201 let content = resp.text().await?;
202 match content_type {
203 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
204 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DestinationStatus`"))),
205 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DestinationStatus`")))),
206 }
207 } else {
208 let content = resp.text().await?;
209 let entity: Option<PostDestinationByPlatformError> = serde_json::from_str(&content).ok();
210 Err(Error::ResponseError(ResponseContent { status, content, entity }))
211 }
212}
213
214pub async fn post_destination_by_platform_test(configuration: &configuration::Configuration, platform: &str) -> Result<models::DestinationTest, Error<PostDestinationByPlatformTestError>> {
216 let p_platform = platform;
218
219 let uri_str = format!("{}/v1/destination/{platform}/test", configuration.base_path, platform=crate::apis::urlencode(p_platform));
220 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
221
222 if let Some(ref user_agent) = configuration.user_agent {
223 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
224 }
225 if let Some(ref token) = configuration.bearer_access_token {
226 req_builder = req_builder.bearer_auth(token.to_owned());
227 };
228
229 let req = req_builder.build()?;
230 let resp = configuration.client.execute(req).await?;
231
232 let status = resp.status();
233 let content_type = resp
234 .headers()
235 .get("content-type")
236 .and_then(|v| v.to_str().ok())
237 .unwrap_or("application/octet-stream");
238 let content_type = super::ContentType::from(content_type);
239
240 if !status.is_client_error() && !status.is_server_error() {
241 let content = resp.text().await?;
242 match content_type {
243 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
244 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DestinationTest`"))),
245 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DestinationTest`")))),
246 }
247 } else {
248 let content = resp.text().await?;
249 let entity: Option<PostDestinationByPlatformTestError> = serde_json::from_str(&content).ok();
250 Err(Error::ResponseError(ResponseContent { status, content, entity }))
251 }
252}
253