pub struct Instances { /* private fields */ }instances only.Expand description
Implements a client for the Google Compute Engine API.
§Example
let client = Instances::builder().build().await?;
// use `client` to make requests to the Google Compute Engine API.§Service Description
Service for the instances resource.
§Configuration
To configure Instances use the with_* methods in the type returned
by builder(). The default configuration should
work for most applications. Common configuration changes include
- with_endpoint(): by default this client uses the global default endpoint
(
https://compute.googleapis.com). Applications using regional endpoints or running in restricted networks (e.g. a network configured override this default. - with_credentials(): by default this client uses Application Default Credentials. Applications using custom authentication may need to override this default.
§Pooling and Cloning
Instances holds a connection pool internally, it is advised to
create one and the reuse it. You do not need to wrap Instances in
an Rc or Arc to reuse it, because it
already uses an Arc internally.
Implementations§
Source§impl Instances
impl Instances
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Returns a builder for Instances.
let client = Instances::builder().build().await?;Sourcepub fn from_stub<T>(stub: T) -> Selfwhere
T: Instances + 'static,
pub fn from_stub<T>(stub: T) -> Selfwhere
T: Instances + 'static,
Creates a new client from the provided stub.
The most common case for calling this function is in tests mocking the client’s behavior.
Sourcepub fn add_access_config(&self) -> AddAccessConfig
pub fn add_access_config(&self) -> AddAccessConfig
Adds an access config to an instance’s network interface.
Sourcepub fn add_network_interface(&self) -> AddNetworkInterface
pub fn add_network_interface(&self) -> AddNetworkInterface
Adds one dynamic network interface to an active instance.
Sourcepub fn add_resource_policies(&self) -> AddResourcePolicies
pub fn add_resource_policies(&self) -> AddResourcePolicies
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.
Sourcepub fn aggregated_list(&self) -> AggregatedList
pub fn aggregated_list(&self) -> AggregatedList
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.
Sourcepub fn attach_disk(&self) -> AttachDisk
pub fn attach_disk(&self) -> AttachDisk
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, readAdding a persistent disk to your instance.
Sourcepub fn bulk_insert(&self) -> BulkInsert
pub fn bulk_insert(&self) -> BulkInsert
Creates multiple instances. Count specifies the number of instances to create. For more information, seeAbout bulk creation of VMs.
Sourcepub fn delete(&self) -> Delete
pub fn delete(&self) -> Delete
Deletes the specified Instance resource. For more information, seeDeleting an instance.
Sourcepub fn delete_access_config(&self) -> DeleteAccessConfig
pub fn delete_access_config(&self) -> DeleteAccessConfig
Deletes an access config from an instance’s network interface.
Sourcepub fn delete_network_interface(&self) -> DeleteNetworkInterface
pub fn delete_network_interface(&self) -> DeleteNetworkInterface
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;
Sourcepub fn detach_disk(&self) -> DetachDisk
pub fn detach_disk(&self) -> DetachDisk
Detaches a disk from an instance.
Sourcepub fn get_effective_firewalls(&self) -> GetEffectiveFirewalls
pub fn get_effective_firewalls(&self) -> GetEffectiveFirewalls
Returns effective firewalls applied to an interface of the instance.
Sourcepub fn get_guest_attributes(&self) -> GetGuestAttributes
pub fn get_guest_attributes(&self) -> GetGuestAttributes
Returns the specified guest attributes entry.
Sourcepub fn get_iam_policy(&self) -> GetIamPolicy
pub fn get_iam_policy(&self) -> GetIamPolicy
Gets the access control policy for a resource. May be empty if no such policy or resource exists.
Sourcepub fn get_screenshot(&self) -> GetScreenshot
pub fn get_screenshot(&self) -> GetScreenshot
Returns the screenshot from the specified instance.
Sourcepub fn get_serial_port_output(&self) -> GetSerialPortOutput
pub fn get_serial_port_output(&self) -> GetSerialPortOutput
Returns the last 1 MB of serial port output from the specified instance.
Sourcepub fn get_shielded_instance_identity(&self) -> GetShieldedInstanceIdentity
pub fn get_shielded_instance_identity(&self) -> GetShieldedInstanceIdentity
Returns the Shielded Instance Identity of an instance
Sourcepub fn insert(&self) -> Insert
pub fn insert(&self) -> Insert
Creates an instance resource in the specified project using the data included in the request.
Sourcepub fn list(&self) -> List
pub fn list(&self) -> List
Retrieves the list of instances contained within the specified zone.
Sourcepub fn list_referrers(&self) -> ListReferrers
pub fn list_referrers(&self) -> ListReferrers
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, readViewing referrers to VM instances.
Sourcepub fn perform_maintenance(&self) -> PerformMaintenance
pub fn perform_maintenance(&self) -> PerformMaintenance
Perform a manual maintenance on the instance.
Sourcepub fn remove_resource_policies(&self) -> RemoveResourcePolicies
pub fn remove_resource_policies(&self) -> RemoveResourcePolicies
Removes resource policies from an instance.
Sourcepub fn report_host_as_faulty(&self) -> ReportHostAsFaulty
pub fn report_host_as_faulty(&self) -> ReportHostAsFaulty
Mark the host as faulty and try to restart the instance on a new host.
Sourcepub fn reset(&self) -> Reset
pub fn reset(&self) -> Reset
Performs a reset on the instance. This is a hard reset. The VM does not do a graceful shutdown. For more information, seeResetting an instance.
Sourcepub fn resume(&self) -> Resume
pub fn resume(&self) -> Resume
Resumes an instance that was suspended using theinstances().suspend method.
Sourcepub fn send_diagnostic_interrupt(&self) -> SendDiagnosticInterrupt
pub fn send_diagnostic_interrupt(&self) -> SendDiagnosticInterrupt
Sends diagnostic interrupt to the instance.
Sourcepub fn set_deletion_protection(&self) -> SetDeletionProtection
pub fn set_deletion_protection(&self) -> SetDeletionProtection
Sets deletion protection on the instance.
Sourcepub fn set_disk_auto_delete(&self) -> SetDiskAutoDelete
pub fn set_disk_auto_delete(&self) -> SetDiskAutoDelete
Sets the auto-delete flag for a disk attached to an instance.
Sourcepub fn set_iam_policy(&self) -> SetIamPolicy
pub fn set_iam_policy(&self) -> SetIamPolicy
Sets the access control policy on the specified resource. Replaces any existing policy.
Sourcepub fn set_labels(&self) -> SetLabels
pub fn set_labels(&self) -> SetLabels
Sets labels on an instance. To learn more about labels, read theLabeling Resources documentation.
Sourcepub fn set_machine_resources(&self) -> SetMachineResources
pub fn set_machine_resources(&self) -> SetMachineResources
Changes the number and/or type of accelerator for a stopped instance to the values specified in the request.
Sourcepub fn set_machine_type(&self) -> SetMachineType
pub fn set_machine_type(&self) -> SetMachineType
Changes the machine type for a stopped instance to the machine type specified in the request.
Sourcepub fn set_metadata(&self) -> SetMetadata
pub fn set_metadata(&self) -> SetMetadata
Sets metadata for the specified instance to the data included in the request.
Sourcepub fn set_min_cpu_platform(&self) -> SetMinCpuPlatform
pub fn set_min_cpu_platform(&self) -> SetMinCpuPlatform
Changes the minimum CPU platform that this instance should use. This method can only be called on a stopped instance. For more information, readSpecifying a Minimum CPU Platform.
Sourcepub fn set_scheduling(&self) -> SetScheduling
pub fn set_scheduling(&self) -> SetScheduling
Sets an instance’s scheduling options. You can only call this method on astopped instance,
that is, a VM instance that is in a TERMINATED state. SeeInstance Life
Cycle for more information on the possible instance states.
For more information about setting scheduling options for a VM, seeSet
VM host maintenance policy.
Sourcepub fn set_security_policy(&self) -> SetSecurityPolicy
pub fn set_security_policy(&self) -> SetSecurityPolicy
Sets the Google Cloud Armor security policy for the specified instance. For more information, seeGoogle Cloud Armor Overview
Sourcepub fn set_service_account(&self) -> SetServiceAccount
pub fn set_service_account(&self) -> SetServiceAccount
Sets the service account on the instance. For more information, readChanging the service account and access scopes for an instance.
Sourcepub fn set_shielded_instance_integrity_policy(
&self,
) -> SetShieldedInstanceIntegrityPolicy
pub fn set_shielded_instance_integrity_policy( &self, ) -> SetShieldedInstanceIntegrityPolicy
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.
Sets network tags for the specified instance to the data included in the request.
Sourcepub fn simulate_maintenance_event(&self) -> SimulateMaintenanceEvent
pub fn simulate_maintenance_event(&self) -> SimulateMaintenanceEvent
Simulates a host maintenance event on a VM. For more information, see Simulate a host maintenance event.
Sourcepub fn start(&self) -> Start
pub fn start(&self) -> Start
Starts an instance that was stopped using theinstances().stop method. For more information, seeRestart an instance.
Sourcepub fn start_with_encryption_key(&self) -> StartWithEncryptionKey
pub fn start_with_encryption_key(&self) -> StartWithEncryptionKey
Starts an instance that was stopped using theinstances().stop method. For more information, seeRestart an instance.
Sourcepub fn stop(&self) -> Stop
pub fn stop(&self) -> Stop
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, seeStopping an instance.
Sourcepub fn suspend(&self) -> Suspend
pub fn suspend(&self) -> Suspend
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.
Sourcepub fn test_iam_permissions(&self) -> TestIamPermissions
pub fn test_iam_permissions(&self) -> TestIamPermissions
Returns permissions that a caller has on the specified resource.
Sourcepub fn update(&self) -> Update
pub fn update(&self) -> Update
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.
Sourcepub fn update_access_config(&self) -> UpdateAccessConfig
pub fn update_access_config(&self) -> UpdateAccessConfig
Updates the specified access config from an instance’s network interface with the data included in the request. This method supportsPATCH semantics and uses theJSON merge patch format and processing rules.
Sourcepub fn update_display_device(&self) -> UpdateDisplayDevice
pub fn update_display_device(&self) -> UpdateDisplayDevice
Updates the Display config for a VM instance. You can only use this method on a stopped VM instance. This method supportsPATCH semantics and uses theJSON merge patch format and processing rules.
Sourcepub fn update_network_interface(&self) -> UpdateNetworkInterface
pub fn update_network_interface(&self) -> UpdateNetworkInterface
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.
Sourcepub fn update_shielded_instance_config(&self) -> UpdateShieldedInstanceConfig
pub fn update_shielded_instance_config(&self) -> UpdateShieldedInstanceConfig
Updates the Shielded Instance config for an instance. You can only use this method on a stopped instance. This method supportsPATCH semantics and uses theJSON merge patch format and processing rules.
Sourcepub fn get_operation(&self) -> GetOperation
pub fn get_operation(&self) -> GetOperation
Retrieves the specified zone-specific Operations resource.