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 ArchiveDataMigrationByPathError {
22 Status402(String),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum CreateDataMigrationError {
30 Status402(String),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum DataMigrationDryRunError {
38 Status400(String),
39 Status402(String),
40 UnknownValue(serde_json::Value),
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum DataMigrationGetRunError {
47 Status402(String),
48 UnknownValue(serde_json::Value),
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum DataMigrationListRunsError {
55 Status402(String),
56 UnknownValue(serde_json::Value),
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum DataMigrationRunError {
63 Status400(String),
64 Status402(String),
65 UnknownValue(serde_json::Value),
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum DeleteDataMigrationByPathError {
72 Status402(String),
73 UnknownValue(serde_json::Value),
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum ExistsDataMigrationByPathError {
80 Status402(String),
81 UnknownValue(serde_json::Value),
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum GetDataMigrationByPathError {
88 Status402(String),
89 UnknownValue(serde_json::Value),
90}
91
92#[derive(Debug, Clone, Serialize, Deserialize)]
94#[serde(untagged)]
95pub enum ListDataMigrationsError {
96 Status402(String),
97 UnknownValue(serde_json::Value),
98}
99
100#[derive(Debug, Clone, Serialize, Deserialize)]
102#[serde(untagged)]
103pub enum UpdateDataMigrationError {
104 Status402(String),
105 UnknownValue(serde_json::Value),
106}
107
108
109pub async fn archive_data_migration_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str, archive_flow_by_path_request: models::ArchiveFlowByPathRequest) -> Result<String, Error<ArchiveDataMigrationByPathError>> {
110 let local_var_configuration = configuration;
111
112 let local_var_client = &local_var_configuration.client;
113
114 let local_var_uri_str = format!("{}/w/{workspace}/data_migration/definitions/archive/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
115 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
116
117 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
118 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
119 }
120 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
121 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
122 };
123 local_var_req_builder = local_var_req_builder.json(&archive_flow_by_path_request);
124
125 let local_var_req = local_var_req_builder.build()?;
126 let local_var_resp = local_var_client.execute(local_var_req).await?;
127
128 let local_var_status = local_var_resp.status();
129 let local_var_content = local_var_resp.text().await?;
130
131 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
132 crate::from_str_patched(&local_var_content).map_err(Error::from)
133 } else {
134 let local_var_entity: Option<ArchiveDataMigrationByPathError> = crate::from_str_patched(&local_var_content).ok();
135 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
136 Err(Error::ResponseError(local_var_error))
137 }
138}
139
140pub async fn create_data_migration(configuration: &configuration::Configuration, workspace: &str, new_data_migration: models::NewDataMigration) -> Result<String, Error<CreateDataMigrationError>> {
141 let local_var_configuration = configuration;
142
143 let local_var_client = &local_var_configuration.client;
144
145 let local_var_uri_str = format!("{}/w/{workspace}/data_migration/definitions/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
146 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
147
148 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
149 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
150 }
151 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
152 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
153 };
154 local_var_req_builder = local_var_req_builder.json(&new_data_migration);
155
156 let local_var_req = local_var_req_builder.build()?;
157 let local_var_resp = local_var_client.execute(local_var_req).await?;
158
159 let local_var_status = local_var_resp.status();
160 let local_var_content = local_var_resp.text().await?;
161
162 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
163 crate::from_str_patched(&local_var_content).map_err(Error::from)
164 } else {
165 let local_var_entity: Option<CreateDataMigrationError> = crate::from_str_patched(&local_var_content).ok();
166 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
167 Err(Error::ResponseError(local_var_error))
168 }
169}
170
171pub async fn data_migration_dry_run(configuration: &configuration::Configuration, workspace: &str, data_migration_request: models::DataMigrationRequest) -> Result<models::DryRunReport, Error<DataMigrationDryRunError>> {
172 let local_var_configuration = configuration;
173
174 let local_var_client = &local_var_configuration.client;
175
176 let local_var_uri_str = format!("{}/w/{workspace}/data_migration/dry_run", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
177 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
178
179 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
180 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
181 }
182 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
183 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
184 };
185 local_var_req_builder = local_var_req_builder.json(&data_migration_request);
186
187 let local_var_req = local_var_req_builder.build()?;
188 let local_var_resp = local_var_client.execute(local_var_req).await?;
189
190 let local_var_status = local_var_resp.status();
191 let local_var_content = local_var_resp.text().await?;
192
193 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
194 crate::from_str_patched(&local_var_content).map_err(Error::from)
195 } else {
196 let local_var_entity: Option<DataMigrationDryRunError> = crate::from_str_patched(&local_var_content).ok();
197 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
198 Err(Error::ResponseError(local_var_error))
199 }
200}
201
202pub async fn data_migration_get_run(configuration: &configuration::Configuration, workspace: &str, id: i64) -> Result<models::DataMigrationRunDetail, Error<DataMigrationGetRunError>> {
203 let local_var_configuration = configuration;
204
205 let local_var_client = &local_var_configuration.client;
206
207 let local_var_uri_str = format!("{}/w/{workspace}/data_migration/runs/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=id);
208 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
209
210 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
211 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
212 }
213 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
214 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
215 };
216
217 let local_var_req = local_var_req_builder.build()?;
218 let local_var_resp = local_var_client.execute(local_var_req).await?;
219
220 let local_var_status = local_var_resp.status();
221 let local_var_content = local_var_resp.text().await?;
222
223 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
224 crate::from_str_patched(&local_var_content).map_err(Error::from)
225 } else {
226 let local_var_entity: Option<DataMigrationGetRunError> = crate::from_str_patched(&local_var_content).ok();
227 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
228 Err(Error::ResponseError(local_var_error))
229 }
230}
231
232pub async fn data_migration_list_runs(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>, status: Option<&str>) -> Result<Vec<models::DataMigrationRunSummary>, Error<DataMigrationListRunsError>> {
233 let local_var_configuration = configuration;
234
235 let local_var_client = &local_var_configuration.client;
236
237 let local_var_uri_str = format!("{}/w/{workspace}/data_migration/runs", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
238 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
239
240 if let Some(ref local_var_str) = page {
241 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
242 }
243 if let Some(ref local_var_str) = per_page {
244 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
245 }
246 if let Some(ref local_var_str) = status {
247 local_var_req_builder = local_var_req_builder.query(&[("status", &local_var_str.to_string())]);
248 }
249 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
250 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
251 }
252 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
253 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
254 };
255
256 let local_var_req = local_var_req_builder.build()?;
257 let local_var_resp = local_var_client.execute(local_var_req).await?;
258
259 let local_var_status = local_var_resp.status();
260 let local_var_content = local_var_resp.text().await?;
261
262 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
263 crate::from_str_patched(&local_var_content).map_err(Error::from)
264 } else {
265 let local_var_entity: Option<DataMigrationListRunsError> = crate::from_str_patched(&local_var_content).ok();
266 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
267 Err(Error::ResponseError(local_var_error))
268 }
269}
270
271pub async fn data_migration_run(configuration: &configuration::Configuration, workspace: &str, data_migration_request: models::DataMigrationRequest) -> Result<models::QueuedDataMigrationRun, Error<DataMigrationRunError>> {
273 let local_var_configuration = configuration;
274
275 let local_var_client = &local_var_configuration.client;
276
277 let local_var_uri_str = format!("{}/w/{workspace}/data_migration/run", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
278 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
279
280 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
281 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
282 }
283 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
284 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
285 };
286 local_var_req_builder = local_var_req_builder.json(&data_migration_request);
287
288 let local_var_req = local_var_req_builder.build()?;
289 let local_var_resp = local_var_client.execute(local_var_req).await?;
290
291 let local_var_status = local_var_resp.status();
292 let local_var_content = local_var_resp.text().await?;
293
294 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
295 crate::from_str_patched(&local_var_content).map_err(Error::from)
296 } else {
297 let local_var_entity: Option<DataMigrationRunError> = crate::from_str_patched(&local_var_content).ok();
298 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
299 Err(Error::ResponseError(local_var_error))
300 }
301}
302
303pub async fn delete_data_migration_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<String, Error<DeleteDataMigrationByPathError>> {
304 let local_var_configuration = configuration;
305
306 let local_var_client = &local_var_configuration.client;
307
308 let local_var_uri_str = format!("{}/w/{workspace}/data_migration/definitions/delete/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
309 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
310
311 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
312 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
313 }
314 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
315 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
316 };
317
318 let local_var_req = local_var_req_builder.build()?;
319 let local_var_resp = local_var_client.execute(local_var_req).await?;
320
321 let local_var_status = local_var_resp.status();
322 let local_var_content = local_var_resp.text().await?;
323
324 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
325 crate::from_str_patched(&local_var_content).map_err(Error::from)
326 } else {
327 let local_var_entity: Option<DeleteDataMigrationByPathError> = crate::from_str_patched(&local_var_content).ok();
328 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
329 Err(Error::ResponseError(local_var_error))
330 }
331}
332
333pub async fn exists_data_migration_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<bool, Error<ExistsDataMigrationByPathError>> {
334 let local_var_configuration = configuration;
335
336 let local_var_client = &local_var_configuration.client;
337
338 let local_var_uri_str = format!("{}/w/{workspace}/data_migration/definitions/exists/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
339 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
340
341 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
342 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
343 }
344 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
345 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
346 };
347
348 let local_var_req = local_var_req_builder.build()?;
349 let local_var_resp = local_var_client.execute(local_var_req).await?;
350
351 let local_var_status = local_var_resp.status();
352 let local_var_content = local_var_resp.text().await?;
353
354 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
355 crate::from_str_patched(&local_var_content).map_err(Error::from)
356 } else {
357 let local_var_entity: Option<ExistsDataMigrationByPathError> = crate::from_str_patched(&local_var_content).ok();
358 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
359 Err(Error::ResponseError(local_var_error))
360 }
361}
362
363pub async fn get_data_migration_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::DataMigrationDefinition, Error<GetDataMigrationByPathError>> {
364 let local_var_configuration = configuration;
365
366 let local_var_client = &local_var_configuration.client;
367
368 let local_var_uri_str = format!("{}/w/{workspace}/data_migration/definitions/get/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
369 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
370
371 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
372 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
373 }
374 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
375 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
376 };
377
378 let local_var_req = local_var_req_builder.build()?;
379 let local_var_resp = local_var_client.execute(local_var_req).await?;
380
381 let local_var_status = local_var_resp.status();
382 let local_var_content = local_var_resp.text().await?;
383
384 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
385 crate::from_str_patched(&local_var_content).map_err(Error::from)
386 } else {
387 let local_var_entity: Option<GetDataMigrationByPathError> = crate::from_str_patched(&local_var_content).ok();
388 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
389 Err(Error::ResponseError(local_var_error))
390 }
391}
392
393pub async fn list_data_migrations(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>, order_desc: Option<bool>, path_start: Option<&str>, path_exact: Option<&str>, show_archived: Option<bool>, label: Option<&str>, edited_by: Option<&str>, without_description: Option<bool>) -> Result<Vec<models::ListableDataMigration>, Error<ListDataMigrationsError>> {
394 let local_var_configuration = configuration;
395
396 let local_var_client = &local_var_configuration.client;
397
398 let local_var_uri_str = format!("{}/w/{workspace}/data_migration/definitions/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
399 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
400
401 if let Some(ref local_var_str) = page {
402 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
403 }
404 if let Some(ref local_var_str) = per_page {
405 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
406 }
407 if let Some(ref local_var_str) = order_desc {
408 local_var_req_builder = local_var_req_builder.query(&[("order_desc", &local_var_str.to_string())]);
409 }
410 if let Some(ref local_var_str) = path_start {
411 local_var_req_builder = local_var_req_builder.query(&[("path_start", &local_var_str.to_string())]);
412 }
413 if let Some(ref local_var_str) = path_exact {
414 local_var_req_builder = local_var_req_builder.query(&[("path_exact", &local_var_str.to_string())]);
415 }
416 if let Some(ref local_var_str) = show_archived {
417 local_var_req_builder = local_var_req_builder.query(&[("show_archived", &local_var_str.to_string())]);
418 }
419 if let Some(ref local_var_str) = label {
420 local_var_req_builder = local_var_req_builder.query(&[("label", &local_var_str.to_string())]);
421 }
422 if let Some(ref local_var_str) = edited_by {
423 local_var_req_builder = local_var_req_builder.query(&[("edited_by", &local_var_str.to_string())]);
424 }
425 if let Some(ref local_var_str) = without_description {
426 local_var_req_builder = local_var_req_builder.query(&[("without_description", &local_var_str.to_string())]);
427 }
428 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
429 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
430 }
431 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
432 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
433 };
434
435 let local_var_req = local_var_req_builder.build()?;
436 let local_var_resp = local_var_client.execute(local_var_req).await?;
437
438 let local_var_status = local_var_resp.status();
439 let local_var_content = local_var_resp.text().await?;
440
441 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
442 crate::from_str_patched(&local_var_content).map_err(Error::from)
443 } else {
444 let local_var_entity: Option<ListDataMigrationsError> = crate::from_str_patched(&local_var_content).ok();
445 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
446 Err(Error::ResponseError(local_var_error))
447 }
448}
449
450pub async fn update_data_migration(configuration: &configuration::Configuration, workspace: &str, path: &str, new_data_migration: models::NewDataMigration) -> Result<String, Error<UpdateDataMigrationError>> {
451 let local_var_configuration = configuration;
452
453 let local_var_client = &local_var_configuration.client;
454
455 let local_var_uri_str = format!("{}/w/{workspace}/data_migration/definitions/update/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
456 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
457
458 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
459 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
460 }
461 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
462 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
463 };
464 local_var_req_builder = local_var_req_builder.json(&new_data_migration);
465
466 let local_var_req = local_var_req_builder.build()?;
467 let local_var_resp = local_var_client.execute(local_var_req).await?;
468
469 let local_var_status = local_var_resp.status();
470 let local_var_content = local_var_resp.text().await?;
471
472 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
473 crate::from_str_patched(&local_var_content).map_err(Error::from)
474 } else {
475 let local_var_entity: Option<UpdateDataMigrationError> = crate::from_str_patched(&local_var_content).ok();
476 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
477 Err(Error::ResponseError(local_var_error))
478 }
479}
480