google_cloud_container_v1/
client.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16#![allow(rustdoc::redundant_explicit_links)]
17#![allow(rustdoc::broken_intra_doc_links)]
18
19/// Implements a client for the Kubernetes Engine API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_container_v1::client::ClusterManager;
25/// let client = ClusterManager::builder().build().await?;
26/// // use `client` to make requests to the Kubernetes Engine API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// Google Kubernetes Engine Cluster Manager v1
33///
34/// # Configuration
35///
36/// To configure `ClusterManager` use the `with_*` methods in the type returned
37/// by [builder()][ClusterManager::builder]. The default configuration should
38/// work for most applications. Common configuration changes include
39///
40/// * [with_endpoint()]: by default this client uses the global default endpoint
41///   (`https://container.googleapis.com`). Applications using regional
42///   endpoints or running in restricted networks (e.g. a network configured
43//    with [Private Google Access with VPC Service Controls]) may want to
44///   override this default.
45/// * [with_credentials()]: by default this client uses
46///   [Application Default Credentials]. Applications using custom
47///   authentication may need to override this default.
48///
49/// [with_endpoint()]: super::builder::cluster_manager::ClientBuilder::with_endpoint
50/// [with_credentials()]: super::builder::cluster_manager::ClientBuilder::credentials
51/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
52/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
53///
54/// # Pooling and Cloning
55///
56/// `ClusterManager` holds a connection pool internally, it is advised to
57/// create one and the reuse it.  You do not need to wrap `ClusterManager` in
58/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
59/// already uses an `Arc` internally.
60#[derive(Clone, Debug)]
61pub struct ClusterManager {
62    inner: std::sync::Arc<dyn super::stub::dynamic::ClusterManager>,
63}
64
65impl ClusterManager {
66    /// Returns a builder for [ClusterManager].
67    ///
68    /// ```
69    /// # tokio_test::block_on(async {
70    /// # use google_cloud_container_v1::client::ClusterManager;
71    /// let client = ClusterManager::builder().build().await?;
72    /// # gax::client_builder::Result::<()>::Ok(()) });
73    /// ```
74    pub fn builder() -> super::builder::cluster_manager::ClientBuilder {
75        gax::client_builder::internal::new_builder(super::builder::cluster_manager::client::Factory)
76    }
77
78    /// Creates a new client from the provided stub.
79    ///
80    /// The most common case for calling this function is in tests mocking the
81    /// client's behavior.
82    pub fn from_stub<T>(stub: T) -> Self
83    where
84        T: super::stub::ClusterManager + 'static,
85    {
86        Self {
87            inner: std::sync::Arc::new(stub),
88        }
89    }
90
91    pub(crate) async fn new(
92        config: gaxi::options::ClientConfig,
93    ) -> gax::client_builder::Result<Self> {
94        let inner = Self::build_inner(config).await?;
95        Ok(Self { inner })
96    }
97
98    async fn build_inner(
99        conf: gaxi::options::ClientConfig,
100    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::ClusterManager>> {
101        if gaxi::options::tracing_enabled(&conf) {
102            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
103        }
104        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
105    }
106
107    async fn build_transport(
108        conf: gaxi::options::ClientConfig,
109    ) -> gax::client_builder::Result<impl super::stub::ClusterManager> {
110        super::transport::ClusterManager::new(conf).await
111    }
112
113    async fn build_with_tracing(
114        conf: gaxi::options::ClientConfig,
115    ) -> gax::client_builder::Result<impl super::stub::ClusterManager> {
116        Self::build_transport(conf)
117            .await
118            .map(super::tracing::ClusterManager::new)
119    }
120
121    /// Lists all clusters owned by a project in either the specified zone or all
122    /// zones.
123    pub fn list_clusters(&self) -> super::builder::cluster_manager::ListClusters {
124        super::builder::cluster_manager::ListClusters::new(self.inner.clone())
125    }
126
127    /// Gets the details of a specific cluster.
128    pub fn get_cluster(&self) -> super::builder::cluster_manager::GetCluster {
129        super::builder::cluster_manager::GetCluster::new(self.inner.clone())
130    }
131
132    /// Creates a cluster, consisting of the specified number and type of Google
133    /// Compute Engine instances.
134    ///
135    /// By default, the cluster is created in the project's
136    /// [default
137    /// network](https://cloud.google.com/compute/docs/networks-and-firewalls#networks).
138    ///
139    /// One firewall is added for the cluster. After cluster creation,
140    /// the kubelet creates routes for each node to allow the containers
141    /// on that node to communicate with all other instances in the
142    /// cluster.
143    ///
144    /// Finally, an entry is added to the project's global metadata indicating
145    /// which CIDR range the cluster is using.
146    pub fn create_cluster(&self) -> super::builder::cluster_manager::CreateCluster {
147        super::builder::cluster_manager::CreateCluster::new(self.inner.clone())
148    }
149
150    /// Updates the settings of a specific cluster.
151    pub fn update_cluster(&self) -> super::builder::cluster_manager::UpdateCluster {
152        super::builder::cluster_manager::UpdateCluster::new(self.inner.clone())
153    }
154
155    /// Updates the version and/or image type for the specified node pool.
156    pub fn update_node_pool(&self) -> super::builder::cluster_manager::UpdateNodePool {
157        super::builder::cluster_manager::UpdateNodePool::new(self.inner.clone())
158    }
159
160    /// Sets the autoscaling settings for the specified node pool.
161    pub fn set_node_pool_autoscaling(
162        &self,
163    ) -> super::builder::cluster_manager::SetNodePoolAutoscaling {
164        super::builder::cluster_manager::SetNodePoolAutoscaling::new(self.inner.clone())
165    }
166
167    /// Sets the logging service for a specific cluster.
168    pub fn set_logging_service(&self) -> super::builder::cluster_manager::SetLoggingService {
169        super::builder::cluster_manager::SetLoggingService::new(self.inner.clone())
170    }
171
172    /// Sets the monitoring service for a specific cluster.
173    pub fn set_monitoring_service(&self) -> super::builder::cluster_manager::SetMonitoringService {
174        super::builder::cluster_manager::SetMonitoringService::new(self.inner.clone())
175    }
176
177    /// Sets the addons for a specific cluster.
178    pub fn set_addons_config(&self) -> super::builder::cluster_manager::SetAddonsConfig {
179        super::builder::cluster_manager::SetAddonsConfig::new(self.inner.clone())
180    }
181
182    /// Sets the locations for a specific cluster.
183    /// Deprecated. Use
184    /// [projects.locations.clusters.update](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1/projects.locations.clusters/update)
185    /// instead.
186    #[deprecated]
187    pub fn set_locations(&self) -> super::builder::cluster_manager::SetLocations {
188        super::builder::cluster_manager::SetLocations::new(self.inner.clone())
189    }
190
191    /// Updates the master for a specific cluster.
192    pub fn update_master(&self) -> super::builder::cluster_manager::UpdateMaster {
193        super::builder::cluster_manager::UpdateMaster::new(self.inner.clone())
194    }
195
196    /// Sets master auth materials. Currently supports changing the admin password
197    /// or a specific cluster, either via password generation or explicitly setting
198    /// the password.
199    pub fn set_master_auth(&self) -> super::builder::cluster_manager::SetMasterAuth {
200        super::builder::cluster_manager::SetMasterAuth::new(self.inner.clone())
201    }
202
203    /// Deletes the cluster, including the Kubernetes endpoint and all worker
204    /// nodes.
205    ///
206    /// Firewalls and routes that were configured during cluster creation
207    /// are also deleted.
208    ///
209    /// Other Google Compute Engine resources that might be in use by the cluster,
210    /// such as load balancer resources, are not deleted if they weren't present
211    /// when the cluster was initially created.
212    pub fn delete_cluster(&self) -> super::builder::cluster_manager::DeleteCluster {
213        super::builder::cluster_manager::DeleteCluster::new(self.inner.clone())
214    }
215
216    /// Lists all operations in a project in a specific zone or all zones.
217    pub fn list_operations(&self) -> super::builder::cluster_manager::ListOperations {
218        super::builder::cluster_manager::ListOperations::new(self.inner.clone())
219    }
220
221    /// Gets the specified operation.
222    pub fn get_operation(&self) -> super::builder::cluster_manager::GetOperation {
223        super::builder::cluster_manager::GetOperation::new(self.inner.clone())
224    }
225
226    /// Cancels the specified operation.
227    pub fn cancel_operation(&self) -> super::builder::cluster_manager::CancelOperation {
228        super::builder::cluster_manager::CancelOperation::new(self.inner.clone())
229    }
230
231    /// Returns configuration info about the Google Kubernetes Engine service.
232    pub fn get_server_config(&self) -> super::builder::cluster_manager::GetServerConfig {
233        super::builder::cluster_manager::GetServerConfig::new(self.inner.clone())
234    }
235
236    /// Gets the public component of the cluster signing keys in
237    /// JSON Web Key format.
238    pub fn get_json_web_keys(&self) -> super::builder::cluster_manager::GetJSONWebKeys {
239        super::builder::cluster_manager::GetJSONWebKeys::new(self.inner.clone())
240    }
241
242    /// Lists the node pools for a cluster.
243    pub fn list_node_pools(&self) -> super::builder::cluster_manager::ListNodePools {
244        super::builder::cluster_manager::ListNodePools::new(self.inner.clone())
245    }
246
247    /// Retrieves the requested node pool.
248    pub fn get_node_pool(&self) -> super::builder::cluster_manager::GetNodePool {
249        super::builder::cluster_manager::GetNodePool::new(self.inner.clone())
250    }
251
252    /// Creates a node pool for a cluster.
253    pub fn create_node_pool(&self) -> super::builder::cluster_manager::CreateNodePool {
254        super::builder::cluster_manager::CreateNodePool::new(self.inner.clone())
255    }
256
257    /// Deletes a node pool from a cluster.
258    pub fn delete_node_pool(&self) -> super::builder::cluster_manager::DeleteNodePool {
259        super::builder::cluster_manager::DeleteNodePool::new(self.inner.clone())
260    }
261
262    /// CompleteNodePoolUpgrade will signal an on-going node pool upgrade to
263    /// complete.
264    pub fn complete_node_pool_upgrade(
265        &self,
266    ) -> super::builder::cluster_manager::CompleteNodePoolUpgrade {
267        super::builder::cluster_manager::CompleteNodePoolUpgrade::new(self.inner.clone())
268    }
269
270    /// Rolls back a previously Aborted or Failed NodePool upgrade.
271    /// This makes no changes if the last upgrade successfully completed.
272    pub fn rollback_node_pool_upgrade(
273        &self,
274    ) -> super::builder::cluster_manager::RollbackNodePoolUpgrade {
275        super::builder::cluster_manager::RollbackNodePoolUpgrade::new(self.inner.clone())
276    }
277
278    /// Sets the NodeManagement options for a node pool.
279    pub fn set_node_pool_management(
280        &self,
281    ) -> super::builder::cluster_manager::SetNodePoolManagement {
282        super::builder::cluster_manager::SetNodePoolManagement::new(self.inner.clone())
283    }
284
285    /// Sets labels on a cluster.
286    pub fn set_labels(&self) -> super::builder::cluster_manager::SetLabels {
287        super::builder::cluster_manager::SetLabels::new(self.inner.clone())
288    }
289
290    /// Enables or disables the ABAC authorization mechanism on a cluster.
291    pub fn set_legacy_abac(&self) -> super::builder::cluster_manager::SetLegacyAbac {
292        super::builder::cluster_manager::SetLegacyAbac::new(self.inner.clone())
293    }
294
295    /// Starts master IP rotation.
296    pub fn start_ip_rotation(&self) -> super::builder::cluster_manager::StartIPRotation {
297        super::builder::cluster_manager::StartIPRotation::new(self.inner.clone())
298    }
299
300    /// Completes master IP rotation.
301    pub fn complete_ip_rotation(&self) -> super::builder::cluster_manager::CompleteIPRotation {
302        super::builder::cluster_manager::CompleteIPRotation::new(self.inner.clone())
303    }
304
305    /// Sets the size for a specific node pool. The new size will be used for all
306    /// replicas, including future replicas created by modifying
307    /// [NodePool.locations][google.container.v1.NodePool.locations].
308    ///
309    /// [google.container.v1.NodePool.locations]: crate::model::NodePool::locations
310    pub fn set_node_pool_size(&self) -> super::builder::cluster_manager::SetNodePoolSize {
311        super::builder::cluster_manager::SetNodePoolSize::new(self.inner.clone())
312    }
313
314    /// Enables or disables Network Policy for a cluster.
315    pub fn set_network_policy(&self) -> super::builder::cluster_manager::SetNetworkPolicy {
316        super::builder::cluster_manager::SetNetworkPolicy::new(self.inner.clone())
317    }
318
319    /// Sets the maintenance policy for a cluster.
320    pub fn set_maintenance_policy(&self) -> super::builder::cluster_manager::SetMaintenancePolicy {
321        super::builder::cluster_manager::SetMaintenancePolicy::new(self.inner.clone())
322    }
323
324    /// Lists subnetworks that are usable for creating clusters in a project.
325    pub fn list_usable_subnetworks(
326        &self,
327    ) -> super::builder::cluster_manager::ListUsableSubnetworks {
328        super::builder::cluster_manager::ListUsableSubnetworks::new(self.inner.clone())
329    }
330
331    /// Checks the cluster compatibility with Autopilot mode, and returns a list of
332    /// compatibility issues.
333    pub fn check_autopilot_compatibility(
334        &self,
335    ) -> super::builder::cluster_manager::CheckAutopilotCompatibility {
336        super::builder::cluster_manager::CheckAutopilotCompatibility::new(self.inner.clone())
337    }
338
339    /// Fetch upgrade information of a specific cluster.
340    pub fn fetch_cluster_upgrade_info(
341        &self,
342    ) -> super::builder::cluster_manager::FetchClusterUpgradeInfo {
343        super::builder::cluster_manager::FetchClusterUpgradeInfo::new(self.inner.clone())
344    }
345
346    /// Fetch upgrade information of a specific nodepool.
347    pub fn fetch_node_pool_upgrade_info(
348        &self,
349    ) -> super::builder::cluster_manager::FetchNodePoolUpgradeInfo {
350        super::builder::cluster_manager::FetchNodePoolUpgradeInfo::new(self.inner.clone())
351    }
352}