Compute V1 Client - Class AttachedDisk (1.17.0)

Reference documentation and code samples for the Compute V1 Client class AttachedDisk.

An instance-attached disk resource.

Generated from protobuf message google.cloud.compute.v1.AttachedDisk

Namespace

Google \ Cloud \ Compute \ V1

Methods

__construct

Constructor.

Parameters
Name Description
data array

Optional. Data for populating the Message object.

↳ architecture string

[Output Only] The architecture of the attached disk. Valid values are ARM64 or X86_64. Check the Architecture enum for the list of possible values.

↳ auto_delete bool

Specifies whether the disk will be auto-deleted when the instance is deleted (but not when the disk is detached from the instance).

↳ boot bool

Indicates that this is a boot disk. The virtual machine will use the first partition of the disk for its root filesystem.

↳ device_name string

Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* tree of a Linux operating system running within the instance. This name can be used to reference the device for mounting, resizing, and so on, from within the instance. If not specified, the server chooses a default device name to apply to this disk, in the form persistent-disk-x, where x is a number assigned by Google Compute Engine. This field is only applicable for persistent disks.

↳ disk_encryption_key Google\Cloud\Compute\V1\CustomerEncryptionKey

Encrypts or decrypts a disk using a customer-supplied encryption key. If you are creating a new disk, this field encrypts the new disk using an encryption key that you provide. If you are attaching an existing disk that is already encrypted, this field decrypts the disk using the customer-supplied encryption key. If you encrypt a disk using a customer-supplied key, you must provide the same key again when you attempt to use this resource at a later time. For example, you must provide the key when you create a snapshot or an image from the disk or when you attach the disk to a virtual machine instance. If you do not provide an encryption key, then the disk will be encrypted using an automatically generated key and you do not need to provide a key to use the disk later. Instance templates do not store customer-supplied encryption keys, so you cannot use your own keys to encrypt disks in a managed instance group.

↳ disk_size_gb int|string

The size of the disk in GB.

↳ force_attach bool

[Input Only] Whether to force attach the regional disk even if it's currently attached to another instance. If you try to force attach a zonal disk to an instance, you will receive an error.

↳ guest_os_features array<Google\Cloud\Compute\V1\GuestOsFeature>

A list of features to enable on the guest operating system. Applicable only for bootable images. Read Enabling guest operating system features to see a list of available options.

↳ index int

[Output Only] A zero-based index to this disk, where 0 is reserved for the boot disk. If you have many disks attached to an instance, each disk would have a unique index number.

↳ initialize_params Google\Cloud\Compute\V1\AttachedDiskInitializeParams

[Input Only] Specifies the parameters for a new disk that will be created alongside the new instance. Use initialization parameters to create boot disks or local SSDs attached to the new instance. This property is mutually exclusive with the source property; you can only define one or the other, but not both.

↳ interface string

Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. For most machine types, the default is SCSI. Local SSDs can use either NVME or SCSI. In certain configurations, persistent disks can use NVMe. For more information, see About persistent disks. Check the Interface enum for the list of possible values.

↳ kind string

[Output Only] Type of the resource. Always compute#attachedDisk for attached disks.

↳ licenses array

[Output Only] Any valid publicly visible licenses.

↳ mode string

The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode. Check the Mode enum for the list of possible values.

↳ saved_state string

For LocalSSD disks on VM Instances in STOPPED or SUSPENDED state, this field is set to PRESERVED if the LocalSSD data has been saved to a persistent location by customer request. (see the discard_local_ssd option on Stop/Suspend). Read-only in the api. Check the SavedState enum for the list of possible values.

↳ shielded_instance_initial_state Google\Cloud\Compute\V1\InitialStateConfig

[Output Only] shielded vm initial state stored on disk

↳ source string

Specifies a valid partial or full URL to an existing Persistent Disk resource. When creating a new instance, one of initializeParams.sourceImage or initializeParams.sourceSnapshot or disks.source is required except for local SSD. If desired, you can also attach existing non-root persistent disks using this property. This field is only applicable for persistent disks. Note that for InstanceTemplate, specify the disk name for zonal disk, and the URL for regional disk.

↳ type string

Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, the default is PERSISTENT. Check the Type enum for the list of possible values.

getArchitecture

[Output Only] The architecture of the attached disk. Valid values are ARM64 or X86_64.

Check the Architecture enum for the list of possible values.

Returns
Type Description
string

hasArchitecture

clearArchitecture

setArchitecture

[Output Only] The architecture of the attached disk. Valid values are ARM64 or X86_64.

Check the Architecture enum for the list of possible values.

Parameter
Name Description
var string
Returns
Type Description
$this

getAutoDelete

