google_cloud_compute_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 Google Compute Engine API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_compute_v1::client::Images;
25/// let client = Images::builder().build().await?;
26/// // use `client` to make requests to the Google Compute Engine API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// Service for the `images` resource.
33///
34/// # Configuration
35///
36/// To configure `Images` use the `with_*` methods in the type returned
37/// by [builder()][Images::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://compute.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::images::ClientBuilder::with_endpoint
50/// [with_credentials()]: super::builder::images::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/// `Images` holds a connection pool internally, it is advised to
57/// create one and the reuse it. You do not need to wrap `Images` in
58/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
59/// already uses an `Arc` internally.
60#[cfg(feature = "images")]
61#[cfg_attr(docsrs, doc(cfg(feature = "images")))]
62#[derive(Clone, Debug)]
63pub struct Images {
64 inner: std::sync::Arc<dyn super::stub::dynamic::Images>,
65}
66
67#[cfg(feature = "images")]
68impl Images {
69 /// Returns a builder for [Images].
70 ///
71 /// ```
72 /// # tokio_test::block_on(async {
73 /// # use google_cloud_compute_v1::client::Images;
74 /// let client = Images::builder().build().await?;
75 /// # gax::client_builder::Result::<()>::Ok(()) });
76 /// ```
77 pub fn builder() -> super::builder::images::ClientBuilder {
78 gax::client_builder::internal::new_builder(super::builder::images::client::Factory)
79 }
80
81 /// Creates a new client from the provided stub.
82 ///
83 /// The most common case for calling this function is in tests mocking the
84 /// client's behavior.
85 pub fn from_stub<T>(stub: T) -> Self
86 where
87 T: super::stub::Images + 'static,
88 {
89 Self {
90 inner: std::sync::Arc::new(stub),
91 }
92 }
93
94 pub(crate) async fn new(
95 config: gaxi::options::ClientConfig,
96 ) -> gax::client_builder::Result<Self> {
97 let inner = Self::build_inner(config).await?;
98 Ok(Self { inner })
99 }
100
101 async fn build_inner(
102 conf: gaxi::options::ClientConfig,
103 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Images>> {
104 if gaxi::options::tracing_enabled(&conf) {
105 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
106 }
107 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
108 }
109
110 async fn build_transport(
111 conf: gaxi::options::ClientConfig,
112 ) -> gax::client_builder::Result<impl super::stub::Images> {
113 super::transport::Images::new(conf).await
114 }
115
116 async fn build_with_tracing(
117 conf: gaxi::options::ClientConfig,
118 ) -> gax::client_builder::Result<impl super::stub::Images> {
119 Self::build_transport(conf)
120 .await
121 .map(super::tracing::Images::new)
122 }
123
124 /// Deletes the specified image.
125 pub fn delete(&self) -> super::builder::images::Delete {
126 super::builder::images::Delete::new(self.inner.clone())
127 }
128
129 /// Sets the deprecation status of an image. If an empty request body is given, clears the deprecation status instead.
130 pub fn deprecate(&self) -> super::builder::images::Deprecate {
131 super::builder::images::Deprecate::new(self.inner.clone())
132 }
133
134 /// Returns the specified image.
135 pub fn get(&self) -> super::builder::images::Get {
136 super::builder::images::Get::new(self.inner.clone())
137 }
138
139 /// Returns the latest image that is part of an image family and is not deprecated. For more information on image families, see Public image families documentation.
140 pub fn get_from_family(&self) -> super::builder::images::GetFromFamily {
141 super::builder::images::GetFromFamily::new(self.inner.clone())
142 }
143
144 /// Gets the access control policy for a resource. May be empty if no such policy or resource exists.
145 pub fn get_iam_policy(&self) -> super::builder::images::GetIamPolicy {
146 super::builder::images::GetIamPolicy::new(self.inner.clone())
147 }
148
149 /// Creates an image in the specified project using the data included in the request.
150 pub fn insert(&self) -> super::builder::images::Insert {
151 super::builder::images::Insert::new(self.inner.clone())
152 }
153
154 /// Retrieves the list of custom images available to the specified project. Custom images are images you create that belong to your project. This method does not get any images that belong to other projects, including publicly-available images, like Debian 8. If you want to get a list of publicly-available images, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud.
155 pub fn list(&self) -> super::builder::images::List {
156 super::builder::images::List::new(self.inner.clone())
157 }
158
159 /// Patches the specified image with the data included in the request. Only the following fields can be modified: family, description, deprecation status.
160 pub fn patch(&self) -> super::builder::images::Patch {
161 super::builder::images::Patch::new(self.inner.clone())
162 }
163
164 /// Sets the access control policy on the specified resource. Replaces any existing policy.
165 pub fn set_iam_policy(&self) -> super::builder::images::SetIamPolicy {
166 super::builder::images::SetIamPolicy::new(self.inner.clone())
167 }
168
169 /// Sets the labels on an image. To learn more about labels, read the Labeling Resources documentation.
170 pub fn set_labels(&self) -> super::builder::images::SetLabels {
171 super::builder::images::SetLabels::new(self.inner.clone())
172 }
173
174 /// Returns permissions that a caller has on the specified resource.
175 pub fn test_iam_permissions(&self) -> super::builder::images::TestIamPermissions {
176 super::builder::images::TestIamPermissions::new(self.inner.clone())
177 }
178}
179
180/// Implements a client for the Google Compute Engine API.
181///
182/// # Example
183/// ```
184/// # tokio_test::block_on(async {
185/// # use google_cloud_compute_v1::client::InstanceGroupManagerResizeRequests;
186/// let client = InstanceGroupManagerResizeRequests::builder().build().await?;
187/// // use `client` to make requests to the Google Compute Engine API.
188/// # gax::client_builder::Result::<()>::Ok(()) });
189/// ```
190///
191/// # Service Description
192///
193/// Service for the `instanceGroupManagerResizeRequests` resource.
194///
195/// # Configuration
196///
197/// To configure `InstanceGroupManagerResizeRequests` use the `with_*` methods in the type returned
198/// by [builder()][InstanceGroupManagerResizeRequests::builder]. The default configuration should
199/// work for most applications. Common configuration changes include
200///
201/// * [with_endpoint()]: by default this client uses the global default endpoint
202/// (`https://compute.googleapis.com`). Applications using regional
203/// endpoints or running in restricted networks (e.g. a network configured
204// with [Private Google Access with VPC Service Controls]) may want to
205/// override this default.
206/// * [with_credentials()]: by default this client uses
207/// [Application Default Credentials]. Applications using custom
208/// authentication may need to override this default.
209///
210/// [with_endpoint()]: super::builder::instance_group_manager_resize_requests::ClientBuilder::with_endpoint
211/// [with_credentials()]: super::builder::instance_group_manager_resize_requests::ClientBuilder::credentials
212/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
213/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
214///
215/// # Pooling and Cloning
216///
217/// `InstanceGroupManagerResizeRequests` holds a connection pool internally, it is advised to
218/// create one and the reuse it. You do not need to wrap `InstanceGroupManagerResizeRequests` in
219/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
220/// already uses an `Arc` internally.
221#[cfg(feature = "instance-group-manager-resize-requests")]
222#[cfg_attr(docsrs, doc(cfg(feature = "instance-group-manager-resize-requests")))]
223#[derive(Clone, Debug)]
224pub struct InstanceGroupManagerResizeRequests {
225 inner: std::sync::Arc<dyn super::stub::dynamic::InstanceGroupManagerResizeRequests>,
226}
227
228#[cfg(feature = "instance-group-manager-resize-requests")]
229impl InstanceGroupManagerResizeRequests {
230 /// Returns a builder for [InstanceGroupManagerResizeRequests].
231 ///
232 /// ```
233 /// # tokio_test::block_on(async {
234 /// # use google_cloud_compute_v1::client::InstanceGroupManagerResizeRequests;
235 /// let client = InstanceGroupManagerResizeRequests::builder().build().await?;
236 /// # gax::client_builder::Result::<()>::Ok(()) });
237 /// ```
238 pub fn builder() -> super::builder::instance_group_manager_resize_requests::ClientBuilder {
239 gax::client_builder::internal::new_builder(
240 super::builder::instance_group_manager_resize_requests::client::Factory,
241 )
242 }
243
244 /// Creates a new client from the provided stub.
245 ///
246 /// The most common case for calling this function is in tests mocking the
247 /// client's behavior.
248 pub fn from_stub<T>(stub: T) -> Self
249 where
250 T: super::stub::InstanceGroupManagerResizeRequests + 'static,
251 {
252 Self {
253 inner: std::sync::Arc::new(stub),
254 }
255 }
256
257 pub(crate) async fn new(
258 config: gaxi::options::ClientConfig,
259 ) -> gax::client_builder::Result<Self> {
260 let inner = Self::build_inner(config).await?;
261 Ok(Self { inner })
262 }
263
264 async fn build_inner(
265 conf: gaxi::options::ClientConfig,
266 ) -> gax::client_builder::Result<
267 std::sync::Arc<dyn super::stub::dynamic::InstanceGroupManagerResizeRequests>,
268 > {
269 if gaxi::options::tracing_enabled(&conf) {
270 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
271 }
272 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
273 }
274
275 async fn build_transport(
276 conf: gaxi::options::ClientConfig,
277 ) -> gax::client_builder::Result<impl super::stub::InstanceGroupManagerResizeRequests> {
278 super::transport::InstanceGroupManagerResizeRequests::new(conf).await
279 }
280
281 async fn build_with_tracing(
282 conf: gaxi::options::ClientConfig,
283 ) -> gax::client_builder::Result<impl super::stub::InstanceGroupManagerResizeRequests> {
284 Self::build_transport(conf)
285 .await
286 .map(super::tracing::InstanceGroupManagerResizeRequests::new)
287 }
288
289 /// Cancels the specified resize request and removes it from the queue. Cancelled resize request does no longer wait for the resources to be provisioned. Cancel is only possible for requests that are accepted in the queue.
290 pub fn cancel(&self) -> super::builder::instance_group_manager_resize_requests::Cancel {
291 super::builder::instance_group_manager_resize_requests::Cancel::new(self.inner.clone())
292 }
293
294 /// Deletes the specified, inactive resize request. Requests that are still active cannot be deleted. Deleting request does not delete instances that were provisioned previously.
295 pub fn delete(&self) -> super::builder::instance_group_manager_resize_requests::Delete {
296 super::builder::instance_group_manager_resize_requests::Delete::new(self.inner.clone())
297 }
298
299 /// Returns all of the details about the specified resize request.
300 pub fn get(&self) -> super::builder::instance_group_manager_resize_requests::Get {
301 super::builder::instance_group_manager_resize_requests::Get::new(self.inner.clone())
302 }
303
304 /// Creates a new resize request that starts provisioning VMs immediately or queues VM creation.
305 pub fn insert(&self) -> super::builder::instance_group_manager_resize_requests::Insert {
306 super::builder::instance_group_manager_resize_requests::Insert::new(self.inner.clone())
307 }
308
309 /// Retrieves a list of resize requests that are contained in the managed instance group.
310 pub fn list(&self) -> super::builder::instance_group_manager_resize_requests::List {
311 super::builder::instance_group_manager_resize_requests::List::new(self.inner.clone())
312 }
313}
314
315/// Implements a client for the Google Compute Engine API.
316///
317/// # Example
318/// ```
319/// # tokio_test::block_on(async {
320/// # use google_cloud_compute_v1::client::InstanceGroupManagers;
321/// let client = InstanceGroupManagers::builder().build().await?;
322/// // use `client` to make requests to the Google Compute Engine API.
323/// # gax::client_builder::Result::<()>::Ok(()) });
324/// ```
325///
326/// # Service Description
327///
328/// Service for the `instanceGroupManagers` resource.
329///
330/// # Configuration
331///
332/// To configure `InstanceGroupManagers` use the `with_*` methods in the type returned
333/// by [builder()][InstanceGroupManagers::builder]. The default configuration should
334/// work for most applications. Common configuration changes include
335///
336/// * [with_endpoint()]: by default this client uses the global default endpoint
337/// (`https://compute.googleapis.com`). Applications using regional
338/// endpoints or running in restricted networks (e.g. a network configured
339// with [Private Google Access with VPC Service Controls]) may want to
340/// override this default.
341/// * [with_credentials()]: by default this client uses
342/// [Application Default Credentials]. Applications using custom
343/// authentication may need to override this default.
344///
345/// [with_endpoint()]: super::builder::instance_group_managers::ClientBuilder::with_endpoint
346/// [with_credentials()]: super::builder::instance_group_managers::ClientBuilder::credentials
347/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
348/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
349///
350/// # Pooling and Cloning
351///
352/// `InstanceGroupManagers` holds a connection pool internally, it is advised to
353/// create one and the reuse it. You do not need to wrap `InstanceGroupManagers` in
354/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
355/// already uses an `Arc` internally.
356#[cfg(feature = "instance-group-managers")]
357#[cfg_attr(docsrs, doc(cfg(feature = "instance-group-managers")))]
358#[derive(Clone, Debug)]
359pub struct InstanceGroupManagers {
360 inner: std::sync::Arc<dyn super::stub::dynamic::InstanceGroupManagers>,
361}
362
363#[cfg(feature = "instance-group-managers")]
364impl InstanceGroupManagers {
365 /// Returns a builder for [InstanceGroupManagers].
366 ///
367 /// ```
368 /// # tokio_test::block_on(async {
369 /// # use google_cloud_compute_v1::client::InstanceGroupManagers;
370 /// let client = InstanceGroupManagers::builder().build().await?;
371 /// # gax::client_builder::Result::<()>::Ok(()) });
372 /// ```
373 pub fn builder() -> super::builder::instance_group_managers::ClientBuilder {
374 gax::client_builder::internal::new_builder(
375 super::builder::instance_group_managers::client::Factory,
376 )
377 }
378
379 /// Creates a new client from the provided stub.
380 ///
381 /// The most common case for calling this function is in tests mocking the
382 /// client's behavior.
383 pub fn from_stub<T>(stub: T) -> Self
384 where
385 T: super::stub::InstanceGroupManagers + 'static,
386 {
387 Self {
388 inner: std::sync::Arc::new(stub),
389 }
390 }
391
392 pub(crate) async fn new(
393 config: gaxi::options::ClientConfig,
394 ) -> gax::client_builder::Result<Self> {
395 let inner = Self::build_inner(config).await?;
396 Ok(Self { inner })
397 }
398
399 async fn build_inner(
400 conf: gaxi::options::ClientConfig,
401 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::InstanceGroupManagers>>
402 {
403 if gaxi::options::tracing_enabled(&conf) {
404 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
405 }
406 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
407 }
408
409 async fn build_transport(
410 conf: gaxi::options::ClientConfig,
411 ) -> gax::client_builder::Result<impl super::stub::InstanceGroupManagers> {
412 super::transport::InstanceGroupManagers::new(conf).await
413 }
414
415 async fn build_with_tracing(
416 conf: gaxi::options::ClientConfig,
417 ) -> gax::client_builder::Result<impl super::stub::InstanceGroupManagers> {
418 Self::build_transport(conf)
419 .await
420 .map(super::tracing::InstanceGroupManagers::new)
421 }
422
423 /// Flags the specified instances to be removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.
424 pub fn abandon_instances(&self) -> super::builder::instance_group_managers::AbandonInstances {
425 super::builder::instance_group_managers::AbandonInstances::new(self.inner.clone())
426 }
427
428 /// Retrieves the list of managed instance groups and groups them by zone. To prevent failure, Google recommends that you set the `returnPartialSuccess` parameter to `true`.
429 pub fn aggregated_list(&self) -> super::builder::instance_group_managers::AggregatedList {
430 super::builder::instance_group_managers::AggregatedList::new(self.inner.clone())
431 }
432
433 /// Applies changes to selected instances on the managed instance group. This method can be used to apply new overrides and/or new versions.
434 pub fn apply_updates_to_instances(
435 &self,
436 ) -> super::builder::instance_group_managers::ApplyUpdatesToInstances {
437 super::builder::instance_group_managers::ApplyUpdatesToInstances::new(self.inner.clone())
438 }
439
440 /// Creates instances with per-instance configurations in this managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method.
441 pub fn create_instances(&self) -> super::builder::instance_group_managers::CreateInstances {
442 super::builder::instance_group_managers::CreateInstances::new(self.inner.clone())
443 }
444
445 /// Deletes the specified managed instance group and all of the instances in that group. Note that the instance group must not belong to a backend service. Read Deleting an instance group for more information.
446 pub fn delete(&self) -> super::builder::instance_group_managers::Delete {
447 super::builder::instance_group_managers::Delete::new(self.inner.clone())
448 }
449
450 /// Flags the specified instances in the managed instance group for immediate deletion. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. This operation is marked as DONE when the action is scheduled even if the instances are still being deleted. You must separately verify the status of the deleting action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.
451 pub fn delete_instances(&self) -> super::builder::instance_group_managers::DeleteInstances {
452 super::builder::instance_group_managers::DeleteInstances::new(self.inner.clone())
453 }
454
455 /// Deletes selected per-instance configurations for the managed instance group.
456 pub fn delete_per_instance_configs(
457 &self,
458 ) -> super::builder::instance_group_managers::DeletePerInstanceConfigs {
459 super::builder::instance_group_managers::DeletePerInstanceConfigs::new(self.inner.clone())
460 }
461
462 /// Returns all of the details about the specified managed instance group.
463 pub fn get(&self) -> super::builder::instance_group_managers::Get {
464 super::builder::instance_group_managers::Get::new(self.inner.clone())
465 }
466
467 /// Creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. A managed instance group can have up to 1000 VM instances per group. Please contact Cloud Support if you need an increase in this limit.
468 pub fn insert(&self) -> super::builder::instance_group_managers::Insert {
469 super::builder::instance_group_managers::Insert::new(self.inner.clone())
470 }
471
472 /// Retrieves a list of managed instance groups that are contained within the specified project and zone.
473 pub fn list(&self) -> super::builder::instance_group_managers::List {
474 super::builder::instance_group_managers::List::new(self.inner.clone())
475 }
476
477 /// Lists all errors thrown by actions on instances for a given managed instance group. The filter and orderBy query parameters are not supported.
478 pub fn list_errors(&self) -> super::builder::instance_group_managers::ListErrors {
479 super::builder::instance_group_managers::ListErrors::new(self.inner.clone())
480 }
481
482 /// Lists all of the instances in the managed instance group. Each instance in the list has a currentAction, which indicates the action that the managed instance group is performing on the instance. For example, if the group is still creating an instance, the currentAction is CREATING. If a previous action failed, the list displays the errors for that failed action. The orderBy query parameter is not supported. The `pageToken` query parameter is supported only if the group's `listManagedInstancesResults` field is set to `PAGINATED`.
483 pub fn list_managed_instances(
484 &self,
485 ) -> super::builder::instance_group_managers::ListManagedInstances {
486 super::builder::instance_group_managers::ListManagedInstances::new(self.inner.clone())
487 }
488
489 /// Lists all of the per-instance configurations defined for the managed instance group. The orderBy query parameter is not supported.
490 pub fn list_per_instance_configs(
491 &self,
492 ) -> super::builder::instance_group_managers::ListPerInstanceConfigs {
493 super::builder::instance_group_managers::ListPerInstanceConfigs::new(self.inner.clone())
494 }
495
496 /// Updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listManagedInstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. If you update your group to specify a new template or instance configuration, it's possible that your intended specification for each VM in the group is different from the current state of that VM. To learn how to apply an updated configuration to the VMs in a MIG, see Updating instances in a MIG.
497 pub fn patch(&self) -> super::builder::instance_group_managers::Patch {
498 super::builder::instance_group_managers::Patch::new(self.inner.clone())
499 }
500
501 /// Inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch.
502 pub fn patch_per_instance_configs(
503 &self,
504 ) -> super::builder::instance_group_managers::PatchPerInstanceConfigs {
505 super::builder::instance_group_managers::PatchPerInstanceConfigs::new(self.inner.clone())
506 }
507
508 /// Flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group's current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.
509 pub fn recreate_instances(&self) -> super::builder::instance_group_managers::RecreateInstances {
510 super::builder::instance_group_managers::RecreateInstances::new(self.inner.clone())
511 }
512
513 /// Resizes the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes instances. The resize operation is marked DONE when the resize actions are scheduled even if the group has not yet added or deleted any instances. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. When resizing down, the instance group arbitrarily chooses the order in which VMs are deleted. The group takes into account some VM attributes when making the selection including: + The status of the VM instance. + The health of the VM instance. + The instance template version the VM is based on. + For regional managed instance groups, the location of the VM instance. This list is subject to change. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted.
514 pub fn resize(&self) -> super::builder::instance_group_managers::Resize {
515 super::builder::instance_group_managers::Resize::new(self.inner.clone())
516 }
517
518 /// Flags the specified instances in the managed instance group to be resumed. This method increases the targetSize and decreases the targetSuspendedSize of the managed instance group by the number of instances that you resume. The resumeInstances operation is marked DONE if the resumeInstances request is successful. The underlying actions take additional time. You must separately verify the status of the RESUMING action with the listmanagedinstances method. In this request, you can only specify instances that are suspended. For example, if an instance was previously suspended using the suspendInstances method, it can be resumed using the resumeInstances method. If a health check is attached to the managed instance group, the specified instances will be verified as healthy after they are resumed. You can specify a maximum of 1000 instances with this method per request.
519 pub fn resume_instances(&self) -> super::builder::instance_group_managers::ResumeInstances {
520 super::builder::instance_group_managers::ResumeInstances::new(self.inner.clone())
521 }
522
523 /// Specifies the instance template to use when creating new instances in this group. The templates for existing instances in the group do not change unless you run recreateInstances, run applyUpdatesToInstances, or set the group's updatePolicy.type to PROACTIVE.
524 pub fn set_instance_template(
525 &self,
526 ) -> super::builder::instance_group_managers::SetInstanceTemplate {
527 super::builder::instance_group_managers::SetInstanceTemplate::new(self.inner.clone())
528 }
529
530 /// Modifies the target pools to which all instances in this managed instance group are assigned. The target pools automatically apply to all of the instances in the managed instance group. This operation is marked DONE when you make the request even if the instances have not yet been added to their target pools. The change might take some time to apply to all of the instances in the group depending on the size of the group.
531 pub fn set_target_pools(&self) -> super::builder::instance_group_managers::SetTargetPools {
532 super::builder::instance_group_managers::SetTargetPools::new(self.inner.clone())
533 }
534
535 /// Flags the specified instances in the managed instance group to be started. This method increases the targetSize and decreases the targetStoppedSize of the managed instance group by the number of instances that you start. The startInstances operation is marked DONE if the startInstances request is successful. The underlying actions take additional time. You must separately verify the status of the STARTING action with the listmanagedinstances method. In this request, you can only specify instances that are stopped. For example, if an instance was previously stopped using the stopInstances method, it can be started using the startInstances method. If a health check is attached to the managed instance group, the specified instances will be verified as healthy after they are started. You can specify a maximum of 1000 instances with this method per request.
536 pub fn start_instances(&self) -> super::builder::instance_group_managers::StartInstances {
537 super::builder::instance_group_managers::StartInstances::new(self.inner.clone())
538 }
539
540 /// Flags the specified instances in the managed instance group to be immediately stopped. You can only specify instances that are running in this request. This method reduces the targetSize and increases the targetStoppedSize of the managed instance group by the number of instances that you stop. The stopInstances operation is marked DONE if the stopInstances request is successful. The underlying actions take additional time. You must separately verify the status of the STOPPING action with the listmanagedinstances method. If the standbyPolicy.initialDelaySec field is set, the group delays stopping the instances until initialDelaySec have passed from instance.creationTimestamp (that is, when the instance was created). This delay gives your application time to set itself up and initialize on the instance. If more than initialDelaySec seconds have passed since instance.creationTimestamp when this method is called, there will be zero delay. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is stopped. Stopped instances can be started using the startInstances method. You can specify a maximum of 1000 instances with this method per request.
541 pub fn stop_instances(&self) -> super::builder::instance_group_managers::StopInstances {
542 super::builder::instance_group_managers::StopInstances::new(self.inner.clone())
543 }
544
545 /// Flags the specified instances in the managed instance group to be immediately suspended. You can only specify instances that are running in this request. This method reduces the targetSize and increases the targetSuspendedSize of the managed instance group by the number of instances that you suspend. The suspendInstances operation is marked DONE if the suspendInstances request is successful. The underlying actions take additional time. You must separately verify the status of the SUSPENDING action with the listmanagedinstances method. If the standbyPolicy.initialDelaySec field is set, the group delays suspension of the instances until initialDelaySec have passed from instance.creationTimestamp (that is, when the instance was created). This delay gives your application time to set itself up and initialize on the instance. If more than initialDelaySec seconds have passed since instance.creationTimestamp when this method is called, there will be zero delay. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is suspended. Suspended instances can be resumed using the resumeInstances method. You can specify a maximum of 1000 instances with this method per request.
546 pub fn suspend_instances(&self) -> super::builder::instance_group_managers::SuspendInstances {
547 super::builder::instance_group_managers::SuspendInstances::new(self.inner.clone())
548 }
549
550 /// Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch.
551 pub fn update_per_instance_configs(
552 &self,
553 ) -> super::builder::instance_group_managers::UpdatePerInstanceConfigs {
554 super::builder::instance_group_managers::UpdatePerInstanceConfigs::new(self.inner.clone())
555 }
556}
557
558/// Implements a client for the Google Compute Engine API.
559///
560/// # Example
561/// ```
562/// # tokio_test::block_on(async {
563/// # use google_cloud_compute_v1::client::InstanceGroups;
564/// let client = InstanceGroups::builder().build().await?;
565/// // use `client` to make requests to the Google Compute Engine API.
566/// # gax::client_builder::Result::<()>::Ok(()) });
567/// ```
568///
569/// # Service Description
570///
571/// Service for the `instanceGroups` resource.
572///
573/// # Configuration
574///
575/// To configure `InstanceGroups` use the `with_*` methods in the type returned
576/// by [builder()][InstanceGroups::builder]. The default configuration should
577/// work for most applications. Common configuration changes include
578///
579/// * [with_endpoint()]: by default this client uses the global default endpoint
580/// (`https://compute.googleapis.com`). Applications using regional
581/// endpoints or running in restricted networks (e.g. a network configured
582// with [Private Google Access with VPC Service Controls]) may want to
583/// override this default.
584/// * [with_credentials()]: by default this client uses
585/// [Application Default Credentials]. Applications using custom
586/// authentication may need to override this default.
587///
588/// [with_endpoint()]: super::builder::instance_groups::ClientBuilder::with_endpoint
589/// [with_credentials()]: super::builder::instance_groups::ClientBuilder::credentials
590/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
591/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
592///
593/// # Pooling and Cloning
594///
595/// `InstanceGroups` holds a connection pool internally, it is advised to
596/// create one and the reuse it. You do not need to wrap `InstanceGroups` in
597/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
598/// already uses an `Arc` internally.
599#[cfg(feature = "instance-groups")]
600#[cfg_attr(docsrs, doc(cfg(feature = "instance-groups")))]
601#[derive(Clone, Debug)]
602pub struct InstanceGroups {
603 inner: std::sync::Arc<dyn super::stub::dynamic::InstanceGroups>,
604}
605
606#[cfg(feature = "instance-groups")]
607impl InstanceGroups {
608 /// Returns a builder for [InstanceGroups].
609 ///
610 /// ```
611 /// # tokio_test::block_on(async {
612 /// # use google_cloud_compute_v1::client::InstanceGroups;
613 /// let client = InstanceGroups::builder().build().await?;
614 /// # gax::client_builder::Result::<()>::Ok(()) });
615 /// ```
616 pub fn builder() -> super::builder::instance_groups::ClientBuilder {
617 gax::client_builder::internal::new_builder(super::builder::instance_groups::client::Factory)
618 }
619
620 /// Creates a new client from the provided stub.
621 ///
622 /// The most common case for calling this function is in tests mocking the
623 /// client's behavior.
624 pub fn from_stub<T>(stub: T) -> Self
625 where
626 T: super::stub::InstanceGroups + 'static,
627 {
628 Self {
629 inner: std::sync::Arc::new(stub),
630 }
631 }
632
633 pub(crate) async fn new(
634 config: gaxi::options::ClientConfig,
635 ) -> gax::client_builder::Result<Self> {
636 let inner = Self::build_inner(config).await?;
637 Ok(Self { inner })
638 }
639
640 async fn build_inner(
641 conf: gaxi::options::ClientConfig,
642 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::InstanceGroups>> {
643 if gaxi::options::tracing_enabled(&conf) {
644 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
645 }
646 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
647 }
648
649 async fn build_transport(
650 conf: gaxi::options::ClientConfig,
651 ) -> gax::client_builder::Result<impl super::stub::InstanceGroups> {
652 super::transport::InstanceGroups::new(conf).await
653 }
654
655 async fn build_with_tracing(
656 conf: gaxi::options::ClientConfig,
657 ) -> gax::client_builder::Result<impl super::stub::InstanceGroups> {
658 Self::build_transport(conf)
659 .await
660 .map(super::tracing::InstanceGroups::new)
661 }
662
663 /// Adds a list of instances to the specified instance group. All of the instances in the instance group must be in the same network/subnetwork. Read Adding instances for more information.
664 pub fn add_instances(&self) -> super::builder::instance_groups::AddInstances {
665 super::builder::instance_groups::AddInstances::new(self.inner.clone())
666 }
667
668 /// Retrieves the list of instance groups and sorts them by zone. To prevent failure, Google recommends that you set the `returnPartialSuccess` parameter to `true`.
669 pub fn aggregated_list(&self) -> super::builder::instance_groups::AggregatedList {
670 super::builder::instance_groups::AggregatedList::new(self.inner.clone())
671 }
672
673 /// Deletes the specified instance group. The instances in the group are not deleted. Note that instance group must not belong to a backend service. Read Deleting an instance group for more information.
674 pub fn delete(&self) -> super::builder::instance_groups::Delete {
675 super::builder::instance_groups::Delete::new(self.inner.clone())
676 }
677
678 /// Returns the specified zonal instance group. Get a list of available zonal instance groups by making a list() request. For managed instance groups, use the instanceGroupManagers or regionInstanceGroupManagers methods instead.
679 pub fn get(&self) -> super::builder::instance_groups::Get {
680 super::builder::instance_groups::Get::new(self.inner.clone())
681 }
682
683 /// Creates an instance group in the specified project using the parameters that are included in the request.
684 pub fn insert(&self) -> super::builder::instance_groups::Insert {
685 super::builder::instance_groups::Insert::new(self.inner.clone())
686 }
687
688 /// Retrieves the list of zonal instance group resources contained within the specified zone. For managed instance groups, use the instanceGroupManagers or regionInstanceGroupManagers methods instead.
689 pub fn list(&self) -> super::builder::instance_groups::List {
690 super::builder::instance_groups::List::new(self.inner.clone())
691 }
692
693 /// Lists the instances in the specified instance group. The orderBy query parameter is not supported. The filter query parameter is supported, but only for expressions that use `eq` (equal) or `ne` (not equal) operators.
694 pub fn list_instances(&self) -> super::builder::instance_groups::ListInstances {
695 super::builder::instance_groups::ListInstances::new(self.inner.clone())
696 }
697
698 /// Removes one or more instances from the specified instance group, but does not delete those instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration before the VM instance is removed or deleted.
699 pub fn remove_instances(&self) -> super::builder::instance_groups::RemoveInstances {
700 super::builder::instance_groups::RemoveInstances::new(self.inner.clone())
701 }
702
703 /// Sets the named ports for the specified instance group.
704 pub fn set_named_ports(&self) -> super::builder::instance_groups::SetNamedPorts {
705 super::builder::instance_groups::SetNamedPorts::new(self.inner.clone())
706 }
707
708 /// Returns permissions that a caller has on the specified resource.
709 pub fn test_iam_permissions(&self) -> super::builder::instance_groups::TestIamPermissions {
710 super::builder::instance_groups::TestIamPermissions::new(self.inner.clone())
711 }
712}
713
714/// Implements a client for the Google Compute Engine API.
715///
716/// # Example
717/// ```
718/// # tokio_test::block_on(async {
719/// # use google_cloud_compute_v1::client::Instances;
720/// let client = Instances::builder().build().await?;
721/// // use `client` to make requests to the Google Compute Engine API.
722/// # gax::client_builder::Result::<()>::Ok(()) });
723/// ```
724///
725/// # Service Description
726///
727/// Service for the `instances` resource.
728///
729/// # Configuration
730///
731/// To configure `Instances` use the `with_*` methods in the type returned
732/// by [builder()][Instances::builder]. The default configuration should
733/// work for most applications. Common configuration changes include
734///
735/// * [with_endpoint()]: by default this client uses the global default endpoint
736/// (`https://compute.googleapis.com`). Applications using regional
737/// endpoints or running in restricted networks (e.g. a network configured
738// with [Private Google Access with VPC Service Controls]) may want to
739/// override this default.
740/// * [with_credentials()]: by default this client uses
741/// [Application Default Credentials]. Applications using custom
742/// authentication may need to override this default.
743///
744/// [with_endpoint()]: super::builder::instances::ClientBuilder::with_endpoint
745/// [with_credentials()]: super::builder::instances::ClientBuilder::credentials
746/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
747/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
748///
749/// # Pooling and Cloning
750///
751/// `Instances` holds a connection pool internally, it is advised to
752/// create one and the reuse it. You do not need to wrap `Instances` in
753/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
754/// already uses an `Arc` internally.
755#[cfg(feature = "instances")]
756#[cfg_attr(docsrs, doc(cfg(feature = "instances")))]
757#[derive(Clone, Debug)]
758pub struct Instances {
759 inner: std::sync::Arc<dyn super::stub::dynamic::Instances>,
760}
761
762#[cfg(feature = "instances")]
763impl Instances {
764 /// Returns a builder for [Instances].
765 ///
766 /// ```
767 /// # tokio_test::block_on(async {
768 /// # use google_cloud_compute_v1::client::Instances;
769 /// let client = Instances::builder().build().await?;
770 /// # gax::client_builder::Result::<()>::Ok(()) });
771 /// ```
772 pub fn builder() -> super::builder::instances::ClientBuilder {
773 gax::client_builder::internal::new_builder(super::builder::instances::client::Factory)
774 }
775
776 /// Creates a new client from the provided stub.
777 ///
778 /// The most common case for calling this function is in tests mocking the
779 /// client's behavior.
780 pub fn from_stub<T>(stub: T) -> Self
781 where
782 T: super::stub::Instances + 'static,
783 {
784 Self {
785 inner: std::sync::Arc::new(stub),
786 }
787 }
788
789 pub(crate) async fn new(
790 config: gaxi::options::ClientConfig,
791 ) -> gax::client_builder::Result<Self> {
792 let inner = Self::build_inner(config).await?;
793 Ok(Self { inner })
794 }
795
796 async fn build_inner(
797 conf: gaxi::options::ClientConfig,
798 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Instances>> {
799 if gaxi::options::tracing_enabled(&conf) {
800 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
801 }
802 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
803 }
804
805 async fn build_transport(
806 conf: gaxi::options::ClientConfig,
807 ) -> gax::client_builder::Result<impl super::stub::Instances> {
808 super::transport::Instances::new(conf).await
809 }
810
811 async fn build_with_tracing(
812 conf: gaxi::options::ClientConfig,
813 ) -> gax::client_builder::Result<impl super::stub::Instances> {
814 Self::build_transport(conf)
815 .await
816 .map(super::tracing::Instances::new)
817 }
818
819 /// Adds an access config to an instance's network interface.
820 pub fn add_access_config(&self) -> super::builder::instances::AddAccessConfig {
821 super::builder::instances::AddAccessConfig::new(self.inner.clone())
822 }
823
824 /// Adds one dynamic network interface to an active instance.
825 pub fn add_network_interface(&self) -> super::builder::instances::AddNetworkInterface {
826 super::builder::instances::AddNetworkInterface::new(self.inner.clone())
827 }
828
829 /// Adds existing resource policies to an instance. You can only add one policy right now which will be applied to this instance for scheduling live migrations.
830 pub fn add_resource_policies(&self) -> super::builder::instances::AddResourcePolicies {
831 super::builder::instances::AddResourcePolicies::new(self.inner.clone())
832 }
833
834 /// Retrieves an aggregated list of all of the instances in your project across all regions and zones. The performance of this method degrades when a filter is specified on a project that has a very large number of instances. To prevent failure, Google recommends that you set the `returnPartialSuccess` parameter to `true`.
835 pub fn aggregated_list(&self) -> super::builder::instances::AggregatedList {
836 super::builder::instances::AggregatedList::new(self.inner.clone())
837 }
838
839 /// Attaches an existing Disk resource to an instance. You must first create the disk before you can attach it. It is not possible to create and attach a disk at the same time. For more information, read Adding a persistent disk to your instance.
840 pub fn attach_disk(&self) -> super::builder::instances::AttachDisk {
841 super::builder::instances::AttachDisk::new(self.inner.clone())
842 }
843
844 /// Creates multiple instances. Count specifies the number of instances to create. For more information, see About bulk creation of VMs.
845 pub fn bulk_insert(&self) -> super::builder::instances::BulkInsert {
846 super::builder::instances::BulkInsert::new(self.inner.clone())
847 }
848
849 /// Deletes the specified Instance resource. For more information, see Deleting an instance.
850 pub fn delete(&self) -> super::builder::instances::Delete {
851 super::builder::instances::Delete::new(self.inner.clone())
852 }
853
854 /// Deletes an access config from an instance's network interface.
855 pub fn delete_access_config(&self) -> super::builder::instances::DeleteAccessConfig {
856 super::builder::instances::DeleteAccessConfig::new(self.inner.clone())
857 }
858
859 /// Deletes one dynamic network interface from an active instance. InstancesDeleteNetworkInterfaceRequest indicates: - instance from which to delete, using project+zone+resource_id fields; - dynamic network interface to be deleted, using network_interface_name field;
860 pub fn delete_network_interface(&self) -> super::builder::instances::DeleteNetworkInterface {
861 super::builder::instances::DeleteNetworkInterface::new(self.inner.clone())
862 }
863
864 /// Detaches a disk from an instance.
865 pub fn detach_disk(&self) -> super::builder::instances::DetachDisk {
866 super::builder::instances::DetachDisk::new(self.inner.clone())
867 }
868
869 /// Returns the specified Instance resource.
870 pub fn get(&self) -> super::builder::instances::Get {
871 super::builder::instances::Get::new(self.inner.clone())
872 }
873
874 /// Returns effective firewalls applied to an interface of the instance.
875 pub fn get_effective_firewalls(&self) -> super::builder::instances::GetEffectiveFirewalls {
876 super::builder::instances::GetEffectiveFirewalls::new(self.inner.clone())
877 }
878
879 /// Returns the specified guest attributes entry.
880 pub fn get_guest_attributes(&self) -> super::builder::instances::GetGuestAttributes {
881 super::builder::instances::GetGuestAttributes::new(self.inner.clone())
882 }
883
884 /// Gets the access control policy for a resource. May be empty if no such policy or resource exists.
885 pub fn get_iam_policy(&self) -> super::builder::instances::GetIamPolicy {
886 super::builder::instances::GetIamPolicy::new(self.inner.clone())
887 }
888
889 /// Returns the screenshot from the specified instance.
890 pub fn get_screenshot(&self) -> super::builder::instances::GetScreenshot {
891 super::builder::instances::GetScreenshot::new(self.inner.clone())
892 }
893
894 /// Returns the last 1 MB of serial port output from the specified instance.
895 pub fn get_serial_port_output(&self) -> super::builder::instances::GetSerialPortOutput {
896 super::builder::instances::GetSerialPortOutput::new(self.inner.clone())
897 }
898
899 /// Returns the Shielded Instance Identity of an instance
900 pub fn get_shielded_instance_identity(
901 &self,
902 ) -> super::builder::instances::GetShieldedInstanceIdentity {
903 super::builder::instances::GetShieldedInstanceIdentity::new(self.inner.clone())
904 }
905
906 /// Creates an instance resource in the specified project using the data included in the request.
907 pub fn insert(&self) -> super::builder::instances::Insert {
908 super::builder::instances::Insert::new(self.inner.clone())
909 }
910
911 /// Retrieves the list of instances contained within the specified zone.
912 pub fn list(&self) -> super::builder::instances::List {
913 super::builder::instances::List::new(self.inner.clone())
914 }
915
916 /// Retrieves a list of resources that refer to the VM instance specified in the request. For example, if the VM instance is part of a managed or unmanaged instance group, the referrers list includes the instance group. For more information, read Viewing referrers to VM instances.
917 pub fn list_referrers(&self) -> super::builder::instances::ListReferrers {
918 super::builder::instances::ListReferrers::new(self.inner.clone())
919 }
920
921 /// Perform a manual maintenance on the instance.
922 pub fn perform_maintenance(&self) -> super::builder::instances::PerformMaintenance {
923 super::builder::instances::PerformMaintenance::new(self.inner.clone())
924 }
925
926 /// Removes resource policies from an instance.
927 pub fn remove_resource_policies(&self) -> super::builder::instances::RemoveResourcePolicies {
928 super::builder::instances::RemoveResourcePolicies::new(self.inner.clone())
929 }
930
931 /// Mark the host as faulty and try to restart the instance on a new host.
932 pub fn report_host_as_faulty(&self) -> super::builder::instances::ReportHostAsFaulty {
933 super::builder::instances::ReportHostAsFaulty::new(self.inner.clone())
934 }
935
936 /// Performs a reset on the instance. This is a hard reset. The VM does not do a graceful shutdown. For more information, see Resetting an instance.
937 pub fn reset(&self) -> super::builder::instances::Reset {
938 super::builder::instances::Reset::new(self.inner.clone())
939 }
940
941 /// Resumes an instance that was suspended using the instances().suspend method.
942 pub fn resume(&self) -> super::builder::instances::Resume {
943 super::builder::instances::Resume::new(self.inner.clone())
944 }
945
946 /// Sends diagnostic interrupt to the instance.
947 pub fn send_diagnostic_interrupt(&self) -> super::builder::instances::SendDiagnosticInterrupt {
948 super::builder::instances::SendDiagnosticInterrupt::new(self.inner.clone())
949 }
950
951 /// Sets deletion protection on the instance.
952 pub fn set_deletion_protection(&self) -> super::builder::instances::SetDeletionProtection {
953 super::builder::instances::SetDeletionProtection::new(self.inner.clone())
954 }
955
956 /// Sets the auto-delete flag for a disk attached to an instance.
957 pub fn set_disk_auto_delete(&self) -> super::builder::instances::SetDiskAutoDelete {
958 super::builder::instances::SetDiskAutoDelete::new(self.inner.clone())
959 }
960
961 /// Sets the access control policy on the specified resource. Replaces any existing policy.
962 pub fn set_iam_policy(&self) -> super::builder::instances::SetIamPolicy {
963 super::builder::instances::SetIamPolicy::new(self.inner.clone())
964 }
965
966 /// Sets labels on an instance. To learn more about labels, read the Labeling Resources documentation.
967 pub fn set_labels(&self) -> super::builder::instances::SetLabels {
968 super::builder::instances::SetLabels::new(self.inner.clone())
969 }
970
971 /// Changes the number and/or type of accelerator for a stopped instance to the values specified in the request.
972 pub fn set_machine_resources(&self) -> super::builder::instances::SetMachineResources {
973 super::builder::instances::SetMachineResources::new(self.inner.clone())
974 }
975
976 /// Changes the machine type for a stopped instance to the machine type specified in the request.
977 pub fn set_machine_type(&self) -> super::builder::instances::SetMachineType {
978 super::builder::instances::SetMachineType::new(self.inner.clone())
979 }
980
981 /// Sets metadata for the specified instance to the data included in the request.
982 pub fn set_metadata(&self) -> super::builder::instances::SetMetadata {
983 super::builder::instances::SetMetadata::new(self.inner.clone())
984 }
985
986 /// Changes the minimum CPU platform that this instance should use. This method can only be called on a stopped instance. For more information, read Specifying a Minimum CPU Platform.
987 pub fn set_min_cpu_platform(&self) -> super::builder::instances::SetMinCpuPlatform {
988 super::builder::instances::SetMinCpuPlatform::new(self.inner.clone())
989 }
990
991 /// Sets name of an instance.
992 pub fn set_name(&self) -> super::builder::instances::SetName {
993 super::builder::instances::SetName::new(self.inner.clone())
994 }
995
996 /// Sets an instance's scheduling options. You can only call this method on a stopped instance, that is, a VM instance that is in a `TERMINATED` state. See Instance Life Cycle for more information on the possible instance states. For more information about setting scheduling options for a VM, see Set VM host maintenance policy.
997 pub fn set_scheduling(&self) -> super::builder::instances::SetScheduling {
998 super::builder::instances::SetScheduling::new(self.inner.clone())
999 }
1000
1001 /// Sets the Google Cloud Armor security policy for the specified instance. For more information, see Google Cloud Armor Overview
1002 pub fn set_security_policy(&self) -> super::builder::instances::SetSecurityPolicy {
1003 super::builder::instances::SetSecurityPolicy::new(self.inner.clone())
1004 }
1005
1006 /// Sets the service account on the instance. For more information, read Changing the service account and access scopes for an instance.
1007 pub fn set_service_account(&self) -> super::builder::instances::SetServiceAccount {
1008 super::builder::instances::SetServiceAccount::new(self.inner.clone())
1009 }
1010
1011 /// Sets the Shielded Instance integrity policy for an instance. You can only use this method on a running instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
1012 pub fn set_shielded_instance_integrity_policy(
1013 &self,
1014 ) -> super::builder::instances::SetShieldedInstanceIntegrityPolicy {
1015 super::builder::instances::SetShieldedInstanceIntegrityPolicy::new(self.inner.clone())
1016 }
1017
1018 /// Sets network tags for the specified instance to the data included in the request.
1019 pub fn set_tags(&self) -> super::builder::instances::SetTags {
1020 super::builder::instances::SetTags::new(self.inner.clone())
1021 }
1022
1023 /// Simulates a host maintenance event on a VM. For more information, see Simulate a host maintenance event.
1024 pub fn simulate_maintenance_event(
1025 &self,
1026 ) -> super::builder::instances::SimulateMaintenanceEvent {
1027 super::builder::instances::SimulateMaintenanceEvent::new(self.inner.clone())
1028 }
1029
1030 /// Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance.
1031 pub fn start(&self) -> super::builder::instances::Start {
1032 super::builder::instances::Start::new(self.inner.clone())
1033 }
1034
1035 /// Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance.
1036 pub fn start_with_encryption_key(&self) -> super::builder::instances::StartWithEncryptionKey {
1037 super::builder::instances::StartWithEncryptionKey::new(self.inner.clone())
1038 }
1039
1040 /// Stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. Stopped instances do not incur VM usage charges while they are stopped. However, resources that the VM is using, such as persistent disks and static IP addresses, will continue to be charged until they are deleted. For more information, see Stopping an instance.
1041 pub fn stop(&self) -> super::builder::instances::Stop {
1042 super::builder::instances::Stop::new(self.inner.clone())
1043 }
1044
1045 /// This method suspends a running instance, saving its state to persistent storage, and allows you to resume the instance at a later time. Suspended instances have no compute costs (cores or RAM), and incur only storage charges for the saved VM memory and localSSD data. Any charged resources the virtual machine was using, such as persistent disks and static IP addresses, will continue to be charged while the instance is suspended. For more information, see Suspending and resuming an instance.
1046 pub fn suspend(&self) -> super::builder::instances::Suspend {
1047 super::builder::instances::Suspend::new(self.inner.clone())
1048 }
1049
1050 /// Returns permissions that a caller has on the specified resource.
1051 pub fn test_iam_permissions(&self) -> super::builder::instances::TestIamPermissions {
1052 super::builder::instances::TestIamPermissions::new(self.inner.clone())
1053 }
1054
1055 /// Updates an instance only if the necessary resources are available. This method can update only a specific set of instance properties. See Updating a running instance for a list of updatable instance properties.
1056 pub fn update(&self) -> super::builder::instances::Update {
1057 super::builder::instances::Update::new(self.inner.clone())
1058 }
1059
1060 /// Updates the specified access config from an instance's network interface with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
1061 pub fn update_access_config(&self) -> super::builder::instances::UpdateAccessConfig {
1062 super::builder::instances::UpdateAccessConfig::new(self.inner.clone())
1063 }
1064
1065 /// Updates the Display config for a VM instance. You can only use this method on a stopped VM instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
1066 pub fn update_display_device(&self) -> super::builder::instances::UpdateDisplayDevice {
1067 super::builder::instances::UpdateDisplayDevice::new(self.inner.clone())
1068 }
1069
1070 /// Updates an instance's network interface. This method can only update an interface's alias IP range and attached network. See Modifying alias IP ranges for an existing instance for instructions on changing alias IP ranges. See Migrating a VM between networks for instructions on migrating an interface. This method follows PATCH semantics.
1071 pub fn update_network_interface(&self) -> super::builder::instances::UpdateNetworkInterface {
1072 super::builder::instances::UpdateNetworkInterface::new(self.inner.clone())
1073 }
1074
1075 /// Updates the Shielded Instance config for an instance. You can only use this method on a stopped instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
1076 pub fn update_shielded_instance_config(
1077 &self,
1078 ) -> super::builder::instances::UpdateShieldedInstanceConfig {
1079 super::builder::instances::UpdateShieldedInstanceConfig::new(self.inner.clone())
1080 }
1081}
1082
1083/// Implements a client for the Google Compute Engine API.
1084///
1085/// # Example
1086/// ```
1087/// # tokio_test::block_on(async {
1088/// # use google_cloud_compute_v1::client::MachineTypes;
1089/// let client = MachineTypes::builder().build().await?;
1090/// // use `client` to make requests to the Google Compute Engine API.
1091/// # gax::client_builder::Result::<()>::Ok(()) });
1092/// ```
1093///
1094/// # Service Description
1095///
1096/// Service for the `machineTypes` resource.
1097///
1098/// # Configuration
1099///
1100/// To configure `MachineTypes` use the `with_*` methods in the type returned
1101/// by [builder()][MachineTypes::builder]. The default configuration should
1102/// work for most applications. Common configuration changes include
1103///
1104/// * [with_endpoint()]: by default this client uses the global default endpoint
1105/// (`https://compute.googleapis.com`). Applications using regional
1106/// endpoints or running in restricted networks (e.g. a network configured
1107// with [Private Google Access with VPC Service Controls]) may want to
1108/// override this default.
1109/// * [with_credentials()]: by default this client uses
1110/// [Application Default Credentials]. Applications using custom
1111/// authentication may need to override this default.
1112///
1113/// [with_endpoint()]: super::builder::machine_types::ClientBuilder::with_endpoint
1114/// [with_credentials()]: super::builder::machine_types::ClientBuilder::credentials
1115/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1116/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1117///
1118/// # Pooling and Cloning
1119///
1120/// `MachineTypes` holds a connection pool internally, it is advised to
1121/// create one and the reuse it. You do not need to wrap `MachineTypes` in
1122/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1123/// already uses an `Arc` internally.
1124#[cfg(feature = "machine-types")]
1125#[cfg_attr(docsrs, doc(cfg(feature = "machine-types")))]
1126#[derive(Clone, Debug)]
1127pub struct MachineTypes {
1128 inner: std::sync::Arc<dyn super::stub::dynamic::MachineTypes>,
1129}
1130
1131#[cfg(feature = "machine-types")]
1132impl MachineTypes {
1133 /// Returns a builder for [MachineTypes].
1134 ///
1135 /// ```
1136 /// # tokio_test::block_on(async {
1137 /// # use google_cloud_compute_v1::client::MachineTypes;
1138 /// let client = MachineTypes::builder().build().await?;
1139 /// # gax::client_builder::Result::<()>::Ok(()) });
1140 /// ```
1141 pub fn builder() -> super::builder::machine_types::ClientBuilder {
1142 gax::client_builder::internal::new_builder(super::builder::machine_types::client::Factory)
1143 }
1144
1145 /// Creates a new client from the provided stub.
1146 ///
1147 /// The most common case for calling this function is in tests mocking the
1148 /// client's behavior.
1149 pub fn from_stub<T>(stub: T) -> Self
1150 where
1151 T: super::stub::MachineTypes + 'static,
1152 {
1153 Self {
1154 inner: std::sync::Arc::new(stub),
1155 }
1156 }
1157
1158 pub(crate) async fn new(
1159 config: gaxi::options::ClientConfig,
1160 ) -> gax::client_builder::Result<Self> {
1161 let inner = Self::build_inner(config).await?;
1162 Ok(Self { inner })
1163 }
1164
1165 async fn build_inner(
1166 conf: gaxi::options::ClientConfig,
1167 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::MachineTypes>> {
1168 if gaxi::options::tracing_enabled(&conf) {
1169 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1170 }
1171 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1172 }
1173
1174 async fn build_transport(
1175 conf: gaxi::options::ClientConfig,
1176 ) -> gax::client_builder::Result<impl super::stub::MachineTypes> {
1177 super::transport::MachineTypes::new(conf).await
1178 }
1179
1180 async fn build_with_tracing(
1181 conf: gaxi::options::ClientConfig,
1182 ) -> gax::client_builder::Result<impl super::stub::MachineTypes> {
1183 Self::build_transport(conf)
1184 .await
1185 .map(super::tracing::MachineTypes::new)
1186 }
1187
1188 /// Retrieves an aggregated list of machine types. To prevent failure, Google recommends that you set the `returnPartialSuccess` parameter to `true`.
1189 pub fn aggregated_list(&self) -> super::builder::machine_types::AggregatedList {
1190 super::builder::machine_types::AggregatedList::new(self.inner.clone())
1191 }
1192
1193 /// Returns the specified machine type.
1194 pub fn get(&self) -> super::builder::machine_types::Get {
1195 super::builder::machine_types::Get::new(self.inner.clone())
1196 }
1197
1198 /// Retrieves a list of machine types available to the specified project.
1199 pub fn list(&self) -> super::builder::machine_types::List {
1200 super::builder::machine_types::List::new(self.inner.clone())
1201 }
1202}
1203
1204/// Implements a client for the Google Compute Engine API.
1205///
1206/// # Example
1207/// ```
1208/// # tokio_test::block_on(async {
1209/// # use google_cloud_compute_v1::client::RegionInstanceGroupManagers;
1210/// let client = RegionInstanceGroupManagers::builder().build().await?;
1211/// // use `client` to make requests to the Google Compute Engine API.
1212/// # gax::client_builder::Result::<()>::Ok(()) });
1213/// ```
1214///
1215/// # Service Description
1216///
1217/// Service for the `regionInstanceGroupManagers` resource.
1218///
1219/// # Configuration
1220///
1221/// To configure `RegionInstanceGroupManagers` use the `with_*` methods in the type returned
1222/// by [builder()][RegionInstanceGroupManagers::builder]. The default configuration should
1223/// work for most applications. Common configuration changes include
1224///
1225/// * [with_endpoint()]: by default this client uses the global default endpoint
1226/// (`https://compute.googleapis.com`). Applications using regional
1227/// endpoints or running in restricted networks (e.g. a network configured
1228// with [Private Google Access with VPC Service Controls]) may want to
1229/// override this default.
1230/// * [with_credentials()]: by default this client uses
1231/// [Application Default Credentials]. Applications using custom
1232/// authentication may need to override this default.
1233///
1234/// [with_endpoint()]: super::builder::region_instance_group_managers::ClientBuilder::with_endpoint
1235/// [with_credentials()]: super::builder::region_instance_group_managers::ClientBuilder::credentials
1236/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1237/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1238///
1239/// # Pooling and Cloning
1240///
1241/// `RegionInstanceGroupManagers` holds a connection pool internally, it is advised to
1242/// create one and the reuse it. You do not need to wrap `RegionInstanceGroupManagers` in
1243/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1244/// already uses an `Arc` internally.
1245#[cfg(feature = "region-instance-group-managers")]
1246#[cfg_attr(docsrs, doc(cfg(feature = "region-instance-group-managers")))]
1247#[derive(Clone, Debug)]
1248pub struct RegionInstanceGroupManagers {
1249 inner: std::sync::Arc<dyn super::stub::dynamic::RegionInstanceGroupManagers>,
1250}
1251
1252#[cfg(feature = "region-instance-group-managers")]
1253impl RegionInstanceGroupManagers {
1254 /// Returns a builder for [RegionInstanceGroupManagers].
1255 ///
1256 /// ```
1257 /// # tokio_test::block_on(async {
1258 /// # use google_cloud_compute_v1::client::RegionInstanceGroupManagers;
1259 /// let client = RegionInstanceGroupManagers::builder().build().await?;
1260 /// # gax::client_builder::Result::<()>::Ok(()) });
1261 /// ```
1262 pub fn builder() -> super::builder::region_instance_group_managers::ClientBuilder {
1263 gax::client_builder::internal::new_builder(
1264 super::builder::region_instance_group_managers::client::Factory,
1265 )
1266 }
1267
1268 /// Creates a new client from the provided stub.
1269 ///
1270 /// The most common case for calling this function is in tests mocking the
1271 /// client's behavior.
1272 pub fn from_stub<T>(stub: T) -> Self
1273 where
1274 T: super::stub::RegionInstanceGroupManagers + 'static,
1275 {
1276 Self {
1277 inner: std::sync::Arc::new(stub),
1278 }
1279 }
1280
1281 pub(crate) async fn new(
1282 config: gaxi::options::ClientConfig,
1283 ) -> gax::client_builder::Result<Self> {
1284 let inner = Self::build_inner(config).await?;
1285 Ok(Self { inner })
1286 }
1287
1288 async fn build_inner(
1289 conf: gaxi::options::ClientConfig,
1290 ) -> gax::client_builder::Result<
1291 std::sync::Arc<dyn super::stub::dynamic::RegionInstanceGroupManagers>,
1292 > {
1293 if gaxi::options::tracing_enabled(&conf) {
1294 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1295 }
1296 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1297 }
1298
1299 async fn build_transport(
1300 conf: gaxi::options::ClientConfig,
1301 ) -> gax::client_builder::Result<impl super::stub::RegionInstanceGroupManagers> {
1302 super::transport::RegionInstanceGroupManagers::new(conf).await
1303 }
1304
1305 async fn build_with_tracing(
1306 conf: gaxi::options::ClientConfig,
1307 ) -> gax::client_builder::Result<impl super::stub::RegionInstanceGroupManagers> {
1308 Self::build_transport(conf)
1309 .await
1310 .map(super::tracing::RegionInstanceGroupManagers::new)
1311 }
1312
1313 /// Flags the specified instances to be immediately removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.
1314 pub fn abandon_instances(
1315 &self,
1316 ) -> super::builder::region_instance_group_managers::AbandonInstances {
1317 super::builder::region_instance_group_managers::AbandonInstances::new(self.inner.clone())
1318 }
1319
1320 /// Apply updates to selected instances the managed instance group.
1321 pub fn apply_updates_to_instances(
1322 &self,
1323 ) -> super::builder::region_instance_group_managers::ApplyUpdatesToInstances {
1324 super::builder::region_instance_group_managers::ApplyUpdatesToInstances::new(
1325 self.inner.clone(),
1326 )
1327 }
1328
1329 /// Creates instances with per-instance configurations in this regional managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method.
1330 pub fn create_instances(
1331 &self,
1332 ) -> super::builder::region_instance_group_managers::CreateInstances {
1333 super::builder::region_instance_group_managers::CreateInstances::new(self.inner.clone())
1334 }
1335
1336 /// Deletes the specified managed instance group and all of the instances in that group.
1337 pub fn delete(&self) -> super::builder::region_instance_group_managers::Delete {
1338 super::builder::region_instance_group_managers::Delete::new(self.inner.clone())
1339 }
1340
1341 /// Flags the specified instances in the managed instance group to be immediately deleted. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. The deleteInstances operation is marked DONE if the deleteInstances request is successful. The underlying actions take additional time. You must separately verify the status of the deleting action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.
1342 pub fn delete_instances(
1343 &self,
1344 ) -> super::builder::region_instance_group_managers::DeleteInstances {
1345 super::builder::region_instance_group_managers::DeleteInstances::new(self.inner.clone())
1346 }
1347
1348 /// Deletes selected per-instance configurations for the managed instance group.
1349 pub fn delete_per_instance_configs(
1350 &self,
1351 ) -> super::builder::region_instance_group_managers::DeletePerInstanceConfigs {
1352 super::builder::region_instance_group_managers::DeletePerInstanceConfigs::new(
1353 self.inner.clone(),
1354 )
1355 }
1356
1357 /// Returns all of the details about the specified managed instance group.
1358 pub fn get(&self) -> super::builder::region_instance_group_managers::Get {
1359 super::builder::region_instance_group_managers::Get::new(self.inner.clone())
1360 }
1361
1362 /// Creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. A regional managed instance group can contain up to 2000 instances.
1363 pub fn insert(&self) -> super::builder::region_instance_group_managers::Insert {
1364 super::builder::region_instance_group_managers::Insert::new(self.inner.clone())
1365 }
1366
1367 /// Retrieves the list of managed instance groups that are contained within the specified region.
1368 pub fn list(&self) -> super::builder::region_instance_group_managers::List {
1369 super::builder::region_instance_group_managers::List::new(self.inner.clone())
1370 }
1371
1372 /// Lists all errors thrown by actions on instances for a given regional managed instance group. The filter and orderBy query parameters are not supported.
1373 pub fn list_errors(&self) -> super::builder::region_instance_group_managers::ListErrors {
1374 super::builder::region_instance_group_managers::ListErrors::new(self.inner.clone())
1375 }
1376
1377 /// Lists the instances in the managed instance group and instances that are scheduled to be created. The list includes any current actions that the group has scheduled for its instances. The orderBy query parameter is not supported. The `pageToken` query parameter is supported only if the group's `listManagedInstancesResults` field is set to `PAGINATED`.
1378 pub fn list_managed_instances(
1379 &self,
1380 ) -> super::builder::region_instance_group_managers::ListManagedInstances {
1381 super::builder::region_instance_group_managers::ListManagedInstances::new(
1382 self.inner.clone(),
1383 )
1384 }
1385
1386 /// Lists all of the per-instance configurations defined for the managed instance group. The orderBy query parameter is not supported.
1387 pub fn list_per_instance_configs(
1388 &self,
1389 ) -> super::builder::region_instance_group_managers::ListPerInstanceConfigs {
1390 super::builder::region_instance_group_managers::ListPerInstanceConfigs::new(
1391 self.inner.clone(),
1392 )
1393 }
1394
1395 /// Updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listmanagedinstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. If you update your group to specify a new template or instance configuration, it's possible that your intended specification for each VM in the group is different from the current state of that VM. To learn how to apply an updated configuration to the VMs in a MIG, see Updating instances in a MIG.
1396 pub fn patch(&self) -> super::builder::region_instance_group_managers::Patch {
1397 super::builder::region_instance_group_managers::Patch::new(self.inner.clone())
1398 }
1399
1400 /// Inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch.
1401 pub fn patch_per_instance_configs(
1402 &self,
1403 ) -> super::builder::region_instance_group_managers::PatchPerInstanceConfigs {
1404 super::builder::region_instance_group_managers::PatchPerInstanceConfigs::new(
1405 self.inner.clone(),
1406 )
1407 }
1408
1409 /// Flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group's current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.
1410 pub fn recreate_instances(
1411 &self,
1412 ) -> super::builder::region_instance_group_managers::RecreateInstances {
1413 super::builder::region_instance_group_managers::RecreateInstances::new(self.inner.clone())
1414 }
1415
1416 /// Changes the intended size of the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes one or more instances. The resize operation is marked DONE if the resize request is successful. The underlying actions take additional time. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted.
1417 pub fn resize(&self) -> super::builder::region_instance_group_managers::Resize {
1418 super::builder::region_instance_group_managers::Resize::new(self.inner.clone())
1419 }
1420
1421 /// Flags the specified instances in the managed instance group to be resumed. This method increases the targetSize and decreases the targetSuspendedSize of the managed instance group by the number of instances that you resume. The resumeInstances operation is marked DONE if the resumeInstances request is successful. The underlying actions take additional time. You must separately verify the status of the RESUMING action with the listmanagedinstances method. In this request, you can only specify instances that are suspended. For example, if an instance was previously suspended using the suspendInstances method, it can be resumed using the resumeInstances method. If a health check is attached to the managed instance group, the specified instances will be verified as healthy after they are resumed. You can specify a maximum of 1000 instances with this method per request.
1422 pub fn resume_instances(
1423 &self,
1424 ) -> super::builder::region_instance_group_managers::ResumeInstances {
1425 super::builder::region_instance_group_managers::ResumeInstances::new(self.inner.clone())
1426 }
1427
1428 /// Sets the instance template to use when creating new instances or recreating instances in this group. Existing instances are not affected.
1429 pub fn set_instance_template(
1430 &self,
1431 ) -> super::builder::region_instance_group_managers::SetInstanceTemplate {
1432 super::builder::region_instance_group_managers::SetInstanceTemplate::new(self.inner.clone())
1433 }
1434
1435 /// Modifies the target pools to which all new instances in this group are assigned. Existing instances in the group are not affected.
1436 pub fn set_target_pools(
1437 &self,
1438 ) -> super::builder::region_instance_group_managers::SetTargetPools {
1439 super::builder::region_instance_group_managers::SetTargetPools::new(self.inner.clone())
1440 }
1441
1442 /// Flags the specified instances in the managed instance group to be started. This method increases the targetSize and decreases the targetStoppedSize of the managed instance group by the number of instances that you start. The startInstances operation is marked DONE if the startInstances request is successful. The underlying actions take additional time. You must separately verify the status of the STARTING action with the listmanagedinstances method. In this request, you can only specify instances that are stopped. For example, if an instance was previously stopped using the stopInstances method, it can be started using the startInstances method. If a health check is attached to the managed instance group, the specified instances will be verified as healthy after they are started. You can specify a maximum of 1000 instances with this method per request.
1443 pub fn start_instances(
1444 &self,
1445 ) -> super::builder::region_instance_group_managers::StartInstances {
1446 super::builder::region_instance_group_managers::StartInstances::new(self.inner.clone())
1447 }
1448
1449 /// Flags the specified instances in the managed instance group to be immediately stopped. You can only specify instances that are running in this request. This method reduces the targetSize and increases the targetStoppedSize of the managed instance group by the number of instances that you stop. The stopInstances operation is marked DONE if the stopInstances request is successful. The underlying actions take additional time. You must separately verify the status of the STOPPING action with the listmanagedinstances method. If the standbyPolicy.initialDelaySec field is set, the group delays stopping the instances until initialDelaySec have passed from instance.creationTimestamp (that is, when the instance was created). This delay gives your application time to set itself up and initialize on the instance. If more than initialDelaySec seconds have passed since instance.creationTimestamp when this method is called, there will be zero delay. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is stopped. Stopped instances can be started using the startInstances method. You can specify a maximum of 1000 instances with this method per request.
1450 pub fn stop_instances(&self) -> super::builder::region_instance_group_managers::StopInstances {
1451 super::builder::region_instance_group_managers::StopInstances::new(self.inner.clone())
1452 }
1453
1454 /// Flags the specified instances in the managed instance group to be immediately suspended. You can only specify instances that are running in this request. This method reduces the targetSize and increases the targetSuspendedSize of the managed instance group by the number of instances that you suspend. The suspendInstances operation is marked DONE if the suspendInstances request is successful. The underlying actions take additional time. You must separately verify the status of the SUSPENDING action with the listmanagedinstances method. If the standbyPolicy.initialDelaySec field is set, the group delays suspension of the instances until initialDelaySec have passed from instance.creationTimestamp (that is, when the instance was created). This delay gives your application time to set itself up and initialize on the instance. If more than initialDelaySec seconds have passed since instance.creationTimestamp when this method is called, there will be zero delay. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is suspended. Suspended instances can be resumed using the resumeInstances method. You can specify a maximum of 1000 instances with this method per request.
1455 pub fn suspend_instances(
1456 &self,
1457 ) -> super::builder::region_instance_group_managers::SuspendInstances {
1458 super::builder::region_instance_group_managers::SuspendInstances::new(self.inner.clone())
1459 }
1460
1461 /// Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch.
1462 pub fn update_per_instance_configs(
1463 &self,
1464 ) -> super::builder::region_instance_group_managers::UpdatePerInstanceConfigs {
1465 super::builder::region_instance_group_managers::UpdatePerInstanceConfigs::new(
1466 self.inner.clone(),
1467 )
1468 }
1469}
1470
1471/// Implements a client for the Google Compute Engine API.
1472///
1473/// # Example
1474/// ```
1475/// # tokio_test::block_on(async {
1476/// # use google_cloud_compute_v1::client::RegionInstanceGroups;
1477/// let client = RegionInstanceGroups::builder().build().await?;
1478/// // use `client` to make requests to the Google Compute Engine API.
1479/// # gax::client_builder::Result::<()>::Ok(()) });
1480/// ```
1481///
1482/// # Service Description
1483///
1484/// Service for the `regionInstanceGroups` resource.
1485///
1486/// # Configuration
1487///
1488/// To configure `RegionInstanceGroups` use the `with_*` methods in the type returned
1489/// by [builder()][RegionInstanceGroups::builder]. The default configuration should
1490/// work for most applications. Common configuration changes include
1491///
1492/// * [with_endpoint()]: by default this client uses the global default endpoint
1493/// (`https://compute.googleapis.com`). Applications using regional
1494/// endpoints or running in restricted networks (e.g. a network configured
1495// with [Private Google Access with VPC Service Controls]) may want to
1496/// override this default.
1497/// * [with_credentials()]: by default this client uses
1498/// [Application Default Credentials]. Applications using custom
1499/// authentication may need to override this default.
1500///
1501/// [with_endpoint()]: super::builder::region_instance_groups::ClientBuilder::with_endpoint
1502/// [with_credentials()]: super::builder::region_instance_groups::ClientBuilder::credentials
1503/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1504/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1505///
1506/// # Pooling and Cloning
1507///
1508/// `RegionInstanceGroups` holds a connection pool internally, it is advised to
1509/// create one and the reuse it. You do not need to wrap `RegionInstanceGroups` in
1510/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1511/// already uses an `Arc` internally.
1512#[cfg(feature = "region-instance-groups")]
1513#[cfg_attr(docsrs, doc(cfg(feature = "region-instance-groups")))]
1514#[derive(Clone, Debug)]
1515pub struct RegionInstanceGroups {
1516 inner: std::sync::Arc<dyn super::stub::dynamic::RegionInstanceGroups>,
1517}
1518
1519#[cfg(feature = "region-instance-groups")]
1520impl RegionInstanceGroups {
1521 /// Returns a builder for [RegionInstanceGroups].
1522 ///
1523 /// ```
1524 /// # tokio_test::block_on(async {
1525 /// # use google_cloud_compute_v1::client::RegionInstanceGroups;
1526 /// let client = RegionInstanceGroups::builder().build().await?;
1527 /// # gax::client_builder::Result::<()>::Ok(()) });
1528 /// ```
1529 pub fn builder() -> super::builder::region_instance_groups::ClientBuilder {
1530 gax::client_builder::internal::new_builder(
1531 super::builder::region_instance_groups::client::Factory,
1532 )
1533 }
1534
1535 /// Creates a new client from the provided stub.
1536 ///
1537 /// The most common case for calling this function is in tests mocking the
1538 /// client's behavior.
1539 pub fn from_stub<T>(stub: T) -> Self
1540 where
1541 T: super::stub::RegionInstanceGroups + 'static,
1542 {
1543 Self {
1544 inner: std::sync::Arc::new(stub),
1545 }
1546 }
1547
1548 pub(crate) async fn new(
1549 config: gaxi::options::ClientConfig,
1550 ) -> gax::client_builder::Result<Self> {
1551 let inner = Self::build_inner(config).await?;
1552 Ok(Self { inner })
1553 }
1554
1555 async fn build_inner(
1556 conf: gaxi::options::ClientConfig,
1557 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::RegionInstanceGroups>>
1558 {
1559 if gaxi::options::tracing_enabled(&conf) {
1560 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1561 }
1562 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1563 }
1564
1565 async fn build_transport(
1566 conf: gaxi::options::ClientConfig,
1567 ) -> gax::client_builder::Result<impl super::stub::RegionInstanceGroups> {
1568 super::transport::RegionInstanceGroups::new(conf).await
1569 }
1570
1571 async fn build_with_tracing(
1572 conf: gaxi::options::ClientConfig,
1573 ) -> gax::client_builder::Result<impl super::stub::RegionInstanceGroups> {
1574 Self::build_transport(conf)
1575 .await
1576 .map(super::tracing::RegionInstanceGroups::new)
1577 }
1578
1579 /// Returns the specified instance group resource.
1580 pub fn get(&self) -> super::builder::region_instance_groups::Get {
1581 super::builder::region_instance_groups::Get::new(self.inner.clone())
1582 }
1583
1584 /// Retrieves the list of instance group resources contained within the specified region.
1585 pub fn list(&self) -> super::builder::region_instance_groups::List {
1586 super::builder::region_instance_groups::List::new(self.inner.clone())
1587 }
1588
1589 /// Lists the instances in the specified instance group and displays information about the named ports. Depending on the specified options, this method can list all instances or only the instances that are running. The orderBy query parameter is not supported.
1590 pub fn list_instances(&self) -> super::builder::region_instance_groups::ListInstances {
1591 super::builder::region_instance_groups::ListInstances::new(self.inner.clone())
1592 }
1593
1594 /// Sets the named ports for the specified regional instance group.
1595 pub fn set_named_ports(&self) -> super::builder::region_instance_groups::SetNamedPorts {
1596 super::builder::region_instance_groups::SetNamedPorts::new(self.inner.clone())
1597 }
1598
1599 /// Returns permissions that a caller has on the specified resource.
1600 pub fn test_iam_permissions(
1601 &self,
1602 ) -> super::builder::region_instance_groups::TestIamPermissions {
1603 super::builder::region_instance_groups::TestIamPermissions::new(self.inner.clone())
1604 }
1605}
1606
1607/// Implements a client for the Google Compute Engine API.
1608///
1609/// # Example
1610/// ```
1611/// # tokio_test::block_on(async {
1612/// # use google_cloud_compute_v1::client::RegionInstanceTemplates;
1613/// let client = RegionInstanceTemplates::builder().build().await?;
1614/// // use `client` to make requests to the Google Compute Engine API.
1615/// # gax::client_builder::Result::<()>::Ok(()) });
1616/// ```
1617///
1618/// # Service Description
1619///
1620/// Service for the `regionInstanceTemplates` resource.
1621///
1622/// # Configuration
1623///
1624/// To configure `RegionInstanceTemplates` use the `with_*` methods in the type returned
1625/// by [builder()][RegionInstanceTemplates::builder]. The default configuration should
1626/// work for most applications. Common configuration changes include
1627///
1628/// * [with_endpoint()]: by default this client uses the global default endpoint
1629/// (`https://compute.googleapis.com`). Applications using regional
1630/// endpoints or running in restricted networks (e.g. a network configured
1631// with [Private Google Access with VPC Service Controls]) may want to
1632/// override this default.
1633/// * [with_credentials()]: by default this client uses
1634/// [Application Default Credentials]. Applications using custom
1635/// authentication may need to override this default.
1636///
1637/// [with_endpoint()]: super::builder::region_instance_templates::ClientBuilder::with_endpoint
1638/// [with_credentials()]: super::builder::region_instance_templates::ClientBuilder::credentials
1639/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1640/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1641///
1642/// # Pooling and Cloning
1643///
1644/// `RegionInstanceTemplates` holds a connection pool internally, it is advised to
1645/// create one and the reuse it. You do not need to wrap `RegionInstanceTemplates` in
1646/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1647/// already uses an `Arc` internally.
1648#[cfg(feature = "region-instance-templates")]
1649#[cfg_attr(docsrs, doc(cfg(feature = "region-instance-templates")))]
1650#[derive(Clone, Debug)]
1651pub struct RegionInstanceTemplates {
1652 inner: std::sync::Arc<dyn super::stub::dynamic::RegionInstanceTemplates>,
1653}
1654
1655#[cfg(feature = "region-instance-templates")]
1656impl RegionInstanceTemplates {
1657 /// Returns a builder for [RegionInstanceTemplates].
1658 ///
1659 /// ```
1660 /// # tokio_test::block_on(async {
1661 /// # use google_cloud_compute_v1::client::RegionInstanceTemplates;
1662 /// let client = RegionInstanceTemplates::builder().build().await?;
1663 /// # gax::client_builder::Result::<()>::Ok(()) });
1664 /// ```
1665 pub fn builder() -> super::builder::region_instance_templates::ClientBuilder {
1666 gax::client_builder::internal::new_builder(
1667 super::builder::region_instance_templates::client::Factory,
1668 )
1669 }
1670
1671 /// Creates a new client from the provided stub.
1672 ///
1673 /// The most common case for calling this function is in tests mocking the
1674 /// client's behavior.
1675 pub fn from_stub<T>(stub: T) -> Self
1676 where
1677 T: super::stub::RegionInstanceTemplates + 'static,
1678 {
1679 Self {
1680 inner: std::sync::Arc::new(stub),
1681 }
1682 }
1683
1684 pub(crate) async fn new(
1685 config: gaxi::options::ClientConfig,
1686 ) -> gax::client_builder::Result<Self> {
1687 let inner = Self::build_inner(config).await?;
1688 Ok(Self { inner })
1689 }
1690
1691 async fn build_inner(
1692 conf: gaxi::options::ClientConfig,
1693 ) -> gax::client_builder::Result<
1694 std::sync::Arc<dyn super::stub::dynamic::RegionInstanceTemplates>,
1695 > {
1696 if gaxi::options::tracing_enabled(&conf) {
1697 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1698 }
1699 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1700 }
1701
1702 async fn build_transport(
1703 conf: gaxi::options::ClientConfig,
1704 ) -> gax::client_builder::Result<impl super::stub::RegionInstanceTemplates> {
1705 super::transport::RegionInstanceTemplates::new(conf).await
1706 }
1707
1708 async fn build_with_tracing(
1709 conf: gaxi::options::ClientConfig,
1710 ) -> gax::client_builder::Result<impl super::stub::RegionInstanceTemplates> {
1711 Self::build_transport(conf)
1712 .await
1713 .map(super::tracing::RegionInstanceTemplates::new)
1714 }
1715
1716 /// Deletes the specified instance template. Deleting an instance template is permanent and cannot be undone.
1717 pub fn delete(&self) -> super::builder::region_instance_templates::Delete {
1718 super::builder::region_instance_templates::Delete::new(self.inner.clone())
1719 }
1720
1721 /// Returns the specified instance template.
1722 pub fn get(&self) -> super::builder::region_instance_templates::Get {
1723 super::builder::region_instance_templates::Get::new(self.inner.clone())
1724 }
1725
1726 /// Creates an instance template in the specified project and region using the global instance template whose URL is included in the request.
1727 pub fn insert(&self) -> super::builder::region_instance_templates::Insert {
1728 super::builder::region_instance_templates::Insert::new(self.inner.clone())
1729 }
1730
1731 /// Retrieves a list of instance templates that are contained within the specified project and region.
1732 pub fn list(&self) -> super::builder::region_instance_templates::List {
1733 super::builder::region_instance_templates::List::new(self.inner.clone())
1734 }
1735}
1736
1737/// Implements a client for the Google Compute Engine API.
1738///
1739/// # Example
1740/// ```
1741/// # tokio_test::block_on(async {
1742/// # use google_cloud_compute_v1::client::RegionInstances;
1743/// let client = RegionInstances::builder().build().await?;
1744/// // use `client` to make requests to the Google Compute Engine API.
1745/// # gax::client_builder::Result::<()>::Ok(()) });
1746/// ```
1747///
1748/// # Service Description
1749///
1750/// Service for the `regionInstances` resource.
1751///
1752/// # Configuration
1753///
1754/// To configure `RegionInstances` use the `with_*` methods in the type returned
1755/// by [builder()][RegionInstances::builder]. The default configuration should
1756/// work for most applications. Common configuration changes include
1757///
1758/// * [with_endpoint()]: by default this client uses the global default endpoint
1759/// (`https://compute.googleapis.com`). Applications using regional
1760/// endpoints or running in restricted networks (e.g. a network configured
1761// with [Private Google Access with VPC Service Controls]) may want to
1762/// override this default.
1763/// * [with_credentials()]: by default this client uses
1764/// [Application Default Credentials]. Applications using custom
1765/// authentication may need to override this default.
1766///
1767/// [with_endpoint()]: super::builder::region_instances::ClientBuilder::with_endpoint
1768/// [with_credentials()]: super::builder::region_instances::ClientBuilder::credentials
1769/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1770/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1771///
1772/// # Pooling and Cloning
1773///
1774/// `RegionInstances` holds a connection pool internally, it is advised to
1775/// create one and the reuse it. You do not need to wrap `RegionInstances` in
1776/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1777/// already uses an `Arc` internally.
1778#[cfg(feature = "region-instances")]
1779#[cfg_attr(docsrs, doc(cfg(feature = "region-instances")))]
1780#[derive(Clone, Debug)]
1781pub struct RegionInstances {
1782 inner: std::sync::Arc<dyn super::stub::dynamic::RegionInstances>,
1783}
1784
1785#[cfg(feature = "region-instances")]
1786impl RegionInstances {
1787 /// Returns a builder for [RegionInstances].
1788 ///
1789 /// ```
1790 /// # tokio_test::block_on(async {
1791 /// # use google_cloud_compute_v1::client::RegionInstances;
1792 /// let client = RegionInstances::builder().build().await?;
1793 /// # gax::client_builder::Result::<()>::Ok(()) });
1794 /// ```
1795 pub fn builder() -> super::builder::region_instances::ClientBuilder {
1796 gax::client_builder::internal::new_builder(
1797 super::builder::region_instances::client::Factory,
1798 )
1799 }
1800
1801 /// Creates a new client from the provided stub.
1802 ///
1803 /// The most common case for calling this function is in tests mocking the
1804 /// client's behavior.
1805 pub fn from_stub<T>(stub: T) -> Self
1806 where
1807 T: super::stub::RegionInstances + 'static,
1808 {
1809 Self {
1810 inner: std::sync::Arc::new(stub),
1811 }
1812 }
1813
1814 pub(crate) async fn new(
1815 config: gaxi::options::ClientConfig,
1816 ) -> gax::client_builder::Result<Self> {
1817 let inner = Self::build_inner(config).await?;
1818 Ok(Self { inner })
1819 }
1820
1821 async fn build_inner(
1822 conf: gaxi::options::ClientConfig,
1823 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::RegionInstances>>
1824 {
1825 if gaxi::options::tracing_enabled(&conf) {
1826 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1827 }
1828 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1829 }
1830
1831 async fn build_transport(
1832 conf: gaxi::options::ClientConfig,
1833 ) -> gax::client_builder::Result<impl super::stub::RegionInstances> {
1834 super::transport::RegionInstances::new(conf).await
1835 }
1836
1837 async fn build_with_tracing(
1838 conf: gaxi::options::ClientConfig,
1839 ) -> gax::client_builder::Result<impl super::stub::RegionInstances> {
1840 Self::build_transport(conf)
1841 .await
1842 .map(super::tracing::RegionInstances::new)
1843 }
1844
1845 /// Creates multiple instances in a given region. Count specifies the number of instances to create.
1846 pub fn bulk_insert(&self) -> super::builder::region_instances::BulkInsert {
1847 super::builder::region_instances::BulkInsert::new(self.inner.clone())
1848 }
1849}
1850
1851/// Implements a client for the Google Compute Engine API.
1852///
1853/// # Example
1854/// ```
1855/// # tokio_test::block_on(async {
1856/// # use google_cloud_compute_v1::client::RegionOperations;
1857/// let client = RegionOperations::builder().build().await?;
1858/// // use `client` to make requests to the Google Compute Engine API.
1859/// # gax::client_builder::Result::<()>::Ok(()) });
1860/// ```
1861///
1862/// # Service Description
1863///
1864/// Service for the `regionOperations` resource.
1865///
1866/// # Configuration
1867///
1868/// To configure `RegionOperations` use the `with_*` methods in the type returned
1869/// by [builder()][RegionOperations::builder]. The default configuration should
1870/// work for most applications. Common configuration changes include
1871///
1872/// * [with_endpoint()]: by default this client uses the global default endpoint
1873/// (`https://compute.googleapis.com`). Applications using regional
1874/// endpoints or running in restricted networks (e.g. a network configured
1875// with [Private Google Access with VPC Service Controls]) may want to
1876/// override this default.
1877/// * [with_credentials()]: by default this client uses
1878/// [Application Default Credentials]. Applications using custom
1879/// authentication may need to override this default.
1880///
1881/// [with_endpoint()]: super::builder::region_operations::ClientBuilder::with_endpoint
1882/// [with_credentials()]: super::builder::region_operations::ClientBuilder::credentials
1883/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1884/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1885///
1886/// # Pooling and Cloning
1887///
1888/// `RegionOperations` holds a connection pool internally, it is advised to
1889/// create one and the reuse it. You do not need to wrap `RegionOperations` in
1890/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1891/// already uses an `Arc` internally.
1892#[cfg(feature = "region-operations")]
1893#[cfg_attr(docsrs, doc(cfg(feature = "region-operations")))]
1894#[derive(Clone, Debug)]
1895pub struct RegionOperations {
1896 inner: std::sync::Arc<dyn super::stub::dynamic::RegionOperations>,
1897}
1898
1899#[cfg(feature = "region-operations")]
1900impl RegionOperations {
1901 /// Returns a builder for [RegionOperations].
1902 ///
1903 /// ```
1904 /// # tokio_test::block_on(async {
1905 /// # use google_cloud_compute_v1::client::RegionOperations;
1906 /// let client = RegionOperations::builder().build().await?;
1907 /// # gax::client_builder::Result::<()>::Ok(()) });
1908 /// ```
1909 pub fn builder() -> super::builder::region_operations::ClientBuilder {
1910 gax::client_builder::internal::new_builder(
1911 super::builder::region_operations::client::Factory,
1912 )
1913 }
1914
1915 /// Creates a new client from the provided stub.
1916 ///
1917 /// The most common case for calling this function is in tests mocking the
1918 /// client's behavior.
1919 pub fn from_stub<T>(stub: T) -> Self
1920 where
1921 T: super::stub::RegionOperations + 'static,
1922 {
1923 Self {
1924 inner: std::sync::Arc::new(stub),
1925 }
1926 }
1927
1928 pub(crate) async fn new(
1929 config: gaxi::options::ClientConfig,
1930 ) -> gax::client_builder::Result<Self> {
1931 let inner = Self::build_inner(config).await?;
1932 Ok(Self { inner })
1933 }
1934
1935 async fn build_inner(
1936 conf: gaxi::options::ClientConfig,
1937 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::RegionOperations>>
1938 {
1939 if gaxi::options::tracing_enabled(&conf) {
1940 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1941 }
1942 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1943 }
1944
1945 async fn build_transport(
1946 conf: gaxi::options::ClientConfig,
1947 ) -> gax::client_builder::Result<impl super::stub::RegionOperations> {
1948 super::transport::RegionOperations::new(conf).await
1949 }
1950
1951 async fn build_with_tracing(
1952 conf: gaxi::options::ClientConfig,
1953 ) -> gax::client_builder::Result<impl super::stub::RegionOperations> {
1954 Self::build_transport(conf)
1955 .await
1956 .map(super::tracing::RegionOperations::new)
1957 }
1958
1959 /// Deletes the specified region-specific Operations resource.
1960 pub fn delete(&self) -> super::builder::region_operations::Delete {
1961 super::builder::region_operations::Delete::new(self.inner.clone())
1962 }
1963
1964 /// Retrieves the specified region-specific Operations resource.
1965 pub fn get(&self) -> super::builder::region_operations::Get {
1966 super::builder::region_operations::Get::new(self.inner.clone())
1967 }
1968
1969 /// Retrieves a list of Operation resources contained within the specified region.
1970 pub fn list(&self) -> super::builder::region_operations::List {
1971 super::builder::region_operations::List::new(self.inner.clone())
1972 }
1973
1974 /// Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the `GET` method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`.
1975 pub fn wait(&self) -> super::builder::region_operations::Wait {
1976 super::builder::region_operations::Wait::new(self.inner.clone())
1977 }
1978}
1979
1980/// Implements a client for the Google Compute Engine API.
1981///
1982/// # Example
1983/// ```
1984/// # tokio_test::block_on(async {
1985/// # use google_cloud_compute_v1::client::ZoneOperations;
1986/// let client = ZoneOperations::builder().build().await?;
1987/// // use `client` to make requests to the Google Compute Engine API.
1988/// # gax::client_builder::Result::<()>::Ok(()) });
1989/// ```
1990///
1991/// # Service Description
1992///
1993/// Service for the `zoneOperations` resource.
1994///
1995/// # Configuration
1996///
1997/// To configure `ZoneOperations` use the `with_*` methods in the type returned
1998/// by [builder()][ZoneOperations::builder]. The default configuration should
1999/// work for most applications. Common configuration changes include
2000///
2001/// * [with_endpoint()]: by default this client uses the global default endpoint
2002/// (`https://compute.googleapis.com`). Applications using regional
2003/// endpoints or running in restricted networks (e.g. a network configured
2004// with [Private Google Access with VPC Service Controls]) may want to
2005/// override this default.
2006/// * [with_credentials()]: by default this client uses
2007/// [Application Default Credentials]. Applications using custom
2008/// authentication may need to override this default.
2009///
2010/// [with_endpoint()]: super::builder::zone_operations::ClientBuilder::with_endpoint
2011/// [with_credentials()]: super::builder::zone_operations::ClientBuilder::credentials
2012/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
2013/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
2014///
2015/// # Pooling and Cloning
2016///
2017/// `ZoneOperations` holds a connection pool internally, it is advised to
2018/// create one and the reuse it. You do not need to wrap `ZoneOperations` in
2019/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
2020/// already uses an `Arc` internally.
2021#[cfg(feature = "zone-operations")]
2022#[cfg_attr(docsrs, doc(cfg(feature = "zone-operations")))]
2023#[derive(Clone, Debug)]
2024pub struct ZoneOperations {
2025 inner: std::sync::Arc<dyn super::stub::dynamic::ZoneOperations>,
2026}
2027
2028#[cfg(feature = "zone-operations")]
2029impl ZoneOperations {
2030 /// Returns a builder for [ZoneOperations].
2031 ///
2032 /// ```
2033 /// # tokio_test::block_on(async {
2034 /// # use google_cloud_compute_v1::client::ZoneOperations;
2035 /// let client = ZoneOperations::builder().build().await?;
2036 /// # gax::client_builder::Result::<()>::Ok(()) });
2037 /// ```
2038 pub fn builder() -> super::builder::zone_operations::ClientBuilder {
2039 gax::client_builder::internal::new_builder(super::builder::zone_operations::client::Factory)
2040 }
2041
2042 /// Creates a new client from the provided stub.
2043 ///
2044 /// The most common case for calling this function is in tests mocking the
2045 /// client's behavior.
2046 pub fn from_stub<T>(stub: T) -> Self
2047 where
2048 T: super::stub::ZoneOperations + 'static,
2049 {
2050 Self {
2051 inner: std::sync::Arc::new(stub),
2052 }
2053 }
2054
2055 pub(crate) async fn new(
2056 config: gaxi::options::ClientConfig,
2057 ) -> gax::client_builder::Result<Self> {
2058 let inner = Self::build_inner(config).await?;
2059 Ok(Self { inner })
2060 }
2061
2062 async fn build_inner(
2063 conf: gaxi::options::ClientConfig,
2064 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::ZoneOperations>> {
2065 if gaxi::options::tracing_enabled(&conf) {
2066 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
2067 }
2068 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
2069 }
2070
2071 async fn build_transport(
2072 conf: gaxi::options::ClientConfig,
2073 ) -> gax::client_builder::Result<impl super::stub::ZoneOperations> {
2074 super::transport::ZoneOperations::new(conf).await
2075 }
2076
2077 async fn build_with_tracing(
2078 conf: gaxi::options::ClientConfig,
2079 ) -> gax::client_builder::Result<impl super::stub::ZoneOperations> {
2080 Self::build_transport(conf)
2081 .await
2082 .map(super::tracing::ZoneOperations::new)
2083 }
2084
2085 /// Deletes the specified zone-specific Operations resource.
2086 pub fn delete(&self) -> super::builder::zone_operations::Delete {
2087 super::builder::zone_operations::Delete::new(self.inner.clone())
2088 }
2089
2090 /// Retrieves the specified zone-specific Operations resource.
2091 pub fn get(&self) -> super::builder::zone_operations::Get {
2092 super::builder::zone_operations::Get::new(self.inner.clone())
2093 }
2094
2095 /// Retrieves a list of Operation resources contained within the specified zone.
2096 pub fn list(&self) -> super::builder::zone_operations::List {
2097 super::builder::zone_operations::List::new(self.inner.clone())
2098 }
2099
2100 /// Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method waits for no more than the 2 minutes and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`.
2101 pub fn wait(&self) -> super::builder::zone_operations::Wait {
2102 super::builder::zone_operations::Wait::new(self.inner.clone())
2103 }
2104}
2105
2106/// Implements a client for the Google Compute Engine API.
2107///
2108/// # Example
2109/// ```
2110/// # tokio_test::block_on(async {
2111/// # use google_cloud_compute_v1::client::Zones;
2112/// let client = Zones::builder().build().await?;
2113/// // use `client` to make requests to the Google Compute Engine API.
2114/// # gax::client_builder::Result::<()>::Ok(()) });
2115/// ```
2116///
2117/// # Service Description
2118///
2119/// Service for the `zones` resource.
2120///
2121/// # Configuration
2122///
2123/// To configure `Zones` use the `with_*` methods in the type returned
2124/// by [builder()][Zones::builder]. The default configuration should
2125/// work for most applications. Common configuration changes include
2126///
2127/// * [with_endpoint()]: by default this client uses the global default endpoint
2128/// (`https://compute.googleapis.com`). Applications using regional
2129/// endpoints or running in restricted networks (e.g. a network configured
2130// with [Private Google Access with VPC Service Controls]) may want to
2131/// override this default.
2132/// * [with_credentials()]: by default this client uses
2133/// [Application Default Credentials]. Applications using custom
2134/// authentication may need to override this default.
2135///
2136/// [with_endpoint()]: super::builder::zones::ClientBuilder::with_endpoint
2137/// [with_credentials()]: super::builder::zones::ClientBuilder::credentials
2138/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
2139/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
2140///
2141/// # Pooling and Cloning
2142///
2143/// `Zones` holds a connection pool internally, it is advised to
2144/// create one and the reuse it. You do not need to wrap `Zones` in
2145/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
2146/// already uses an `Arc` internally.
2147#[cfg(feature = "zones")]
2148#[cfg_attr(docsrs, doc(cfg(feature = "zones")))]
2149#[derive(Clone, Debug)]
2150pub struct Zones {
2151 inner: std::sync::Arc<dyn super::stub::dynamic::Zones>,
2152}
2153
2154#[cfg(feature = "zones")]
2155impl Zones {
2156 /// Returns a builder for [Zones].
2157 ///
2158 /// ```
2159 /// # tokio_test::block_on(async {
2160 /// # use google_cloud_compute_v1::client::Zones;
2161 /// let client = Zones::builder().build().await?;
2162 /// # gax::client_builder::Result::<()>::Ok(()) });
2163 /// ```
2164 pub fn builder() -> super::builder::zones::ClientBuilder {
2165 gax::client_builder::internal::new_builder(super::builder::zones::client::Factory)
2166 }
2167
2168 /// Creates a new client from the provided stub.
2169 ///
2170 /// The most common case for calling this function is in tests mocking the
2171 /// client's behavior.
2172 pub fn from_stub<T>(stub: T) -> Self
2173 where
2174 T: super::stub::Zones + 'static,
2175 {
2176 Self {
2177 inner: std::sync::Arc::new(stub),
2178 }
2179 }
2180
2181 pub(crate) async fn new(
2182 config: gaxi::options::ClientConfig,
2183 ) -> gax::client_builder::Result<Self> {
2184 let inner = Self::build_inner(config).await?;
2185 Ok(Self { inner })
2186 }
2187
2188 async fn build_inner(
2189 conf: gaxi::options::ClientConfig,
2190 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Zones>> {
2191 if gaxi::options::tracing_enabled(&conf) {
2192 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
2193 }
2194 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
2195 }
2196
2197 async fn build_transport(
2198 conf: gaxi::options::ClientConfig,
2199 ) -> gax::client_builder::Result<impl super::stub::Zones> {
2200 super::transport::Zones::new(conf).await
2201 }
2202
2203 async fn build_with_tracing(
2204 conf: gaxi::options::ClientConfig,
2205 ) -> gax::client_builder::Result<impl super::stub::Zones> {
2206 Self::build_transport(conf)
2207 .await
2208 .map(super::tracing::Zones::new)
2209 }
2210
2211 /// Returns the specified Zone resource.
2212 pub fn get(&self) -> super::builder::zones::Get {
2213 super::builder::zones::Get::new(self.inner.clone())
2214 }
2215
2216 /// Retrieves the list of Zone resources available to the specified project.
2217 pub fn list(&self) -> super::builder::zones::List {
2218 super::builder::zones::List::new(self.inner.clone())
2219 }
2220}