github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/drs/v3/public/BatchCreateTasks.go (about) 1 package public 2 3 import ( 4 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/build" 6 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 7 "github.com/opentelekomcloud/gophertelekomcloud/openstack/common/tags" 8 ) 9 10 type BatchCreateTaskOpts struct { 11 Jobs []CreateJobOpts `json:"jobs"` 12 } 13 14 type CreateJobOpts struct { 15 // Whether to bind an EIP. This parameter is mandatory and set to true when the network type is EIP. 16 BindEip *bool `json:"bind_eip,omitempty"` 17 // The migration scenario. The value can be migration (real-time migration), sync (real-time synchronization), 18 // or cloudDataGuard (real-time disaster recovery). 19 // Values: migration sync cloudDataGuard 20 DbUseType string `json:"db_use_type" required:"true"` 21 // The task name. The task name can be 4 to 50 characters in length. 22 // It is case-insensitive and can contain only letters, digits, hyphens (-), and underscores (_). 23 // Minimum length: 4 characters 24 // Maximum length: 50 characters 25 Name string `json:"name" required:"true"` 26 // Task description. The task description can contain a maximum of 256 characters 27 // and cannot contain the following special characters: !<>'&"\ 28 Description string `json:"description,omitempty"` 29 // The engine type. The options are as follows: mysql (MySQL migration and MySQL synchronization), 30 // mongodb (used for migration), mysql-to-taurus (used for MySQL to GaussDB(for MySQL) primary/standby synchronization), 31 // cloudDataGuard-mysql (used for DR), postgresql (used for PostgreSQL synchronization). 32 // Values: mysql mongodb cloudDataGuard-mysql mysql-to-taurus postgresql 33 EngineType string `json:"engine_type" required:"true"` 34 // Whether the destination DB instance can be read-only. This parameter is valid only when the destination 35 // DB instance is a MySQL DB instance and the job_direction value is up. 36 // In the DR scenario, this parameter is mandatory and set to true if the current cloud is a standby cloud. 37 // If this parameter is not specified, the default value is true. 38 IsTargetReadonly *bool `json:"is_target_readonly,omitempty"` 39 // l The migration direction. The value can be up (to the cloud and current cloud as standby in disaster recovery), 40 // down (out of cloud and current cloud as active in disaster recovery), or non-dbs (for self-built databases). 41 // Values: − up − down − non-dbs 42 JobDirection string `json:"job_direction" required:"true"` 43 // This parameter is mandatory when db_use_type is set to cloudDataGuard. 44 // If the DR type is dual-active, the value of multi_write is true. Otherwise, the value is false. 45 // If db_use_type is set to other values, multi_write is optional. 46 // Default value: false 47 MultiWrite *bool `json:"multi_write,omitempty"` 48 // Network type. 49 // Value: vpn vpc eip 50 // The VPC network cannot be selected in the DR scenario. 51 NetType string `json:"net_type" required:"true"` 52 // The number of nodes. For a MongoDB database, this parameter indicates the number of source shards. 53 // This parameter is mandatory when the source database is a cluster. 54 // The value ranges from 1 to 32. The default value is 2 for MySQL dual-active DR. 55 NodeNum int `json:"node_num,omitempty"` 56 // The flavor type. Value: high 57 NodeType string `json:"node_type" required:"true"` 58 // The source database information. 59 SourceEndpoint Endpoint `json:"source_endpoint" required:"true"` 60 // The destination database information. 61 TargetEndpoint Endpoint `json:"target_endpoint" required:"true"` 62 // Tag information. Up to 20 tags can be added. 63 Tags []tags.ResourceTag `json:"tags,omitempty"` 64 // The migration type. FULL_TRANS indicates full migration. 65 // FULL_INCR_TRANS: indicates full+incremental migration. 66 // INCR_TRANS: indicates incremental migration. 67 // In single-active DR scenarios, only full plus incremental migration (FULL_INCR_TRANS) is supported. 68 // Default value: FULL_INCR_TRANS 69 // Values: FULL_TRANS FULL_INCR_TRANS INCR_TRANS 70 TaskType string `json:"task_type" required:"true"` 71 // ID of the subnet associated with the DRS instance. 72 CustomizeSubnetId string `json:"customize_sutnet_id" required:"true"` 73 // After a task is in the abnormal status for a period of time, the task is automatically stopped. 74 // The unit is day. The value ranges from 14 to 100. If this parameter is not transferred, the default value is 14. 75 ExpiredDays string `json:"expired_days,omitempty"` 76 // AzCode of the active node. This parameter is mandatory for cross-AZ node tasks. 77 MasterAz string `json:"master_az,omitempty"` 78 // AzCode of the standby node. This parameter is mandatory for cross-AZ node tasks. 79 SlaveAz string `json:"slave_az,omitempty"` 80 } 81 82 type Endpoint struct { 83 // Database type. 84 // Values: mysql mongodb taurus postgresql 85 DbType string `json:"db_type,omitempty"` 86 // azCode of the AZ where the database is located. 87 AzCode string `json:"az_code,omitempty"` 88 // Region where the RDS or GaussDB(for MySQL) instance is located. 89 // This parameter is mandatory when an RDS or GaussDB(for MySQL) instance is used. 90 // In DR scenarios, this parameter is mandatory in source_endpoint when job_direction is down 91 // and is mandatory in target_endpoint when job_direction is up. 92 Region string `json:"region,omitempty"` 93 // RDS or GaussDB(for MySQL) instance ID. 94 // This parameter is mandatory when an RDS or GaussDB(for MySQL) instance is used. 95 // In DR scenarios, this parameter is mandatory in source_endpoint 96 // when job_direction is down and is mandatory in target_endpoint when job_direction is up. 97 InstId string `json:"inst_id,omitempty"` 98 // ID of the VPC where the database is located. 99 VpcId string `json:"vpc_id,omitempty"` 100 // ID of the subnet where the database is located. 101 SubnetId string `json:"subnet_id,omitempty"` 102 // ID of the security group to which the database belongs. 103 SecurityGroupId string `json:"security_group_id,omitempty"` 104 // The project ID of an RDS or GaussDB(for MySQL) instance. 105 ProjectId string `json:"project_id,omitempty"` 106 // Database password. 107 DbPassword string `json:"db_password,omitempty"` 108 // Database port. The value is an integer ranging from 1 to 65535. 109 DbPort int `json:"db_port,omitempty"` 110 // Database user. 111 DbUser string `json:"db_user,omitempty"` 112 // The name of an RDS or GaussDB(for MySQL) instance. 113 InstName string `json:"inst_name,omitempty"` 114 // Database IP address. 115 Ip string `json:"ip,omitempty"` 116 // Mongo HA mode. 117 MongoHaMode string `json:"mongo_ha_mode,omitempty"` 118 // SSL certificate password. The certificate file name extension is .p12. 119 SslCertPassword string `json:"ssl_cert_password,omitempty"` 120 // The checksum value of the SSL certificate, which is used for backend verification. 121 // This parameter is mandatory for secure connection to the source database. 122 SslCertCheckSum string `json:"ssl_cert_check_sum,omitempty"` 123 // SSL certificate content, which is encrypted using Base64. 124 SslCertKey string `json:"ssl_cert_key,omitempty"` 125 // SSL certificate name. 126 SslCertName string `json:"ssl_cert_name,omitempty"` 127 // Whether SSL is enabled. 128 SslLink bool `json:"ssl_link,omitempty"` 129 // For MongoDB 4.0 or later, if the cluster instance cannot obtain the IP address of the sharded node, 130 // set source_endpoint to Sharding4.0+. Default value: Sharding4.0+ 131 // Values: Sharding4.0+ 132 ClusterMode string `json:"cluster_mode,omitempty"` 133 } 134 135 func BatchCreateTasks(client *golangsdk.ServiceClient, opts BatchCreateTaskOpts) (*BatchCreateTasksResponse, error) { 136 b, err := build.RequestBody(opts, "") 137 if err != nil { 138 return nil, err 139 } 140 141 // POST /v3/{project_id}/jobs/batch-creation 142 raw, err := client.Post(client.ServiceURL("jobs", "batch-creation"), b, nil, nil) 143 if err != nil { 144 return nil, err 145 } 146 147 var res BatchCreateTasksResponse 148 err = extract.Into(raw.Body, &res) 149 return &res, err 150 } 151 152 type BatchCreateTasksResponse struct { 153 Results []CreateTaskResp `json:"results,omitempty"` 154 Count int `json:"count,omitempty"` 155 } 156 157 type CreateTaskResp struct { 158 // Task ID. 159 Id string `json:"id"` 160 // Task name. 161 Name string `json:"name,omitempty"` 162 // Task status. 163 Status string `json:"status,omitempty"` 164 // Creation time (timestamp). 165 CreateTime string `json:"create_time,omitempty"` 166 // Error code, which is optional and indicates the returned information about the failure status. 167 ErrorCode string `json:"error_code,omitempty"` 168 // Error message, which is optional and indicates the returned information about the failure status. 169 ErrorMsg string `json:"error_msg,omitempty"` 170 // Subtask ID set. 171 ChildIds []string `json:"child_ids,omitempty"` 172 }