github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/rds/v3/backups/List.go (about)

     1  package backups
     2  
     3  import (
     4  	"github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/openstack"
     7  )
     8  
     9  type ListOpts struct {
    10  	// Specifies the DB instance ID.
    11  	InstanceID string `q:"instance_id"`
    12  	// Specifies the backup ID.
    13  	BackupID string `q:"backup_id"`
    14  	// Specifies the backup type. Value:
    15  	//
    16  	// auto: automated full backup
    17  	// manual: manual full backup
    18  	// fragment: differential full backup
    19  	// incremental: automated incremental backup
    20  	BackupType string `q:"backup_type"`
    21  	// Specifies the index position. If offset is set to N, the resource query starts from the N+1 piece of data. The value is 0 by default, indicating that the query starts from the first piece of data. The value must be a positive number.
    22  	Offset int `q:"offset"`
    23  	// Specifies the number of records to be queried. The default value is 100. The value cannot be a negative number. The minimum value is 1 and the maximum value is 100.
    24  	Limit int `q:"limit"`
    25  	// Specifies the start time for obtaining the backup list. The format of the start time is "yyyy-mm-ddThh:mm:ssZ".
    26  	// T is the separator between the calendar and the hourly notation of time. Z indicates the time zone offset.
    27  	// NOTE:
    28  	// When begin_time is not empty, end_time is mandatory.
    29  	BeginTime string `q:"begin_time"`
    30  	// Specifies the end time for obtaining the backup list. The format of the end time is "yyyy-mm-ddThh:mm:ssZ" and the end time must be later than the start time.
    31  	// T is the separator between the calendar and the hourly notation of time. Z indicates the time zone offset.
    32  	// NOTE:
    33  	// When end_time is not empty, begin_time is mandatory.
    34  	EndTime string `q:"end_time"`
    35  }
    36  
    37  func List(client *golangsdk.ServiceClient, opts ListOpts) ([]Backup, error) {
    38  	url, err := golangsdk.NewURLBuilder().WithEndpoints("backups").WithQueryParams(&opts).Build()
    39  	if err != nil {
    40  		return nil, err
    41  	}
    42  
    43  	// GET https://{Endpoint}/v3/{project_id}/backups
    44  	raw, err := client.Get(client.ServiceURL(url.String()), nil, openstack.StdRequestOpts())
    45  	if err != nil {
    46  		return nil, err
    47  	}
    48  
    49  	var res []Backup
    50  	err = extract.IntoSlicePtr(raw.Body, &res, "backups")
    51  	return res, err
    52  }