github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/autoscaling/v1/policyexecutelogs/requests.go (about)

     1  package policyexecutelogs
     2  
     3  import (
     4  	"github.com/chnsz/golangsdk"
     5  	"github.com/chnsz/golangsdk/pagination"
     6  )
     7  
     8  // ListOpts is the structure that used to query the execution logs of scaling policy.
     9  type ListOpts struct {
    10  	// The scaling policy ID.
    11  	PolicyID string `json:"scaling_policy_id" required:"true"`
    12  	// The policy execution log ID.
    13  	LogID string `q:"log_id"`
    14  	// The scaling resource type. The value can be SCALING_GROUP or BANDWIDTH.
    15  	ResourceType string `q:"scaling_resource_type"`
    16  	// The scaling resource ID.
    17  	ResourceID string `q:"scaling_resource_id"`
    18  	// The policy execution type. The value can be SCHEDULED, RECURRENCE, ALARM or MANUAL.
    19  	ExecuteType string `q:"execute_type"`
    20  	// The starting time of query.
    21  	StartTime string `q:"start_time"`
    22  	// The ending time of query.
    23  	EndTime string `q:"end_time"`
    24  	// Start number value. The value must be a positive integer.
    25  	StartNumber int `q:"start_number"`
    26  	// Number of records displayed per page.
    27  	// The value must be a positive integer.
    28  	Limit int `q:"limit"`
    29  }
    30  
    31  // List is a method used to query the execution logs of scaling policy with given parameters.
    32  func List(client *golangsdk.ServiceClient, opts ListOpts) ([]ExecuteLog, error) {
    33  	url := listURL(client, opts.PolicyID)
    34  	query, err := golangsdk.BuildQueryString(opts)
    35  	if err != nil {
    36  		return nil, err
    37  	}
    38  	url += query.String()
    39  
    40  	pages, err := pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
    41  		p := ExecuteLogPage{pagination.OffsetPageBase{PageResult: r}}
    42  		return p
    43  	}).AllPages()
    44  
    45  	if err != nil {
    46  		return nil, err
    47  	}
    48  	return extractExecuteLogs(pages)
    49  }