github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/gaussdb/v3/backup/ListBackups.go (about) 1 package backup 2 3 import ( 4 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 6 ) 7 8 type BackupListOpts struct { 9 // Instance ID 10 InstanceId string `q:"instance_id"` 11 // Backup ID 12 BackupId string `q:"backup_id"` 13 // Backup type 14 // auto: automated full backup 15 // manual: manual full backup 16 BackupType string `q:"backup_type"` 17 // Index offset. If offset is set to N, the resource query starts from the N+1 piece of data. 18 // The default value is 0, indicating that the query starts from the first piece of data. The value must be a positive integer. 19 Offset string `q:"offset"` 20 // Number of records to be queried. The default value is 100. 21 // The value must be a positive integer. The minimum value is 1 and the maximum value is 100. 22 Limit string `q:"limit"` 23 // Query start time. The format is "yyyy-mm-ddThh:mm:ssZ". 24 BeginTime string `q:"begin_time"` 25 // Query end time. The format is "yyyy-mm-ddThh:mm:ssZ" and the end time must be later than the start time. 26 EndTime string `q:"end_time"` 27 } 28 29 func ListBackups(client *golangsdk.ServiceClient, opts BackupListOpts) (*BackupListResponse, error) { 30 url, err := golangsdk.NewURLBuilder().WithEndpoints("backups").WithQueryParams(&opts).Build() 31 if err != nil { 32 return nil, err 33 } 34 35 // GET https://{Endpoint}/mysql/v3/{project_id}/backups 36 raw, err := client.Get(client.ServiceURL(url.String()), nil, nil) 37 if err != nil { 38 return nil, err 39 } 40 41 var res BackupListResponse 42 err = extract.Into(raw.Body, &res) 43 return &res, err 44 } 45 46 type BackupListResponse struct { 47 // Backup information 48 Backups []Backups `json:"backups"` 49 // Total number of backup files 50 TotalCount int `json:"total_count"` 51 } 52 53 type Backups struct { 54 // Backup ID 55 Id string `json:"id"` 56 // Backup name 57 Name string `json:"name"` 58 // Backup start time in the "yyyy-mm-ddThh:mm:ssZ" format. 59 BeginTime string `json:"begin_time"` 60 // Backup end time in the "yyyy-mm-ddThh:mm:ssZ" format. 61 EndTime string `json:"end_time"` 62 // Backup status. Value: 63 // BUILDING: Backup in progress 64 // COMPLETED: Backup completed 65 // FAILED: Backup failed 66 // AVAILABLE: Backup available 67 Status string `json:"status"` 68 // Backup duration in minutes 69 TakeUpTime int32 `json:"take_up_time"` 70 // Backup type 71 // auto: automated full backup 72 // manual: manual full backup 73 Type string `json:"type"` 74 // Backup size in MB. 75 Size int64 `json:"size"` 76 // Database information 77 Datastore MysqlDatastore `json:"datastore"` 78 // Instance ID 79 InstanceId string `json:"instance_id"` 80 // Backup level. This parameter is returned when the level-1 backup function is enabled. Value: 81 // 1: level-1 backup 82 // 2: level-2 backup 83 // 0: Backup being created or creation failed 84 BackupLevel string `json:"backup_level"` 85 // Description of the backup file 86 Description string `json:"description"` 87 } 88 89 type MysqlDatastore struct { 90 // DB engine. Currently, only gaussdb-mysql is supported. 91 Type string `json:"type"` 92 // DB engine version 93 Version string `json:"version"` 94 }