github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/autoscaling/v1/instances/results.go (about)

     1  package instances
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/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  }
    20  
    21  //InstancePage is a struct which can do the page function
    22  type InstancePage struct {
    23  	pagination.SinglePageBase
    24  }
    25  
    26  // IsEmpty returns true if a instances number equal to 0.
    27  func (r InstancePage) IsEmpty() (bool, error) {
    28  	groups, err := r.Extract()
    29  	return len(groups) == 0, err
    30  }
    31  
    32  func (r InstancePage) Extract() ([]Instance, error) {
    33  	var instances []Instance
    34  	err := r.Result.ExtractIntoSlicePtr(&instances, "scaling_group_instances")
    35  	return instances, err
    36  }
    37  
    38  //DeleteResult is a struct which contains the result of deletion instance
    39  type DeleteResult struct {
    40  	golangsdk.ErrResult
    41  }
    42  
    43  //BatchResult is a struct which contains the result of batch operations
    44  type BatchResult struct {
    45  	golangsdk.ErrResult
    46  }