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

     1  package backups
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/openstack"
     7  )
     8  
     9  type ListRestoreTimesOpts struct {
    10  	// Specifies the DB instance ID.
    11  	InstanceId string `json:"-"`
    12  	// Specifies the date to be queried. The value is in the yyyy-mm-dd format, and the time zone is UTC.
    13  	Date string `json:"date,omitempty"`
    14  }
    15  
    16  func ListRestoreTimes(client *golangsdk.ServiceClient, opts ListRestoreTimesOpts) ([]RestoreTime, error) {
    17  	url, err := golangsdk.NewURLBuilder().WithEndpoints("instances", opts.InstanceId, "restore-time").WithQueryParams(&opts).Build()
    18  	if err != nil {
    19  		return nil, err
    20  	}
    21  
    22  	// GET https://{Endpoint}/v3/{project_id}/instances/{instance_id}/restore-time
    23  	raw, err := client.Get(client.ServiceURL(url.String()), nil, openstack.StdRequestOpts())
    24  	if err != nil {
    25  		return nil, err
    26  	}
    27  
    28  	var res []RestoreTime
    29  	err = extract.IntoSlicePtr(raw.Body, &res, "restore_time")
    30  	return res, err
    31  }
    32  
    33  type RestoreTime struct {
    34  	// Indicates the start time of the restoration time range in the UNIX timestamp format. The unit is millisecond and the time zone is UTC.
    35  	StartTime int64 `json:"start_time"`
    36  	// Indicates the end time of the restoration time range in the UNIX timestamp format. The unit is millisecond and the time zone is UTC.
    37  	EndTime int64 `json:"end_time"`
    38  }