github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/cce/v3/nodepools/results.go (about) 1 package nodepools 2 3 import ( 4 "github.com/chnsz/golangsdk" 5 "github.com/chnsz/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 // Pod security group configurations 61 PodSecurityGroups []PodSecurityGroupSpec `json:"podSecurityGroups"` 62 // Node security group configurations 63 CustomSecurityGroups []string `json:"customSecurityGroups"` 64 } 65 66 type AutoscalingSpec struct { 67 // Whether to enable auto scaling 68 Enable bool `json:"enable"` 69 // Minimum number of nodes allowed if auto scaling is enabled 70 MinNodeCount int `json:"minNodeCount"` 71 // This value must be greater than or equal to the value of minNodeCount 72 MaxNodeCount int `json:"maxNodeCount"` 73 // Interval between two scaling operations, in minutes 74 ScaleDownCooldownTime int `json:"scaleDownCooldownTime"` 75 // Weight of a node pool 76 Priority int `json:"priority"` 77 } 78 79 type NodeManagementSpec struct { 80 // ECS group ID 81 ServerGroupReference string `json:"serverGroupReference"` 82 } 83 84 type commonResult struct { 85 golangsdk.Result 86 } 87 88 // Extract is a function that accepts a result and extracts a node pool. 89 func (r commonResult) Extract() (*NodePool, error) { 90 var s NodePool 91 err := r.ExtractInto(&s) 92 return &s, err 93 } 94 95 // ExtractNodePool is a function that accepts a ListOpts struct, which allows you to filter and sort 96 // the returned collection for greater efficiency. 97 func (r commonResult) ExtractNodePool() ([]NodePool, error) { 98 var s ListNodePool 99 err := r.ExtractInto(&s) 100 if err != nil { 101 return nil, err 102 } 103 return s.NodePools, nil 104 } 105 106 // ListResult represents the result of a list operation. Call its ExtractNode 107 // method to interpret it as a Node Pool. 108 type ListResult struct { 109 commonResult 110 } 111 112 // CreateResult represents the result of a create operation. Call its Extract 113 // method to interpret it as a Node Pool. 114 type CreateResult struct { 115 commonResult 116 } 117 118 // GetResult represents the result of a get operation. Call its Extract 119 // method to interpret it as a Node Pool. 120 type GetResult struct { 121 commonResult 122 } 123 124 // UpdateResult represents the result of an update operation. Call its Extract 125 // method to interpret it as a Node Pool. 126 type UpdateResult struct { 127 commonResult 128 } 129 130 // DeleteResult represents the result of a delete operation. Call its ExtractErr 131 // method to determine if the request succeeded or failed. 132 type DeleteResult struct { 133 golangsdk.ErrResult 134 }