github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/autoscaling/v1/policies/get.go (about) 1 package policies 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 6 ) 7 8 func Get(client *golangsdk.ServiceClient, id string) (*Policy, error) { 9 raw, err := client.Get(client.ServiceURL("scaling_policy", id), nil, nil) 10 if err != nil { 11 return nil, err 12 } 13 14 var res Policy 15 err = extract.IntoStructPtr(raw.Body, &res, "scaling_policy") 16 return &res, err 17 } 18 19 type Policy struct { 20 // Specifies the AS group ID. 21 ID string `json:"scaling_group_id"` 22 // Specifies the AS policy name. 23 Name string `json:"scaling_policy_name"` 24 // Specifies the AS policy status. 25 // INSERVICE: The AS policy is enabled. 26 // PAUSED: The AS policy is disabled. 27 // EXECUTING: The AS policy is being executed. 28 Status string `json:"policy_status"` 29 // Specifies the AS policy type. 30 // ALARM: indicates that the scaling action is triggered by an alarm. A value is returned for alarm_id, and no value is returned for scheduled_policy. 31 // SCHEDULED: indicates that the scaling action is triggered as scheduled. 32 // A value is returned for scheduled_policy, and no value is returned for alarm_id, recurrence_type, recurrence_value, start_time, or end_time. 33 // RECURRENCE: indicates that the scaling action is triggered periodically. 34 // Values are returned for scheduled_policy, recurrence_type, recurrence_value, start_time, and end_time, and no value is returned for alarm_id. 35 Type string `json:"scaling_policy_type"` 36 // Specifies the alarm ID. 37 AlarmID string `json:"alarm_id"` 38 // Specifies the periodic or scheduled AS policy. 39 SchedulePolicy SchedulePolicy `json:"scheduled_policy"` 40 // Specifies the scaling action of the AS policy. 41 Action Action `json:"scaling_policy_action"` 42 // Specifies the cooldown period (s). 43 CoolDownTime int `json:"cool_down_time"` 44 // Specifies the time when an AS policy was created. The time format complies with UTC. 45 CreateTime string `json:"create_time"` 46 } 47 48 type SchedulePolicy struct { 49 // Specifies the time when the scaling action is triggered. The time format complies with UTC. 50 // If scaling_policy_type is set to SCHEDULED, the time format is YYYY-MM-DDThh:mmZ. 51 // If scaling_policy_type is set to RECURRENCE, the time format is hh:mm. 52 LaunchTime string `json:"launch_time"` 53 // Specifies the type of periodically triggered scaling action. 54 // Daily: indicates that the scaling action is triggered once a day. 55 // Weekly: indicates that the scaling action is triggered once a week. 56 // Monthly: indicates that the scaling action is triggered once a month. 57 RecurrenceType string `json:"recurrence_type"` 58 // Specifies the frequency at which scaling actions are triggered. 59 // If recurrence_type is set to Daily, the value is null, indicating that the scaling action is triggered once a day. 60 // If recurrence_type is set to Weekly, the value ranges from 1 (Sunday) to 7 (Saturday). 61 // The digits refer to dates in each week and separated by a comma, such as 1,3,5. 62 // If recurrence_type is set to Monthly, the value ranges from 1 to 31. 63 // The digits refer to the dates in each month and separated by a comma, such as 1,10,13,28. 64 RecurrenceValue string `json:"recurrence_value"` 65 // Specifies the start time of the scaling action triggered periodically. 66 // The time format complies with UTC. 67 // The time format is YYYY-MM-DDThh:mmZ. 68 StartTime string `json:"start_time"` 69 // Specifies the end time of the scaling action triggered periodically. 70 // The time format complies with UTC. 71 // The time format is YYYY-MM-DDThh:mmZ. 72 EndTime string `json:"end_time"` 73 } 74 75 type Action struct { 76 // Specifies the operation to be performed. The default operation is ADD. 77 // ADD: adds specified number of instances to the AS group. 78 // REMOVE/REDUCE: removes or reduces specified number of instances from the AS group. 79 // SET: sets the number of instances in the AS group. 80 Operation string `json:"operation,omitempty"` 81 // Specifies the number of instances to be operated. The default number is 1. 82 // The value range is as follows for a default quota: 83 // If operation is set to SET, the value range is 0 to 200. 84 // If operation is set to ADD, REMOVE, or REDUCE, the value range is 1 to 200. 85 // NOTE: 86 // Either instance_number or instance_percentage is required. 87 InstanceNum int `json:"instance_number,omitempty"` 88 // Specifies the percentage of instances to be operated. You can increase, decrease, 89 // or set the number of instances in an AS group to the specified percentage of the current number of instances. 90 // If operation is set to ADD, REMOVE or REDUCE, the value of this parameter is an integer from 1 to 20000. 91 // If operation is set to SET, the value is an integer from 0 to 20000. 92 // If neither instance_number nor instance_percentage is specified, the number of instances to be operated is 1. 93 // Either instance_number or instance_percentage is required. 94 InstancePercentage int `json:"instance_percentage,omitempty"` 95 }