Search in sources :

Example 1 with CryptoKeyVersion

use of com.google.cloud.kms.v1.CryptoKeyVersion in project gapic-generator-java by googleapis.

the class KeyManagementServiceClientTest method listCryptoKeyVersionsTest.

@Test
public void listCryptoKeyVersionsTest() throws Exception {
    CryptoKeyVersion responsesElement = CryptoKeyVersion.newBuilder().build();
    ListCryptoKeyVersionsResponse expectedResponse = ListCryptoKeyVersionsResponse.newBuilder().setNextPageToken("").addAllCryptoKeyVersions(Arrays.asList(responsesElement)).build();
    mockKeyManagementService.addResponse(expectedResponse);
    CryptoKeyName parent = CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
    ListCryptoKeyVersionsPagedResponse pagedListResponse = client.listCryptoKeyVersions(parent);
    List<CryptoKeyVersion> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getCryptoKeyVersionsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockKeyManagementService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListCryptoKeyVersionsRequest actualRequest = ((ListCryptoKeyVersionsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListCryptoKeyVersionsPagedResponse(com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse) Test(org.junit.Test)

Example 2 with CryptoKeyVersion

use of com.google.cloud.kms.v1.CryptoKeyVersion in project gapic-generator-java by googleapis.

the class SyncRestoreCryptoKeyVersionCryptokeyversionname method syncRestoreCryptoKeyVersionCryptokeyversionname.

public static void syncRestoreCryptoKeyVersionCryptokeyversionname() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        CryptoKeyVersionName name = CryptoKeyVersionName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
        CryptoKeyVersion response = keyManagementServiceClient.restoreCryptoKeyVersion(name);
    }
}
Also used : CryptoKeyVersionName(com.google.cloud.kms.v1.CryptoKeyVersionName) CryptoKeyVersion(com.google.cloud.kms.v1.CryptoKeyVersion) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 3 with CryptoKeyVersion

use of com.google.cloud.kms.v1.CryptoKeyVersion in project gapic-generator-java by googleapis.

the class SyncRestoreCryptoKeyVersionString method syncRestoreCryptoKeyVersionString.

public static void syncRestoreCryptoKeyVersionString() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        String name = CryptoKeyVersionName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]").toString();
        CryptoKeyVersion response = keyManagementServiceClient.restoreCryptoKeyVersion(name);
    }
}
Also used : CryptoKeyVersion(com.google.cloud.kms.v1.CryptoKeyVersion) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 4 with CryptoKeyVersion

use of com.google.cloud.kms.v1.CryptoKeyVersion in project gapic-generator-java by googleapis.

the class SyncUpdateCryptoKeyVersion method syncUpdateCryptoKeyVersion.

public static void syncUpdateCryptoKeyVersion() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        UpdateCryptoKeyVersionRequest request = UpdateCryptoKeyVersionRequest.newBuilder().setCryptoKeyVersion(CryptoKeyVersion.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
        CryptoKeyVersion response = keyManagementServiceClient.updateCryptoKeyVersion(request);
    }
}
Also used : UpdateCryptoKeyVersionRequest(com.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest) CryptoKeyVersion(com.google.cloud.kms.v1.CryptoKeyVersion) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 5 with CryptoKeyVersion

use of com.google.cloud.kms.v1.CryptoKeyVersion in project gapic-generator-java by googleapis.

the class SyncCreateCryptoKeyVersionStringCryptokeyversion method syncCreateCryptoKeyVersionStringCryptokeyversion.

public static void syncCreateCryptoKeyVersionStringCryptokeyversion() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        String parent = CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString();
        CryptoKeyVersion cryptoKeyVersion = CryptoKeyVersion.newBuilder().build();
        CryptoKeyVersion response = keyManagementServiceClient.createCryptoKeyVersion(parent, cryptoKeyVersion);
    }
}
Also used : CryptoKeyVersion(com.google.cloud.kms.v1.CryptoKeyVersion) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Aggregations

CryptoKeyVersion (com.google.cloud.kms.v1.CryptoKeyVersion)43 KeyManagementServiceClient (com.google.cloud.kms.v1.KeyManagementServiceClient)39 CryptoKeyVersionName (com.google.cloud.kms.v1.CryptoKeyVersionName)13 Test (org.junit.Test)8 FieldMask (com.google.protobuf.FieldMask)7 ByteString (com.google.protobuf.ByteString)6 CryptoKeyName (com.google.cloud.kms.v1.CryptoKeyName)5 ListCryptoKeyVersionsPagedResponse (com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse)4 ListCryptoKeyVersionsRequest (com.google.cloud.kms.v1.ListCryptoKeyVersionsRequest)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 CreateCryptoKeyVersionRequest (com.google.cloud.kms.v1.CreateCryptoKeyVersionRequest)2 CryptoKey (com.google.cloud.kms.v1.CryptoKey)2 DestroyCryptoKeyVersionRequest (com.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest)2 GetCryptoKeyVersionRequest (com.google.cloud.kms.v1.GetCryptoKeyVersionRequest)2 ImportCryptoKeyVersionRequest (com.google.cloud.kms.v1.ImportCryptoKeyVersionRequest)2 KeyOperationAttestation (com.google.cloud.kms.v1.KeyOperationAttestation)2 RestoreCryptoKeyVersionRequest (com.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest)2 UpdateCryptoKeyVersionRequest (com.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest)2 TimeoutException (java.util.concurrent.TimeoutException)2 AfterClass (org.junit.AfterClass)2