github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/autoscaling/v1/groups/list.go (about)

     1  package groups
     2  
     3  import (
     4  	"github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     6  )
     7  
     8  type ListOpts struct {
     9  	// Specifies the AS group name.
    10  	// Supports fuzzy search.
    11  	Name string `q:"scaling_group_name"`
    12  	// Specifies the AS configuration ID, which can be obtained using the API for querying AS configurations.
    13  	ConfigurationID string `q:"scaling_configuration_id"`
    14  	// Specifies the AS group status. The options are as follows:
    15  	// INSERVICE: indicates that the AS group is functional.
    16  	// PAUSED: indicates that the AS group is paused.
    17  	// ERROR: indicates that the AS group malfunctions.
    18  	// DELETING: indicates that the AS group is being deleted.
    19  	Status string `q:"scaling_group_status"`
    20  	// Specifies the start line number. The default value is 0. The minimum value is 0, and there is no limit on the maximum value.
    21  	StartNumber int `q:"start_number"`
    22  	// Specifies the number of query records. The default value is 20. The value range is 0 to 100.
    23  	Limit int `q:"limit"`
    24  	// Specifies the enterprise project ID. If all_granted_eps is transferred,
    25  	// this API will query AS groups in the enterprise projects that you have permissions to.
    26  	EnterpriseProjectID string `q:"enterprise_project_id"`
    27  }
    28  
    29  func List(client *golangsdk.ServiceClient, opts ListOpts) (*ListScalingGroupsResponse, error) {
    30  	url, err := golangsdk.NewURLBuilder().WithEndpoints("scaling_group").WithQueryParams(&opts).Build()
    31  	if err != nil {
    32  		return nil, err
    33  	}
    34  
    35  	raw, err := client.Get(client.ServiceURL(url.String()), nil, nil)
    36  	if err != nil {
    37  		return nil, err
    38  	}
    39  
    40  	var res ListScalingGroupsResponse
    41  	err = extract.Into(raw.Body, &res)
    42  	return &res, err
    43  }
    44  
    45  type ListScalingGroupsResponse struct {
    46  	TotalNumber   int32   `json:"total_number,omitempty"`
    47  	StartNumber   int32   `json:"start_number,omitempty"`
    48  	Limit         int32   `json:"limit,omitempty"`
    49  	ScalingGroups []Group `json:"scaling_groups,omitempty"`
    50  }