github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/autoscaling/v1/groups/results.go (about) 1 package groups 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 "github.com/huaweicloud/golangsdk/pagination" 6 ) 7 8 //CreateGroupResult is a struct retured by CreateGroup request 9 type CreateResult struct { 10 golangsdk.Result 11 } 12 13 //Extract the create group result as a string type. 14 func (r CreateResult) Extract() (string, error) { 15 var a struct { 16 GroupID string `json:"scaling_group_id"` 17 } 18 err := r.Result.ExtractInto(&a) 19 return a.GroupID, err 20 } 21 22 //DeleteGroupResult contains the body of the deleting group request 23 type DeleteResult struct { 24 golangsdk.ErrResult 25 } 26 27 //GetGroupResult contains the body of getting detailed group request 28 type GetResult struct { 29 golangsdk.Result 30 } 31 32 //Extract method will parse the result body into Group struct 33 func (r GetResult) Extract() (Group, error) { 34 var g Group 35 err := r.Result.ExtractIntoStructPtr(&g, "scaling_group") 36 return g, err 37 } 38 39 //Group represents the struct of one autoscaling group 40 type Group struct { 41 Name string `json:"scaling_group_name"` 42 ID string `json:"scaling_group_id"` 43 Status string `json:"scaling_group_status"` 44 ConfigurationID string `json:"scaling_configuration_id"` 45 ConfigurationName string `json:"scaling_configuration_name"` 46 ActualInstanceNumber int `json:"current_instance_number"` 47 DesireInstanceNumber int `json:"desire_instance_number"` 48 MinInstanceNumber int `json:"min_instance_number"` 49 MaxInstanceNumber int `json:"max_instance_number"` 50 CoolDownTime int `json:"cool_down_time"` 51 LBListenerID string `json:"lb_listener_id"` 52 LBaaSListeners []LBaaSListener `json:"lbaas_listeners"` 53 AvailableZones []string `json:"available_zones"` 54 Networks []Network `json:"networks"` 55 SecurityGroups []SecurityGroup `json:"security_groups"` 56 CreateTime string `json:"create_time"` 57 VpcID string `json:"vpc_id"` 58 Detail string `json:"detail"` 59 IsScaling bool `json:"is_scaling"` 60 HealthPeriodicAuditMethod string `json:"health_periodic_audit_method"` 61 HealthPeriodicAuditTime int `json:"health_periodic_audit_time"` 62 HealthPeriodicAuditGrace int `json:"health_periodic_audit_grace_period"` 63 InstanceTerminatePolicy string `json:"instance_terminate_policy"` 64 Notifications []string `json:"notifications"` 65 DeletePublicip bool `json:"delete_publicip"` 66 CloudLocationID string `json:"cloud_location_id"` 67 EnterpriseProjectID string `json:"enterprise_project_id"` 68 } 69 70 type Network struct { 71 ID string `json:"id"` 72 } 73 74 type SecurityGroup struct { 75 ID string `json:"id"` 76 } 77 78 type LBaaSListener struct { 79 ListenerID string `json:"listener_id"` 80 PoolID string `json:"pool_id"` 81 ProtocolPort int `json:"protocol_port"` 82 Weight int `json:"weight"` 83 } 84 85 type GroupPage struct { 86 pagination.SinglePageBase 87 } 88 89 // IsEmpty returns true if a ListResult contains no Volumes. 90 func (r GroupPage) IsEmpty() (bool, error) { 91 groups, err := r.Extract() 92 return len(groups) == 0, err 93 } 94 95 func (r GroupPage) Extract() ([]Group, error) { 96 var gs []Group 97 err := r.Result.ExtractIntoSlicePtr(&gs, "scaling_groups") 98 return gs, err 99 } 100 101 //UpdateResult is a struct from which can get the result of udpate method 102 type UpdateResult struct { 103 golangsdk.Result 104 } 105 106 //Extract will deserialize the result to group id with string 107 func (r UpdateResult) Extract() (string, error) { 108 var a struct { 109 ID string `json:"scaling_group_id"` 110 } 111 err := r.Result.ExtractInto(&a) 112 return a.ID, err 113 } 114 115 //this is the action result which is the result of enable or disable operations 116 type ActionResult struct { 117 golangsdk.ErrResult 118 }