github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/cce/v3/nodepools/results.go (about)

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