Cloud KMS V1 Client - Class CryptoKey (1.20.3)

Reference documentation and code samples for the Cloud KMS V1 Client class CryptoKey.

A CryptoKey represents a logical key that can be used for cryptographic operations.

A CryptoKey is made up of zero or more versions, which represent the actual key material used in cryptographic operations.

Generated from protobuf message google.cloud.kms.v1.CryptoKey

Namespace

Google \ Cloud \ Kms \ V1

Methods

__construct

Constructor.

Parameters
NameDescription
data array

Optional. Data for populating the Message object.

↳ name string

Output only. The resource name for this CryptoKey in the format projects/*/locations/*/keyRings/*/cryptoKeys/*.

↳ primary Google\Cloud\Kms\V1\CryptoKeyVersion

Output only. A copy of the "primary" CryptoKeyVersion that will be used by Encrypt when this CryptoKey is given in EncryptRequest.name. The CryptoKey's primary version can be updated via UpdateCryptoKeyPrimaryVersion. Keys with purpose ENCRYPT_DECRYPT may have a primary. For other keys, this field will be omitted.

↳ purpose int

Immutable. The immutable purpose of this CryptoKey.

↳ create_time Google\Protobuf\Timestamp

Output only. The time at which this CryptoKey was created.

↳ next_rotation_time Google\Protobuf\Timestamp

At next_rotation_time, the Key Management Service will automatically: 1. Create a new version of this CryptoKey. 2. Mark the new version as primary. Key rotations performed manually via CreateCryptoKeyVersion and UpdateCryptoKeyPrimaryVersion do not affect next_rotation_time. Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted.

↳ rotation_period Google\Protobuf\Duration

next_rotation_time will be advanced by this period when the service automatically rotates a key. Must be at least 24 hours and at most 876,000 hours. If rotation_period is set, next_rotation_time must also be set. Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted.

↳ version_template Google\Cloud\Kms\V1\CryptoKeyVersionTemplate

A template describing settings for new CryptoKeyVersion instances. The properties of new CryptoKeyVersion instances created by either CreateCryptoKeyVersion or auto-rotation are controlled by this template.

↳ labels array|Google\Protobuf\Internal\MapField

Labels with user-defined metadata. For more information, see Labeling Keys.

↳ import_only bool

Immutable. Whether this key may contain imported versions only.

↳ destroy_scheduled_duration Google\Protobuf\Duration

Immutable. The period of time that versions of this key spend in the DESTROY_SCHEDULED state before transitioning to DESTROYED. If not specified at creation time, the default duration is 24 hours.

↳ crypto_key_backend string

Immutable. The resource name of the backend environment where the key material for all CryptoKeyVersions associated with this CryptoKey reside and where all related cryptographic operations are performed. Only applicable if CryptoKeyVersions have a ProtectionLevel of EXTERNAL_VPC, with the resource name in the format projects/*/locations/*/ekmConnections/*. Note, this list is non-exhaustive and may apply to additional ProtectionLevels in the future.

getName

Output only. The resource name for this CryptoKey in the format projects/*/locations/*/keyRings/*/cryptoKeys/*.

Returns
TypeDescription
string

setName

Output only. The resource name for this CryptoKey in the format projects/*/locations/*/keyRings/*/cryptoKeys/*.

Parameter
NameDescription
var string
Returns
TypeDescription
$this

getPrimary

Output only. A copy of the "primary" CryptoKeyVersion that will be used by Encrypt when this CryptoKey is given in EncryptRequest.name.

The CryptoKey's primary version can be updated via UpdateCryptoKeyPrimaryVersion. Keys with purpose ENCRYPT_DECRYPT may have a primary. For other keys, this field will be omitted.

Returns
TypeDescription
Google\Cloud\Kms\V1\CryptoKeyVersion|null

hasPrimary

clearPrimary

setPrimary

Output only. A copy of the "primary" CryptoKeyVersion that will be used by Encrypt when this CryptoKey is given in EncryptRequest.name.

The CryptoKey's primary version can be updated via UpdateCryptoKeyPrimaryVersion. Keys with purpose ENCRYPT_DECRYPT may have a primary. For other keys, this field will be omitted.

Parameter
NameDescription
var Google\Cloud\Kms\V1\CryptoKeyVersion
Returns
TypeDescription
$this

getPurpose

Immutable. The immutable purpose of this CryptoKey.

Returns
TypeDescription
int

setPurpose

Immutable. The immutable purpose of this CryptoKey.

Parameter
NameDescription
var int
Returns
TypeDescription
$this

getCreateTime

Output only. The time at which this CryptoKey was created.

Returns
TypeDescription
Google\Protobuf\Timestamp|null

hasCreateTime

clearCreateTime

setCreateTime

Output only. The time at which this CryptoKey was created.

Parameter
NameDescription
var Google\Protobuf\Timestamp
Returns
TypeDescription
$this

getNextRotationTime

At next_rotation_time, the Key Management Service will automatically:

  1. Create a new version of this CryptoKey.

  2. Mark the new version as primary. Key rotations performed manually via CreateCryptoKeyVersion and UpdateCryptoKeyPrimaryVersion do not affect next_rotation_time. Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted.

Returns
TypeDescription
Google\Protobuf\Timestamp|null

hasNextRotationTime

clearNextRotationTime

setNextRotationTime

At next_rotation_time, the Key Management Service will automatically:

  1. Create a new version of this CryptoKey.

  2. Mark the new version as primary. Key rotations performed manually via CreateCryptoKeyVersion and UpdateCryptoKeyPrimaryVersion do not affect next_rotation_time. Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted.

Parameter
NameDescription
var Google\Protobuf\Timestamp
Returns
TypeDescription
$this

getRotationPeriod

next_rotation_time will be advanced by this period when the service automatically rotates a key. Must be at least 24 hours and at most 876,000 hours.

If rotation_period is set, next_rotation_time must also be set. Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted.

Returns
TypeDescription
Google\Protobuf\Duration|null

hasRotationPeriod

setRotationPeriod

next_rotation_time will be advanced by this period when the service automatically rotates a key. Must be at least 24 hours and at most 876,000 hours.

If rotation_period is set, next_rotation_time must also be set. Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted.

Parameter
NameDescription
var Google\Protobuf\Duration
Returns
TypeDescription
$this

getVersionTemplate

A template describing settings for new CryptoKeyVersion instances. The properties of new CryptoKeyVersion instances created by either CreateCryptoKeyVersion or auto-rotation are controlled by this template.

Returns
TypeDescription
Google\Cloud\Kms\V1\CryptoKeyVersionTemplate|null

hasVersionTemplate

clearVersionTemplate

setVersionTemplate

A template describing settings for new CryptoKeyVersion instances. The properties of new CryptoKeyVersion instances created by either CreateCryptoKeyVersion or auto-rotation are controlled by this template.

Parameter
NameDescription
var Google\Cloud\Kms\V1\CryptoKeyVersionTemplate
Returns
TypeDescription
$this

getLabels

Labels with user-defined metadata. For more information, see Labeling Keys.

Returns
TypeDescription
Google\Protobuf\Internal\MapField

setLabels

Labels with user-defined metadata. For more information, see Labeling Keys.

Parameter
NameDescription
var array|Google\Protobuf\Internal\MapField
Returns
TypeDescription
$this

getImportOnly

Immutable. Whether this key may contain imported versions only.

Returns
TypeDescription
bool

setImportOnly

Immutable. Whether this key may contain imported versions only.

Parameter
NameDescription
var bool
Returns
TypeDescription
$this

getDestroyScheduledDuration

Immutable. The period of time that versions of this key spend in the DESTROY_SCHEDULED state before transitioning to DESTROYED.

If not specified at creation time, the default duration is 24 hours.

Returns
TypeDescription
Google\Protobuf\Duration|null

hasDestroyScheduledDuration

clearDestroyScheduledDuration

setDestroyScheduledDuration

Immutable. The period of time that versions of this key spend in the DESTROY_SCHEDULED state before transitioning to DESTROYED.

If not specified at creation time, the default duration is 24 hours.

Parameter
NameDescription
var Google\Protobuf\Duration
Returns
TypeDescription
$this

getCryptoKeyBackend

Immutable. The resource name of the backend environment where the key material for all CryptoKeyVersions associated with this CryptoKey reside and where all related cryptographic operations are performed. Only applicable if CryptoKeyVersions have a ProtectionLevel of EXTERNAL_VPC, with the resource name in the format projects/*/locations/*/ekmConnections/*.

Note, this list is non-exhaustive and may apply to additional ProtectionLevels in the future.

Returns
TypeDescription
string

setCryptoKeyBackend

Immutable. The resource name of the backend environment where the key material for all CryptoKeyVersions associated with this CryptoKey reside and where all related cryptographic operations are performed. Only applicable if CryptoKeyVersions have a ProtectionLevel of EXTERNAL_VPC, with the resource name in the format projects/*/locations/*/ekmConnections/*.

Note, this list is non-exhaustive and may apply to additional ProtectionLevels in the future.

Parameter
NameDescription
var string
Returns
TypeDescription
$this

getRotationSchedule

Returns
TypeDescription
string