github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/autoscaling/v2/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 policy ID. 21 PolicyID string `json:"scaling_policy_id"` 22 // Specifies the AS policy name. 23 // Supports fuzzy search. 24 PolicyName string `json:"scaling_policy_name"` 25 // Specifies the scaling resource ID. 26 ResourceID string `json:"scaling_resource_id"` 27 // Specifies the scaling resource type. 28 // AS group: SCALING_GROUP 29 // Bandwidth: BANDWIDTH 30 ScalingResourceType string `json:"scaling_resource_type"` 31 // Specifies the AS policy status. 32 // INSERVICE: The AS policy is enabled. 33 // PAUSED: The AS policy is disabled. 34 // EXECUTING: The AS policy is being executed. 35 PolicyStatus string `json:"policy_status"` 36 // Specifies the AS policy type. 37 // ALARM: indicates that the scaling action is triggered by an alarm. 38 // A value is returned for alarm_id, and no value is returned for scheduled_policy. 39 // SCHEDULED: indicates that the scaling action is triggered as scheduled. 40 // A value is returned for scheduled_policy, and no value is returned for alarm_id, recurrence_type, recurrence_value, start_time, or end_time. 41 // RECURRENCE: indicates that the scaling action is triggered periodically. 42 // Values are returned for scheduled_policy, recurrence_type, recurrence_value, start_time, and end_time, and no value is returned for alarm_id. 43 Type string `json:"scaling_policy_type"` 44 // Specifies the alarm ID. 45 AlarmID string `json:"alarm_id"` 46 // Specifies the periodic or scheduled AS policy. 47 SchedulePolicy SchedulePolicy `json:"scheduled_policy"` 48 // Specifies the scaling action of the AS policy. 49 PolicyAction Action `json:"scaling_policy_action"` 50 // Specifies the cooldown period (s). 51 CoolDownTime int `json:"cool_down_time"` 52 // Specifies the time when an AS policy was created. The time format complies with UTC. 53 CreateTime string `json:"create_time"` 54 // Provides additional information. 55 Metadata Metadata `json:"meta_data"` 56 } 57 58 type SchedulePolicy struct { 59 // Specifies the time when the scaling action is triggered. The time format complies with UTC. 60 // If scaling_policy_type is set to SCHEDULED, the time format is YYYY-MM-DDThh:mmZ. 61 // If scaling_policy_type is set to RECURRENCE, the time format is hh:mm. 62 LaunchTime string `json:"launch_time"` 63 // Specifies the type of a periodically triggered scaling action. 64 // Daily: indicates that the scaling action is triggered once a day. 65 // Weekly: indicates that the scaling action is triggered once a week. 66 // Monthly: indicates that the scaling action is triggered once a month. 67 RecurrenceType string `json:"recurrence_type"` 68 // Specifies the frequency at which scaling actions are triggered. 69 // If recurrence_type is set to Daily, the value is null, indicating that the scaling action is triggered once a day. 70 // If recurrence_type is set to Weekly, the value ranges from 1 (Sunday) to 7 (Saturday). 71 // The digits refer to dates in each week and separated by a comma, such as 1,3,5. 72 // If recurrence_type is set to Monthly, the value ranges from 1 to 31. 73 // The digits refer to the dates in each month and separated by a comma, such as 1,10,13,28. 74 RecurrenceValue string `json:"recurrence_value"` 75 // Specifies the start time of the scaling action triggered periodically. The time format complies with UTC. 76 // The time format is YYYY-MM-DDThh:mmZ. 77 StartTime string `json:"start_time"` 78 // Specifies the end time of the scaling action triggered periodically. The time format complies with UTC. 79 // The time format is YYYY-MM-DDThh:mmZ. 80 EndTime string `json:"end_time"` 81 } 82 83 type Action struct { 84 // Specifies the scaling action. 85 // ADD: indicates adding instances. 86 // REDUCE: indicates reducing instances. 87 // SET: indicates setting the number of instances to a specified value. 88 Operation string `json:"operation"` 89 // Specifies the operation size. 90 Size int `json:"size"` 91 // Specifies the percentage of instances to be operated. 92 Percentage int `json:"percentage"` 93 // Specifies the operation restrictions. 94 Limits int `json:"limits"` 95 } 96 97 type Metadata struct { 98 // Specifies the bandwidth sharing type in the bandwidth scaling policy. 99 BandwidthShareType string `json:"metadata_bandwidth_share_type"` 100 // Specifies the EIP ID for the bandwidth in the bandwidth scaling policy. 101 EipID string `json:"metadata_eip_id"` 102 // Specifies the EIP for the bandwidth in the bandwidth scaling policy. 103 EipAddress string `json:"metadata_eip_address"` 104 }