github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/cloudeyeservice/v2/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 ResourcesInfo struct { 23 ResourceGroupID string `json:"resource_group_id"` 24 ResourceGroupName string `json:"resource_group_name"` 25 Dimensions []DimensionOpts `json:"dimensions"` 26 } 27 28 type AlarmRule struct { 29 AlarmID string `json:"alarm_id"` 30 Name string `json:"name"` 31 Description string `json:"description"` 32 Namespace string `json:"namespace"` 33 Resources []ResourcesInfo `json:"resources"` 34 Policies []PolicyOpts `json:"policies"` 35 Type string `json:"type"` 36 AlarmNotifications []NotificationOpts `json:"alarm_notifications"` 37 OkNotifications []NotificationOpts `json:"ok_notifications"` 38 NotificationBeginTime string `json:"notification_begin_time"` 39 NotificationEndTime string `json:"notification_end_time"` 40 EnterpriseProjectID string `json:"enterprise_project_id"` 41 Enabled bool `json:"enabled"` 42 NotificationEnabled bool `json:"notification_enabled"` 43 AlarmTemplateID string `json:"alarm_template_id"` 44 } 45 46 type GetResult struct { 47 golangsdk.Result 48 } 49 50 func (g GetResult) Extract() (*AlarmRule, error) { 51 var r struct { 52 Alarms []AlarmRule `json:"alarms"` 53 } 54 err := g.ExtractInto(&r) 55 if err != nil { 56 return nil, err 57 } 58 if len(r.Alarms) != 1 { 59 return nil, fmt.Errorf("get %d alarm rules", len(r.Alarms)) 60 } 61 return &(r.Alarms[0]), nil 62 } 63 64 type GetResourcesResult struct { 65 golangsdk.Result 66 } 67 68 func (g GetResourcesResult) Extract() (*[][]DimensionOpts, error) { 69 var r struct { 70 Resources [][]DimensionOpts `json:"resources"` 71 } 72 err := g.ExtractInto(&r) 73 if err != nil { 74 return nil, err 75 } 76 if len(r.Resources) < 1 { 77 return nil, fmt.Errorf("get %d alarm resources", len(r.Resources)) 78 } 79 return &(r.Resources), nil 80 } 81 82 type UpdateResult struct { 83 golangsdk.ErrResult 84 } 85 86 type ActionResult struct { 87 golangsdk.ErrResult 88 } 89 90 type BatchResourcesResult struct { 91 golangsdk.ErrResult 92 } 93 94 type PoliciesResult struct { 95 golangsdk.ErrResult 96 } 97 98 type DeleteResult struct { 99 golangsdk.ErrResult 100 }