/*
* Orvanta API
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 6.5.0
* Contact: contact@orvanta.cloud
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// DataMigrationRequest : Body shared by `dry_run` and `run` -- `run` executes exactly what `dry_run` would preview for the same request.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct DataMigrationRequest {
/// 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.
#[serde(rename = "source_resource_path")]
pub source_resource_path: String,
/// 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.
#[serde(rename = "target_resource_path")]
pub target_resource_path: String,
#[serde(rename = "source_table")]
pub source_table: String,
#[serde(rename = "target_table")]
pub target_table: String,
#[serde(rename = "mapping")]
pub mapping: Vec<models::ColumnMapping>,
/// 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).
#[serde(rename = "batch_size", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub batch_size: Option<Option<i64>>,
#[serde(rename = "conflict_mode", skip_serializing_if = "Option::is_none")]
pub conflict_mode: Option<models::ConflictMode>,
/// `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.
#[serde(rename = "resume_run_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub resume_run_id: Option<Option<i64>>,
/// `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.
#[serde(rename = "definition_path", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub definition_path: Option<Option<String>>,
}
impl DataMigrationRequest {
/// Body shared by `dry_run` and `run` -- `run` executes exactly what `dry_run` would preview for the same request.
pub fn new(source_resource_path: String, target_resource_path: String, source_table: String, target_table: String, mapping: Vec<models::ColumnMapping>) -> DataMigrationRequest {
DataMigrationRequest {
source_resource_path,
target_resource_path,
source_table,
target_table,
mapping,
batch_size: None,
conflict_mode: None,
resume_run_id: None,
definition_path: None,
}
}
}