Skip to content
Permalink
Browse files
feat: add support for Key Reimport (#602)
PiperOrigin-RevId: 393749648

Source-Author: Google APIs <noreply@google.com>
Source-Date: Mon Aug 30 05:26:24 2021 -0700
Source-Repo: googleapis/googleapis
Source-Sha: e3d9b11abaec81e1c3c9c7cab1f3bb6fa3990651
Source-Link: googleapis/googleapis@e3d9b11
  • Loading branch information
yoshi-automation committed Sep 1, 2021
1 parent 918e9e7 commit ced1d5c03e838bcef3c0ed8070342c6795891987
@@ -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:
@@ -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);
@@ -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:
@@ -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 =
@@ -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.
*
@@ -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.
*
@@ -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.
*
@@ -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.
*
@@ -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);

@@ -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);

@@ -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);

@@ -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);

@@ -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);

@@ -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();

@@ -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());
@@ -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);
@@ -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);

@@ -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);

@@ -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);

@@ -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);

@@ -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);

0 comments on commit ced1d5c

Please sign in to comment.