github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/cce/v3/nodepools/results.go (about)

     1  package nodepools
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/golangsdk/openstack/cce/v3/nodes"
     6  )
     7  
     8  //Describes the Node Pool Structure of cluster
     9  type ListNodePool struct {
    10  	// API type, fixed value "List"
    11  	Kind string `json:"kind"`
    12  	// API version, fixed value "v3"
    13  	Apiversion string `json:"apiVersion"`
    14  	// all Node Pools
    15  	NodePools []NodePool `json:"items"`
    16  }
    17  
    18  // Individual node pools of the cluster
    19  type NodePool struct {
    20  	//  API type, fixed value " Host "
    21  	Kind string `json:"kind"`
    22  	// API version, fixed value v3
    23  	Apiversion string `json:"apiVersion"`
    24  	// Node Pool metadata
    25  	Metadata Metadata `json:"metadata"`
    26  	// Node Pool detailed parameters
    27  	Spec Spec `json:"spec"`
    28  	// Node Pool status information
    29  	Status Status `json:"status"`
    30  }
    31  
    32  // Metadata of the node pool
    33  type Metadata struct {
    34  	//Node Pool name
    35  	Name string `json:"name"`
    36  	//Node Pool ID
    37  	Id string `json:"uid"`
    38  }
    39  
    40  // Gives the current status of the node pool
    41  type Status struct {
    42  	// The state of the node pool
    43  	Phase string `json:"phase"`
    44  	// Number of nodes in the node pool
    45  	CurrentNode int `json:"currentNode"`
    46  }
    47  
    48  // Spec describes Node pools specification
    49  type Spec struct {
    50  	// Node type. Currently, only VM nodes are supported.
    51  	Type string `json:"type" required:"true"`
    52  	// Node Pool template
    53  	NodeTemplate nodes.Spec `json:"nodeTemplate" required:"true"`
    54  	// Initial number of expected node pools
    55  	InitialNodeCount int `json:"initialNodeCount" required:"true"`
    56  	// Auto scaling parameters
    57  	Autoscaling AutoscalingSpec `json:"autoscaling"`
    58  	// Node pool management parameters
    59  	NodeManagement NodeManagementSpec `json:"nodeManagement"`
    60  }
    61  
    62  type AutoscalingSpec struct {
    63  	// Whether to enable auto scaling
    64  	Enable bool `json:"enable"`
    65  	// Minimum number of nodes allowed if auto scaling is enabled
    66  	MinNodeCount int `json:"minNodeCount"`
    67  	// This value must be greater than or equal to the value of minNodeCount
    68  	MaxNodeCount int `json:"maxNodeCount"`
    69  	// Interval between two scaling operations, in minutes
    70  	ScaleDownCooldownTime int `json:"scaleDownCooldownTime"`
    71  	// Weight of a node pool
    72  	Priority int `json:"priority"`
    73  }
    74  
    75  type NodeManagementSpec struct {
    76  	// ECS group ID
    77  	ServerGroupReference string `json:"serverGroupReference"`
    78  }
    79  
    80  type commonResult struct {
    81  	golangsdk.Result
    82  }
    83  
    84  // Extract is a function that accepts a result and extracts a node pool.
    85  func (r commonResult) Extract() (*NodePool, error) {
    86  	var s NodePool
    87  	err := r.ExtractInto(&s)
    88  	return &s, err
    89  }
    90  
    91  // ExtractNodePool is a function that accepts a ListOpts struct, which allows you to filter and sort
    92  // the returned collection for greater efficiency.
    93  func (r commonResult) ExtractNodePool() ([]NodePool, error) {
    94  	var s ListNodePool
    95  	err := r.ExtractInto(&s)
    96  	if err != nil {
    97  		return nil, err
    98  	}
    99  	return s.NodePools, nil
   100  }
   101  
   102  // ListResult represents the result of a list operation. Call its ExtractNode
   103  // method to interpret it as a Node Pool.
   104  type ListResult struct {
   105  	commonResult
   106  }
   107  
   108  // CreateResult represents the result of a create operation. Call its Extract
   109  // method to interpret it as a Node Pool.
   110  type CreateResult struct {
   111  	commonResult
   112  }
   113  
   114  // GetResult represents the result of a get operation. Call its Extract
   115  // method to interpret it as a Node Pool.
   116  type GetResult struct {
   117  	commonResult
   118  }
   119  
   120  // UpdateResult represents the result of an update operation. Call its Extract
   121  // method to interpret it as a Node Pool.
   122  type UpdateResult struct {
   123  	commonResult
   124  }
   125  
   126  // DeleteResult represents the result of a delete operation. Call its ExtractErr
   127  // method to determine if the request succeeded or failed.
   128  type DeleteResult struct {
   129  	golangsdk.ErrResult
   130  }