orvanta_api/models/data_migration_request.rs
1/*
2 * Orvanta API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 4.1.0
7 * Contact: contact@orvanta.cloud
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// DataMigrationRequest : Body shared by `dry_run` and `run` -- `run` executes exactly what `dry_run` would preview for the same request.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct DataMigrationRequest {
17 /// Path of a resource the **caller** can read (RLS-bound, #1404 -- not merely one that exists in the workspace). Which connector opens it is **derived from that resource's `resource_type`** (#1419); there is deliberately no store-kind field on this body. A tagged field would be a second source of truth that can disagree with the resource it names, and the resolver has to fetch the resource anyway. A `resource_type` with no connector in this build is a **400 naming it**, never a silent attempt to open it as Postgres. Supported today: `postgresql`, and `mysql` -- which serves **MySQL and MariaDB alike** (#1217/#1461: one resource type, one driver, one connector), on builds carrying the `mysql` cargo feature. File/object sources (#1218) and MongoDB (#1219) each add one, and a client that hard-codes the list will drift -- the supported set is per-*build*, not per-version, and the 400's message enumerates what the instance it is talking to actually supports.
18 #[serde(rename = "source_resource_path")]
19 pub source_resource_path: String,
20 /// As `source_resource_path`, but the connector must also be usable as a *target*. The two are dispatched separately: a source-only connector (MongoDB is one -- `store_mongo` reads documents and does not write them) resolves fine as a source and is refused here. `dry_run` applies the same check, so a preview never greenlights a `run` against a connection this build could not write to.
21 #[serde(rename = "target_resource_path")]
22 pub target_resource_path: String,
23 #[serde(rename = "source_table")]
24 pub source_table: String,
25 #[serde(rename = "target_table")]
26 pub target_table: String,
27 #[serde(rename = "mapping")]
28 pub mapping: Vec<models::ColumnMapping>,
29 /// Rows fetched from the source and inserted into the target per round-trip. Defaults to 1000 when omitted; rejected with 400 if it exceeds the hard ceiling of 10000 (a batch is materialized in memory in a single round-trip).
30 #[serde(rename = "batch_size", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
31 pub batch_size: Option<Option<i64>>,
32 #[serde(rename = "conflict_mode", skip_serializing_if = "Option::is_none")]
33 pub conflict_mode: Option<models::ConflictMode>,
34 /// `run` only. Id of an interrupted `data_migration_run` to continue from its checkpoint instead of starting a new run. The run that cannot be safely continued is a 400 naming the reason, never a silent restart from the beginning.
35 #[serde(rename = "resume_run_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
36 pub resume_run_id: Option<Option<i64>>,
37 /// `path` of the saved `data_migration` definition this run came from (#1220), recorded on the run row. Purely a label: the config that runs is the one in this body, and nothing is read back out of the definition -- a run must never execute a mapping different from the one its caller sent. Omit it for a one-off run, which stays fully supported.
38 #[serde(rename = "definition_path", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
39 pub definition_path: Option<Option<String>>,
40}
41
42impl DataMigrationRequest {
43 /// Body shared by `dry_run` and `run` -- `run` executes exactly what `dry_run` would preview for the same request.
44 pub fn new(source_resource_path: String, target_resource_path: String, source_table: String, target_table: String, mapping: Vec<models::ColumnMapping>) -> DataMigrationRequest {
45 DataMigrationRequest {
46 source_resource_path,
47 target_resource_path,
48 source_table,
49 target_table,
50 mapping,
51 batch_size: None,
52 conflict_mode: None,
53 resume_run_id: None,
54 definition_path: None,
55 }
56 }
57}
58