github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/drs/v3/public/BatchModifyTask.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 BatchModifyJobOpts struct {
    11  	Jobs []ModifyJobReq `json:"jobs"`
    12  }
    13  
    14  type ModifyJobReq struct {
    15  	// Task ID.
    16  	JobId string `json:"job_id" required:"true"`
    17  	// Task description. This parameter is mandatory when you modify the task description.
    18  	// Minimum length: 0 character
    19  	// Maximum length: 256
    20  	Description string `json:"description,omitempty"`
    21  	// Task name.
    22  	Name string `json:"name,omitempty"`
    23  	// Set exception notification.
    24  	AlarmNotify *AlarmNotifyInfo `json:"alarm_notify,omitempty"`
    25  	// Task mode. FULL_TRANS: full. FULL_INCR_TRANS: full + incremental. INCR_TRANS: incremental.
    26  	// Values:
    27  	// FULL_TRANS
    28  	// INCR_TRANS
    29  	// FULL_INCR_TRANS
    30  	TaskType string `json:"task_type,omitempty"`
    31  	// Source database information. This parameter is mandatory for calling the API after the connection test.
    32  	SourceEndpoint *Endpoint `json:"source_endpoint,omitempty"`
    33  	// Destination database information. This parameter is mandatory for calling the API after the connection test.
    34  	TargetEndpoint *Endpoint `json:"target_endpoint,omitempty"`
    35  	// Node specification type. This parameter is mandatory when this API is invoked to modify a task after the connection test.
    36  	// Default value: high
    37  	// Values: high
    38  	NodeType string `json:"node_type,omitempty"`
    39  	// Engine type. This parameter is mandatory when this API is invoked to modify a task after the connection test.
    40  	// mysql: used for migration and synchronization of MySQL databases
    41  	// mongodb: used for migration.
    42  	// cloudDataGuard-mysql: used for disaster recovery
    43  	// mysql-to-taurus: used for synchronization from MySQL to GaussDB(for MySQL) primary/standby.
    44  	// postgresql: used for PostgreSQL synchronization.
    45  	// Values:
    46  	// mysql
    47  	// mongodb
    48  	// cloudDataGuard-mysql
    49  	// mysql-to-taurus
    50  	// postgresql
    51  	EngineType string `json:"engine_type,omitempty"`
    52  	// Network type. This parameter is mandatory after the connection test. Values:
    53  	// vpn
    54  	// vpc
    55  	// eip
    56  	NetType string `json:"net_type,omitempty"`
    57  	// Whether to save the database information. This parameter is mandatory when the API is called after the connection test.
    58  	StoreDbInfo *bool `json:"store_db_info,omitempty"`
    59  	// Whether the task is a rebuilding task.。
    60  	IsRecreate *bool `json:"is_recreate,omitempty"`
    61  	// The migration direction. The value can be up (to the cloud and current cloud as standby in disaster recovery),
    62  	// down (out of cloud and current cloud as active in disaster recovery), or non-dbs (for self-built databases).
    63  	// Values:
    64  	// up
    65  	// down
    66  	// non-dbs
    67  	JobDirection string `json:"job_direction,omitempty"`
    68  	// Whether the destination DB instance can be read-only.
    69  	IsTargetReadonly *bool `json:"is_target_readonly,omitempty"`
    70  	// Whether to migrate all Definers to the user. MySQL databases support this setting.
    71  	// This parameter is mandatory when this API is invoked to modify a task after the connection test. Values:
    72  	// true: The Definers of all source database objects will be migrated to the user.
    73  	// Other users do not have permissions on database objects unless they are authorized.
    74  	// false: The Definers of all source database objects will not be changed.
    75  	// You need to migrate all accounts and permissions of the source database in the next step.
    76  	ReplaceDefiner *bool `json:"replace_definer,omitempty"`
    77  	// Specifies the tag information.
    78  	Tags []tags.ResourceTag `json:"tags,omitempty"`
    79  	// Migration type. The options are migration (real-time migration),
    80  	// sync (real-time synchronization), and cloudDataGuard (real-time DR).
    81  	// Values:
    82  	// migration
    83  	// sync
    84  	// cloudDataGuard
    85  	DbUseType string `json:"db_use_type,omitempty"`
    86  }
    87  
    88  type AlarmNotifyInfo struct {
    89  	// Subscription delay, in seconds.
    90  	// Minimum value: 1
    91  	// Maximum value: 3600
    92  	// Default value: 0
    93  	DelayTime int `json:"delay_time,omitempty"`
    94  	// RTO delay.
    95  	// Minimum value: 1
    96  	// Maximum value: 3600
    97  	// Default value: 0
    98  	RtoDelay int `json:"rto_delay,omitempty"`
    99  	// RPO delay.
   100  	// Minimum value: 1
   101  	// Maximum value: 3600
   102  	// Default value: 0
   103  	RpoDelay int `json:"rpo_delay,omitempty"`
   104  	// Whether to notify users of alarms. The default value is false.
   105  	AlarmToUser *bool `json:"alarm_to_user,omitempty"`
   106  	// Receiving method and message body. Up to two receiving modes and message bodies are supported.
   107  	Subscriptions []SubscriptionInfo `json:"subscriptions,omitempty"`
   108  }
   109  
   110  type SubscriptionInfo struct {
   111  	// List of mobile numbers or email addresses.
   112  	// Use commas (,) to separate multiple mobile numbers or email addresses.
   113  	// Up to 10 mobile numbers or email addresses are supported.
   114  	Endpoints []string `json:"endpoints,omitempty"`
   115  	// Receiving method. Values:
   116  	// sms: SMS message
   117  	// email: email.
   118  	Protocol string `json:"protocol,omitempty"`
   119  }
   120  
   121  func BatchUpdateTask(client *golangsdk.ServiceClient, opts BatchModifyJobOpts) (*BatchTasksResponse, error) {
   122  	b, err := build.RequestBody(opts, "")
   123  	if err != nil {
   124  		return nil, err
   125  	}
   126  
   127  	// PUT /v3/{project_id}/jobs/batch-modification
   128  	raw, err := client.Put(client.ServiceURL("jobs", "batch-modification"), b, nil, &golangsdk.RequestOpts{
   129  		OkCodes: []int{200}})
   130  	if err != nil {
   131  		return nil, err
   132  	}
   133  
   134  	var res BatchTasksResponse
   135  	err = extract.Into(raw.Body, &res)
   136  	return &res, err
   137  }