github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/autoscaling/v1/policies/list.go (about) 1 package policies 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 ID. 10 ScalingGroupId string 11 // Specifies the AS policy name. 12 // Supports fuzzy search. 13 ScalingPolicyName string `q:"scaling_policy_name,omitempty"` 14 // Specifies the AS policy type. 15 // ALARM: alarm policy 16 // SCHEDULED: scheduled policy 17 // RECURRENCE: periodic policy 18 ScalingPolicyType string `q:"scaling_policy_type,omitempty"` 19 // Specifies the AS policy ID. 20 ScalingPolicyId string `q:"scaling_policy_id,omitempty"` 21 // Specifies the start line number. The default value is 0. The minimum parameter value is 0. 22 StartNumber int32 `q:"start_number,omitempty"` 23 // Specifies the number of query records. The default value is 20. The value range is 0 to 100. 24 Limit int32 `q:"limit,omitempty"` 25 } 26 27 func List(client *golangsdk.ServiceClient, opts ListOpts) (*ListScalingInstancesResponse, error) { 28 url, err := golangsdk.NewURLBuilder().WithEndpoints("scaling_policy", opts.ScalingGroupId, "list").WithQueryParams(&opts).Build() 29 if err != nil { 30 return nil, err 31 } 32 33 // GET /autoscaling-api/v1/{project_id}/scaling_policy/{scaling_group_id}/list 34 raw, err := client.Get(client.ServiceURL(url.String()), nil, nil) 35 if err != nil { 36 return nil, err 37 } 38 39 var res ListScalingInstancesResponse 40 err = extract.Into(raw.Body, &res) 41 return &res, err 42 } 43 44 type ListScalingInstancesResponse struct { 45 TotalNumber int32 `json:"total_number,omitempty"` 46 StartNumber int32 `json:"start_number,omitempty"` 47 Limit int32 `json:"limit,omitempty"` 48 ScalingPolicies []ScalingV1PolicyDetail `json:"scaling_policies,omitempty"` 49 } 50 51 type ScalingV1PolicyDetail struct { 52 // Specifies the AS group ID. 53 ScalingGroupId string `json:"scaling_group_id,omitempty"` 54 // Specifies the AS policy name. 55 ScalingPolicyName string `json:"scaling_policy_name,omitempty"` 56 // Specifies the AS policy ID. 57 ScalingPolicyId string `json:"scaling_policy_id,omitempty"` 58 // Specifies the AS policy status. 59 // INSERVICE: The AS policy is enabled. 60 // PAUSED: The AS policy is disabled. 61 // EXECUTING: The AS policy is being executed. 62 PolicyStatus string `json:"policy_status,omitempty"` 63 // Specifies the AS policy type. 64 // ALARM: indicates that the scaling action is triggered by an alarm. 65 // A value is returned for alarm_id, and no value is returned for scheduled_policy. 66 // SCHEDULED: indicates that the scaling action is triggered as scheduled. A value is returned for scheduled_policy, 67 // and no value is returned for alarm_id, recurrence_type, recurrence_value, start_time, or end_time. 68 // RECURRENCE: indicates that the scaling action is triggered periodically. Values are returned for scheduled_policy, 69 // recurrence_type, recurrence_value, start_time, and end_time, and no value is returned for alarm_id. 70 ScalingPolicyType string `json:"scaling_policy_type,omitempty"` 71 // Specifies the alarm ID. 72 AlarmId string `json:"alarm_id,omitempty"` 73 // Specifies the periodic or scheduled AS policy. 74 ScheduledPolicy ScheduledPolicy `json:"scheduled_policy,omitempty"` 75 // Specifies the scaling action of the AS policy. 76 ScalingPolicyAction ScalingPolicyActionV1 `json:"scaling_policy_action,omitempty"` 77 // Specifies the cooldown period (s). 78 CoolDownTime int32 `json:"cool_down_time,omitempty"` 79 // Specifies the time when an AS policy was created. The time format complies with UTC. 80 CreateTime string `json:"create_time,omitempty"` 81 } 82 83 type ScheduledPolicy struct { 84 // Specifies the time when the scaling action is triggered. The time format complies with UTC. 85 // If scaling_policy_type is set to SCHEDULED, the time format is YYYY-MM-DDThh:mmZ. 86 // If scaling_policy_type is set to RECURRENCE, the time format is hh:mm. 87 LaunchTime string `json:"launch_time"` 88 // Specifies the type of periodically triggered scaling action. 89 // Daily: indicates that the scaling action is triggered once a day. 90 // Weekly: indicates that the scaling action is triggered once a week. 91 // Monthly: indicates that the scaling action is triggered once a month. 92 RecurrenceType string `json:"recurrence_type,omitempty"` 93 // Specifies the frequency at which scaling actions are triggered. 94 // If recurrence_type is set to Daily, the value is null, indicating that the scaling action is triggered once a day. 95 // If recurrence_type is set to Weekly, the value ranges from 1 (Sunday) to 7 (Saturday). 96 // The digits refer to dates in each week and separated by a comma, such as 1,3,5. 97 // If recurrence_type is set to Monthly, the value ranges from 1 to 31. 98 // The digits refer to the dates in each month and separated by a comma, such as 1,10,13,28. 99 RecurrenceValue string `json:"recurrence_value,omitempty"` 100 // Specifies the start time of the scaling action triggered periodically. The time format complies with UTC. 101 // The time format is YYYY-MM-DDThh:mmZ. 102 StartTime string `json:"start_time,omitempty"` 103 // Specifies the end time of the scaling action triggered periodically. The time format complies with UTC. 104 // The time format is YYYY-MM-DDThh:mmZ. 105 EndTime string `json:"end_time,omitempty"` 106 } 107 108 type ScalingPolicyActionV1 struct { 109 // Specifies the scaling action. 110 // ADD: adds specified number of instances to the AS group. 111 // REMOVE: removes specified number of instances from the AS group. 112 // SET: sets the number of instances in the AS group. 113 Operation string `json:"operation,omitempty"` 114 // Specifies the number of instances to be operated. 115 InstanceNumber int32 `json:"instance_number,omitempty"` 116 // Specifies the percentage of instances to be operated. 117 InstancePercentage int32 `json:"instance_percentage,omitempty"` 118 }