github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/drs/v3/public/BatchSetSpeed.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 ) 8 9 type BatchLimitSpeedOpts struct { 10 SpeedLimits []LimitSpeedReq `json:"speed_limits"` 11 } 12 13 type LimitSpeedReq struct { 14 // Task ID. 15 JobId string `json:"job_id"` 16 // Request body of flow control information. 17 SpeedLimit []SpeedLimitInfo `json:"speed_limit"` 18 } 19 20 type SpeedLimitInfo struct { 21 // Start time (UTC) of flow control. The start time is an integer in hh:mm format and the minutes part is ignored. 22 // hh indicates the hour, for example, 01:00. 23 Begin string `json:"begin" required:"true"` 24 // End time (UTC) in the format of hh:mm, for example, 15:59. The value must end with 59. 25 End string `json:"end" required:"true"` 26 // Speed. The value ranges from 1 to 9,999, in MB/s. 27 Speed string `json:"speed" required:"true"` 28 // Whether the UTC time is used. 29 IsUtc *bool `json:"is_utc,omitempty"` 30 } 31 32 func BatchSetSpeed(client *golangsdk.ServiceClient, opts BatchLimitSpeedOpts) (*BatchJobsResponse, error) { 33 b, err := build.RequestBody(opts, "") 34 if err != nil { 35 return nil, err 36 } 37 38 // PUT /v3/{project_id}/jobs/batch-limit-speed 39 raw, err := client.Put(client.ServiceURL("jobs", "batch-limit-speed"), b, nil, &golangsdk.RequestOpts{ 40 OkCodes: []int{200}}) 41 if err != nil { 42 return nil, err 43 } 44 45 var res BatchJobsResponse 46 err = extract.Into(raw.Body, &res) 47 return &res, err 48 } 49 50 type BatchUpdateDatabaseObjectOpts struct { 51 Jobs []UpdateDatabaseObjectReq `json:"jobs"` 52 } 53 54 type UpdateDatabaseObjectReq struct { 55 // Task ID. 56 JobId string `json:"job_id"` 57 // Whether to select an object. If this parameter is not set, the default value is No. 58 // Yes: Customize the objects to be migrated. 59 // No: Migrate all VMs. 60 Selected bool `json:"selected,omitempty"` 61 // Whether to perform database-level synchronization. 62 SyncDatabase bool `json:"sync_database,omitempty"` 63 // Data object selection information. This parameter is mandatory when selected is set to true. 64 Job []DatabaseInfo `json:"job,omitempty"` 65 } 66 67 type DatabaseInfo struct { 68 // When object_type is set to database, this parameter indicates the database name. 69 // If object_type is set to table or view, set the field value by referring to the example. 70 Id string `json:"id,omitempty"` 71 // Database name. This parameter is mandatory when object_type is set to table or view. 72 ParentId string `json:"parent_id,omitempty"` 73 // Type. Values: 74 // ⦁ database 75 // ⦁ table 76 // ⦁ schema 77 // ⦁ view 78 ObjectType string `json:"object_type,omitempty"` 79 // Database object name, database name, table name, and view name. 80 ObjectName string `json:"object_name,omitempty"` 81 // Alias, which is the new mapped name. 82 ObjectAliasName string `json:"object_alias_name,omitempty"` 83 // Whether to migrate the database objects. true indicates that the database objects will be migrated. 84 // false indicates that the database objects will not be migrated. 85 // partial indicates some tables in the database will be migrated. 86 // If this parameter is not specified, the default value is false. 87 Select string `json:"select,omitempty"` 88 } 89 90 type BatchJobsResponse struct { 91 Results []IdJobResp `json:"results,omitempty"` 92 Count int `json:"count,omitempty"` 93 }