From 55a3d61af231a030d429e514b77583bb251a3cf1 Mon Sep 17 00:00:00 2001 From: yangxin Date: Tue, 27 Jan 2026 15:51:40 +0800 Subject: [PATCH] migration support physical import mode --- internal/cli/serverless/migration/create.go | 60 +++++++-- .../cli/serverless/migration/create_test.go | 17 ++- internal/cli/serverless/migration/template.go | 4 + .../v1beta1/serverless/dm.swagger.json | 124 +++++++++++++++--- .../migration/.openapi-generator/FILES | 1 + .../v1beta1/serverless/migration/README.md | 1 + .../serverless/migration/api/openapi.yaml | 24 ++++ .../serverless/migration/model_import_mode.go | 105 +++++++++++++++ .../serverless/migration/model_migration.go | 40 +++++- ...migration_service_create_migration_body.go | 40 +++++- .../model_migration_service_precheck_body.go | 40 +++++- 11 files changed, 425 insertions(+), 31 deletions(-) create mode 100644 pkg/tidbcloud/v1beta1/serverless/migration/model_import_mode.go diff --git a/internal/cli/serverless/migration/create.go b/internal/cli/serverless/migration/create.go index 6e70f9fc..2d4f290f 100644 --- a/internal/cli/serverless/migration/create.go +++ b/internal/cli/serverless/migration/create.go @@ -86,7 +86,7 @@ func CreateCmd(h *internal.Helper) *cobra.Command { } definitionStr := string(definitionBytes) - sources, target, mode, err := parseMigrationDefinition(definitionStr) + sources, target, mode, importMode, err := parseMigrationDefinition(definitionStr) if err != nil { return err } @@ -97,6 +97,7 @@ func CreateCmd(h *internal.Helper) *cobra.Command { Sources: sources, Target: target, Mode: mode, + ImportMode: importMode, } return runMigrationPrecheck(ctx, d, clusterID, precheckBody, h) } @@ -106,6 +107,7 @@ func CreateCmd(h *internal.Helper) *cobra.Command { Sources: sources, Target: target, Mode: mode, + ImportMode: importMode, } resp, err := d.CreateMigration(ctx, clusterID, createBody) @@ -247,34 +249,44 @@ func shouldPrintPrecheckItem(status *pkgmigration.PrecheckItemStatus) bool { } } -func parseMigrationDefinition(value string) ([]pkgmigration.Source, pkgmigration.Target, pkgmigration.TaskMode, error) { +func parseMigrationDefinition(value string) ([]pkgmigration.Source, pkgmigration.Target, pkgmigration.TaskMode, *pkgmigration.ImportMode, error) { trimmed := strings.TrimSpace(value) if trimmed == "" { - return nil, pkgmigration.Target{}, "", errors.New("migration config is required; use --config-file") + return nil, pkgmigration.Target{}, "", nil, errors.New("migration config is required; use --config-file") } var payload struct { - Sources []pkgmigration.Source `json:"sources"` - Target *pkgmigration.Target `json:"target"` - Mode string `json:"mode"` + Sources []pkgmigration.Source `json:"sources"` + Target *pkgmigration.Target `json:"target"` + Mode string `json:"mode"` + ImportMode *string `json:"importMode"` } stdJson, err := standardizeJSON([]byte(trimmed)) if err != nil { - return nil, pkgmigration.Target{}, "", errors.Annotate(err, "invalid migration definition JSON") + return nil, pkgmigration.Target{}, "", nil, errors.Annotate(err, "invalid migration definition JSON") } if err := json.Unmarshal(stdJson, &payload); err != nil { - return nil, pkgmigration.Target{}, "", errors.Annotate(err, "invalid migration definition JSON") + return nil, pkgmigration.Target{}, "", nil, errors.Annotate(err, "invalid migration definition JSON") } if len(payload.Sources) == 0 { - return nil, pkgmigration.Target{}, "", errors.New("migration definition must include at least one source") + return nil, pkgmigration.Target{}, "", nil, errors.New("migration definition must include at least one source") } if payload.Target == nil { - return nil, pkgmigration.Target{}, "", errors.New("migration definition must include the target block") + return nil, pkgmigration.Target{}, "", nil, errors.New("migration definition must include the target block") } mode, err := parseMigrationMode(payload.Mode) if err != nil { - return nil, pkgmigration.Target{}, "", err + return nil, pkgmigration.Target{}, "", nil, err } - return payload.Sources, *payload.Target, mode, nil + + importMode, err := parseImportMode(payload.ImportMode) + if err != nil { + return nil, pkgmigration.Target{}, "", nil, err + } + if mode == pkgmigration.TASKMODE_INCREMENTAL && importMode != nil { + return nil, pkgmigration.Target{}, "", nil, errors.New("importMode is only applicable for mode=ALL; remove importMode or switch to mode=ALL") + } + + return payload.Sources, *payload.Target, mode, importMode, nil } func parseMigrationMode(value string) (pkgmigration.TaskMode, error) { @@ -290,6 +302,30 @@ func parseMigrationMode(value string) (pkgmigration.TaskMode, error) { return "", errors.Errorf("invalid mode %q, allowed values: %s", value, pkgmigration.AllowedTaskModeEnumValues) } +func parseImportMode(raw *string) (*pkgmigration.ImportMode, error) { + if raw == nil { + return nil, nil + } + trimmed := strings.TrimSpace(*raw) + if trimmed == "" { + return nil, nil + } + + normalized := strings.ToUpper(trimmed) + switch normalized { + case "LOGICAL": + normalized = "IMPORT_MODE_LOGICAL" + case "PHYSICAL": + normalized = "IMPORT_MODE_PHYSICAL" + } + + mode := pkgmigration.ImportMode(normalized) + if slices.Contains(pkgmigration.AllowedImportModeEnumValues, mode) { + return &mode, nil + } + return nil, errors.Errorf("invalid importMode %q, allowed values: %s", trimmed, pkgmigration.AllowedImportModeEnumValues) +} + // standardizeJSON accepts JSON With Commas and Comments(JWCC) see // https://nigeltao.github.io/blog/2021/json-with-commas-comments.html) and // returns a standard JSON byte slice ready for json.Unmarshal. diff --git a/internal/cli/serverless/migration/create_test.go b/internal/cli/serverless/migration/create_test.go index 23461daf..666c4a6d 100644 --- a/internal/cli/serverless/migration/create_test.go +++ b/internal/cli/serverless/migration/create_test.go @@ -69,11 +69,13 @@ func (suite *CreateMigrationSuite) TestCreateMigration() { ctx, clusterID, mockTool.MatchedBy(func(body *pkgmigration.MigrationServiceCreateMigrationBody) bool { + hasImportMode := body != nil && body.ImportMode != nil && *body.ImportMode == pkgmigration.IMPORTMODE_IMPORT_MODE_LOGICAL return body != nil && body.DisplayName == displayName && body.Mode == pkgmigration.TASKMODE_ALL && len(body.Sources) == 1 && - body.Target.User == "migration_user" + body.Target.User == "migration_user" && + hasImportMode }), ).Return(&pkgmigration.Migration{MigrationId: aws.String(migrationID)}, nil) @@ -98,6 +100,8 @@ func (suite *CreateMigrationSuite) TestCreateMigrationInvalidInputs() { blankPath := suite.writeTempConfig(" ") invalidJSONPath := suite.writeTempConfig("{invalid") invalidModePath := suite.writeTempConfig(`{ "mode": "invalid", "target": {"user":"u","password":"p"}, "sources": [{"sourceType":"MYSQL","connProfile":{"connType":"PUBLIC","host":"h","port":3306,"user":"u","password":"p"}}] }`) + invalidImportModePath := suite.writeTempConfig(`{ "mode": "ALL", "importMode": "nope", "target": {"user":"u","password":"p"}, "sources": [{"sourceType":"MYSQL","connProfile":{"connType":"PUBLIC","host":"h","port":3306,"user":"u","password":"p"}}] }`) + importModeWithIncrementalPath := suite.writeTempConfig(`{ "mode": "INCREMENTAL", "importMode": "logical", "target": {"user":"u","password":"p"}, "sources": [{"sourceType":"MYSQL","connProfile":{"connType":"PUBLIC","host":"h","port":3306,"user":"u","password":"p"}}] }`) tests := []struct { name string @@ -124,6 +128,16 @@ func (suite *CreateMigrationSuite) TestCreateMigrationInvalidInputs() { args: []string{"--cluster-id", "c1", "--display-name", "name", "--config-file", invalidModePath}, errContains: "invalid mode", }, + { + name: "invalid importMode", + args: []string{"--cluster-id", "c1", "--display-name", "name", "--config-file", invalidImportModePath}, + errContains: "invalid importMode", + }, + { + name: "importMode with incremental mode", + args: []string{"--cluster-id", "c1", "--display-name", "name", "--config-file", importModeWithIncrementalPath}, + errContains: "importMode is only applicable for mode=ALL", + }, } for _, tt := range tests { @@ -152,6 +166,7 @@ func (suite *CreateMigrationSuite) writeTempConfig(content string) string { func validMigrationConfig() string { return `{ "mode": "ALL", + "importMode": "IMPORT_MODE_LOGICAL", "target": { "user": "migration_user", "password": "Passw0rd!" diff --git a/internal/cli/serverless/migration/template.go b/internal/cli/serverless/migration/template.go index 8ce8ea04..9e7a840d 100644 --- a/internal/cli/serverless/migration/template.go +++ b/internal/cli/serverless/migration/template.go @@ -31,6 +31,10 @@ const ( migrationDefinitionAllTemplate = `{ // Required migration mode. Use "ALL" for full + incremental. "mode": "ALL", + // Optional import mode for full migration phase. + // Supported values: IMPORT_MODE_LOGICAL, IMPORT_MODE_PHYSICAL + // Note: Not applicable for mode = INCREMENTAL. + "importMode": "IMPORT_MODE_LOGICAL", // Target TiDB Cloud user credentials used by the migration "target": { "user": "migration_user", diff --git a/pkg/tidbcloud/v1beta1/serverless/dm.swagger.json b/pkg/tidbcloud/v1beta1/serverless/dm.swagger.json index 98b2a0c0..a8e6103c 100644 --- a/pkg/tidbcloud/v1beta1/serverless/dm.swagger.json +++ b/pkg/tidbcloud/v1beta1/serverless/dm.swagger.json @@ -518,11 +518,19 @@ ] } }, - "required": ["connType", "port", "user", "password"] + "required": [ + "connType", + "port", + "user", + "password" + ] }, "ConnType": { "type": "string", - "enum": ["PUBLIC", "PRIVATE_LINK"], + "enum": [ + "PUBLIC", + "PRIVATE_LINK" + ], "description": "The connection type used to connect to the source database.\n\n - PUBLIC: Connect over the public internet.\n - PRIVATE_LINK: Connect via Private Link/Private Endpoint." }, "CreateMigrationPrecheckResp": { @@ -576,6 +584,14 @@ } } }, + "ImportMode": { + "type": "string", + "enum": [ + "IMPORT_MODE_LOGICAL", + "IMPORT_MODE_PHYSICAL" + ], + "description": "Import mode for full migration phase." + }, "ListMigrationsResp": { "type": "object", "properties": { @@ -680,12 +696,27 @@ "$ref": "#/definitions/Migration.State" } ] + }, + "importMode": { + "description": "Import mode for full migration phase.", + "readOnly": true, + "allOf": [ + { + "$ref": "#/definitions/ImportMode" + } + ] } } }, "Migration.State": { "type": "string", - "enum": ["CREATING", "RUNNING", "PAUSED", "FAILED", "DELETING"], + "enum": [ + "CREATING", + "RUNNING", + "PAUSED", + "FAILED", + "DELETING" + ], "description": "Overall state of a migration.\n\n - CREATING: Task is being created.\n - RUNNING: Task is actively running.\n - PAUSED: Task is paused.\n - FAILED: Task failed with error.\n - DELETING: Task is being deleted." }, "MigrationPrecheck": { @@ -742,7 +773,13 @@ }, "MigrationPrecheck.Status": { "type": "string", - "enum": ["RUNNING", "FINISHED", "PENDING", "FAILED", "CANCELED"], + "enum": [ + "RUNNING", + "FINISHED", + "PENDING", + "FAILED", + "CANCELED" + ], "description": " - RUNNING: Precheck is in progress.\n - FINISHED: Precheck finished successfully.\n - PENDING: Precheck is pending.\n - FAILED: Precheck failed.\n - CANCELED: Precheck is canceled." }, "MigrationRule": { @@ -778,7 +815,9 @@ "description": "Table pattern of the source, supports wildcards." } }, - "required": ["schemaPattern"] + "required": [ + "schemaPattern" + ] }, "MigrationRule.Table": { "type": "object", @@ -792,7 +831,9 @@ "description": "Table name. Wildcards are not supported. Set empty to use the source table name." } }, - "required": ["schema"] + "required": [ + "schema" + ] }, "MigrationService.CreateMigrationBody": { "type": "object", @@ -824,9 +865,22 @@ "$ref": "#/definitions/TaskMode" } ] + }, + "importMode": { + "description": "Import mode for full migration phase.", + "allOf": [ + { + "$ref": "#/definitions/ImportMode" + } + ] } }, - "required": ["displayName", "sources", "target", "mode"] + "required": [ + "displayName", + "sources", + "target", + "mode" + ] }, "MigrationService.PauseMigrationBody": { "type": "object", @@ -862,9 +916,22 @@ "$ref": "#/definitions/TaskMode" } ] + }, + "importMode": { + "description": "Import mode for full migration phase.", + "allOf": [ + { + "$ref": "#/definitions/ImportMode" + } + ] } }, - "required": ["displayName", "sources", "target", "mode"] + "required": [ + "displayName", + "sources", + "target", + "mode" + ] }, "MigrationService.ResumeMigrationBody": { "type": "object", @@ -915,7 +982,11 @@ }, "PrecheckItem.Status": { "type": "string", - "enum": ["SUCCESS", "WARNING", "FAILED"], + "enum": [ + "SUCCESS", + "WARNING", + "FAILED" + ], "description": " - SUCCESS: Check passed successfully.\n - WARNING: Check resulted in a warning.\n - FAILED: Check failed." }, "PrecheckItemType": { @@ -1009,11 +1080,18 @@ ] } }, - "required": ["connProfile", "sourceType"] + "required": [ + "connProfile", + "sourceType" + ] }, "Source.SourceType": { "type": "string", - "enum": ["MYSQL", "ALICLOUD_RDS_MYSQL", "AWS_RDS_MYSQL"], + "enum": [ + "MYSQL", + "ALICLOUD_RDS_MYSQL", + "AWS_RDS_MYSQL" + ], "description": "The source database type.\n\n - MYSQL: Self-managed MySQL.\n - ALICLOUD_RDS_MYSQL: Alibaba Cloud RDS for MySQL.\n - AWS_RDS_MYSQL: Amazon RDS for MySQL." }, "Status": { @@ -1102,12 +1180,22 @@ }, "SubTask.Stage": { "type": "string", - "enum": ["RUNNING", "PAUSED", "FAILED", "FINISHED", "UNKNOWN"], + "enum": [ + "RUNNING", + "PAUSED", + "FAILED", + "FINISHED", + "UNKNOWN" + ], "description": "The high-level lifecycle stage of a subtask.\n\n - RUNNING: Subtask is running.\n - PAUSED: Subtask is paused.\n - FAILED: Subtask failed.\n - FINISHED: Subtask finished successfully.\n - UNKNOWN: Subtask stage is unknown." }, "SubTask.Step": { "type": "string", - "enum": ["DUMP", "LOAD", "SYNC"], + "enum": [ + "DUMP", + "LOAD", + "SYNC" + ], "description": "The current step within a subtask.\n\n - DUMP: Dump/export data from source.\n - LOAD: Load/import data into target.\n - SYNC: Sync/replicate binlog changes." }, "SyncDetail": { @@ -1144,11 +1232,17 @@ "description": "Target database password." } }, - "required": ["user", "password"] + "required": [ + "user", + "password" + ] }, "TaskMode": { "type": "string", - "enum": ["ALL", "INCREMENTAL"], + "enum": [ + "ALL", + "INCREMENTAL" + ], "description": "Migration task mode.\n\n - ALL: Full + incremental migration (all phases).\n - INCREMENTAL: Incremental-only migration (replication)." } } diff --git a/pkg/tidbcloud/v1beta1/serverless/migration/.openapi-generator/FILES b/pkg/tidbcloud/v1beta1/serverless/migration/.openapi-generator/FILES index 66d4257c..5608c57f 100644 --- a/pkg/tidbcloud/v1beta1/serverless/migration/.openapi-generator/FILES +++ b/pkg/tidbcloud/v1beta1/serverless/migration/.openapi-generator/FILES @@ -12,6 +12,7 @@ model_conn_profile.go model_conn_type.go model_create_migration_precheck_resp.go model_dump_detail.go +model_import_mode.go model_list_migrations_resp.go model_load_detail.go model_migration.go diff --git a/pkg/tidbcloud/v1beta1/serverless/migration/README.md b/pkg/tidbcloud/v1beta1/serverless/migration/README.md index 6fe901cc..f2808df8 100644 --- a/pkg/tidbcloud/v1beta1/serverless/migration/README.md +++ b/pkg/tidbcloud/v1beta1/serverless/migration/README.md @@ -96,6 +96,7 @@ Class | Method | HTTP request | Description - [ConnType](docs/ConnType.md) - [CreateMigrationPrecheckResp](docs/CreateMigrationPrecheckResp.md) - [DumpDetail](docs/DumpDetail.md) + - [ImportMode](docs/ImportMode.md) - [ListMigrationsResp](docs/ListMigrationsResp.md) - [LoadDetail](docs/LoadDetail.md) - [Migration](docs/Migration.md) diff --git a/pkg/tidbcloud/v1beta1/serverless/migration/api/openapi.yaml b/pkg/tidbcloud/v1beta1/serverless/migration/api/openapi.yaml index 4e84f8cf..c71229bf 100644 --- a/pkg/tidbcloud/v1beta1/serverless/migration/api/openapi.yaml +++ b/pkg/tidbcloud/v1beta1/serverless/migration/api/openapi.yaml @@ -489,12 +489,19 @@ components: readOnly: true type: string type: object + ImportMode: + description: Import mode for full migration phase. + enum: + - IMPORT_MODE_LOGICAL + - IMPORT_MODE_PHYSICAL + type: string ListMigrationsResp: example: totalSize: 0 migrations: - mode: "{}" migrationId: migrationId + importMode: "{}" createTime: 2000-01-23T04:56:07.000+00:00 displayName: displayName subTasks: @@ -516,6 +523,7 @@ components: targetUser: targetUser - mode: "{}" migrationId: migrationId + importMode: "{}" createTime: 2000-01-23T04:56:07.000+00:00 displayName: displayName subTasks: @@ -580,6 +588,7 @@ components: example: mode: "{}" migrationId: migrationId + importMode: "{}" createTime: 2000-01-23T04:56:07.000+00:00 displayName: displayName subTasks: @@ -633,6 +642,11 @@ components: - $ref: '#/components/schemas/Migration.State' description: The current state of the migration. type: object + importMode: + allOf: + - $ref: '#/components/schemas/ImportMode' + description: Import mode for full migration phase. + type: object type: object Migration.State: description: |- @@ -778,6 +792,11 @@ components: - $ref: '#/components/schemas/TaskMode' description: The migration mode (full+incremental or incremental-only). type: object + importMode: + allOf: + - $ref: '#/components/schemas/ImportMode' + description: Import mode for full migration phase. + type: object required: - displayName - mode @@ -807,6 +826,11 @@ components: - $ref: '#/components/schemas/TaskMode' description: The migration mode (full+incremental or incremental-only). type: object + importMode: + allOf: + - $ref: '#/components/schemas/ImportMode' + description: Import mode for full migration phase. + type: object required: - displayName - mode diff --git a/pkg/tidbcloud/v1beta1/serverless/migration/model_import_mode.go b/pkg/tidbcloud/v1beta1/serverless/migration/model_import_mode.go new file mode 100644 index 00000000..b8e1058f --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/migration/model_import_mode.go @@ -0,0 +1,105 @@ +/* +TiDB Cloud Starter and Essential API + +TiDB Cloud Starter and Essential API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package migration + +import ( + "encoding/json" +) + +// ImportMode Import mode for full migration phase. +type ImportMode string + +// List of ImportMode +const ( + IMPORTMODE_IMPORT_MODE_LOGICAL ImportMode = "IMPORT_MODE_LOGICAL" + IMPORTMODE_IMPORT_MODE_PHYSICAL ImportMode = "IMPORT_MODE_PHYSICAL" +) + +// All allowed values of ImportMode enum +var AllowedImportModeEnumValues = []ImportMode{ + "IMPORT_MODE_LOGICAL", + "IMPORT_MODE_PHYSICAL", +} + +func (v *ImportMode) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := ImportMode(value) + for _, existing := range AllowedImportModeEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + *v = ImportMode(value) + return nil +} + +// NewImportModeFromValue returns a pointer to a valid ImportMode for the value passed as argument +func NewImportModeFromValue(v string) *ImportMode { + ev := ImportMode(v) + return &ev +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v ImportMode) IsValid() bool { + for _, existing := range AllowedImportModeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ImportMode value +func (v ImportMode) Ptr() *ImportMode { + return &v +} + +type NullableImportMode struct { + value *ImportMode + isSet bool +} + +func (v NullableImportMode) Get() *ImportMode { + return v.value +} + +func (v *NullableImportMode) Set(val *ImportMode) { + v.value = val + v.isSet = true +} + +func (v NullableImportMode) IsSet() bool { + return v.isSet +} + +func (v *NullableImportMode) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableImportMode(val *ImportMode) *NullableImportMode { + return &NullableImportMode{value: val, isSet: true} +} + +func (v NullableImportMode) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableImportMode) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/migration/model_migration.go b/pkg/tidbcloud/v1beta1/serverless/migration/model_migration.go index 1012d2ec..9d8cc500 100644 --- a/pkg/tidbcloud/v1beta1/serverless/migration/model_migration.go +++ b/pkg/tidbcloud/v1beta1/serverless/migration/model_migration.go @@ -33,7 +33,9 @@ type Migration struct { // The migration mode of the migration. Mode *TaskMode `json:"mode,omitempty"` // The current state of the migration. - State *MigrationState `json:"state,omitempty"` + State *MigrationState `json:"state,omitempty"` + // Import mode for full migration phase. + ImportMode *ImportMode `json:"importMode,omitempty"` AdditionalProperties map[string]interface{} } @@ -280,6 +282,38 @@ func (o *Migration) SetState(v MigrationState) { o.State = &v } +// GetImportMode returns the ImportMode field value if set, zero value otherwise. +func (o *Migration) GetImportMode() ImportMode { + if o == nil || IsNil(o.ImportMode) { + var ret ImportMode + return ret + } + return *o.ImportMode +} + +// GetImportModeOk returns a tuple with the ImportMode field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Migration) GetImportModeOk() (*ImportMode, bool) { + if o == nil || IsNil(o.ImportMode) { + return nil, false + } + return o.ImportMode, true +} + +// HasImportMode returns a boolean if a field has been set. +func (o *Migration) HasImportMode() bool { + if o != nil && !IsNil(o.ImportMode) { + return true + } + + return false +} + +// SetImportMode gets a reference to the given ImportMode and assigns it to the ImportMode field. +func (o *Migration) SetImportMode(v ImportMode) { + o.ImportMode = &v +} + func (o Migration) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { @@ -311,6 +345,9 @@ func (o Migration) ToMap() (map[string]interface{}, error) { if !IsNil(o.State) { toSerialize["state"] = o.State } + if !IsNil(o.ImportMode) { + toSerialize["importMode"] = o.ImportMode + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -340,6 +377,7 @@ func (o *Migration) UnmarshalJSON(data []byte) (err error) { delete(additionalProperties, "createTime") delete(additionalProperties, "mode") delete(additionalProperties, "state") + delete(additionalProperties, "importMode") o.AdditionalProperties = additionalProperties } diff --git a/pkg/tidbcloud/v1beta1/serverless/migration/model_migration_service_create_migration_body.go b/pkg/tidbcloud/v1beta1/serverless/migration/model_migration_service_create_migration_body.go index 1c5f1ab0..4c95ae3c 100644 --- a/pkg/tidbcloud/v1beta1/serverless/migration/model_migration_service_create_migration_body.go +++ b/pkg/tidbcloud/v1beta1/serverless/migration/model_migration_service_create_migration_body.go @@ -27,7 +27,9 @@ type MigrationServiceCreateMigrationBody struct { // The target database credentials. Target Target `json:"target"` // The migration mode (full+incremental or incremental-only). - Mode TaskMode `json:"mode"` + Mode TaskMode `json:"mode"` + // Import mode for full migration phase. + ImportMode *ImportMode `json:"importMode,omitempty"` AdditionalProperties map[string]interface{} } @@ -150,6 +152,38 @@ func (o *MigrationServiceCreateMigrationBody) SetMode(v TaskMode) { o.Mode = v } +// GetImportMode returns the ImportMode field value if set, zero value otherwise. +func (o *MigrationServiceCreateMigrationBody) GetImportMode() ImportMode { + if o == nil || IsNil(o.ImportMode) { + var ret ImportMode + return ret + } + return *o.ImportMode +} + +// GetImportModeOk returns a tuple with the ImportMode field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MigrationServiceCreateMigrationBody) GetImportModeOk() (*ImportMode, bool) { + if o == nil || IsNil(o.ImportMode) { + return nil, false + } + return o.ImportMode, true +} + +// HasImportMode returns a boolean if a field has been set. +func (o *MigrationServiceCreateMigrationBody) HasImportMode() bool { + if o != nil && !IsNil(o.ImportMode) { + return true + } + + return false +} + +// SetImportMode gets a reference to the given ImportMode and assigns it to the ImportMode field. +func (o *MigrationServiceCreateMigrationBody) SetImportMode(v ImportMode) { + o.ImportMode = &v +} + func (o MigrationServiceCreateMigrationBody) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { @@ -164,6 +198,9 @@ func (o MigrationServiceCreateMigrationBody) ToMap() (map[string]interface{}, er toSerialize["sources"] = o.Sources toSerialize["target"] = o.Target toSerialize["mode"] = o.Mode + if !IsNil(o.ImportMode) { + toSerialize["importMode"] = o.ImportMode + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -214,6 +251,7 @@ func (o *MigrationServiceCreateMigrationBody) UnmarshalJSON(data []byte) (err er delete(additionalProperties, "sources") delete(additionalProperties, "target") delete(additionalProperties, "mode") + delete(additionalProperties, "importMode") o.AdditionalProperties = additionalProperties } diff --git a/pkg/tidbcloud/v1beta1/serverless/migration/model_migration_service_precheck_body.go b/pkg/tidbcloud/v1beta1/serverless/migration/model_migration_service_precheck_body.go index 047968a8..37e88206 100644 --- a/pkg/tidbcloud/v1beta1/serverless/migration/model_migration_service_precheck_body.go +++ b/pkg/tidbcloud/v1beta1/serverless/migration/model_migration_service_precheck_body.go @@ -27,7 +27,9 @@ type MigrationServicePrecheckBody struct { // The target database credentials. Target Target `json:"target"` // The migration mode (full+incremental or incremental-only). - Mode TaskMode `json:"mode"` + Mode TaskMode `json:"mode"` + // Import mode for full migration phase. + ImportMode *ImportMode `json:"importMode,omitempty"` AdditionalProperties map[string]interface{} } @@ -150,6 +152,38 @@ func (o *MigrationServicePrecheckBody) SetMode(v TaskMode) { o.Mode = v } +// GetImportMode returns the ImportMode field value if set, zero value otherwise. +func (o *MigrationServicePrecheckBody) GetImportMode() ImportMode { + if o == nil || IsNil(o.ImportMode) { + var ret ImportMode + return ret + } + return *o.ImportMode +} + +// GetImportModeOk returns a tuple with the ImportMode field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MigrationServicePrecheckBody) GetImportModeOk() (*ImportMode, bool) { + if o == nil || IsNil(o.ImportMode) { + return nil, false + } + return o.ImportMode, true +} + +// HasImportMode returns a boolean if a field has been set. +func (o *MigrationServicePrecheckBody) HasImportMode() bool { + if o != nil && !IsNil(o.ImportMode) { + return true + } + + return false +} + +// SetImportMode gets a reference to the given ImportMode and assigns it to the ImportMode field. +func (o *MigrationServicePrecheckBody) SetImportMode(v ImportMode) { + o.ImportMode = &v +} + func (o MigrationServicePrecheckBody) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { @@ -164,6 +198,9 @@ func (o MigrationServicePrecheckBody) ToMap() (map[string]interface{}, error) { toSerialize["sources"] = o.Sources toSerialize["target"] = o.Target toSerialize["mode"] = o.Mode + if !IsNil(o.ImportMode) { + toSerialize["importMode"] = o.ImportMode + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -214,6 +251,7 @@ func (o *MigrationServicePrecheckBody) UnmarshalJSON(data []byte) (err error) { delete(additionalProperties, "sources") delete(additionalProperties, "target") delete(additionalProperties, "mode") + delete(additionalProperties, "importMode") o.AdditionalProperties = additionalProperties }