Search in sources :

Example 36 with KeyManagementServiceClient

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

the class SyncGetPublicKey method syncGetPublicKey.

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

Example 37 with KeyManagementServiceClient

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

the class SyncGetPublicKeyCryptokeyversionname method syncGetPublicKeyCryptokeyversionname.

public static void syncGetPublicKeyCryptokeyversionname() 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]");
        PublicKey response = keyManagementServiceClient.getPublicKey(name);
    }
}
Also used : CryptoKeyVersionName(com.google.cloud.kms.v1.CryptoKeyVersionName) PublicKey(com.google.cloud.kms.v1.PublicKey) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 38 with KeyManagementServiceClient

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

the class AsyncListCryptoKeys method asyncListCryptoKeys.

public static void asyncListCryptoKeys() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        ListCryptoKeysRequest request = ListCryptoKeysRequest.newBuilder().setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").setFilter("filter-1274492040").setOrderBy("orderBy-1207110587").build();
        ApiFuture<CryptoKey> future = keyManagementServiceClient.listCryptoKeysPagedCallable().futureCall(request);
        // Do something.
        for (CryptoKey element : future.get().iterateAll()) {
        // doThingsWith(element);
        }
    }
}
Also used : ListCryptoKeysRequest(com.google.cloud.kms.v1.ListCryptoKeysRequest) CryptoKey(com.google.cloud.kms.v1.CryptoKey) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 39 with KeyManagementServiceClient

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

the class AsyncListKeyRingsPaged method asyncListKeyRingsPaged.

public static void asyncListKeyRingsPaged() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        ListKeyRingsRequest request = ListKeyRingsRequest.newBuilder().setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").setFilter("filter-1274492040").setOrderBy("orderBy-1207110587").build();
        while (true) {
            ListKeyRingsResponse response = keyManagementServiceClient.listKeyRingsCallable().call(request);
            for (KeyRing element : response.getResponsesList()) {
            // doThingsWith(element);
            }
            String nextPageToken = response.getNextPageToken();
            if (!Strings.isNullOrEmpty(nextPageToken)) {
                request = request.toBuilder().setPageToken(nextPageToken).build();
            } else {
                break;
            }
        }
    }
}
Also used : KeyRing(com.google.cloud.kms.v1.KeyRing) ListKeyRingsResponse(com.google.cloud.kms.v1.ListKeyRingsResponse) ListKeyRingsRequest(com.google.cloud.kms.v1.ListKeyRingsRequest) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient)

Example 40 with KeyManagementServiceClient

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

the class AsyncListLocations method asyncListLocations.

public static void asyncListLocations() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        ListLocationsRequest request = ListLocationsRequest.newBuilder().setName("name3373707").setFilter("filter-1274492040").setPageSize(883849137).setPageToken("pageToken873572522").build();
        ApiFuture<Location> future = keyManagementServiceClient.listLocationsPagedCallable().futureCall(request);
        // Do something.
        for (Location element : future.get().iterateAll()) {
        // doThingsWith(element);
        }
    }
}
Also used : ListLocationsRequest(com.google.cloud.location.ListLocationsRequest) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient) Location(com.google.cloud.location.Location)

Aggregations

KeyManagementServiceClient (com.google.cloud.kms.v1.KeyManagementServiceClient)185 CryptoKey (com.google.cloud.kms.v1.CryptoKey)56 CryptoKeyVersion (com.google.cloud.kms.v1.CryptoKeyVersion)39 CryptoKeyVersionName (com.google.cloud.kms.v1.CryptoKeyVersionName)37 CryptoKeyName (com.google.cloud.kms.v1.CryptoKeyName)33 ByteString (com.google.protobuf.ByteString)20 KeyRingName (com.google.cloud.kms.v1.KeyRingName)17 KeyRing (com.google.cloud.kms.v1.KeyRing)16 FieldMask (com.google.protobuf.FieldMask)16 PublicKey (com.google.cloud.kms.v1.PublicKey)14 ImportJob (com.google.cloud.kms.v1.ImportJob)10 Test (org.junit.Test)10 Digest (com.google.cloud.kms.v1.Digest)8 EncryptResponse (com.google.cloud.kms.v1.EncryptResponse)8 Policy (com.google.iam.v1.Policy)8 X509EncodedKeySpec (java.security.spec.X509EncodedKeySpec)8 DecryptResponse (com.google.cloud.kms.v1.DecryptResponse)7 AsymmetricDecryptResponse (com.google.cloud.kms.v1.AsymmetricDecryptResponse)6 AsymmetricSignResponse (com.google.cloud.kms.v1.AsymmetricSignResponse)6 LocationName (com.google.cloud.kms.v1.LocationName)6