Specifies whether the disk will be auto-deleted when the instance is deleted (but not when the disk is detached from the instance).

Returns
Type Description
bool

hasAutoDelete

clearAutoDelete

setAutoDelete

Specifies whether the disk will be auto-deleted when the instance is deleted (but not when the disk is detached from the instance).

Parameter
Name Description
var bool
Returns
Type Description
$this

getBoot

Indicates that this is a boot disk. The virtual machine will use the first partition of the disk for its root filesystem.

Returns
Type Description
bool

hasBoot

clearBoot

setBoot

Indicates that this is a boot disk. The virtual machine will use the first partition of the disk for its root filesystem.

Parameter
Name Description
var bool
Returns
Type Description
$this

getDeviceName

Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* tree of a Linux operating system running within the instance. This name can be used to reference the device for mounting, resizing, and so on, from within the instance. If not specified, the server chooses a default device name to apply to this disk, in the form persistent-disk-x, where x is a number assigned by Google Compute Engine. This field is only applicable for persistent disks.

Returns
Type Description
string

hasDeviceName

clearDeviceName

setDeviceName

Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* tree of a Linux operating system running within the instance. This name can be used to reference the device for mounting, resizing, and so on, from within the instance. If not specified, the server chooses a default device name to apply to this disk, in the form persistent-disk-x, where x is a number assigned by Google Compute Engine. This field is only applicable for persistent disks.

Parameter
Name Description
var string
Returns
Type Description
$this

getDiskEncryptionKey

Encrypts or decrypts a disk using a customer-supplied encryption key. If you are creating a new disk, this field encrypts the new disk using an encryption key that you provide. If you are attaching an existing disk that is already encrypted, this field decrypts the disk using the customer-supplied encryption key. If you encrypt a disk using a customer-supplied key, you must provide the same key again when you attempt to use this resource at a later time. For example, you must provide the key when you create a snapshot or an image from the disk or when you attach the disk to a virtual machine instance. If you do not provide an encryption key, then the disk will be encrypted using an automatically generated key and you do not need to provide a key to use the disk later. Instance templates do not store customer-supplied encryption keys, so you cannot use your own keys to encrypt disks in a managed instance group.

Returns
Type Description
Google\Cloud\Compute\V1\CustomerEncryptionKey|null

hasDiskEncryptionKey

clearDiskEncryptionKey

setDiskEncryptionKey

Encrypts or decrypts a disk using a customer-supplied encryption key. If you are creating a new disk, this field encrypts the new disk using an encryption key that you provide. If you are attaching an existing disk that is already encrypted, this field decrypts the disk using the customer-supplied encryption key. If you encrypt a disk using a customer-supplied key, you must provide the same key again when you attempt to use this resource at a later time. For example, you must provide the key when you create a snapshot or an image from the disk or when you attach the disk to a virtual machine instance. If you do not provide an encryption key, then the disk will be encrypted using an automatically generated key and you do not need to provide a key to use the disk later. Instance templates do not store customer-supplied encryption keys, so you cannot use your own keys to encrypt disks in a managed instance group.

Parameter
Name Description
var Google\Cloud\Compute\V1\CustomerEncryptionKey
Returns
Type Description
$this

getDiskSizeGb

The size of the disk in GB.

Returns
Type Description
int|string

hasDiskSizeGb

clearDiskSizeGb

setDiskSizeGb

The size of the disk in GB.

Parameter
Name Description
var int|string
Returns
Type Description
$this

getForceAttach

[Input Only] Whether to force attach the regional disk even if it's currently attached to another instance. If you try to force attach a zonal disk to an instance, you will receive an error.

Returns
Type Description
bool

hasForceAttach

clearForceAttach

setForceAttach

[Input Only] Whether to force attach the regional disk even if it's currently attached to another instance. If you try to force attach a zonal disk to an instance, you will receive an error.

Parameter
Name Description
var bool
Returns
Type Description
$this

getGuestOsFeatures

A list of features to enable on the guest operating system. Applicable only for bootable images. Read Enabling guest operating system features to see a list of available options.

Returns
Type Description
Google\Protobuf\Internal\RepeatedField

setGuestOsFeatures

A list of features to enable on the guest operating system. Applicable only for bootable images. Read Enabling guest operating system features to see a list of available options.

Parameter
Name Description
var array<Google\Cloud\Compute\V1\GuestOsFeature>
Returns
Type Description
$this

getIndex

[Output Only] A zero-based index to this disk, where 0 is reserved for the boot disk. If you have many disks attached to an instance, each disk would have a unique index number.

Returns
Type Description
int

hasIndex

clearIndex

setIndex

