github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/gaussdb/v3/backup/CreateBackup.go (about) 1 package backup 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 CreateBackupOpts struct { 10 // Instance ID, which is compliant with the UUID format. 11 InstanceId string `json:"instance_id"` 12 // Backup name 13 // The name consists of 4 to 64 characters and starts with a letter. 14 // It is case-sensitive and can contain only letters, digits, hyphens (-), and underscores (_). 15 Name string `json:"name"` 16 // Backup description. It contains up to 256 characters and cannot contain the following special characters: >!<"&'= 17 Description string `json:"description,omitempty"` 18 } 19 20 func CreateBackup(client *golangsdk.ServiceClient, opts CreateBackupOpts) (*CreateBackupResponse, error) { 21 b, err := build.RequestBody(opts, "") 22 if err != nil { 23 return nil, err 24 } 25 26 // POST https://{Endpoint}/mysql/v3/{project_id}/backups/create 27 raw, err := client.Post(client.ServiceURL("backups", "create"), b, nil, nil) 28 if err != nil { 29 return nil, err 30 } 31 32 var res CreateBackupResponse 33 err = extract.Into(raw.Body, &res) 34 return &res, err 35 } 36 37 type CreateBackupResponse struct { 38 Backup Backup `json:"backup"` 39 JobId string `json:"job_id"` 40 } 41 42 type Backup struct { 43 // Backup ID 44 Id string `json:"id"` 45 // Backup name 46 Name string `json:"name"` 47 // Backup description 48 Description string `json:"description"` 49 // Backup start time in the "yyyy-mm-ddThh:mm:ssZ" format, 50 // where "T" indicates the start time of the time field, and "Z" indicates the time zone offset. 51 BeginTime string `json:"begin_time"` 52 // Backup status 53 // Valid value: 54 // BUILDING: Backup in progress 55 // COMPLETED: Backup completed 56 // FAILED: Backup failed 57 // AVAILABLE: Backup available 58 Status string `json:"status"` 59 // Backup type 60 // Valid value: 61 // manual: manual full backup 62 Type string `json:"type"` 63 // Instance ID 64 InstanceId string `json:"instance_id"` 65 }