github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/cloudeyeservice/v1/alarmrule/results.go (about) 1 package alarmrule 2 3 import ( 4 "fmt" 5 6 "github.com/chnsz/golangsdk" 7 ) 8 9 type CreateResponse struct { 10 AlarmID string `json:"alarm_id"` 11 } 12 13 type CreateResult struct { 14 golangsdk.Result 15 } 16 17 func (c CreateResult) Extract() (*CreateResponse, error) { 18 r := &CreateResponse{} 19 return r, c.ExtractInto(r) 20 } 21 22 type DimensionInfo struct { 23 Name string `json:"name"` 24 Value string `json:"value"` 25 } 26 27 type MetricInfo struct { 28 Namespace string `json:"namespace"` 29 MetricName string `json:"metric_name"` 30 Dimensions []DimensionInfo `json:"dimensions"` 31 } 32 33 type ConditionInfo struct { 34 Period int `json:"period"` 35 Filter string `json:"filter"` 36 ComparisonOperator string `json:"comparison_operator"` 37 Value float64 `json:"value"` 38 Unit string `json:"unit"` 39 Count int `json:"count"` 40 SuppressDuration int `json:"suppress_duration"` 41 } 42 43 type ActionInfo struct { 44 Type string `json:"type"` 45 NotificationList []string `json:"notificationList"` 46 } 47 48 type AlarmRule struct { 49 AlarmName string `json:"alarm_name"` 50 AlarmDescription string `json:"alarm_description"` 51 AlarmType string `json:"alarm_type"` 52 AlarmLevel int `json:"alarm_level"` 53 Metric MetricInfo `json:"metric"` 54 Condition ConditionInfo `json:"condition"` 55 AlarmActions []ActionInfo `json:"alarm_actions"` 56 InsufficientdataActions []ActionInfo `json:"insufficientdata_actions"` 57 OkActions []ActionInfo `json:"ok_actions"` 58 AlarmEnabled bool `json:"alarm_enabled"` 59 AlarmActionEnabled bool `json:"alarm_action_enabled"` 60 UpdateTime int64 `json:"update_time"` 61 AlarmState string `json:"alarm_state"` 62 EnterpriseProjectID string `json:"enterprise_project_id"` 63 } 64 65 type GetResult struct { 66 golangsdk.Result 67 } 68 69 func (g GetResult) Extract() (*AlarmRule, error) { 70 var r struct { 71 MetricAlarms []AlarmRule `json:"metric_alarms"` 72 } 73 err := g.ExtractInto(&r) 74 if err != nil { 75 return nil, err 76 } 77 if len(r.MetricAlarms) != 1 { 78 return nil, fmt.Errorf("get %d alarm rules", len(r.MetricAlarms)) 79 } 80 return &(r.MetricAlarms[0]), nil 81 } 82 83 type UpdateResult struct { 84 golangsdk.ErrResult 85 } 86 87 type EnableResult struct { 88 golangsdk.ErrResult 89 } 90 91 type DeleteResult struct { 92 golangsdk.ErrResult 93 }