google_cloud_edgecontainer_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
19use crate::Result;
20use std::sync::Arc;
21
22/// Implements a client for the Distributed Cloud Edge Container API.
23///
24/// # Example
25/// ```
26/// # tokio_test::block_on(async {
27/// # use google_cloud_edgecontainer_v1::client::EdgeContainer;
28/// let client = EdgeContainer::builder().build().await?;
29/// // use `client` to make requests to the {Codec.APITitle}}.
30/// # gax::Result::<()>::Ok(()) });
31/// ```
32///
33/// # Service Description
34///
35/// EdgeContainer API provides management of Kubernetes Clusters on Google Edge
36/// Cloud deployments.
37///
38/// # Configuration
39///
40/// To configure `EdgeContainer` use the `with_*` methods in the type returned
41/// by [builder()][EdgeContainer::builder]. The default configuration should
42/// work for most applications. Common configuration changes include
43///
44/// * [with_endpoint()]: by default this client uses the global default endpoint
45/// (`https://edgecontainer.googleapis.com`). Applications using regional
46/// endpoints or running in restricted networks (e.g. a network configured
47// with [Private Google Access with VPC Service Controls]) may want to
48/// override this default.
49/// * [with_credentials()]: by default this client uses
50/// [Application Default Credentials]. Applications using custom
51/// authentication may need to override this default.
52///
53/// [with_endpoint()]: super::builder::edge_container::ClientBuilder::with_endpoint
54/// [with_credentials()]: super::builder::edge_container::ClientBuilder::credentials
55/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
56/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
57///
58/// # Pooling and Cloning
59///
60/// `EdgeContainer` holds a connection pool internally, it is advised to
61/// create one and the reuse it. You do not need to wrap `EdgeContainer` in
62/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc`
63/// internally.
64#[derive(Clone, Debug)]
65pub struct EdgeContainer {
66 inner: Arc<dyn super::stub::dynamic::EdgeContainer>,
67}
68
69impl EdgeContainer {
70 /// Returns a builder for [EdgeContainer].
71 ///
72 /// ```
73 /// # tokio_test::block_on(async {
74 /// # use google_cloud_edgecontainer_v1::client::EdgeContainer;
75 /// let client = EdgeContainer::builder().build().await?;
76 /// # gax::Result::<()>::Ok(()) });
77 /// ```
78 pub fn builder() -> super::builder::edge_container::ClientBuilder {
79 gax::client_builder::internal::new_builder(super::builder::edge_container::client::Factory)
80 }
81
82 /// Creates a new client from the provided stub.
83 ///
84 /// The most common case for calling this function is in tests mocking the
85 /// client's behavior.
86 pub fn from_stub<T>(stub: T) -> Self
87 where
88 T: super::stub::EdgeContainer + 'static,
89 {
90 Self {
91 inner: Arc::new(stub),
92 }
93 }
94
95 pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
96 let inner = Self::build_inner(config).await?;
97 Ok(Self { inner })
98 }
99
100 async fn build_inner(
101 conf: gaxi::options::ClientConfig,
102 ) -> Result<Arc<dyn super::stub::dynamic::EdgeContainer>> {
103 if gaxi::options::tracing_enabled(&conf) {
104 return Ok(Arc::new(Self::build_with_tracing(conf).await?));
105 }
106 Ok(Arc::new(Self::build_transport(conf).await?))
107 }
108
109 async fn build_transport(
110 conf: gaxi::options::ClientConfig,
111 ) -> Result<impl super::stub::EdgeContainer> {
112 super::transport::EdgeContainer::new(conf).await
113 }
114
115 async fn build_with_tracing(
116 conf: gaxi::options::ClientConfig,
117 ) -> Result<impl super::stub::EdgeContainer> {
118 Self::build_transport(conf)
119 .await
120 .map(super::tracing::EdgeContainer::new)
121 }
122
123 /// Lists Clusters in a given project and location.
124 pub fn list_clusters(
125 &self,
126 parent: impl Into<std::string::String>,
127 ) -> super::builder::edge_container::ListClusters {
128 super::builder::edge_container::ListClusters::new(self.inner.clone())
129 .set_parent(parent.into())
130 }
131
132 /// Gets details of a single Cluster.
133 pub fn get_cluster(
134 &self,
135 name: impl Into<std::string::String>,
136 ) -> super::builder::edge_container::GetCluster {
137 super::builder::edge_container::GetCluster::new(self.inner.clone()).set_name(name.into())
138 }
139
140 /// Creates a new Cluster in a given project and location.
141 ///
142 /// # Long running operations
143 ///
144 /// This method is used to start, and/or poll a [long-running Operation].
145 /// The [Working with long-running operations] chapter in the [user guide]
146 /// covers these operations in detail.
147 ///
148 /// [long-running operation]: https://google.aip.dev/151
149 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
150 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
151 pub fn create_cluster(
152 &self,
153 parent: impl Into<std::string::String>,
154 ) -> super::builder::edge_container::CreateCluster {
155 super::builder::edge_container::CreateCluster::new(self.inner.clone())
156 .set_parent(parent.into())
157 }
158
159 /// Updates the parameters of a single Cluster.
160 ///
161 /// # Long running operations
162 ///
163 /// This method is used to start, and/or poll a [long-running Operation].
164 /// The [Working with long-running operations] chapter in the [user guide]
165 /// covers these operations in detail.
166 ///
167 /// [long-running operation]: https://google.aip.dev/151
168 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
169 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
170 pub fn update_cluster(
171 &self,
172 cluster: impl Into<crate::model::Cluster>,
173 ) -> super::builder::edge_container::UpdateCluster {
174 super::builder::edge_container::UpdateCluster::new(self.inner.clone())
175 .set_cluster(cluster.into())
176 }
177
178 /// Upgrades a single cluster.
179 ///
180 /// # Long running operations
181 ///
182 /// This method is used to start, and/or poll a [long-running Operation].
183 /// The [Working with long-running operations] chapter in the [user guide]
184 /// covers these operations in detail.
185 ///
186 /// [long-running operation]: https://google.aip.dev/151
187 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
188 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
189 pub fn upgrade_cluster(
190 &self,
191 name: impl Into<std::string::String>,
192 ) -> super::builder::edge_container::UpgradeCluster {
193 super::builder::edge_container::UpgradeCluster::new(self.inner.clone())
194 .set_name(name.into())
195 }
196
197 /// Deletes a single Cluster.
198 ///
199 /// # Long running operations
200 ///
201 /// This method is used to start, and/or poll a [long-running Operation].
202 /// The [Working with long-running operations] chapter in the [user guide]
203 /// covers these operations in detail.
204 ///
205 /// [long-running operation]: https://google.aip.dev/151
206 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
207 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
208 pub fn delete_cluster(
209 &self,
210 name: impl Into<std::string::String>,
211 ) -> super::builder::edge_container::DeleteCluster {
212 super::builder::edge_container::DeleteCluster::new(self.inner.clone()).set_name(name.into())
213 }
214
215 /// Generates an access token for a Cluster.
216 pub fn generate_access_token(
217 &self,
218 cluster: impl Into<std::string::String>,
219 ) -> super::builder::edge_container::GenerateAccessToken {
220 super::builder::edge_container::GenerateAccessToken::new(self.inner.clone())
221 .set_cluster(cluster.into())
222 }
223
224 /// Generates an offline credential for a Cluster.
225 pub fn generate_offline_credential(
226 &self,
227 cluster: impl Into<std::string::String>,
228 ) -> super::builder::edge_container::GenerateOfflineCredential {
229 super::builder::edge_container::GenerateOfflineCredential::new(self.inner.clone())
230 .set_cluster(cluster.into())
231 }
232
233 /// Lists NodePools in a given project and location.
234 pub fn list_node_pools(
235 &self,
236 parent: impl Into<std::string::String>,
237 ) -> super::builder::edge_container::ListNodePools {
238 super::builder::edge_container::ListNodePools::new(self.inner.clone())
239 .set_parent(parent.into())
240 }
241
242 /// Gets details of a single NodePool.
243 pub fn get_node_pool(
244 &self,
245 name: impl Into<std::string::String>,
246 ) -> super::builder::edge_container::GetNodePool {
247 super::builder::edge_container::GetNodePool::new(self.inner.clone()).set_name(name.into())
248 }
249
250 /// Creates a new NodePool in a given project and location.
251 ///
252 /// # Long running operations
253 ///
254 /// This method is used to start, and/or poll a [long-running Operation].
255 /// The [Working with long-running operations] chapter in the [user guide]
256 /// covers these operations in detail.
257 ///
258 /// [long-running operation]: https://google.aip.dev/151
259 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
260 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
261 pub fn create_node_pool(
262 &self,
263 parent: impl Into<std::string::String>,
264 ) -> super::builder::edge_container::CreateNodePool {
265 super::builder::edge_container::CreateNodePool::new(self.inner.clone())
266 .set_parent(parent.into())
267 }
268
269 /// Updates the parameters of a single NodePool.
270 ///
271 /// # Long running operations
272 ///
273 /// This method is used to start, and/or poll a [long-running Operation].
274 /// The [Working with long-running operations] chapter in the [user guide]
275 /// covers these operations in detail.
276 ///
277 /// [long-running operation]: https://google.aip.dev/151
278 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
279 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
280 pub fn update_node_pool(
281 &self,
282 node_pool: impl Into<crate::model::NodePool>,
283 ) -> super::builder::edge_container::UpdateNodePool {
284 super::builder::edge_container::UpdateNodePool::new(self.inner.clone())
285 .set_node_pool(node_pool.into())
286 }
287
288 /// Deletes a single NodePool.
289 ///
290 /// # Long running operations
291 ///
292 /// This method is used to start, and/or poll a [long-running Operation].
293 /// The [Working with long-running operations] chapter in the [user guide]
294 /// covers these operations in detail.
295 ///
296 /// [long-running operation]: https://google.aip.dev/151
297 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
298 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
299 pub fn delete_node_pool(
300 &self,
301 name: impl Into<std::string::String>,
302 ) -> super::builder::edge_container::DeleteNodePool {
303 super::builder::edge_container::DeleteNodePool::new(self.inner.clone())
304 .set_name(name.into())
305 }
306
307 /// Lists Machines in a given project and location.
308 pub fn list_machines(
309 &self,
310 parent: impl Into<std::string::String>,
311 ) -> super::builder::edge_container::ListMachines {
312 super::builder::edge_container::ListMachines::new(self.inner.clone())
313 .set_parent(parent.into())
314 }
315
316 /// Gets details of a single Machine.
317 pub fn get_machine(
318 &self,
319 name: impl Into<std::string::String>,
320 ) -> super::builder::edge_container::GetMachine {
321 super::builder::edge_container::GetMachine::new(self.inner.clone()).set_name(name.into())
322 }
323
324 /// Lists VPN connections in a given project and location.
325 pub fn list_vpn_connections(
326 &self,
327 parent: impl Into<std::string::String>,
328 ) -> super::builder::edge_container::ListVpnConnections {
329 super::builder::edge_container::ListVpnConnections::new(self.inner.clone())
330 .set_parent(parent.into())
331 }
332
333 /// Gets details of a single VPN connection.
334 pub fn get_vpn_connection(
335 &self,
336 name: impl Into<std::string::String>,
337 ) -> super::builder::edge_container::GetVpnConnection {
338 super::builder::edge_container::GetVpnConnection::new(self.inner.clone())
339 .set_name(name.into())
340 }
341
342 /// Creates a new VPN connection in a given project and location.
343 ///
344 /// # Long running operations
345 ///
346 /// This method is used to start, and/or poll a [long-running Operation].
347 /// The [Working with long-running operations] chapter in the [user guide]
348 /// covers these operations in detail.
349 ///
350 /// [long-running operation]: https://google.aip.dev/151
351 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
352 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
353 pub fn create_vpn_connection(
354 &self,
355 parent: impl Into<std::string::String>,
356 ) -> super::builder::edge_container::CreateVpnConnection {
357 super::builder::edge_container::CreateVpnConnection::new(self.inner.clone())
358 .set_parent(parent.into())
359 }
360
361 /// Deletes a single VPN connection.
362 ///
363 /// # Long running operations
364 ///
365 /// This method is used to start, and/or poll a [long-running Operation].
366 /// The [Working with long-running operations] chapter in the [user guide]
367 /// covers these operations in detail.
368 ///
369 /// [long-running operation]: https://google.aip.dev/151
370 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
371 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
372 pub fn delete_vpn_connection(
373 &self,
374 name: impl Into<std::string::String>,
375 ) -> super::builder::edge_container::DeleteVpnConnection {
376 super::builder::edge_container::DeleteVpnConnection::new(self.inner.clone())
377 .set_name(name.into())
378 }
379
380 /// Gets the server config.
381 pub fn get_server_config(
382 &self,
383 name: impl Into<std::string::String>,
384 ) -> super::builder::edge_container::GetServerConfig {
385 super::builder::edge_container::GetServerConfig::new(self.inner.clone())
386 .set_name(name.into())
387 }
388
389 /// Lists information about the supported locations for this service.
390 pub fn list_locations(
391 &self,
392 name: impl Into<std::string::String>,
393 ) -> super::builder::edge_container::ListLocations {
394 super::builder::edge_container::ListLocations::new(self.inner.clone()).set_name(name.into())
395 }
396
397 /// Gets information about a location.
398 pub fn get_location(
399 &self,
400 name: impl Into<std::string::String>,
401 ) -> super::builder::edge_container::GetLocation {
402 super::builder::edge_container::GetLocation::new(self.inner.clone()).set_name(name.into())
403 }
404
405 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
406 ///
407 /// [google.longrunning.Operations]: longrunning::client::Operations
408 pub fn list_operations(
409 &self,
410 name: impl Into<std::string::String>,
411 ) -> super::builder::edge_container::ListOperations {
412 super::builder::edge_container::ListOperations::new(self.inner.clone())
413 .set_name(name.into())
414 }
415
416 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
417 ///
418 /// [google.longrunning.Operations]: longrunning::client::Operations
419 pub fn get_operation(
420 &self,
421 name: impl Into<std::string::String>,
422 ) -> super::builder::edge_container::GetOperation {
423 super::builder::edge_container::GetOperation::new(self.inner.clone()).set_name(name.into())
424 }
425
426 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
427 ///
428 /// [google.longrunning.Operations]: longrunning::client::Operations
429 pub fn delete_operation(
430 &self,
431 name: impl Into<std::string::String>,
432 ) -> super::builder::edge_container::DeleteOperation {
433 super::builder::edge_container::DeleteOperation::new(self.inner.clone())
434 .set_name(name.into())
435 }
436
437 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
438 ///
439 /// [google.longrunning.Operations]: longrunning::client::Operations
440 pub fn cancel_operation(
441 &self,
442 name: impl Into<std::string::String>,
443 ) -> super::builder::edge_container::CancelOperation {
444 super::builder::edge_container::CancelOperation::new(self.inner.clone())
445 .set_name(name.into())
446 }
447}