1use 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 GetRegistryImagesError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetRegistryPackagesError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetRegistryProjectsError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetRegistryStatusError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetRegistryTagsError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum PostRegistryTokenError {
57 UnknownValue(serde_json::Value),
58}
59
60
61pub async fn get_registry_images(configuration: &configuration::Configuration, ) -> Result<models::RegistryImageList, Error<GetRegistryImagesError>> {
63
64 let uri_str = format!("{}/v1/registry/images", configuration.base_path);
65 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
66
67 if let Some(ref user_agent) = configuration.user_agent {
68 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
69 }
70 if let Some(ref token) = configuration.bearer_access_token {
71 req_builder = req_builder.bearer_auth(token.to_owned());
72 };
73
74 let req = req_builder.build()?;
75 let resp = configuration.client.execute(req).await?;
76
77 let status = resp.status();
78 let content_type = resp
79 .headers()
80 .get("content-type")
81 .and_then(|v| v.to_str().ok())
82 .unwrap_or("application/octet-stream");
83 let content_type = super::ContentType::from(content_type);
84
85 if !status.is_client_error() && !status.is_server_error() {
86 let content = resp.text().await?;
87 match content_type {
88 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
89 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistryImageList`"))),
90 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::RegistryImageList`")))),
91 }
92 } else {
93 let content = resp.text().await?;
94 let entity: Option<GetRegistryImagesError> = serde_json::from_str(&content).ok();
95 Err(Error::ResponseError(ResponseContent { status, content, entity }))
96 }
97}
98
99pub async fn get_registry_packages(configuration: &configuration::Configuration, query: Option<&str>) -> Result<models::RegistryPackageList, Error<GetRegistryPackagesError>> {
101 let p_query = query;
103
104 let uri_str = format!("{}/v1/registry/packages", configuration.base_path);
105 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
106
107 if let Some(ref param_value) = p_query {
108 req_builder = req_builder.query(&[("query", ¶m_value.to_string())]);
109 }
110 if let Some(ref user_agent) = configuration.user_agent {
111 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
112 }
113 if let Some(ref token) = configuration.bearer_access_token {
114 req_builder = req_builder.bearer_auth(token.to_owned());
115 };
116
117 let req = req_builder.build()?;
118 let resp = configuration.client.execute(req).await?;
119
120 let status = resp.status();
121 let content_type = resp
122 .headers()
123 .get("content-type")
124 .and_then(|v| v.to_str().ok())
125 .unwrap_or("application/octet-stream");
126 let content_type = super::ContentType::from(content_type);
127
128 if !status.is_client_error() && !status.is_server_error() {
129 let content = resp.text().await?;
130 match content_type {
131 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
132 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistryPackageList`"))),
133 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::RegistryPackageList`")))),
134 }
135 } else {
136 let content = resp.text().await?;
137 let entity: Option<GetRegistryPackagesError> = serde_json::from_str(&content).ok();
138 Err(Error::ResponseError(ResponseContent { status, content, entity }))
139 }
140}
141
142pub async fn get_registry_projects(configuration: &configuration::Configuration, ) -> Result<models::RegistryProjectList, Error<GetRegistryProjectsError>> {
144
145 let uri_str = format!("{}/v1/registry/projects", configuration.base_path);
146 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
147
148 if let Some(ref user_agent) = configuration.user_agent {
149 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
150 }
151 if let Some(ref token) = configuration.bearer_access_token {
152 req_builder = req_builder.bearer_auth(token.to_owned());
153 };
154
155 let req = req_builder.build()?;
156 let resp = configuration.client.execute(req).await?;
157
158 let status = resp.status();
159 let content_type = resp
160 .headers()
161 .get("content-type")
162 .and_then(|v| v.to_str().ok())
163 .unwrap_or("application/octet-stream");
164 let content_type = super::ContentType::from(content_type);
165
166 if !status.is_client_error() && !status.is_server_error() {
167 let content = resp.text().await?;
168 match content_type {
169 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
170 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistryProjectList`"))),
171 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::RegistryProjectList`")))),
172 }
173 } else {
174 let content = resp.text().await?;
175 let entity: Option<GetRegistryProjectsError> = serde_json::from_str(&content).ok();
176 Err(Error::ResponseError(ResponseContent { status, content, entity }))
177 }
178}
179
180pub async fn get_registry_status(configuration: &configuration::Configuration, ) -> Result<models::RegistryStatus, Error<GetRegistryStatusError>> {
182
183 let uri_str = format!("{}/v1/registry/status", configuration.base_path);
184 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
185
186 if let Some(ref user_agent) = configuration.user_agent {
187 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
188 }
189 if let Some(ref token) = configuration.bearer_access_token {
190 req_builder = req_builder.bearer_auth(token.to_owned());
191 };
192
193 let req = req_builder.build()?;
194 let resp = configuration.client.execute(req).await?;
195
196 let status = resp.status();
197 let content_type = resp
198 .headers()
199 .get("content-type")
200 .and_then(|v| v.to_str().ok())
201 .unwrap_or("application/octet-stream");
202 let content_type = super::ContentType::from(content_type);
203
204 if !status.is_client_error() && !status.is_server_error() {
205 let content = resp.text().await?;
206 match content_type {
207 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
208 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistryStatus`"))),
209 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::RegistryStatus`")))),
210 }
211 } else {
212 let content = resp.text().await?;
213 let entity: Option<GetRegistryStatusError> = serde_json::from_str(&content).ok();
214 Err(Error::ResponseError(ResponseContent { status, content, entity }))
215 }
216}
217
218pub async fn get_registry_tags(configuration: &configuration::Configuration, image: Option<&str>) -> Result<models::RegistryTagList, Error<GetRegistryTagsError>> {
220 let p_image = image;
222
223 let uri_str = format!("{}/v1/registry/tags", configuration.base_path);
224 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
225
226 if let Some(ref param_value) = p_image {
227 req_builder = req_builder.query(&[("image", ¶m_value.to_string())]);
228 }
229 if let Some(ref user_agent) = configuration.user_agent {
230 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
231 }
232 if let Some(ref token) = configuration.bearer_access_token {
233 req_builder = req_builder.bearer_auth(token.to_owned());
234 };
235
236 let req = req_builder.build()?;
237 let resp = configuration.client.execute(req).await?;
238
239 let status = resp.status();
240 let content_type = resp
241 .headers()
242 .get("content-type")
243 .and_then(|v| v.to_str().ok())
244 .unwrap_or("application/octet-stream");
245 let content_type = super::ContentType::from(content_type);
246
247 if !status.is_client_error() && !status.is_server_error() {
248 let content = resp.text().await?;
249 match content_type {
250 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
251 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistryTagList`"))),
252 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::RegistryTagList`")))),
253 }
254 } else {
255 let content = resp.text().await?;
256 let entity: Option<GetRegistryTagsError> = serde_json::from_str(&content).ok();
257 Err(Error::ResponseError(ResponseContent { status, content, entity }))
258 }
259}
260
261pub async fn post_registry_token(configuration: &configuration::Configuration, registry_mint: models::RegistryMint) -> Result<models::RegistryToken, Error<PostRegistryTokenError>> {
263 let p_registry_mint = registry_mint;
265
266 let uri_str = format!("{}/v1/registry/token", configuration.base_path);
267 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
268
269 if let Some(ref user_agent) = configuration.user_agent {
270 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
271 }
272 if let Some(ref token) = configuration.bearer_access_token {
273 req_builder = req_builder.bearer_auth(token.to_owned());
274 };
275 req_builder = req_builder.json(&p_registry_mint);
276
277 let req = req_builder.build()?;
278 let resp = configuration.client.execute(req).await?;
279
280 let status = resp.status();
281 let content_type = resp
282 .headers()
283 .get("content-type")
284 .and_then(|v| v.to_str().ok())
285 .unwrap_or("application/octet-stream");
286 let content_type = super::ContentType::from(content_type);
287
288 if !status.is_client_error() && !status.is_server_error() {
289 let content = resp.text().await?;
290 match content_type {
291 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
292 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistryToken`"))),
293 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::RegistryToken`")))),
294 }
295 } else {
296 let content = resp.text().await?;
297 let entity: Option<PostRegistryTokenError> = serde_json::from_str(&content).ok();
298 Err(Error::ResponseError(ResponseContent { status, content, entity }))
299 }
300}
301