1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum ManagedBlueprintsApplyCreateError {
20 Status400(models::ValidationError),
21 Status403(models::GenericError),
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ManagedBlueprintsAvailableListError {
29 Status400(models::ValidationError),
30 Status403(models::GenericError),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum ManagedBlueprintsCreateError {
38 Status400(models::ValidationError),
39 Status403(models::GenericError),
40 UnknownValue(serde_json::Value),
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum ManagedBlueprintsDestroyError {
47 Status400(models::ValidationError),
48 Status403(models::GenericError),
49 UnknownValue(serde_json::Value),
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum ManagedBlueprintsListError {
56 Status400(models::ValidationError),
57 Status403(models::GenericError),
58 UnknownValue(serde_json::Value),
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum ManagedBlueprintsPartialUpdateError {
65 Status400(models::ValidationError),
66 Status403(models::GenericError),
67 UnknownValue(serde_json::Value),
68}
69
70#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum ManagedBlueprintsRetrieveError {
74 Status400(models::ValidationError),
75 Status403(models::GenericError),
76 UnknownValue(serde_json::Value),
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize)]
81#[serde(untagged)]
82pub enum ManagedBlueprintsUpdateError {
83 Status400(models::ValidationError),
84 Status403(models::GenericError),
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum ManagedBlueprintsUsedByListError {
92 Status400(models::ValidationError),
93 Status403(models::GenericError),
94 UnknownValue(serde_json::Value),
95}
96
97pub async fn managed_blueprints_apply_create(
99 configuration: &configuration::Configuration,
100 instance_uuid: &str,
101) -> Result<models::BlueprintInstance, Error<ManagedBlueprintsApplyCreateError>> {
102 let p_path_instance_uuid = instance_uuid;
104
105 let uri_str = format!(
106 "{}/managed/blueprints/{instance_uuid}/apply/",
107 configuration.base_path,
108 instance_uuid = crate::apis::urlencode(p_path_instance_uuid)
109 );
110 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
111
112 if let Some(ref user_agent) = configuration.user_agent {
113 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
114 }
115 if let Some(ref token) = configuration.bearer_access_token {
116 req_builder = req_builder.bearer_auth(token.to_owned());
117 };
118
119 let req = req_builder.build()?;
120 let resp = configuration.client.execute(req).await?;
121
122 let status = resp.status();
123 let content_type = resp
124 .headers()
125 .get("content-type")
126 .and_then(|v| v.to_str().ok())
127 .unwrap_or("application/octet-stream");
128 let content_type = super::ContentType::from(content_type);
129
130 if !status.is_client_error() && !status.is_server_error() {
131 let content = resp.text().await?;
132 match content_type {
133 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
134 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BlueprintInstance`"))),
135 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::BlueprintInstance`")))),
136 }
137 } else {
138 let content = resp.text().await?;
139 let entity: Option<ManagedBlueprintsApplyCreateError> = serde_json::from_str(&content).ok();
140 Err(Error::ResponseError(ResponseContent {
141 status,
142 content,
143 entity,
144 }))
145 }
146}
147
148pub async fn managed_blueprints_available_list(
150 configuration: &configuration::Configuration,
151) -> Result<Vec<models::BlueprintFile>, Error<ManagedBlueprintsAvailableListError>> {
152 let uri_str = format!("{}/managed/blueprints/available/", configuration.base_path);
153 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
154
155 if let Some(ref user_agent) = configuration.user_agent {
156 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
157 }
158 if let Some(ref token) = configuration.bearer_access_token {
159 req_builder = req_builder.bearer_auth(token.to_owned());
160 };
161
162 let req = req_builder.build()?;
163 let resp = configuration.client.execute(req).await?;
164
165 let status = resp.status();
166 let content_type = resp
167 .headers()
168 .get("content-type")
169 .and_then(|v| v.to_str().ok())
170 .unwrap_or("application/octet-stream");
171 let content_type = super::ContentType::from(content_type);
172
173 if !status.is_client_error() && !status.is_server_error() {
174 let content = resp.text().await?;
175 match content_type {
176 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
177 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::BlueprintFile>`"))),
178 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::BlueprintFile>`")))),
179 }
180 } else {
181 let content = resp.text().await?;
182 let entity: Option<ManagedBlueprintsAvailableListError> = serde_json::from_str(&content).ok();
183 Err(Error::ResponseError(ResponseContent {
184 status,
185 content,
186 entity,
187 }))
188 }
189}
190
191pub async fn managed_blueprints_create(
193 configuration: &configuration::Configuration,
194 blueprint_instance_request: models::BlueprintInstanceRequest,
195) -> Result<models::BlueprintInstance, Error<ManagedBlueprintsCreateError>> {
196 let p_body_blueprint_instance_request = blueprint_instance_request;
198
199 let uri_str = format!("{}/managed/blueprints/", configuration.base_path);
200 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
201
202 if let Some(ref user_agent) = configuration.user_agent {
203 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
204 }
205 if let Some(ref token) = configuration.bearer_access_token {
206 req_builder = req_builder.bearer_auth(token.to_owned());
207 };
208 req_builder = req_builder.json(&p_body_blueprint_instance_request);
209
210 let req = req_builder.build()?;
211 let resp = configuration.client.execute(req).await?;
212
213 let status = resp.status();
214 let content_type = resp
215 .headers()
216 .get("content-type")
217 .and_then(|v| v.to_str().ok())
218 .unwrap_or("application/octet-stream");
219 let content_type = super::ContentType::from(content_type);
220
221 if !status.is_client_error() && !status.is_server_error() {
222 let content = resp.text().await?;
223 match content_type {
224 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
225 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BlueprintInstance`"))),
226 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::BlueprintInstance`")))),
227 }
228 } else {
229 let content = resp.text().await?;
230 let entity: Option<ManagedBlueprintsCreateError> = serde_json::from_str(&content).ok();
231 Err(Error::ResponseError(ResponseContent {
232 status,
233 content,
234 entity,
235 }))
236 }
237}
238
239pub async fn managed_blueprints_destroy(
241 configuration: &configuration::Configuration,
242 instance_uuid: &str,
243) -> Result<(), Error<ManagedBlueprintsDestroyError>> {
244 let p_path_instance_uuid = instance_uuid;
246
247 let uri_str = format!(
248 "{}/managed/blueprints/{instance_uuid}/",
249 configuration.base_path,
250 instance_uuid = crate::apis::urlencode(p_path_instance_uuid)
251 );
252 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
253
254 if let Some(ref user_agent) = configuration.user_agent {
255 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
256 }
257 if let Some(ref token) = configuration.bearer_access_token {
258 req_builder = req_builder.bearer_auth(token.to_owned());
259 };
260
261 let req = req_builder.build()?;
262 let resp = configuration.client.execute(req).await?;
263
264 let status = resp.status();
265
266 if !status.is_client_error() && !status.is_server_error() {
267 Ok(())
268 } else {
269 let content = resp.text().await?;
270 let entity: Option<ManagedBlueprintsDestroyError> = serde_json::from_str(&content).ok();
271 Err(Error::ResponseError(ResponseContent {
272 status,
273 content,
274 entity,
275 }))
276 }
277}
278
279pub async fn managed_blueprints_list(
281 configuration: &configuration::Configuration,
282 name: Option<&str>,
283 ordering: Option<&str>,
284 page: Option<i32>,
285 page_size: Option<i32>,
286 path: Option<&str>,
287 search: Option<&str>,
288) -> Result<models::PaginatedBlueprintInstanceList, Error<ManagedBlueprintsListError>> {
289 let p_query_name = name;
291 let p_query_ordering = ordering;
292 let p_query_page = page;
293 let p_query_page_size = page_size;
294 let p_query_path = path;
295 let p_query_search = search;
296
297 let uri_str = format!("{}/managed/blueprints/", configuration.base_path);
298 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
299
300 if let Some(ref param_value) = p_query_name {
301 req_builder = req_builder.query(&[("name", ¶m_value.to_string())]);
302 }
303 if let Some(ref param_value) = p_query_ordering {
304 req_builder = req_builder.query(&[("ordering", ¶m_value.to_string())]);
305 }
306 if let Some(ref param_value) = p_query_page {
307 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
308 }
309 if let Some(ref param_value) = p_query_page_size {
310 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
311 }
312 if let Some(ref param_value) = p_query_path {
313 req_builder = req_builder.query(&[("path", ¶m_value.to_string())]);
314 }
315 if let Some(ref param_value) = p_query_search {
316 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
317 }
318 if let Some(ref user_agent) = configuration.user_agent {
319 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
320 }
321 if let Some(ref token) = configuration.bearer_access_token {
322 req_builder = req_builder.bearer_auth(token.to_owned());
323 };
324
325 let req = req_builder.build()?;
326 let resp = configuration.client.execute(req).await?;
327
328 let status = resp.status();
329 let content_type = resp
330 .headers()
331 .get("content-type")
332 .and_then(|v| v.to_str().ok())
333 .unwrap_or("application/octet-stream");
334 let content_type = super::ContentType::from(content_type);
335
336 if !status.is_client_error() && !status.is_server_error() {
337 let content = resp.text().await?;
338 match content_type {
339 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
340 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedBlueprintInstanceList`"))),
341 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::PaginatedBlueprintInstanceList`")))),
342 }
343 } else {
344 let content = resp.text().await?;
345 let entity: Option<ManagedBlueprintsListError> = serde_json::from_str(&content).ok();
346 Err(Error::ResponseError(ResponseContent {
347 status,
348 content,
349 entity,
350 }))
351 }
352}
353
354pub async fn managed_blueprints_partial_update(
356 configuration: &configuration::Configuration,
357 instance_uuid: &str,
358 patched_blueprint_instance_request: Option<models::PatchedBlueprintInstanceRequest>,
359) -> Result<models::BlueprintInstance, Error<ManagedBlueprintsPartialUpdateError>> {
360 let p_path_instance_uuid = instance_uuid;
362 let p_body_patched_blueprint_instance_request = patched_blueprint_instance_request;
363
364 let uri_str = format!(
365 "{}/managed/blueprints/{instance_uuid}/",
366 configuration.base_path,
367 instance_uuid = crate::apis::urlencode(p_path_instance_uuid)
368 );
369 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
370
371 if let Some(ref user_agent) = configuration.user_agent {
372 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
373 }
374 if let Some(ref token) = configuration.bearer_access_token {
375 req_builder = req_builder.bearer_auth(token.to_owned());
376 };
377 req_builder = req_builder.json(&p_body_patched_blueprint_instance_request);
378
379 let req = req_builder.build()?;
380 let resp = configuration.client.execute(req).await?;
381
382 let status = resp.status();
383 let content_type = resp
384 .headers()
385 .get("content-type")
386 .and_then(|v| v.to_str().ok())
387 .unwrap_or("application/octet-stream");
388 let content_type = super::ContentType::from(content_type);
389
390 if !status.is_client_error() && !status.is_server_error() {
391 let content = resp.text().await?;
392 match content_type {
393 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
394 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BlueprintInstance`"))),
395 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::BlueprintInstance`")))),
396 }
397 } else {
398 let content = resp.text().await?;
399 let entity: Option<ManagedBlueprintsPartialUpdateError> = serde_json::from_str(&content).ok();
400 Err(Error::ResponseError(ResponseContent {
401 status,
402 content,
403 entity,
404 }))
405 }
406}
407
408pub async fn managed_blueprints_retrieve(
410 configuration: &configuration::Configuration,
411 instance_uuid: &str,
412) -> Result<models::BlueprintInstance, Error<ManagedBlueprintsRetrieveError>> {
413 let p_path_instance_uuid = instance_uuid;
415
416 let uri_str = format!(
417 "{}/managed/blueprints/{instance_uuid}/",
418 configuration.base_path,
419 instance_uuid = crate::apis::urlencode(p_path_instance_uuid)
420 );
421 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
422
423 if let Some(ref user_agent) = configuration.user_agent {
424 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
425 }
426 if let Some(ref token) = configuration.bearer_access_token {
427 req_builder = req_builder.bearer_auth(token.to_owned());
428 };
429
430 let req = req_builder.build()?;
431 let resp = configuration.client.execute(req).await?;
432
433 let status = resp.status();
434 let content_type = resp
435 .headers()
436 .get("content-type")
437 .and_then(|v| v.to_str().ok())
438 .unwrap_or("application/octet-stream");
439 let content_type = super::ContentType::from(content_type);
440
441 if !status.is_client_error() && !status.is_server_error() {
442 let content = resp.text().await?;
443 match content_type {
444 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
445 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BlueprintInstance`"))),
446 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::BlueprintInstance`")))),
447 }
448 } else {
449 let content = resp.text().await?;
450 let entity: Option<ManagedBlueprintsRetrieveError> = serde_json::from_str(&content).ok();
451 Err(Error::ResponseError(ResponseContent {
452 status,
453 content,
454 entity,
455 }))
456 }
457}
458
459pub async fn managed_blueprints_update(
461 configuration: &configuration::Configuration,
462 instance_uuid: &str,
463 blueprint_instance_request: models::BlueprintInstanceRequest,
464) -> Result<models::BlueprintInstance, Error<ManagedBlueprintsUpdateError>> {
465 let p_path_instance_uuid = instance_uuid;
467 let p_body_blueprint_instance_request = blueprint_instance_request;
468
469 let uri_str = format!(
470 "{}/managed/blueprints/{instance_uuid}/",
471 configuration.base_path,
472 instance_uuid = crate::apis::urlencode(p_path_instance_uuid)
473 );
474 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
475
476 if let Some(ref user_agent) = configuration.user_agent {
477 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
478 }
479 if let Some(ref token) = configuration.bearer_access_token {
480 req_builder = req_builder.bearer_auth(token.to_owned());
481 };
482 req_builder = req_builder.json(&p_body_blueprint_instance_request);
483
484 let req = req_builder.build()?;
485 let resp = configuration.client.execute(req).await?;
486
487 let status = resp.status();
488 let content_type = resp
489 .headers()
490 .get("content-type")
491 .and_then(|v| v.to_str().ok())
492 .unwrap_or("application/octet-stream");
493 let content_type = super::ContentType::from(content_type);
494
495 if !status.is_client_error() && !status.is_server_error() {
496 let content = resp.text().await?;
497 match content_type {
498 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
499 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BlueprintInstance`"))),
500 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::BlueprintInstance`")))),
501 }
502 } else {
503 let content = resp.text().await?;
504 let entity: Option<ManagedBlueprintsUpdateError> = serde_json::from_str(&content).ok();
505 Err(Error::ResponseError(ResponseContent {
506 status,
507 content,
508 entity,
509 }))
510 }
511}
512
513pub async fn managed_blueprints_used_by_list(
515 configuration: &configuration::Configuration,
516 instance_uuid: &str,
517) -> Result<Vec<models::UsedBy>, Error<ManagedBlueprintsUsedByListError>> {
518 let p_path_instance_uuid = instance_uuid;
520
521 let uri_str = format!(
522 "{}/managed/blueprints/{instance_uuid}/used_by/",
523 configuration.base_path,
524 instance_uuid = crate::apis::urlencode(p_path_instance_uuid)
525 );
526 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
527
528 if let Some(ref user_agent) = configuration.user_agent {
529 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
530 }
531 if let Some(ref token) = configuration.bearer_access_token {
532 req_builder = req_builder.bearer_auth(token.to_owned());
533 };
534
535 let req = req_builder.build()?;
536 let resp = configuration.client.execute(req).await?;
537
538 let status = resp.status();
539 let content_type = resp
540 .headers()
541 .get("content-type")
542 .and_then(|v| v.to_str().ok())
543 .unwrap_or("application/octet-stream");
544 let content_type = super::ContentType::from(content_type);
545
546 if !status.is_client_error() && !status.is_server_error() {
547 let content = resp.text().await?;
548 match content_type {
549 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
550 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::UsedBy>`"))),
551 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::UsedBy>`")))),
552 }
553 } else {
554 let content = resp.text().await?;
555 let entity: Option<ManagedBlueprintsUsedByListError> = serde_json::from_str(&content).ok();
556 Err(Error::ResponseError(ResponseContent {
557 status,
558 content,
559 entity,
560 }))
561 }
562}