@@ -18,10 +18,12 @@ type ClusterServiceClientSpec interface {
18
18
PostCSCluster (ctx context.Context , cluster * cmv1.Cluster ) (* cmv1.Cluster , error )
19
19
UpdateCSCluster (ctx context.Context , internalID InternalID , cluster * cmv1.Cluster ) (* cmv1.Cluster , error )
20
20
DeleteCSCluster (ctx context.Context , internalID InternalID ) error
21
+ ListCSClusters (searchExpression string ) ClusterListIterator
21
22
GetCSNodePool (ctx context.Context , internalID InternalID ) (* cmv1.NodePool , error )
22
23
PostCSNodePool (ctx context.Context , clusterInternalID InternalID , nodePool * cmv1.NodePool ) (* cmv1.NodePool , error )
23
24
UpdateCSNodePool (ctx context.Context , internalID InternalID , nodePool * cmv1.NodePool ) (* cmv1.NodePool , error )
24
25
DeleteCSNodePool (ctx context.Context , internalID InternalID ) error
26
+ ListCSNodePools (clusterInternalID InternalID , searchExpression string ) NodePoolListIterator
25
27
}
26
28
27
29
// Get the default set of properties for the Cluster Service
@@ -153,6 +155,17 @@ func (csc *ClusterServiceClient) DeleteCSCluster(ctx context.Context, internalID
153
155
return err
154
156
}
155
157
158
+ // ListCSClusters prepares a GET request with the given search expression. Call Items() on
159
+ // the returned iterator in a for/range loop to execute the request and paginate over results,
160
+ // then call GetError() to check for an iteration error.
161
+ func (csc * ClusterServiceClient ) ListCSClusters (searchExpression string ) ClusterListIterator {
162
+ clustersListRequest := csc .Conn .ClustersMgmt ().V1 ().Clusters ().List ()
163
+ if searchExpression != "" {
164
+ clustersListRequest .Search (searchExpression )
165
+ }
166
+ return ClusterListIterator {request : clustersListRequest }
167
+ }
168
+
156
169
// GetCSNodePool creates and sends a GET request to fetch a node pool from Clusters Service
157
170
func (csc * ClusterServiceClient ) GetCSNodePool (ctx context.Context , internalID InternalID ) (* cmv1.NodePool , error ) {
158
171
client , ok := internalID .GetNodePoolClient (csc .Conn )
@@ -213,3 +226,18 @@ func (csc *ClusterServiceClient) DeleteCSNodePool(ctx context.Context, internalI
213
226
_ , err := client .Delete ().SendContext (ctx )
214
227
return err
215
228
}
229
+
230
+ // ListCSNodePools prepares a GET request with the given search expression. Call Items() on
231
+ // the returned iterator in a for/range loop to execute the request and paginate over results,
232
+ // then call GetError() to check for an iteration error.
233
+ func (csc * ClusterServiceClient ) ListCSNodePools (clusterInternalID InternalID , searchExpression string ) NodePoolListIterator {
234
+ client , ok := clusterInternalID .GetClusterClient (csc .Conn )
235
+ if ! ok {
236
+ return NodePoolListIterator {err : fmt .Errorf ("OCM path is not a cluster: %s" , clusterInternalID )}
237
+ }
238
+ nodePoolsListRequest := client .NodePools ().List ()
239
+ if searchExpression != "" {
240
+ nodePoolsListRequest .Search (searchExpression )
241
+ }
242
+ return NodePoolListIterator {request : nodePoolsListRequest }
243
+ }
0 commit comments