[Output Only] A zero-based index to this disk, where 0 is reserved for the boot disk. If you have many disks attached to an instance, each disk would have a unique index number.

Parameter
Name Description
var int
Returns
Type Description
$this

getInitializeParams

[Input Only] Specifies the parameters for a new disk that will be created alongside the new instance. Use initialization parameters to create boot disks or local SSDs attached to the new instance. This property is mutually exclusive with the source property; you can only define one or the other, but not both.

Returns
Type Description
Google\Cloud\Compute\V1\AttachedDiskInitializeParams|null

hasInitializeParams

clearInitializeParams

setInitializeParams

[Input Only] Specifies the parameters for a new disk that will be created alongside the new instance. Use initialization parameters to create boot disks or local SSDs attached to the new instance. This property is mutually exclusive with the source property; you can only define one or the other, but not both.

Parameter
Name Description
var Google\Cloud\Compute\V1\AttachedDiskInitializeParams
Returns
Type Description
$this

getInterface

Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. For most machine types, the default is SCSI. Local SSDs can use either NVME or SCSI. In certain configurations, persistent disks can use NVMe. For more information, see About persistent disks.

Check the Interface enum for the list of possible values.

Returns
Type Description
string

hasInterface

clearInterface

setInterface

Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. For most machine types, the default is SCSI. Local SSDs can use either NVME or SCSI. In certain configurations, persistent disks can use NVMe. For more information, see About persistent disks.

Check the Interface enum for the list of possible values.

Parameter
Name Description
var string
Returns
Type Description
$this

getKind

[Output Only] Type of the resource. Always compute#attachedDisk for attached disks.

Returns
Type Description
string

hasKind

clearKind

setKind

[Output Only] Type of the resource. Always compute#attachedDisk for attached disks.

Parameter
Name Description
var string
Returns
Type Description
$this

getLicenses

[Output Only] Any valid publicly visible licenses.

Returns
Type Description
Google\Protobuf\Internal\RepeatedField

setLicenses

[Output Only] Any valid publicly visible licenses.

Parameter
Name Description
var string[]
Returns
Type Description
$this

getMode

The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode.

Check the Mode enum for the list of possible values.

Returns
Type Description
string

hasMode

clearMode

setMode

The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode.

Check the Mode enum for the list of possible values.

Parameter
Name Description
var string
Returns
Type Description
$this

getSavedState

For LocalSSD disks on VM Instances in STOPPED or SUSPENDED state, this field is set to PRESERVED if the LocalSSD data has been saved to a persistent location by customer request. (see the discard_local_ssd option on Stop/Suspend). Read-only in the api.

Check the SavedState enum for the list of possible values.

Returns
Type Description
string

hasSavedState

clearSavedState

setSavedState

For LocalSSD disks on VM Instances in STOPPED or SUSPENDED state, this field is set to PRESERVED if the LocalSSD data has been saved to a persistent location by customer request. (see the discard_local_ssd option on Stop/Suspend). Read-only in the api.

Check the SavedState enum for the list of possible values.

Parameter
Name Description
var string
Returns
Type Description
$this

getShieldedInstanceInitialState

[Output Only] shielded vm initial state stored on disk

Returns
Type Description
Google\Cloud\Compute\V1\InitialStateConfig|null

hasShieldedInstanceInitialState

clearShieldedInstanceInitialState

setShieldedInstanceInitialState

[Output Only] shielded vm initial state stored on disk

Parameter
Name Description
var Google\Cloud\Compute\V1\InitialStateConfig
Returns
Type Description
$this

getSource

Specifies a valid partial or full URL to an existing Persistent Disk resource. When creating a new instance, one of initializeParams.sourceImage or initializeParams.sourceSnapshot or disks.source is required except for local SSD. If desired, you can also attach existing non-root persistent disks using this property. This field is only applicable for persistent disks. Note that for InstanceTemplate, specify the disk name for zonal disk, and the URL for regional disk.

Returns
Type Description
string

hasSource

clearSource

setSource

Specifies a valid partial or full URL to an existing Persistent Disk resource. When creating a new instance, one of initializeParams.sourceImage or initializeParams.sourceSnapshot or disks.source is required except for local SSD. If desired, you can also attach existing non-root persistent disks using this property. This field is only applicable for persistent disks. Note that for InstanceTemplate, specify the disk name for zonal disk, and the URL for regional disk.

Parameter
Name Description
var string
Returns
Type Description
$this

getType

Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, the default is PERSISTENT.

Check the Type enum for the list of possible values.

Returns
Type Description
string

hasType

clearType

setType

Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, the default is PERSISTENT.

Check the Type enum for the list of possible values.

Parameter
Name Description
var string
Returns
Type Description
$this