github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/autoscaling/v1/groups_hcs/results.go (about) 1 package groups_hcs 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 InstanceTerminatePolicy string `json:"instance_terminate_policy"` 63 Notifications []string `json:"notifications"` 64 DeletePublicip bool `json:"delete_publicip"` 65 CloudLocationID string `json:"cloud_location_id"` 66 } 67 68 type Network struct { 69 ID string `json:"id"` 70 } 71 72 type SecurityGroup struct { 73 ID string `json:"id"` 74 } 75 76 type LBaaSListener struct { 77 ListenerID string `json:"listener_id"` 78 PoolID string `json:"pool_id"` 79 ProtocolPort int `json:"protocol_port"` 80 Weight int `json:"weight"` 81 } 82 83 type GroupPage struct { 84 pagination.SinglePageBase 85 } 86 87 // IsEmpty returns true if a ListResult contains no Volumes. 88 func (r GroupPage) IsEmpty() (bool, error) { 89 groups, err := r.Extract() 90 return len(groups) == 0, err 91 } 92 93 func (r GroupPage) Extract() ([]Group, error) { 94 var gs []Group 95 err := r.Result.ExtractIntoSlicePtr(&gs, "scaling_groups") 96 return gs, err 97 } 98 99 //UpdateResult is a struct from which can get the result of udpate method 100 type UpdateResult struct { 101 golangsdk.Result 102 } 103 104 //Extract will deserialize the result to group id with string 105 func (r UpdateResult) Extract() (string, error) { 106 var a struct { 107 ID string `json:"scaling_group_id"` 108 } 109 err := r.Result.ExtractInto(&a) 110 return a.ID, err 111 } 112 113 //this is the action result which is the result of enable or disable operations 114 type ActionResult struct { 115 golangsdk.ErrResult 116 }