github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/autoscaling/v1/instances/results.go (about) 1 package instances 2 3 import ( 4 "github.com/chnsz/golangsdk" 5 "github.com/chnsz/golangsdk/pagination" 6 ) 7 8 // Instance is a struct which represents all the infromation of a instance 9 type Instance struct { 10 ID string `json:"instance_id"` 11 Name string `json:"instance_name"` 12 GroupID string `json:"scaling_group_id"` 13 GroupName string `json:"scaling_group_name"` 14 LifeCycleStatus string `json:"life_cycle_state"` 15 HealthStatus string `json:"health_status"` 16 ConfigurationName string `json:"scaling_configuration_name"` 17 ConfigurationID string `json:"scaling_configuration_id"` 18 CreateTime string `json:"create_time"` 19 Protected bool `json:"protect_from_scaling_down"` 20 } 21 22 // InstancePage is a struct which can do the page function 23 type InstancePage struct { 24 pagination.SinglePageBase 25 } 26 27 // IsEmpty returns true if a instances number equal to 0. 28 func (r InstancePage) IsEmpty() (bool, error) { 29 groups, err := r.Extract() 30 return len(groups) == 0, err 31 } 32 33 func (r InstancePage) Extract() ([]Instance, error) { 34 var instances []Instance 35 err := r.Result.ExtractIntoSlicePtr(&instances, "scaling_group_instances") 36 return instances, err 37 } 38 39 // DeleteResult is a struct which contains the result of deletion instance 40 type DeleteResult struct { 41 golangsdk.ErrResult 42 } 43 44 // BatchResult is a struct which contains the result of batch operations 45 type BatchResult struct { 46 golangsdk.ErrResult 47 }