Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

feat: add support for Key Reimport #602

Merged
merged 1 commit into from Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -1748,11 +1748,12 @@ public final CryptoKeyVersion createCryptoKeyVersion(CreateCryptoKeyVersionReque

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Imports a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] into an existing
* [CryptoKey][google.cloud.kms.v1.CryptoKey] using the wrapped key material provided in the
* request.
* Import wrapped key material into a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
*
* <p>The version ID will be assigned the next sequential id within the
* <p>All requests must specify a [CryptoKey][google.cloud.kms.v1.CryptoKey]. If a
* [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] is additionally specified in the
* request, key material will be reimported into that version. Otherwise, a new version will be
* created, and will be assigned the next sequential id within the
* [CryptoKey][google.cloud.kms.v1.CryptoKey].
*
* <p>Sample code:
Expand All @@ -1765,6 +1766,14 @@ public final CryptoKeyVersion createCryptoKeyVersion(CreateCryptoKeyVersionReque
* .setParent(
* CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
* .toString())
* .setCryptoKeyVersion(
* CryptoKeyVersionName.of(
* "[PROJECT]",
* "[LOCATION]",
* "[KEY_RING]",
* "[CRYPTO_KEY]",
* "[CRYPTO_KEY_VERSION]")
* .toString())
* .setImportJob("importJob-208547368")
* .build();
* CryptoKeyVersion response = keyManagementServiceClient.importCryptoKeyVersion(request);
Expand All @@ -1780,11 +1789,12 @@ public final CryptoKeyVersion importCryptoKeyVersion(ImportCryptoKeyVersionReque

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Imports a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] into an existing
* [CryptoKey][google.cloud.kms.v1.CryptoKey] using the wrapped key material provided in the
* request.
* Import wrapped key material into a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
*
* <p>The version ID will be assigned the next sequential id within the
* <p>All requests must specify a [CryptoKey][google.cloud.kms.v1.CryptoKey]. If a
* [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] is additionally specified in the
* request, key material will be reimported into that version. Otherwise, a new version will be
* created, and will be assigned the next sequential id within the
* [CryptoKey][google.cloud.kms.v1.CryptoKey].
*
* <p>Sample code:
Expand All @@ -1797,6 +1807,14 @@ public final CryptoKeyVersion importCryptoKeyVersion(ImportCryptoKeyVersionReque
* .setParent(
* CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
* .toString())
* .setCryptoKeyVersion(
* CryptoKeyVersionName.of(
* "[PROJECT]",
* "[LOCATION]",
* "[KEY_RING]",
* "[CRYPTO_KEY]",
* "[CRYPTO_KEY_VERSION]")
* .toString())
* .setImportJob("importJob-208547368")
* .build();
* ApiFuture<CryptoKeyVersion> future =
Expand Down Expand Up @@ -2275,10 +2293,11 @@ public final CryptoKey updateCryptoKeyPrimaryVersion(
*
* <p>Upon calling this method,
* [CryptoKeyVersion.state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
* [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED]
* and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be set to a time 24
* hours in the future, at which point the [state][google.cloud.kms.v1.CryptoKeyVersion.state]
* will be changed to
* [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED],
* and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be set to the time
* [destroy_scheduled_duration][google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration] in the
* future. At that time, the [state][google.cloud.kms.v1.CryptoKeyVersion.state] will
* automatically change to
* [DESTROYED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED], and the key
* material will be irrevocably destroyed.
*
Expand Down Expand Up @@ -2316,10 +2335,11 @@ public final CryptoKeyVersion destroyCryptoKeyVersion(CryptoKeyVersionName name)
*
* <p>Upon calling this method,
* [CryptoKeyVersion.state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
* [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED]
* and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be set to a time 24
* hours in the future, at which point the [state][google.cloud.kms.v1.CryptoKeyVersion.state]
* will be changed to
* [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED],
* and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be set to the time
* [destroy_scheduled_duration][google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration] in the
* future. At that time, the [state][google.cloud.kms.v1.CryptoKeyVersion.state] will
* automatically change to
* [DESTROYED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED], and the key
* material will be irrevocably destroyed.
*
Expand Down Expand Up @@ -2356,10 +2376,11 @@ public final CryptoKeyVersion destroyCryptoKeyVersion(String name) {
*
* <p>Upon calling this method,
* [CryptoKeyVersion.state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
* [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED]
* and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be set to a time 24
* hours in the future, at which point the [state][google.cloud.kms.v1.CryptoKeyVersion.state]
* will be changed to
* [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED],
* and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be set to the time
* [destroy_scheduled_duration][google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration] in the
* future. At that time, the [state][google.cloud.kms.v1.CryptoKeyVersion.state] will
* automatically change to
* [DESTROYED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED], and the key
* material will be irrevocably destroyed.
*
Expand Down Expand Up @@ -2400,10 +2421,11 @@ public final CryptoKeyVersion destroyCryptoKeyVersion(DestroyCryptoKeyVersionReq
*
* <p>Upon calling this method,
* [CryptoKeyVersion.state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
* [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED]
* and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be set to a time 24
* hours in the future, at which point the [state][google.cloud.kms.v1.CryptoKeyVersion.state]
* will be changed to
* [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED],
* and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be set to the time
* [destroy_scheduled_duration][google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration] in the
* future. At that time, the [state][google.cloud.kms.v1.CryptoKeyVersion.state] will
* automatically change to
* [DESTROYED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED], and the key
* material will be irrevocably destroyed.
*
Expand Down
Expand Up @@ -651,6 +651,7 @@ public void getCryptoKeyVersionTest() throws Exception {
.setImportTime(Timestamp.newBuilder().build())
.setImportFailureReason("importFailureReason985493705")
.setExternalProtectionLevelOptions(ExternalProtectionLevelOptions.newBuilder().build())
.setReimportEligible(true)
.build();
mockKeyManagementService.addResponse(expectedResponse);

Expand Down Expand Up @@ -710,6 +711,7 @@ public void getCryptoKeyVersionTest2() throws Exception {
.setImportTime(Timestamp.newBuilder().build())
.setImportFailureReason("importFailureReason985493705")
.setExternalProtectionLevelOptions(ExternalProtectionLevelOptions.newBuilder().build())
.setReimportEligible(true)
.build();
mockKeyManagementService.addResponse(expectedResponse);

Expand Down Expand Up @@ -1142,6 +1144,7 @@ public void createCryptoKeyVersionTest() throws Exception {
.setImportTime(Timestamp.newBuilder().build())
.setImportFailureReason("importFailureReason985493705")
.setExternalProtectionLevelOptions(ExternalProtectionLevelOptions.newBuilder().build())
.setReimportEligible(true)
.build();
mockKeyManagementService.addResponse(expectedResponse);

Expand Down Expand Up @@ -1203,6 +1206,7 @@ public void createCryptoKeyVersionTest2() throws Exception {
.setImportTime(Timestamp.newBuilder().build())
.setImportFailureReason("importFailureReason985493705")
.setExternalProtectionLevelOptions(ExternalProtectionLevelOptions.newBuilder().build())
.setReimportEligible(true)
.build();
mockKeyManagementService.addResponse(expectedResponse);

Expand Down Expand Up @@ -1262,6 +1266,7 @@ public void importCryptoKeyVersionTest() throws Exception {
.setImportTime(Timestamp.newBuilder().build())
.setImportFailureReason("importFailureReason985493705")
.setExternalProtectionLevelOptions(ExternalProtectionLevelOptions.newBuilder().build())
.setReimportEligible(true)
.build();
mockKeyManagementService.addResponse(expectedResponse);

Expand All @@ -1270,6 +1275,14 @@ public void importCryptoKeyVersionTest() throws Exception {
.setParent(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setCryptoKeyVersion(
CryptoKeyVersionName.of(
"[PROJECT]",
"[LOCATION]",
"[KEY_RING]",
"[CRYPTO_KEY]",
"[CRYPTO_KEY_VERSION]")
.toString())
.setImportJob("importJob-208547368")
.build();

Expand All @@ -1282,6 +1295,7 @@ public void importCryptoKeyVersionTest() throws Exception {
((ImportCryptoKeyVersionRequest) actualRequests.get(0));

Assert.assertEquals(request.getParent(), actualRequest.getParent());
Assert.assertEquals(request.getCryptoKeyVersion(), actualRequest.getCryptoKeyVersion());
Assert.assertEquals(request.getAlgorithm(), actualRequest.getAlgorithm());
Assert.assertEquals(request.getImportJob(), actualRequest.getImportJob());
Assert.assertEquals(request.getRsaAesWrappedKey(), actualRequest.getRsaAesWrappedKey());
Expand All @@ -1302,6 +1316,14 @@ public void importCryptoKeyVersionExceptionTest() throws Exception {
.setParent(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setCryptoKeyVersion(
CryptoKeyVersionName.of(
"[PROJECT]",
"[LOCATION]",
"[KEY_RING]",
"[CRYPTO_KEY]",
"[CRYPTO_KEY_VERSION]")
.toString())
.setImportJob("importJob-208547368")
.build();
client.importCryptoKeyVersion(request);
Expand Down Expand Up @@ -1489,6 +1511,7 @@ public void updateCryptoKeyVersionTest() throws Exception {
.setImportTime(Timestamp.newBuilder().build())
.setImportFailureReason("importFailureReason985493705")
.setExternalProtectionLevelOptions(ExternalProtectionLevelOptions.newBuilder().build())
.setReimportEligible(true)
.build();
mockKeyManagementService.addResponse(expectedResponse);

Expand Down Expand Up @@ -1651,6 +1674,7 @@ public void destroyCryptoKeyVersionTest() throws Exception {
.setImportTime(Timestamp.newBuilder().build())
.setImportFailureReason("importFailureReason985493705")
.setExternalProtectionLevelOptions(ExternalProtectionLevelOptions.newBuilder().build())
.setReimportEligible(true)
.build();
mockKeyManagementService.addResponse(expectedResponse);

Expand Down Expand Up @@ -1711,6 +1735,7 @@ public void destroyCryptoKeyVersionTest2() throws Exception {
.setImportTime(Timestamp.newBuilder().build())
.setImportFailureReason("importFailureReason985493705")
.setExternalProtectionLevelOptions(ExternalProtectionLevelOptions.newBuilder().build())
.setReimportEligible(true)
.build();
mockKeyManagementService.addResponse(expectedResponse);

Expand Down Expand Up @@ -1767,6 +1792,7 @@ public void restoreCryptoKeyVersionTest() throws Exception {
.setImportTime(Timestamp.newBuilder().build())
.setImportFailureReason("importFailureReason985493705")
.setExternalProtectionLevelOptions(ExternalProtectionLevelOptions.newBuilder().build())
.setReimportEligible(true)
.build();
mockKeyManagementService.addResponse(expectedResponse);

Expand Down Expand Up @@ -1827,6 +1853,7 @@ public void restoreCryptoKeyVersionTest2() throws Exception {
.setImportTime(Timestamp.newBuilder().build())
.setImportFailureReason("importFailureReason985493705")
.setExternalProtectionLevelOptions(ExternalProtectionLevelOptions.newBuilder().build())
.setReimportEligible(true)
.build();
mockKeyManagementService.addResponse(expectedResponse);

Expand Down