Search in sources :

Example 1 with ListKeyRingsResponse

use of com.google.api.services.cloudkms.v1.model.ListKeyRingsResponse in project java-docs-samples by GoogleCloudPlatform.

the class Quickstart method main.

public static void main(String... args) throws Exception {
    String projectId = args[0];
    // The location of the Key Rings
    String location = args[1];
    // Create the Cloud KMS client.
    CloudKMS kms = createAuthorizedClient();
    // The resource name of the cryptoKey
    String keyRingPath = String.format("projects/%s/locations/%s", projectId, location);
    // Make the RPC call
    ListKeyRingsResponse response = kms.projects().locations().keyRings().list(keyRingPath).execute();
    // Print the returned key rings
    if (null != response.getKeyRings()) {
        System.out.println("Key Rings: ");
        for (KeyRing keyRing : response.getKeyRings()) {
            System.out.println(keyRing.getName());
        }
    } else {
        System.out.println("No key rings defined.");
    }
}
Also used : KeyRing(com.google.api.services.cloudkms.v1.model.KeyRing) CloudKMS(com.google.api.services.cloudkms.v1.CloudKMS) ListKeyRingsResponse(com.google.api.services.cloudkms.v1.model.ListKeyRingsResponse)

Example 2 with ListKeyRingsResponse

use of com.google.api.services.cloudkms.v1.model.ListKeyRingsResponse in project java-docs-samples by GoogleCloudPlatform.

the class Snippets method listKeyRings.

// [END kms_remove_member_from_keyring_policy]
/**
 * Prints all the key rings in the given project.
 */
public static void listKeyRings(String projectId, String locationId) throws IOException {
    // Create the Cloud KMS client.
    CloudKMS kms = createAuthorizedClient();
    // The resource name of the cryptoKey
    String keyRingPath = String.format("projects/%s/locations/%s", projectId, locationId);
    // Make the RPC call
    ListKeyRingsResponse response = kms.projects().locations().keyRings().list(keyRingPath).execute();
    // Print the returned key rings
    if (null != response.getKeyRings()) {
        System.out.println("Key Rings: ");
        for (KeyRing keyRing : response.getKeyRings()) {
            System.out.println(keyRing.getName());
        }
    } else {
        System.out.println("No keyrings defined.");
    }
}
Also used : KeyRing(com.google.api.services.cloudkms.v1.model.KeyRing) CloudKMS(com.google.api.services.cloudkms.v1.CloudKMS) ListKeyRingsResponse(com.google.api.services.cloudkms.v1.model.ListKeyRingsResponse)

Aggregations

CloudKMS (com.google.api.services.cloudkms.v1.CloudKMS)2 KeyRing (com.google.api.services.cloudkms.v1.model.KeyRing)2 ListKeyRingsResponse (com.google.api.services.cloudkms.v1.model.ListKeyRingsResponse)2