github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/csbs/v1/backup/CountBackups.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 CountOpts struct { 9 // Query based on field status is supported. 10 // Value range: waiting_protect, protecting, available, waiting_restore, restoring, error, waiting_delete, deleting, and deleted 11 Status string `q:"status"` 12 // Whether to query the backup of all tenants. Only administrators can query the backup of all tenants. 13 AllTenants string `q:"all_tenants"` 14 // Supports query by backup name. 15 Name string `q:"name"` 16 // AZ-based filtering is supported. 17 Az string `q:"az"` 18 // Filtering based on the backup object ID is supported. 19 ResourceId string `q:"resource_id"` 20 // Filtering based on the backup object name is supported. 21 ResourceName string `q:"resource_name"` 22 // Filtering based on the backup time is supported. This is the backup start time. For example, 2017-04-15T04:25:38 23 StartTime string `q:"start_time"` 24 // Filtering based on the backup time is supported. This is the backup end time. For example, 2017-04-15T04:25:38 25 EndTime string `q:"end_time"` 26 // Supports filtering by backup image type. This parameter can be used only when images are created using backups. 27 // The image type can be obtained from Image Management Service. 28 ImageType string `q:"image_type"` 29 // Filtering based on policy_id is supported. 30 PolicyId string `q:"policy_id"` 31 // Searching based on the VM's IP address is supported. 32 Ip string `q:"ip"` 33 // Filtering based on checkpoint_id is supported. 34 CheckpointId string `q:"checkpoint_id"` 35 // Type of the backup object. For example, OS::Nova::Server 36 ResourceType string `q:"resource_type"` 37 } 38 39 func CountBackups(client *golangsdk.ServiceClient, opts CountOpts) (*int, error) { 40 url, err := golangsdk.NewURLBuilder().WithEndpoints("checkpoint_items", "count").WithQueryParams(&opts).Build() 41 if err != nil { 42 return nil, err 43 } 44 45 // GET https://{endpoint}/v1/{project_id}/checkpoint_items/count 46 raw, err := client.Get(client.ServiceURL(url.String()), nil, nil) 47 if err != nil { 48 return nil, err 49 } 50 51 var res struct { 52 Count int `json:"count"` 53 } 54 err = extract.Into(raw.Body, &res) 55 return &res.Count, err 56 }