Search in sources :

Example 36 with CryptoKeyVersion

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

the class AsyncRestoreCryptoKeyVersion method asyncRestoreCryptoKeyVersion.

public static void asyncRestoreCryptoKeyVersion() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        RestoreCryptoKeyVersionRequest request = RestoreCryptoKeyVersionRequest.newBuilder().setName(CryptoKeyVersionName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]").toString()).build();
        ApiFuture<CryptoKeyVersion> future = keyManagementServiceClient.restoreCryptoKeyVersionCallable().futureCall(request);
        // Do something.
        CryptoKeyVersion response = future.get();
    }
}
Also used : RestoreCryptoKeyVersionRequest(com.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest) CryptoKeyVersion(com.google.cloud.kms.v1.CryptoKeyVersion) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 37 with CryptoKeyVersion

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

the class SyncRestoreCryptoKeyVersion method syncRestoreCryptoKeyVersion.

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

Example 38 with CryptoKeyVersion

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

the class AsyncCreateCryptoKeyVersion method asyncCreateCryptoKeyVersion.

public static void asyncCreateCryptoKeyVersion() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        CreateCryptoKeyVersionRequest request = CreateCryptoKeyVersionRequest.newBuilder().setParent(CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString()).setCryptoKeyVersion(CryptoKeyVersion.newBuilder().build()).build();
        ApiFuture<CryptoKeyVersion> future = keyManagementServiceClient.createCryptoKeyVersionCallable().futureCall(request);
        // Do something.
        CryptoKeyVersion response = future.get();
    }
}
Also used : CreateCryptoKeyVersionRequest(com.google.cloud.kms.v1.CreateCryptoKeyVersionRequest) CryptoKeyVersion(com.google.cloud.kms.v1.CryptoKeyVersion) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 39 with CryptoKeyVersion

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

the class SyncCreateCryptoKeyVersion method syncCreateCryptoKeyVersion.

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

Example 40 with CryptoKeyVersion

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

the class SyncCreateCryptoKeyVersionCryptokeynameCryptokeyversion method syncCreateCryptoKeyVersionCryptokeynameCryptokeyversion.

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