gcp_sdk_container_v1/
client.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
#![allow(rustdoc::broken_intra_doc_links)]

use crate::Result;
use std::sync::Arc;

/// Implements a client for the Kubernetes Engine API.
///
/// # Service Description
///
/// Google Kubernetes Engine Cluster Manager v1
///
/// # Configuration
///
/// `ClusterManager` has various configuration parameters, the defaults should
/// work with most applications.
///
/// # Pooling and Cloning
///
/// `ClusterManager` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `ClusterManager` in
/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc`
/// internally.
#[derive(Clone, Debug)]
pub struct ClusterManager {
    inner: Arc<dyn crate::stubs::dynamic::ClusterManager>,
}

impl ClusterManager {
    /// Creates a new client with the default configuration.
    pub async fn new() -> Result<Self> {
        Self::new_with_config(gax::options::ClientConfig::default()).await
    }

    /// Creates a new client with the specified configuration.
    pub async fn new_with_config(conf: gax::options::ClientConfig) -> Result<Self> {
        let inner = Self::build_inner(conf).await?;
        Ok(Self { inner })
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is when mocking the
    /// client.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: crate::stubs::ClusterManager + 'static,
    {
        Self {
            inner: Arc::new(stub),
        }
    }

    async fn build_inner(
        conf: gax::options::ClientConfig,
    ) -> Result<Arc<dyn crate::stubs::dynamic::ClusterManager>> {
        if conf.tracing_enabled() {
            return Ok(Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gax::options::ClientConfig,
    ) -> Result<impl crate::stubs::ClusterManager> {
        crate::transport::ClusterManager::new(conf).await
    }

    async fn build_with_tracing(
        conf: gax::options::ClientConfig,
    ) -> Result<impl crate::stubs::ClusterManager> {
        Self::build_transport(conf)
            .await
            .map(crate::tracing::ClusterManager::new)
    }

    /// Lists all clusters owned by a project in either the specified zone or all
    /// zones.
    pub fn list_clusters(
        &self,
        parent: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::ListClusters {
        crate::builders::cluster_manager::ListClusters::new(self.inner.clone())
            .set_parent(parent.into())
    }

    /// Gets the details of a specific cluster.
    pub fn get_cluster(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::GetCluster {
        crate::builders::cluster_manager::GetCluster::new(self.inner.clone()).set_name(name.into())
    }

    /// Creates a cluster, consisting of the specified number and type of Google
    /// Compute Engine instances.
    ///
    /// By default, the cluster is created in the project's
    /// [default
    /// network](https://cloud.google.com/compute/docs/networks-and-firewalls#networks).
    ///
    /// One firewall is added for the cluster. After cluster creation,
    /// the Kubelet creates routes for each node to allow the containers
    /// on that node to communicate with all other instances in the
    /// cluster.
    ///
    /// Finally, an entry is added to the project's global metadata indicating
    /// which CIDR range the cluster is using.
    pub fn create_cluster(
        &self,
        parent: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::CreateCluster {
        crate::builders::cluster_manager::CreateCluster::new(self.inner.clone())
            .set_parent(parent.into())
    }

    /// Updates the settings of a specific cluster.
    pub fn update_cluster(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::UpdateCluster {
        crate::builders::cluster_manager::UpdateCluster::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Updates the version and/or image type for the specified node pool.
    pub fn update_node_pool(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::UpdateNodePool {
        crate::builders::cluster_manager::UpdateNodePool::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Sets the autoscaling settings for the specified node pool.
    pub fn set_node_pool_autoscaling(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::SetNodePoolAutoscaling {
        crate::builders::cluster_manager::SetNodePoolAutoscaling::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Sets the logging service for a specific cluster.
    pub fn set_logging_service(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::SetLoggingService {
        crate::builders::cluster_manager::SetLoggingService::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Sets the monitoring service for a specific cluster.
    pub fn set_monitoring_service(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::SetMonitoringService {
        crate::builders::cluster_manager::SetMonitoringService::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Sets the addons for a specific cluster.
    pub fn set_addons_config(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::SetAddonsConfig {
        crate::builders::cluster_manager::SetAddonsConfig::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Sets the locations for a specific cluster.
    /// Deprecated. Use
    /// [projects.locations.clusters.update](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1/projects.locations.clusters/update)
    /// instead.
    pub fn set_locations(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::SetLocations {
        crate::builders::cluster_manager::SetLocations::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Updates the master for a specific cluster.
    pub fn update_master(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::UpdateMaster {
        crate::builders::cluster_manager::UpdateMaster::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Sets master auth materials. Currently supports changing the admin password
    /// or a specific cluster, either via password generation or explicitly setting
    /// the password.
    pub fn set_master_auth(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::SetMasterAuth {
        crate::builders::cluster_manager::SetMasterAuth::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Deletes the cluster, including the Kubernetes endpoint and all worker
    /// nodes.
    ///
    /// Firewalls and routes that were configured during cluster creation
    /// are also deleted.
    ///
    /// Other Google Compute Engine resources that might be in use by the cluster,
    /// such as load balancer resources, are not deleted if they weren't present
    /// when the cluster was initially created.
    pub fn delete_cluster(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::DeleteCluster {
        crate::builders::cluster_manager::DeleteCluster::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Lists all operations in a project in a specific zone or all zones.
    pub fn list_operations(
        &self,
        parent: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::ListOperations {
        crate::builders::cluster_manager::ListOperations::new(self.inner.clone())
            .set_parent(parent.into())
    }

    /// Gets the specified operation.
    pub fn get_operation(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::GetOperation {
        crate::builders::cluster_manager::GetOperation::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Cancels the specified operation.
    pub fn cancel_operation(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::CancelOperation {
        crate::builders::cluster_manager::CancelOperation::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Returns configuration info about the Google Kubernetes Engine service.
    pub fn get_server_config(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::GetServerConfig {
        crate::builders::cluster_manager::GetServerConfig::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Gets the public component of the cluster signing keys in
    /// JSON Web Key format.
    pub fn get_json_web_keys(
        &self,
        parent: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::GetJSONWebKeys {
        crate::builders::cluster_manager::GetJSONWebKeys::new(self.inner.clone())
            .set_parent(parent.into())
    }

    /// Lists the node pools for a cluster.
    pub fn list_node_pools(
        &self,
        parent: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::ListNodePools {
        crate::builders::cluster_manager::ListNodePools::new(self.inner.clone())
            .set_parent(parent.into())
    }

    /// Retrieves the requested node pool.
    pub fn get_node_pool(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::GetNodePool {
        crate::builders::cluster_manager::GetNodePool::new(self.inner.clone()).set_name(name.into())
    }

    /// Creates a node pool for a cluster.
    pub fn create_node_pool(
        &self,
        parent: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::CreateNodePool {
        crate::builders::cluster_manager::CreateNodePool::new(self.inner.clone())
            .set_parent(parent.into())
    }

    /// Deletes a node pool from a cluster.
    pub fn delete_node_pool(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::DeleteNodePool {
        crate::builders::cluster_manager::DeleteNodePool::new(self.inner.clone())
            .set_name(name.into())
    }

    /// CompleteNodePoolUpgrade will signal an on-going node pool upgrade to
    /// complete.
    pub fn complete_node_pool_upgrade(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::CompleteNodePoolUpgrade {
        crate::builders::cluster_manager::CompleteNodePoolUpgrade::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Rolls back a previously Aborted or Failed NodePool upgrade.
    /// This makes no changes if the last upgrade successfully completed.
    pub fn rollback_node_pool_upgrade(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::RollbackNodePoolUpgrade {
        crate::builders::cluster_manager::RollbackNodePoolUpgrade::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Sets the NodeManagement options for a node pool.
    pub fn set_node_pool_management(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::SetNodePoolManagement {
        crate::builders::cluster_manager::SetNodePoolManagement::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Sets labels on a cluster.
    pub fn set_labels(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::SetLabels {
        crate::builders::cluster_manager::SetLabels::new(self.inner.clone()).set_name(name.into())
    }

    /// Enables or disables the ABAC authorization mechanism on a cluster.
    pub fn set_legacy_abac(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::SetLegacyAbac {
        crate::builders::cluster_manager::SetLegacyAbac::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Starts master IP rotation.
    pub fn start_ip_rotation(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::StartIPRotation {
        crate::builders::cluster_manager::StartIPRotation::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Completes master IP rotation.
    pub fn complete_ip_rotation(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::CompleteIPRotation {
        crate::builders::cluster_manager::CompleteIPRotation::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Sets the size for a specific node pool. The new size will be used for all
    /// replicas, including future replicas created by modifying
    /// [NodePool.locations][google.container.v1.NodePool.locations].
    ///
    /// [google.container.v1.NodePool.locations]: crate::model::NodePool::locations
    pub fn set_node_pool_size(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::SetNodePoolSize {
        crate::builders::cluster_manager::SetNodePoolSize::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Enables or disables Network Policy for a cluster.
    pub fn set_network_policy(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::SetNetworkPolicy {
        crate::builders::cluster_manager::SetNetworkPolicy::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Sets the maintenance policy for a cluster.
    pub fn set_maintenance_policy(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::SetMaintenancePolicy {
        crate::builders::cluster_manager::SetMaintenancePolicy::new(self.inner.clone())
            .set_name(name.into())
    }

    /// Lists subnetworks that are usable for creating clusters in a project.
    pub fn list_usable_subnetworks(
        &self,
        parent: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::ListUsableSubnetworks {
        crate::builders::cluster_manager::ListUsableSubnetworks::new(self.inner.clone())
            .set_parent(parent.into())
    }

    /// Checks the cluster compatibility with Autopilot mode, and returns a list of
    /// compatibility issues.
    pub fn check_autopilot_compatibility(
        &self,
        name: impl Into<std::string::String>,
    ) -> crate::builders::cluster_manager::CheckAutopilotCompatibility {
        crate::builders::cluster_manager::CheckAutopilotCompatibility::new(self.inner.clone())
            .set_name(name.into())
    }
}