Skip to main content

Instances

Struct Instances 

Source
pub struct Instances { /* private fields */ }
Available on crate feature 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

Source

pub fn builder() -> ClientBuilder

Returns a builder for Instances.

let client = Instances::builder().build().await?;
Source

pub fn from_stub<T>(stub: T) -> Self
where 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.

Source

pub fn add_access_config(&self) -> AddAccessConfig

Adds an access config to an instance’s network interface.

Source

pub fn add_network_interface(&self) -> AddNetworkInterface

Adds one dynamic network interface to an active instance.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn delete(&self) -> Delete

Deletes the specified Instance resource. For more information, seeDeleting an instance.

Source

pub fn delete_access_config(&self) -> DeleteAccessConfig

Deletes an access config from an instance’s network interface.

Source

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;
Source

pub fn detach_disk(&self) -> DetachDisk

Detaches a disk from an instance.

Source

pub fn get(&self) -> Get

Returns the specified Instance resource.

Source

pub fn get_effective_firewalls(&self) -> GetEffectiveFirewalls

Returns effective firewalls applied to an interface of the instance.

Source

pub fn get_guest_attributes(&self) -> GetGuestAttributes

Returns the specified guest attributes entry.

Source

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.

Source

pub fn get_screenshot(&self) -> GetScreenshot

Returns the screenshot from the specified instance.

Source

pub fn get_serial_port_output(&self) -> GetSerialPortOutput

Returns the last 1 MB of serial port output from the specified instance.

Source

pub fn get_shielded_instance_identity(&self) -> GetShieldedInstanceIdentity

Returns the Shielded Instance Identity of an instance

Source

pub fn insert(&self) -> Insert

Creates an instance resource in the specified project using the data included in the request.

Source

pub fn list(&self) -> List

Retrieves the list of instances contained within the specified zone.

Source

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.

Source

pub fn perform_maintenance(&self) -> PerformMaintenance

Perform a manual maintenance on the instance.

Source

pub fn remove_resource_policies(&self) -> RemoveResourcePolicies

Removes resource policies from an instance.

Source

pub fn report_host_as_faulty(&self) -> ReportHostAsFaulty

Mark the host as faulty and try to restart the instance on a new host.

Source

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.

Source

pub fn resume(&self) -> Resume

Resumes an instance that was suspended using theinstances().suspend method.

Source

pub fn send_diagnostic_interrupt(&self) -> SendDiagnosticInterrupt

Sends diagnostic interrupt to the instance.

Source

pub fn set_deletion_protection(&self) -> SetDeletionProtection

Sets deletion protection on the instance.

Source

pub fn set_disk_auto_delete(&self) -> SetDiskAutoDelete

Sets the auto-delete flag for a disk attached to an instance.

Source

pub fn set_iam_policy(&self) -> SetIamPolicy

Sets the access control policy on the specified resource. Replaces any existing policy.

Source

pub fn set_labels(&self) -> SetLabels

Sets labels on an instance. To learn more about labels, read theLabeling Resources documentation.

Source

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.

Source

pub fn set_machine_type(&self) -> SetMachineType

Changes the machine type for a stopped instance to the machine type specified in the request.

Source

pub fn set_metadata(&self) -> SetMetadata

Sets metadata for the specified instance to the data included in the request.

Source

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.

Source

pub fn set_name(&self) -> SetName

Sets name of an instance.

Source

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.

Source

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

Source

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.

Source

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.

Source

pub fn set_tags(&self) -> SetTags

Sets network tags for the specified instance to the data included in the request.

Source

pub fn simulate_maintenance_event(&self) -> SimulateMaintenanceEvent

Simulates a host maintenance event on a VM. For more information, see Simulate a host maintenance event.

Source

pub fn start(&self) -> Start

Starts an instance that was stopped using theinstances().stop method. For more information, seeRestart an instance.

Source

pub fn start_with_encryption_key(&self) -> StartWithEncryptionKey

Starts an instance that was stopped using theinstances().stop method. For more information, seeRestart an instance.

Source

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.

Source

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.

Source

pub fn test_iam_permissions(&self) -> TestIamPermissions

Returns permissions that a caller has on the specified resource.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn get_operation(&self) -> GetOperation

Retrieves the specified zone-specific Operations resource.

Trait Implementations§

Source§

impl Clone for Instances

Source§

fn clone(&self) -> Instances

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Instances

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more