From 5b8dcd10c08499a8e3a3f352c666ed54d48d857f Mon Sep 17 00:00:00 2001 From: yangxin Date: Wed, 21 Jan 2026 17:09:26 +0800 Subject: [PATCH] add binlog fiter --- .gitignore | 2 + internal/cli/serverless/migration/create.go | 43 ++-- .../cli/serverless/migration/create_test.go | 17 ++ internal/cli/serverless/migration/template.go | 14 ++ .../v1beta1/serverless/dm.swagger.json | 136 +++++++++++-- .../migration/.openapi-generator/FILES | 1 + .../v1beta1/serverless/migration/README.md | 1 + .../serverless/migration/api/openapi.yaml | 33 +++ .../migration/model_binlog_filter_rule.go | 192 ++++++++++++++++++ .../serverless/migration/model_migration.go | 40 +++- ...migration_service_create_migration_body.go | 40 +++- .../model_migration_service_precheck_body.go | 40 +++- 12 files changed, 521 insertions(+), 38 deletions(-) create mode 100644 pkg/tidbcloud/v1beta1/serverless/migration/model_binlog_filter_rule.go diff --git a/.gitignore b/.gitignore index 9a43ed39..4e4228b3 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ dist/ .tidbcloud-cli.toml .CHANGELOG.md node_modules/ +.gomodcache/ +.gocache/ diff --git a/internal/cli/serverless/migration/create.go b/internal/cli/serverless/migration/create.go index 5e91c2bd..5690c4b5 100644 --- a/internal/cli/serverless/migration/create.go +++ b/internal/cli/serverless/migration/create.go @@ -86,26 +86,28 @@ func CreateCmd(h *internal.Helper) *cobra.Command { } definitionStr := string(definitionBytes) - sources, target, mode, err := parseMigrationDefinition(definitionStr) + sources, target, mode, binlogFilterRule, err := parseMigrationDefinition(definitionStr) if err != nil { return err } if dryRun { precheckBody := &pkgmigration.MigrationServicePrecheckBody{ - DisplayName: name, - Sources: sources, - Target: target, - Mode: mode, + DisplayName: name, + Sources: sources, + Target: target, + Mode: mode, + BinlogFilterRule: binlogFilterRule, } return runMigrationPrecheck(ctx, d, clusterID, precheckBody, h) } createBody := &pkgmigration.MigrationServiceCreateMigrationBody{ - DisplayName: name, - Sources: sources, - Target: target, - Mode: mode, + DisplayName: name, + Sources: sources, + Target: target, + Mode: mode, + BinlogFilterRule: binlogFilterRule, } resp, err := d.CreateMigration(ctx, clusterID, createBody) @@ -247,34 +249,35 @@ 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.BinlogFilterRule, 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"` + BinlogFilterRule *pkgmigration.BinlogFilterRule `json:"binlogFilterRule"` } 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 + return payload.Sources, *payload.Target, mode, payload.BinlogFilterRule, nil } func parseMigrationMode(value string) (pkgmigration.TaskMode, error) { diff --git a/internal/cli/serverless/migration/create_test.go b/internal/cli/serverless/migration/create_test.go index 06860de6..20093689 100644 --- a/internal/cli/serverless/migration/create_test.go +++ b/internal/cli/serverless/migration/create_test.go @@ -152,6 +152,10 @@ func (suite *CreateMigrationSuite) writeTempConfig(content string) string { func validMigrationConfig() string { return `{ "mode": "ALL", + "binlogFilterRule": { + "ignoreEvent": ["truncate table", "drop database"], + "ignoreSql": ["^DROP\\s+TABLE.*", "^TRUNCATE\\s+TABLE.*"] + }, "target": { "user": "migration_user", "password": "Passw0rd!" @@ -171,6 +175,19 @@ func validMigrationConfig() string { }` } +func TestParseMigrationDefinition_BinlogFilterRule(t *testing.T) { + assert := require.New(t) + + sources, target, mode, binlogFilterRule, err := parseMigrationDefinition(validMigrationConfig()) + assert.NoError(err) + assert.Equal(pkgmigration.TASKMODE_ALL, mode) + assert.NotNil(binlogFilterRule) + assert.Equal([]string{"truncate table", "drop database"}, binlogFilterRule.IgnoreEvent) + assert.Equal([]string{`^DROP\s+TABLE.*`, `^TRUNCATE\s+TABLE.*`}, binlogFilterRule.IgnoreSql) + assert.NotEmpty(sources) + assert.Equal("migration_user", target.User) +} + func TestCreateMigrationSuite(t *testing.T) { suite.Run(t, new(CreateMigrationSuite)) } diff --git a/internal/cli/serverless/migration/template.go b/internal/cli/serverless/migration/template.go index 5a0ab5fc..6f30d1d7 100644 --- a/internal/cli/serverless/migration/template.go +++ b/internal/cli/serverless/migration/template.go @@ -36,6 +36,13 @@ const ( "user": "migration_user", "password": "Passw0rd!" }, + // Optional global binlog filter rules applied during incremental replication. + "binlogFilterRule": { + // Event types to ignore, see https://docs.pingcap.com/tidb/stable/dm-binlog-event-filter/#parameter-descriptions . + "ignoreEvent": ["truncate table", "drop database"], + // SQL patterns to ignore. + "ignoreSql": ["^DROP\\s+TABLE.*", "^TRUNCATE\\s+TABLE.*"] + }, // List at least one migration source "sources": [ { @@ -111,6 +118,13 @@ const ( "user": "migration_user", "password": "Passw0rd!" }, + // Optional global binlog filter rules applied during incremental replication. + "binlogFilterRule": { + // Event types to ignore, see https://docs.pingcap.com/tidb/stable/dm-binlog-event-filter/#parameter-descriptions . + "ignoreEvent": ["truncate table", "drop database"], + // SQL patterns to ignore. + "ignoreSql": ["^DROP\\s+TABLE.*", "^TRUNCATE\\s+TABLE.*"] + }, "sources": [ { // Required: source database type. Supported values: MYSQL, ALICLOUD_RDS_MYSQL, AWS_RDS_MYSQL diff --git a/pkg/tidbcloud/v1beta1/serverless/dm.swagger.json b/pkg/tidbcloud/v1beta1/serverless/dm.swagger.json index 98b2a0c0..86d95c7b 100644 --- a/pkg/tidbcloud/v1beta1/serverless/dm.swagger.json +++ b/pkg/tidbcloud/v1beta1/serverless/dm.swagger.json @@ -477,6 +477,26 @@ }, "additionalProperties": {} }, + "BinlogFilterRule": { + "type": "object", + "properties": { + "ignoreEvent": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Event types to ignore (e.g., \"truncate table\", \"drop database\")." + }, + "ignoreSql": { + "type": "array", + "items": { + "type": "string" + }, + "description": "SQL patterns to ignore." + } + }, + "description": "Binlog filter rules applied during incremental replication." + }, "ConnProfile": { "type": "object", "properties": { @@ -518,11 +538,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": { @@ -680,12 +708,27 @@ "$ref": "#/definitions/Migration.State" } ] + }, + "binlogFilterRule": { + "description": "Global binlog filter rule applied to the migration.", + "readOnly": true, + "allOf": [ + { + "$ref": "#/definitions/BinlogFilterRule" + } + ] } } }, "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 +785,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 +827,9 @@ "description": "Table pattern of the source, supports wildcards." } }, - "required": ["schemaPattern"] + "required": [ + "schemaPattern" + ] }, "MigrationRule.Table": { "type": "object", @@ -792,7 +843,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 +877,22 @@ "$ref": "#/definitions/TaskMode" } ] + }, + "binlogFilterRule": { + "description": "Global binlog filter rule applied to all migrated tables.", + "allOf": [ + { + "$ref": "#/definitions/BinlogFilterRule" + } + ] } }, - "required": ["displayName", "sources", "target", "mode"] + "required": [ + "displayName", + "sources", + "target", + "mode" + ] }, "MigrationService.PauseMigrationBody": { "type": "object", @@ -862,9 +928,22 @@ "$ref": "#/definitions/TaskMode" } ] + }, + "binlogFilterRule": { + "description": "Global binlog filter rule applied to all migrated tables.", + "allOf": [ + { + "$ref": "#/definitions/BinlogFilterRule" + } + ] } }, - "required": ["displayName", "sources", "target", "mode"] + "required": [ + "displayName", + "sources", + "target", + "mode" + ] }, "MigrationService.ResumeMigrationBody": { "type": "object", @@ -915,7 +994,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 +1092,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 +1192,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 +1244,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..476619ea 100644 --- a/pkg/tidbcloud/v1beta1/serverless/migration/.openapi-generator/FILES +++ b/pkg/tidbcloud/v1beta1/serverless/migration/.openapi-generator/FILES @@ -8,6 +8,7 @@ client.go configuration.go git_push.sh model_any.go +model_binlog_filter_rule.go model_conn_profile.go model_conn_type.go model_create_migration_precheck_resp.go diff --git a/pkg/tidbcloud/v1beta1/serverless/migration/README.md b/pkg/tidbcloud/v1beta1/serverless/migration/README.md index 6fe901cc..ffe56b94 100644 --- a/pkg/tidbcloud/v1beta1/serverless/migration/README.md +++ b/pkg/tidbcloud/v1beta1/serverless/migration/README.md @@ -92,6 +92,7 @@ Class | Method | HTTP request | Description ## Documentation For Models - [Any](docs/Any.md) + - [BinlogFilterRule](docs/BinlogFilterRule.md) - [ConnProfile](docs/ConnProfile.md) - [ConnType](docs/ConnType.md) - [CreateMigrationPrecheckResp](docs/CreateMigrationPrecheckResp.md) diff --git a/pkg/tidbcloud/v1beta1/serverless/migration/api/openapi.yaml b/pkg/tidbcloud/v1beta1/serverless/migration/api/openapi.yaml index 4e84f8cf..85a93e2c 100644 --- a/pkg/tidbcloud/v1beta1/serverless/migration/api/openapi.yaml +++ b/pkg/tidbcloud/v1beta1/serverless/migration/api/openapi.yaml @@ -403,6 +403,21 @@ components: '@type': type: string type: object + BinlogFilterRule: + description: Binlog filter rules applied during incremental replication. + properties: + ignoreEvent: + description: "Event types to ignore (e.g., \"truncate table\", \"drop database\"\ + )." + items: + type: string + type: array + ignoreSql: + description: SQL patterns to ignore. + items: + type: string + type: array + type: object ConnProfile: properties: connType: @@ -495,6 +510,7 @@ components: migrations: - mode: "{}" migrationId: migrationId + binlogFilterRule: "{}" createTime: 2000-01-23T04:56:07.000+00:00 displayName: displayName subTasks: @@ -516,6 +532,7 @@ components: targetUser: targetUser - mode: "{}" migrationId: migrationId + binlogFilterRule: "{}" createTime: 2000-01-23T04:56:07.000+00:00 displayName: displayName subTasks: @@ -580,6 +597,7 @@ components: example: mode: "{}" migrationId: migrationId + binlogFilterRule: "{}" createTime: 2000-01-23T04:56:07.000+00:00 displayName: displayName subTasks: @@ -633,6 +651,11 @@ components: - $ref: '#/components/schemas/Migration.State' description: The current state of the migration. type: object + binlogFilterRule: + allOf: + - $ref: '#/components/schemas/BinlogFilterRule' + description: Global binlog filter rule applied to the migration. + type: object type: object Migration.State: description: |- @@ -778,6 +801,11 @@ components: - $ref: '#/components/schemas/TaskMode' description: The migration mode (full+incremental or incremental-only). type: object + binlogFilterRule: + allOf: + - $ref: '#/components/schemas/BinlogFilterRule' + description: Global binlog filter rule applied to all migrated tables. + type: object required: - displayName - mode @@ -807,6 +835,11 @@ components: - $ref: '#/components/schemas/TaskMode' description: The migration mode (full+incremental or incremental-only). type: object + binlogFilterRule: + allOf: + - $ref: '#/components/schemas/BinlogFilterRule' + description: Global binlog filter rule applied to all migrated tables. + type: object required: - displayName - mode diff --git a/pkg/tidbcloud/v1beta1/serverless/migration/model_binlog_filter_rule.go b/pkg/tidbcloud/v1beta1/serverless/migration/model_binlog_filter_rule.go new file mode 100644 index 00000000..175d8f1e --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/migration/model_binlog_filter_rule.go @@ -0,0 +1,192 @@ +/* +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" +) + +// checks if the BinlogFilterRule type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &BinlogFilterRule{} + +// BinlogFilterRule Binlog filter rules applied during incremental replication. +type BinlogFilterRule struct { + // Event types to ignore (e.g., \"truncate table\", \"drop database\"). + IgnoreEvent []string `json:"ignoreEvent,omitempty"` + // SQL patterns to ignore. + IgnoreSql []string `json:"ignoreSql,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _BinlogFilterRule BinlogFilterRule + +// NewBinlogFilterRule instantiates a new BinlogFilterRule object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewBinlogFilterRule() *BinlogFilterRule { + this := BinlogFilterRule{} + return &this +} + +// NewBinlogFilterRuleWithDefaults instantiates a new BinlogFilterRule object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewBinlogFilterRuleWithDefaults() *BinlogFilterRule { + this := BinlogFilterRule{} + return &this +} + +// GetIgnoreEvent returns the IgnoreEvent field value if set, zero value otherwise. +func (o *BinlogFilterRule) GetIgnoreEvent() []string { + if o == nil || IsNil(o.IgnoreEvent) { + var ret []string + return ret + } + return o.IgnoreEvent +} + +// GetIgnoreEventOk returns a tuple with the IgnoreEvent field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BinlogFilterRule) GetIgnoreEventOk() ([]string, bool) { + if o == nil || IsNil(o.IgnoreEvent) { + return nil, false + } + return o.IgnoreEvent, true +} + +// HasIgnoreEvent returns a boolean if a field has been set. +func (o *BinlogFilterRule) HasIgnoreEvent() bool { + if o != nil && !IsNil(o.IgnoreEvent) { + return true + } + + return false +} + +// SetIgnoreEvent gets a reference to the given []string and assigns it to the IgnoreEvent field. +func (o *BinlogFilterRule) SetIgnoreEvent(v []string) { + o.IgnoreEvent = v +} + +// GetIgnoreSql returns the IgnoreSql field value if set, zero value otherwise. +func (o *BinlogFilterRule) GetIgnoreSql() []string { + if o == nil || IsNil(o.IgnoreSql) { + var ret []string + return ret + } + return o.IgnoreSql +} + +// GetIgnoreSqlOk returns a tuple with the IgnoreSql field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BinlogFilterRule) GetIgnoreSqlOk() ([]string, bool) { + if o == nil || IsNil(o.IgnoreSql) { + return nil, false + } + return o.IgnoreSql, true +} + +// HasIgnoreSql returns a boolean if a field has been set. +func (o *BinlogFilterRule) HasIgnoreSql() bool { + if o != nil && !IsNil(o.IgnoreSql) { + return true + } + + return false +} + +// SetIgnoreSql gets a reference to the given []string and assigns it to the IgnoreSql field. +func (o *BinlogFilterRule) SetIgnoreSql(v []string) { + o.IgnoreSql = v +} + +func (o BinlogFilterRule) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o BinlogFilterRule) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.IgnoreEvent) { + toSerialize["ignoreEvent"] = o.IgnoreEvent + } + if !IsNil(o.IgnoreSql) { + toSerialize["ignoreSql"] = o.IgnoreSql + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *BinlogFilterRule) UnmarshalJSON(data []byte) (err error) { + varBinlogFilterRule := _BinlogFilterRule{} + + err = json.Unmarshal(data, &varBinlogFilterRule) + + if err != nil { + return err + } + + *o = BinlogFilterRule(varBinlogFilterRule) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "ignoreEvent") + delete(additionalProperties, "ignoreSql") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableBinlogFilterRule struct { + value *BinlogFilterRule + isSet bool +} + +func (v NullableBinlogFilterRule) Get() *BinlogFilterRule { + return v.value +} + +func (v *NullableBinlogFilterRule) Set(val *BinlogFilterRule) { + v.value = val + v.isSet = true +} + +func (v NullableBinlogFilterRule) IsSet() bool { + return v.isSet +} + +func (v *NullableBinlogFilterRule) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBinlogFilterRule(val *BinlogFilterRule) *NullableBinlogFilterRule { + return &NullableBinlogFilterRule{value: val, isSet: true} +} + +func (v NullableBinlogFilterRule) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBinlogFilterRule) 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..388f9f8f 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"` + // Global binlog filter rule applied to the migration. + BinlogFilterRule *BinlogFilterRule `json:"binlogFilterRule,omitempty"` AdditionalProperties map[string]interface{} } @@ -280,6 +282,38 @@ func (o *Migration) SetState(v MigrationState) { o.State = &v } +// GetBinlogFilterRule returns the BinlogFilterRule field value if set, zero value otherwise. +func (o *Migration) GetBinlogFilterRule() BinlogFilterRule { + if o == nil || IsNil(o.BinlogFilterRule) { + var ret BinlogFilterRule + return ret + } + return *o.BinlogFilterRule +} + +// GetBinlogFilterRuleOk returns a tuple with the BinlogFilterRule field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Migration) GetBinlogFilterRuleOk() (*BinlogFilterRule, bool) { + if o == nil || IsNil(o.BinlogFilterRule) { + return nil, false + } + return o.BinlogFilterRule, true +} + +// HasBinlogFilterRule returns a boolean if a field has been set. +func (o *Migration) HasBinlogFilterRule() bool { + if o != nil && !IsNil(o.BinlogFilterRule) { + return true + } + + return false +} + +// SetBinlogFilterRule gets a reference to the given BinlogFilterRule and assigns it to the BinlogFilterRule field. +func (o *Migration) SetBinlogFilterRule(v BinlogFilterRule) { + o.BinlogFilterRule = &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.BinlogFilterRule) { + toSerialize["binlogFilterRule"] = o.BinlogFilterRule + } 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, "binlogFilterRule") 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..3f9997ec 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"` + // Global binlog filter rule applied to all migrated tables. + BinlogFilterRule *BinlogFilterRule `json:"binlogFilterRule,omitempty"` AdditionalProperties map[string]interface{} } @@ -150,6 +152,38 @@ func (o *MigrationServiceCreateMigrationBody) SetMode(v TaskMode) { o.Mode = v } +// GetBinlogFilterRule returns the BinlogFilterRule field value if set, zero value otherwise. +func (o *MigrationServiceCreateMigrationBody) GetBinlogFilterRule() BinlogFilterRule { + if o == nil || IsNil(o.BinlogFilterRule) { + var ret BinlogFilterRule + return ret + } + return *o.BinlogFilterRule +} + +// GetBinlogFilterRuleOk returns a tuple with the BinlogFilterRule field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MigrationServiceCreateMigrationBody) GetBinlogFilterRuleOk() (*BinlogFilterRule, bool) { + if o == nil || IsNil(o.BinlogFilterRule) { + return nil, false + } + return o.BinlogFilterRule, true +} + +// HasBinlogFilterRule returns a boolean if a field has been set. +func (o *MigrationServiceCreateMigrationBody) HasBinlogFilterRule() bool { + if o != nil && !IsNil(o.BinlogFilterRule) { + return true + } + + return false +} + +// SetBinlogFilterRule gets a reference to the given BinlogFilterRule and assigns it to the BinlogFilterRule field. +func (o *MigrationServiceCreateMigrationBody) SetBinlogFilterRule(v BinlogFilterRule) { + o.BinlogFilterRule = &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.BinlogFilterRule) { + toSerialize["binlogFilterRule"] = o.BinlogFilterRule + } 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, "binlogFilterRule") 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..4b9132e5 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"` + // Global binlog filter rule applied to all migrated tables. + BinlogFilterRule *BinlogFilterRule `json:"binlogFilterRule,omitempty"` AdditionalProperties map[string]interface{} } @@ -150,6 +152,38 @@ func (o *MigrationServicePrecheckBody) SetMode(v TaskMode) { o.Mode = v } +// GetBinlogFilterRule returns the BinlogFilterRule field value if set, zero value otherwise. +func (o *MigrationServicePrecheckBody) GetBinlogFilterRule() BinlogFilterRule { + if o == nil || IsNil(o.BinlogFilterRule) { + var ret BinlogFilterRule + return ret + } + return *o.BinlogFilterRule +} + +// GetBinlogFilterRuleOk returns a tuple with the BinlogFilterRule field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MigrationServicePrecheckBody) GetBinlogFilterRuleOk() (*BinlogFilterRule, bool) { + if o == nil || IsNil(o.BinlogFilterRule) { + return nil, false + } + return o.BinlogFilterRule, true +} + +// HasBinlogFilterRule returns a boolean if a field has been set. +func (o *MigrationServicePrecheckBody) HasBinlogFilterRule() bool { + if o != nil && !IsNil(o.BinlogFilterRule) { + return true + } + + return false +} + +// SetBinlogFilterRule gets a reference to the given BinlogFilterRule and assigns it to the BinlogFilterRule field. +func (o *MigrationServicePrecheckBody) SetBinlogFilterRule(v BinlogFilterRule) { + o.BinlogFilterRule = &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.BinlogFilterRule) { + toSerialize["binlogFilterRule"] = o.BinlogFilterRule + } 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, "binlogFilterRule") o.AdditionalProperties = additionalProperties }