# Class KeyManagementServiceClient (2.96.0)

2.96.0 (latest) 2.94.0 2.91.0 2.90.0 2.88.0 2.86.0 2.85.0 2.84.0 2.83.0 2.81.0 2.79.0 2.78.0 2.77.0 2.76.0 2.75.0 2.73.0 2.71.0 2.70.0 2.67.0 2.66.0 2.65.0 2.63.0 2.62.0 2.61.0 2.60.0 2.59.0 2.58.0 2.57.0 2.56.0 2.55.0 2.54.0 2.52.0 2.51.0 2.50.0 2.49.0 2.48.0 2.47.0 2.46.0 2.45.0 2.44.0 2.43.0 2.42.0 2.40.0 2.39.0 2.38.0 2.37.0 2.36.0 2.35.0 2.34.0 2.33.0 2.32.0 2.31.0 2.30.0 2.27.0 2.26.0 2.25.0 2.24.0 2.23.0 2.22.0 2.21.0 2.20.0 2.19.0 2.18.0 2.17.0 2.16.0 2.15.0 2.14.0 2.12.0 2.11.0 2.10.0 2.9.0 2.8.0 2.7.0 2.6.8 2.5.3 2.4.4 2.3.1

|---|---|
| [GitHub Repository](https://github.com/googleapis/google-cloud-java/tree/main/java-kms/google-cloud-kms/src/main/java/com/google/cloud/kms/v1/KeyManagementServiceClient.java) | [Product Reference](https://cloud.google.com/kms) |

Service Description: Google Cloud Key Management Service

Manages cryptographic keys and operations using those keys. Implements a REST model with the
following objects:

- KeyRing
- CryptoKey
- CryptoKeyVersion
- ImportJob

If you are using manual gRPC libraries, see [Using gRPC with Cloud
KMS](https://cloud.google.com/kms/docs/grpc).

This class provides the ability to make remote calls to the backing service through method
calls that map to API methods. Sample code to get started:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       KeyRingName name = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
       KeyRing response = keyManagementServiceClient.getKeyRing(name);
     }
     
Note: close() needs to be called on the KeyManagementServiceClient object to clean up
resources such as threads. In the example above, try-with-resources is used, which automatically
calls close().

| Method | Description | Method Variants |
|---|---|---|
| ListKeyRings | Lists KeyRings. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - listKeyRings(ListKeyRingsRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - listKeyRings(LocationName parent) - listKeyRings(String parent) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - listKeyRingsPagedCallable() - listKeyRingsCallable() |
| ListCryptoKeys | Lists CryptoKeys. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - listCryptoKeys(ListCryptoKeysRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - listCryptoKeys(KeyRingName parent) - listCryptoKeys(String parent) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - listCryptoKeysPagedCallable() - listCryptoKeysCallable() |
| ListCryptoKeyVersions | Lists CryptoKeyVersions. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - listCryptoKeyVersions(ListCryptoKeyVersionsRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - listCryptoKeyVersions(CryptoKeyName parent) - listCryptoKeyVersions(String parent) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - listCryptoKeyVersionsPagedCallable() - listCryptoKeyVersionsCallable() |
| ListImportJobs | Lists ImportJobs. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - listImportJobs(ListImportJobsRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - listImportJobs(KeyRingName parent) - listImportJobs(String parent) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - listImportJobsPagedCallable() - listImportJobsCallable() |
| ListRetiredResources | Lists the RetiredResources which are the records of deleted CryptoKeys. RetiredResources prevent the reuse of these resource names after deletion. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - listRetiredResources(ListRetiredResourcesRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - listRetiredResources(LocationName parent) - listRetiredResources(String parent) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - listRetiredResourcesPagedCallable() - listRetiredResourcesCallable() |
| GetKeyRing | Returns metadata for a given KeyRing. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - getKeyRing(GetKeyRingRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - getKeyRing(KeyRingName name) - getKeyRing(String name) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - getKeyRingCallable() |
| GetCryptoKey | Returns metadata for a given CryptoKey, as well as its primary CryptoKeyVersion. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - getCryptoKey(GetCryptoKeyRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - getCryptoKey(CryptoKeyName name) - getCryptoKey(String name) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - getCryptoKeyCallable() |
| GetCryptoKeyVersion | Returns metadata for a given CryptoKeyVersion. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - getCryptoKeyVersion(GetCryptoKeyVersionRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - getCryptoKeyVersion(CryptoKeyVersionName name) - getCryptoKeyVersion(String name) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - getCryptoKeyVersionCallable() |
| GetPublicKey | Returns the public key for the given CryptoKeyVersion. The CryptoKey.purpose must be ASYMMETRIC_SIGN or ASYMMETRIC_DECRYPT. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - getPublicKey(GetPublicKeyRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - getPublicKey(CryptoKeyVersionName name) - getPublicKey(String name) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - getPublicKeyCallable() |
| GetImportJob | Returns metadata for a given ImportJob. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - getImportJob(GetImportJobRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - getImportJob(ImportJobName name) - getImportJob(String name) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - getImportJobCallable() |
| GetRetiredResource | Retrieves a specific RetiredResource resource, which represents the record of a deleted CryptoKey. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - getRetiredResource(GetRetiredResourceRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - getRetiredResource(RetiredResourceName name) - getRetiredResource(String name) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - getRetiredResourceCallable() |
| CreateKeyRing | Create a new KeyRing in a given Project and Location. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - createKeyRing(CreateKeyRingRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - createKeyRing(LocationName parent, String keyRingId, KeyRing keyRing) - createKeyRing(String parent, String keyRingId, KeyRing keyRing) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - createKeyRingCallable() |
| CreateCryptoKey | Create a new CryptoKey within a KeyRing. CryptoKey.purpose and CryptoKey.version_template.algorithm are required. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - createCryptoKey(CreateCryptoKeyRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - createCryptoKey(KeyRingName parent, String cryptoKeyId, CryptoKey cryptoKey) - createCryptoKey(String parent, String cryptoKeyId, CryptoKey cryptoKey) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - createCryptoKeyCallable() |
| CreateCryptoKeyVersion | Create a new CryptoKeyVersion in a CryptoKey. The server will assign the next sequential id. If unset, state will be set to ENABLED. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - createCryptoKeyVersion(CreateCryptoKeyVersionRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - createCryptoKeyVersion(CryptoKeyName parent, CryptoKeyVersion cryptoKeyVersion) - createCryptoKeyVersion(String parent, CryptoKeyVersion cryptoKeyVersion) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - createCryptoKeyVersionCallable() |
| DeleteCryptoKey | Permanently deletes the given CryptoKey. All child CryptoKeyVersions must have been previously deleted using KeyManagementService.DeleteCryptoKeyVersion. The specified crypto key will be immediately and permanently deleted upon calling this method. This action cannot be undone. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - deleteCryptoKeyAsync(DeleteCryptoKeyRequest request) Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service. - deleteCryptoKeyAsync(CryptoKeyName name) - deleteCryptoKeyAsync(String name) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - deleteCryptoKeyOperationCallable() - deleteCryptoKeyCallable() |
| DeleteCryptoKeyVersion | Permanently deletes the given CryptoKeyVersion. Only possible if the version has not been previously imported and if its state is one of DESTROYED, IMPORT_FAILED, or GENERATION_FAILED. Successfully imported CryptoKeyVersions cannot be deleted at this time. The specified version will be immediately and permanently deleted upon calling this method. This action cannot be undone. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - deleteCryptoKeyVersionAsync(DeleteCryptoKeyVersionRequest request) Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service. - deleteCryptoKeyVersionAsync(CryptoKeyVersionName name) - deleteCryptoKeyVersionAsync(String name) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - deleteCryptoKeyVersionOperationCallable() - deleteCryptoKeyVersionCallable() |
| ImportCryptoKeyVersion | Import wrapped key material into a CryptoKeyVersion. All requests must specify a CryptoKey. If a 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. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - importCryptoKeyVersion(ImportCryptoKeyVersionRequest request) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - importCryptoKeyVersionCallable() |
| CreateImportJob | Create a new ImportJob within a KeyRing. ImportJob.import_method is required. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - createImportJob(CreateImportJobRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - createImportJob(KeyRingName parent, String importJobId, ImportJob importJob) - createImportJob(String parent, String importJobId, ImportJob importJob) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - createImportJobCallable() |
| UpdateCryptoKey | Update a CryptoKey. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - updateCryptoKey(UpdateCryptoKeyRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - updateCryptoKey(CryptoKey cryptoKey, FieldMask updateMask) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - updateCryptoKeyCallable() |
| UpdateCryptoKeyVersion | Update a CryptoKeyVersion's metadata. state may be changed between ENABLED and DISABLED using this method. See DestroyCryptoKeyVersion and RestoreCryptoKeyVersion to move between other states. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - updateCryptoKeyVersion(UpdateCryptoKeyVersionRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - updateCryptoKeyVersion(CryptoKeyVersion cryptoKeyVersion, FieldMask updateMask) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - updateCryptoKeyVersionCallable() |
| UpdateCryptoKeyPrimaryVersion | Update the version of a CryptoKey that will be used in Encrypt. Returns an error if called on a key whose purpose is not ENCRYPT_DECRYPT. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - updateCryptoKeyPrimaryVersion(UpdateCryptoKeyPrimaryVersionRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - updateCryptoKeyPrimaryVersion(CryptoKeyName name, String cryptoKeyVersionId) - updateCryptoKeyPrimaryVersion(String name, String cryptoKeyVersionId) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - updateCryptoKeyPrimaryVersionCallable() |
| DestroyCryptoKeyVersion | Schedule a CryptoKeyVersion for destruction. Upon calling this method, CryptoKeyVersion.state will be set to DESTROY_SCHEDULED, and destroy_time will be set to the time destroy_scheduled_duration in the future. At that time, the state will automatically change to DESTROYED, and the key material will be irrevocably destroyed. Before the destroy_time is reached, RestoreCryptoKeyVersion may be called to reverse the process. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - destroyCryptoKeyVersion(DestroyCryptoKeyVersionRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - destroyCryptoKeyVersion(CryptoKeyVersionName name) - destroyCryptoKeyVersion(String name) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - destroyCryptoKeyVersionCallable() |
| RestoreCryptoKeyVersion | Restore a CryptoKeyVersion in the DESTROY_SCHEDULED state. Upon restoration of the CryptoKeyVersion, state will be set to DISABLED, and destroy_time will be cleared. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - restoreCryptoKeyVersion(RestoreCryptoKeyVersionRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - restoreCryptoKeyVersion(CryptoKeyVersionName name) - restoreCryptoKeyVersion(String name) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - restoreCryptoKeyVersionCallable() |
| Encrypt | Encrypts data, so that it can only be recovered by a call to Decrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - encrypt(EncryptRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - encrypt(ResourceName name, ByteString plaintext) - encrypt(String name, ByteString plaintext) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - encryptCallable() |
| Decrypt | Decrypts data that was protected by Encrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - decrypt(DecryptRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - decrypt(CryptoKeyName name, ByteString ciphertext) - decrypt(String name, ByteString ciphertext) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - decryptCallable() |
| RawEncrypt | Encrypts data using portable cryptographic primitives. Most users should choose Encrypt and Decrypt rather than their raw counterparts. The CryptoKey.purpose must be RAW_ENCRYPT_DECRYPT. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - rawEncrypt(RawEncryptRequest request) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - rawEncryptCallable() |
| RawDecrypt | Decrypts data that was originally encrypted using a raw cryptographic mechanism. The CryptoKey.purpose must be RAW_ENCRYPT_DECRYPT. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - rawDecrypt(RawDecryptRequest request) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - rawDecryptCallable() |
| AsymmetricSign | Signs data using a CryptoKeyVersion with CryptoKey.purpose ASYMMETRIC_SIGN, producing a signature that can be verified with the public key retrieved from GetPublicKey. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - asymmetricSign(AsymmetricSignRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - asymmetricSign(CryptoKeyVersionName name, Digest digest) - asymmetricSign(String name, Digest digest) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - asymmetricSignCallable() |
| AsymmetricDecrypt | Decrypts data that was encrypted with a public key retrieved from GetPublicKey corresponding to a CryptoKeyVersion with CryptoKey.purpose ASYMMETRIC_DECRYPT. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - asymmetricDecrypt(AsymmetricDecryptRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - asymmetricDecrypt(CryptoKeyVersionName name, ByteString ciphertext) - asymmetricDecrypt(String name, ByteString ciphertext) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - asymmetricDecryptCallable() |
| MacSign | Signs data using a CryptoKeyVersion with CryptoKey.purpose MAC, producing a tag that can be verified by another source with the same key. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - macSign(MacSignRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - macSign(CryptoKeyVersionName name, ByteString data) - macSign(String name, ByteString data) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - macSignCallable() |
| MacVerify | Verifies MAC tag using a CryptoKeyVersion with CryptoKey.purpose MAC, and returns a response that indicates whether or not the verification was successful. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - macVerify(MacVerifyRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - macVerify(CryptoKeyVersionName name, ByteString data, ByteString mac) - macVerify(String name, ByteString data, ByteString mac) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - macVerifyCallable() |
| Decapsulate | Decapsulates data that was encapsulated with a public key retrieved from GetPublicKey corresponding to a CryptoKeyVersion with CryptoKey.purpose KEY_ENCAPSULATION. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - decapsulate(DecapsulateRequest request) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - decapsulateCallable() |
| GenerateRandomBytes | Generate random bytes using the Cloud KMS randomness source in the provided location. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - generateRandomBytes(GenerateRandomBytesRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - generateRandomBytes(String location, int lengthBytes, ProtectionLevel protectionLevel) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - generateRandomBytesCallable() |
| ListLocations | Lists information about the supported locations for this service. This method lists locations based on the resource scope provided inthe \[ListLocationsRequest.name\] field: \* \*\*Global locations\*\*: If `name` is empty, the method lists thepublic locations available to all projects. \* \*\*Project-specificlocations\*\*: If `name` follows the format`projects/{project}`, the method lists locations visible to thatspecific project. This includes public, private, or otherproject-specific locations enabled for the project. For gRPC and client library implementations, the resource name ispassed as the `name` field. For direct service calls, the resourcename isincorporated into the request path based on the specific serviceimplementation and version. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - listLocations(ListLocationsRequest request) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - listLocationsPagedCallable() - listLocationsCallable() |
| GetLocation | Gets information about a location. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - getLocation(GetLocationRequest request) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - getLocationCallable() |
| SetIamPolicy | Sets the access control policy on the specified resource. Replacesany existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - setIamPolicy(SetIamPolicyRequest request) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - setIamPolicyCallable() |
| GetIamPolicy | Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - getIamPolicy(GetIamPolicyRequest request) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - getIamPolicyCallable() |
| TestIamPermissions | Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - testIamPermissions(TestIamPermissionsRequest request) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - testIamPermissionsCallable() |
[Methods]

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with
these names, this class includes a format method for each type of name, and additionally a parse
method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of KeyManagementServiceSettings
to create(). For example:

To customize credentials:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     KeyManagementServiceSettings keyManagementServiceSettings =
         KeyManagementServiceSettings.newBuilder()
             .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
             .build();
     KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create(keyManagementServiceSettings);
     
To customize the endpoint:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     KeyManagementServiceSettings keyManagementServiceSettings =
         KeyManagementServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
     KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create(keyManagementServiceSettings);
     
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
the wire:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     KeyManagementServiceSettings keyManagementServiceSettings =
         KeyManagementServiceSettings.newHttpJsonBuilder().build();
     KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create(keyManagementServiceSettings);
     
Please refer to the GitHub repository's samples for more quickstart code snippets.

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> KeyManagementServiceClient

## Static Methods

### create()

    public static final KeyManagementServiceClient create()

Constructs an instance of KeyManagementServiceClient with default settings.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### create(KeyManagementServiceSettings settings)

    public static final KeyManagementServiceClient create(KeyManagementServiceSettings settings)

Constructs an instance of KeyManagementServiceClient, using the given settings. The channels
are created based on the settings passed in, or defaults for any settings that are not set.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `settings` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceSettings` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### create(KeyManagementServiceStub stub)

    public static final KeyManagementServiceClient create(KeyManagementServiceStub stub)

Constructs an instance of KeyManagementServiceClient, using the given stub for making calls.
This is for advanced usage - prefer using create(KeyManagementServiceSettings).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `stub` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.stub.KeyManagementServiceStub` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient` |   |

## Constructors

### KeyManagementServiceClient(KeyManagementServiceSettings settings)

    protected KeyManagementServiceClient(KeyManagementServiceSettings settings)

Constructs an instance of KeyManagementServiceClient, using the given settings. This is
protected so that it is easy to make a subclass, but otherwise, the static factory methods
should be preferred.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `settings` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceSettings` |

### KeyManagementServiceClient(KeyManagementServiceStub stub)

    protected KeyManagementServiceClient(KeyManagementServiceStub stub)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `stub` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.stub.KeyManagementServiceStub` |

## Methods

### asymmetricDecrypt(AsymmetricDecryptRequest request)

    public final AsymmetricDecryptResponse asymmetricDecrypt(AsymmetricDecryptRequest request)

Decrypts data that was encrypted with a public key retrieved from
GetPublicKey corresponding to a
CryptoKeyVersion with
CryptoKey.purpose ASYMMETRIC_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       AsymmetricDecryptRequest request =
           AsymmetricDecryptRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .setCiphertext(ByteString.EMPTY)
               .setCiphertextCrc32C(Int64Value.newBuilder().build())
               .build();
       AsymmetricDecryptResponse response = keyManagementServiceClient.asymmetricDecrypt(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.AsymmetricDecryptRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.AsymmetricDecryptResponse` |   |

### asymmetricDecrypt(CryptoKeyVersionName name, ByteString ciphertext)

    public final AsymmetricDecryptResponse asymmetricDecrypt(CryptoKeyVersionName name, ByteString ciphertext)

Decrypts data that was encrypted with a public key retrieved from
GetPublicKey corresponding to a
CryptoKeyVersion with
CryptoKey.purpose ASYMMETRIC_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CryptoKeyVersionName name =
           CryptoKeyVersionName.of(
               "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
       ByteString ciphertext = ByteString.EMPTY;
       AsymmetricDecryptResponse response =
           keyManagementServiceClient.asymmetricDecrypt(name, ciphertext);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersionName` Required. The resource name of the CryptoKeyVersion to use for decryption. |
| `ciphertext` | `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` Required. The data encrypted with the named CryptoKeyVersion's public key using OAEP. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.AsymmetricDecryptResponse` |   |

### asymmetricDecrypt(String name, ByteString ciphertext)

    public final AsymmetricDecryptResponse asymmetricDecrypt(String name, ByteString ciphertext)

Decrypts data that was encrypted with a public key retrieved from
GetPublicKey corresponding to a
CryptoKeyVersion with
CryptoKey.purpose ASYMMETRIC_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String name =
           CryptoKeyVersionName.of(
                   "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
               .toString();
       ByteString ciphertext = ByteString.EMPTY;
       AsymmetricDecryptResponse response =
           keyManagementServiceClient.asymmetricDecrypt(name, ciphertext);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The resource name of the CryptoKeyVersion to use for decryption. |
| `ciphertext` | `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` Required. The data encrypted with the named CryptoKeyVersion's public key using OAEP. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.AsymmetricDecryptResponse` |   |

### asymmetricDecryptCallable()

    public final UnaryCallable<AsymmetricDecryptRequest,AsymmetricDecryptResponse> asymmetricDecryptCallable()

Decrypts data that was encrypted with a public key retrieved from
GetPublicKey corresponding to a
CryptoKeyVersion with
CryptoKey.purpose ASYMMETRIC_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       AsymmetricDecryptRequest request =
           AsymmetricDecryptRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .setCiphertext(ByteString.EMPTY)
               .setCiphertextCrc32C(Int64Value.newBuilder().build())
               .build();
       ApiFuture<AsymmetricDecryptResponse> future =
           keyManagementServiceClient.asymmetricDecryptCallable().futureCall(request);
       // Do something.
       AsymmetricDecryptResponse response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.AsymmetricDecryptRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.AsymmetricDecryptResponse>` |   |

### asymmetricSign(AsymmetricSignRequest request)

    public final AsymmetricSignResponse asymmetricSign(AsymmetricSignRequest request)

Signs data using a CryptoKeyVersion with
CryptoKey.purpose ASYMMETRIC_SIGN, producing a
signature that can be verified with the public key retrieved from
GetPublicKey.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       AsymmetricSignRequest request =
           AsymmetricSignRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .setDigest(Digest.newBuilder().build())
               .setDigestCrc32C(Int64Value.newBuilder().build())
               .setData(ByteString.EMPTY)
               .setDataCrc32C(Int64Value.newBuilder().build())
               .build();
       AsymmetricSignResponse response = keyManagementServiceClient.asymmetricSign(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.AsymmetricSignRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.AsymmetricSignResponse` |   |

### asymmetricSign(CryptoKeyVersionName name, Digest digest)

    public final AsymmetricSignResponse asymmetricSign(CryptoKeyVersionName name, Digest digest)

Signs data using a CryptoKeyVersion with
CryptoKey.purpose ASYMMETRIC_SIGN, producing a
signature that can be verified with the public key retrieved from
GetPublicKey.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CryptoKeyVersionName name =
           CryptoKeyVersionName.of(
               "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
       Digest digest = Digest.newBuilder().build();
       AsymmetricSignResponse response = keyManagementServiceClient.asymmetricSign(name, digest);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersionName` Required. The resource name of the CryptoKeyVersion to use for signing. |
| `digest` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.Digest` Optional. The digest of the data to sign. The digest must be produced with the same digest algorithm as specified by the key version's algorithm. This field may not be supplied if AsymmetricSignRequest.data is supplied. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.AsymmetricSignResponse` |   |

### asymmetricSign(String name, Digest digest)

    public final AsymmetricSignResponse asymmetricSign(String name, Digest digest)

Signs data using a CryptoKeyVersion with
CryptoKey.purpose ASYMMETRIC_SIGN, producing a
signature that can be verified with the public key retrieved from
GetPublicKey.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String name =
           CryptoKeyVersionName.of(
                   "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
               .toString();
       Digest digest = Digest.newBuilder().build();
       AsymmetricSignResponse response = keyManagementServiceClient.asymmetricSign(name, digest);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The resource name of the CryptoKeyVersion to use for signing. |
| `digest` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.Digest` Optional. The digest of the data to sign. The digest must be produced with the same digest algorithm as specified by the key version's algorithm. This field may not be supplied if AsymmetricSignRequest.data is supplied. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.AsymmetricSignResponse` |   |

### asymmetricSignCallable()

    public final UnaryCallable<AsymmetricSignRequest,AsymmetricSignResponse> asymmetricSignCallable()

Signs data using a CryptoKeyVersion with
CryptoKey.purpose ASYMMETRIC_SIGN, producing a
signature that can be verified with the public key retrieved from
GetPublicKey.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       AsymmetricSignRequest request =
           AsymmetricSignRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .setDigest(Digest.newBuilder().build())
               .setDigestCrc32C(Int64Value.newBuilder().build())
               .setData(ByteString.EMPTY)
               .setDataCrc32C(Int64Value.newBuilder().build())
               .build();
       ApiFuture<AsymmetricSignResponse> future =
           keyManagementServiceClient.asymmetricSignCallable().futureCall(request);
       // Do something.
       AsymmetricSignResponse response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.AsymmetricSignRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.AsymmetricSignResponse>` |   |

### awaitTermination(long duration, TimeUnit unit)

    public boolean awaitTermination(long duration, TimeUnit unit)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `duration` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |
| `unit` | `https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/TimeUnit.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/InterruptedException.html` |   |

### close()

    public final void close()

### createCryptoKey(CreateCryptoKeyRequest request)

    public final CryptoKey createCryptoKey(CreateCryptoKeyRequest request)

Create a new CryptoKey within a
KeyRing.

CryptoKey.purpose and
CryptoKey.version_template.algorithm
are required.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CreateCryptoKeyRequest request =
           CreateCryptoKeyRequest.newBuilder()
               .setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
               .setCryptoKeyId("cryptoKeyId-1643185255")
               .setCryptoKey(CryptoKey.newBuilder().build())
               .setSkipInitialVersionCreation(true)
               .build();
       CryptoKey response = keyManagementServiceClient.createCryptoKey(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CreateCryptoKeyRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey` |   |

### createCryptoKey(KeyRingName parent, String cryptoKeyId, CryptoKey cryptoKey)

    public final CryptoKey createCryptoKey(KeyRingName parent, String cryptoKeyId, CryptoKey cryptoKey)

Create a new CryptoKey within a
KeyRing.

CryptoKey.purpose and
CryptoKey.version_template.algorithm
are required.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       KeyRingName parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
       String cryptoKeyId = "cryptoKeyId-1643185255";
       CryptoKey cryptoKey = CryptoKey.newBuilder().build();
       CryptoKey response =
           keyManagementServiceClient.createCryptoKey(parent, cryptoKeyId, cryptoKey);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyRingName` Required. The name of the KeyRing associated with the CryptoKeys. |
| `cryptoKeyId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. It must be unique within a KeyRing and match the regular expression `[a-zA-Z0-9_-]{1,63}` |
| `cryptoKey` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey` Required. A CryptoKey with initial field values. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey` |   |

### createCryptoKey(String parent, String cryptoKeyId, CryptoKey cryptoKey)

    public final CryptoKey createCryptoKey(String parent, String cryptoKeyId, CryptoKey cryptoKey)

Create a new CryptoKey within a
KeyRing.

CryptoKey.purpose and
CryptoKey.version_template.algorithm
are required.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString();
       String cryptoKeyId = "cryptoKeyId-1643185255";
       CryptoKey cryptoKey = CryptoKey.newBuilder().build();
       CryptoKey response =
           keyManagementServiceClient.createCryptoKey(parent, cryptoKeyId, cryptoKey);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The name of the KeyRing associated with the CryptoKeys. |
| `cryptoKeyId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. It must be unique within a KeyRing and match the regular expression `[a-zA-Z0-9_-]{1,63}` |
| `cryptoKey` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey` Required. A CryptoKey with initial field values. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey` |   |

### createCryptoKeyCallable()

    public final UnaryCallable<CreateCryptoKeyRequest,CryptoKey> createCryptoKeyCallable()

Create a new CryptoKey within a
KeyRing.

CryptoKey.purpose and
CryptoKey.version_template.algorithm
are required.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CreateCryptoKeyRequest request =
           CreateCryptoKeyRequest.newBuilder()
               .setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
               .setCryptoKeyId("cryptoKeyId-1643185255")
               .setCryptoKey(CryptoKey.newBuilder().build())
               .setSkipInitialVersionCreation(true)
               .build();
       ApiFuture<CryptoKey> future =
           keyManagementServiceClient.createCryptoKeyCallable().futureCall(request);
       // Do something.
       CryptoKey response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CreateCryptoKeyRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey>` |   |

### createCryptoKeyVersion(CreateCryptoKeyVersionRequest request)

    public final CryptoKeyVersion createCryptoKeyVersion(CreateCryptoKeyVersionRequest request)

Create a new CryptoKeyVersion in a
CryptoKey.

The server will assign the next sequential id. If unset,
state will be set to
ENABLED.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     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);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CreateCryptoKeyVersionRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` |   |

### createCryptoKeyVersion(CryptoKeyName parent, CryptoKeyVersion cryptoKeyVersion)

    public final CryptoKeyVersion createCryptoKeyVersion(CryptoKeyName parent, CryptoKeyVersion cryptoKeyVersion)

Create a new CryptoKeyVersion in a
CryptoKey.

The server will assign the next sequential id. If unset,
state will be set to
ENABLED.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     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);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyName` Required. The name of the CryptoKey associated with the CryptoKeyVersions. |
| `cryptoKeyVersion` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` Required. A CryptoKeyVersion with initial field values. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` |   |

### createCryptoKeyVersion(String parent, CryptoKeyVersion cryptoKeyVersion)

    public final CryptoKeyVersion createCryptoKeyVersion(String parent, CryptoKeyVersion cryptoKeyVersion)

Create a new CryptoKeyVersion in a
CryptoKey.

The server will assign the next sequential id. If unset,
state will be set to
ENABLED.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     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);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The name of the CryptoKey associated with the CryptoKeyVersions. |
| `cryptoKeyVersion` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` Required. A CryptoKeyVersion with initial field values. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` |   |

### createCryptoKeyVersionCallable()

    public final UnaryCallable<CreateCryptoKeyVersionRequest,CryptoKeyVersion> createCryptoKeyVersionCallable()

Create a new CryptoKeyVersion in a
CryptoKey.

The server will assign the next sequential id. If unset,
state will be set to
ENABLED.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     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();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CreateCryptoKeyVersionRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion>` |   |

### createImportJob(CreateImportJobRequest request)

    public final ImportJob createImportJob(CreateImportJobRequest request)

Create a new ImportJob within a
KeyRing.

ImportJob.import_method is required.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CreateImportJobRequest request =
           CreateImportJobRequest.newBuilder()
               .setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
               .setImportJobId("importJobId1449444627")
               .setImportJob(ImportJob.newBuilder().build())
               .build();
       ImportJob response = keyManagementServiceClient.createImportJob(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CreateImportJobRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ImportJob` |   |

### createImportJob(KeyRingName parent, String importJobId, ImportJob importJob)

    public final ImportJob createImportJob(KeyRingName parent, String importJobId, ImportJob importJob)

Create a new ImportJob within a
KeyRing.

ImportJob.import_method is required.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       KeyRingName parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
       String importJobId = "importJobId1449444627";
       ImportJob importJob = ImportJob.newBuilder().build();
       ImportJob response =
           keyManagementServiceClient.createImportJob(parent, importJobId, importJob);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyRingName` Required. The name of the KeyRing associated with the ImportJobs. |
| `importJobId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. It must be unique within a KeyRing and match the regular expression `[a-zA-Z0-9_-]{1,63}` |
| `importJob` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ImportJob` Required. An ImportJob with initial field values. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ImportJob` |   |

### createImportJob(String parent, String importJobId, ImportJob importJob)

    public final ImportJob createImportJob(String parent, String importJobId, ImportJob importJob)

Create a new ImportJob within a
KeyRing.

ImportJob.import_method is required.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString();
       String importJobId = "importJobId1449444627";
       ImportJob importJob = ImportJob.newBuilder().build();
       ImportJob response =
           keyManagementServiceClient.createImportJob(parent, importJobId, importJob);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The name of the KeyRing associated with the ImportJobs. |
| `importJobId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. It must be unique within a KeyRing and match the regular expression `[a-zA-Z0-9_-]{1,63}` |
| `importJob` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ImportJob` Required. An ImportJob with initial field values. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ImportJob` |   |

### createImportJobCallable()

    public final UnaryCallable<CreateImportJobRequest,ImportJob> createImportJobCallable()

Create a new ImportJob within a
KeyRing.

ImportJob.import_method is required.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CreateImportJobRequest request =
           CreateImportJobRequest.newBuilder()
               .setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
               .setImportJobId("importJobId1449444627")
               .setImportJob(ImportJob.newBuilder().build())
               .build();
       ApiFuture<ImportJob> future =
           keyManagementServiceClient.createImportJobCallable().futureCall(request);
       // Do something.
       ImportJob response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CreateImportJobRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ImportJob>` |   |

### createKeyRing(CreateKeyRingRequest request)

    public final KeyRing createKeyRing(CreateKeyRingRequest request)

Create a new KeyRing in a given Project and Location.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CreateKeyRingRequest request =
           CreateKeyRingRequest.newBuilder()
               .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
               .setKeyRingId("keyRingId-2027180374")
               .setKeyRing(KeyRing.newBuilder().build())
               .build();
       KeyRing response = keyManagementServiceClient.createKeyRing(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CreateKeyRingRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyRing` |   |

### createKeyRing(LocationName parent, String keyRingId, KeyRing keyRing)

    public final KeyRing createKeyRing(LocationName parent, String keyRingId, KeyRing keyRing)

Create a new KeyRing in a given Project and Location.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
       String keyRingId = "keyRingId-2027180374";
       KeyRing keyRing = KeyRing.newBuilder().build();
       KeyRing response = keyManagementServiceClient.createKeyRing(parent, keyRingId, keyRing);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.LocationName` Required. The resource name of the location associated with the KeyRings, in the format `projects/*/locations/*`. |
| `keyRingId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. It must be unique within a location and match the regular expression `[a-zA-Z0-9_-]{1,63}` |
| `keyRing` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyRing` Required. A KeyRing with initial field values. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyRing` |   |

### createKeyRing(String parent, String keyRingId, KeyRing keyRing)

    public final KeyRing createKeyRing(String parent, String keyRingId, KeyRing keyRing)

Create a new KeyRing in a given Project and Location.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
       String keyRingId = "keyRingId-2027180374";
       KeyRing keyRing = KeyRing.newBuilder().build();
       KeyRing response = keyManagementServiceClient.createKeyRing(parent, keyRingId, keyRing);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The resource name of the location associated with the KeyRings, in the format `projects/*/locations/*`. |
| `keyRingId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. It must be unique within a location and match the regular expression `[a-zA-Z0-9_-]{1,63}` |
| `keyRing` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyRing` Required. A KeyRing with initial field values. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyRing` |   |

### createKeyRingCallable()

    public final UnaryCallable<CreateKeyRingRequest,KeyRing> createKeyRingCallable()

Create a new KeyRing in a given Project and Location.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CreateKeyRingRequest request =
           CreateKeyRingRequest.newBuilder()
               .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
               .setKeyRingId("keyRingId-2027180374")
               .setKeyRing(KeyRing.newBuilder().build())
               .build();
       ApiFuture<KeyRing> future =
           keyManagementServiceClient.createKeyRingCallable().futureCall(request);
       // Do something.
       KeyRing response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CreateKeyRingRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyRing>` |   |

### decapsulate(DecapsulateRequest request)

    public final DecapsulateResponse decapsulate(DecapsulateRequest request)

Decapsulates data that was encapsulated with a public key retrieved from
GetPublicKey corresponding to a
CryptoKeyVersion with
CryptoKey.purpose KEY_ENCAPSULATION.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       DecapsulateRequest request =
           DecapsulateRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .setCiphertext(ByteString.EMPTY)
               .setCiphertextCrc32C(Int64Value.newBuilder().build())
               .build();
       DecapsulateResponse response = keyManagementServiceClient.decapsulate(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DecapsulateRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DecapsulateResponse` |   |

### decapsulateCallable()

    public final UnaryCallable<DecapsulateRequest,DecapsulateResponse> decapsulateCallable()

Decapsulates data that was encapsulated with a public key retrieved from
GetPublicKey corresponding to a
CryptoKeyVersion with
CryptoKey.purpose KEY_ENCAPSULATION.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       DecapsulateRequest request =
           DecapsulateRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .setCiphertext(ByteString.EMPTY)
               .setCiphertextCrc32C(Int64Value.newBuilder().build())
               .build();
       ApiFuture<DecapsulateResponse> future =
           keyManagementServiceClient.decapsulateCallable().futureCall(request);
       // Do something.
       DecapsulateResponse response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DecapsulateRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DecapsulateResponse>` |   |

### decrypt(CryptoKeyName name, ByteString ciphertext)

    public final DecryptResponse decrypt(CryptoKeyName name, ByteString ciphertext)

Decrypts data that was protected by
Encrypt. The
CryptoKey.purpose must be
ENCRYPT_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CryptoKeyName name =
           CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
       ByteString ciphertext = ByteString.EMPTY;
       DecryptResponse response = keyManagementServiceClient.decrypt(name, ciphertext);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyName` Required. The resource name of the CryptoKey to use for decryption. The server will choose the appropriate version. |
| `ciphertext` | `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` Required. The encrypted data originally returned in EncryptResponse.ciphertext. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DecryptResponse` |   |

### decrypt(DecryptRequest request)

    public final DecryptResponse decrypt(DecryptRequest request)

Decrypts data that was protected by
Encrypt. The
CryptoKey.purpose must be
ENCRYPT_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       DecryptRequest request =
           DecryptRequest.newBuilder()
               .setName(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .setCiphertext(ByteString.EMPTY)
               .setAdditionalAuthenticatedData(ByteString.EMPTY)
               .setCiphertextCrc32C(Int64Value.newBuilder().build())
               .setAdditionalAuthenticatedDataCrc32C(Int64Value.newBuilder().build())
               .build();
       DecryptResponse response = keyManagementServiceClient.decrypt(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DecryptRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DecryptResponse` |   |

### decrypt(String name, ByteString ciphertext)

    public final DecryptResponse decrypt(String name, ByteString ciphertext)

Decrypts data that was protected by
Encrypt. The
CryptoKey.purpose must be
ENCRYPT_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String name =
           CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString();
       ByteString ciphertext = ByteString.EMPTY;
       DecryptResponse response = keyManagementServiceClient.decrypt(name, ciphertext);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The resource name of the CryptoKey to use for decryption. The server will choose the appropriate version. |
| `ciphertext` | `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` Required. The encrypted data originally returned in EncryptResponse.ciphertext. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DecryptResponse` |   |

### decryptCallable()

    public final UnaryCallable<DecryptRequest,DecryptResponse> decryptCallable()

Decrypts data that was protected by
Encrypt. The
CryptoKey.purpose must be
ENCRYPT_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       DecryptRequest request =
           DecryptRequest.newBuilder()
               .setName(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .setCiphertext(ByteString.EMPTY)
               .setAdditionalAuthenticatedData(ByteString.EMPTY)
               .setCiphertextCrc32C(Int64Value.newBuilder().build())
               .setAdditionalAuthenticatedDataCrc32C(Int64Value.newBuilder().build())
               .build();
       ApiFuture<DecryptResponse> future =
           keyManagementServiceClient.decryptCallable().futureCall(request);
       // Do something.
       DecryptResponse response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DecryptRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DecryptResponse>` |   |

### deleteCryptoKeyAsync(CryptoKeyName name)

    public final OperationFuture<Empty,DeleteCryptoKeyMetadata> deleteCryptoKeyAsync(CryptoKeyName name)

Permanently deletes the given CryptoKey. All child
CryptoKeyVersions must have been previously deleted
using
KeyManagementService.DeleteCryptoKeyVersion.
The specified crypto key will be immediately and permanently deleted upon calling this method.
This action cannot be undone.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CryptoKeyName name =
           CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
       keyManagementServiceClient.deleteCryptoKeyAsync(name).get();
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyName` Required. The name of the CryptoKey to delete. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.longrunning.OperationFuture.html<https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Empty.html,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DeleteCryptoKeyMetadata>` |   |

### deleteCryptoKeyAsync(DeleteCryptoKeyRequest request)

    public final OperationFuture<Empty,DeleteCryptoKeyMetadata> deleteCryptoKeyAsync(DeleteCryptoKeyRequest request)

Permanently deletes the given CryptoKey. All child
CryptoKeyVersions must have been previously deleted
using
KeyManagementService.DeleteCryptoKeyVersion.
The specified crypto key will be immediately and permanently deleted upon calling this method.
This action cannot be undone.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       DeleteCryptoKeyRequest request =
           DeleteCryptoKeyRequest.newBuilder()
               .setName(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .build();
       keyManagementServiceClient.deleteCryptoKeyAsync(request).get();
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DeleteCryptoKeyRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.longrunning.OperationFuture.html<https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Empty.html,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DeleteCryptoKeyMetadata>` |   |

### deleteCryptoKeyAsync(String name)

    public final OperationFuture<Empty,DeleteCryptoKeyMetadata> deleteCryptoKeyAsync(String name)

Permanently deletes the given CryptoKey. All child
CryptoKeyVersions must have been previously deleted
using
KeyManagementService.DeleteCryptoKeyVersion.
The specified crypto key will be immediately and permanently deleted upon calling this method.
This action cannot be undone.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String name =
           CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString();
       keyManagementServiceClient.deleteCryptoKeyAsync(name).get();
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The name of the CryptoKey to delete. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.longrunning.OperationFuture.html<https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Empty.html,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DeleteCryptoKeyMetadata>` |   |

### deleteCryptoKeyCallable()

    public final UnaryCallable<DeleteCryptoKeyRequest,Operation> deleteCryptoKeyCallable()

Permanently deletes the given CryptoKey. All child
CryptoKeyVersions must have been previously deleted
using
KeyManagementService.DeleteCryptoKeyVersion.
The specified crypto key will be immediately and permanently deleted upon calling this method.
This action cannot be undone.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       DeleteCryptoKeyRequest request =
           DeleteCryptoKeyRequest.newBuilder()
               .setName(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .build();
       ApiFuture<Operation> future =
           keyManagementServiceClient.deleteCryptoKeyCallable().futureCall(request);
       // Do something.
       future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DeleteCryptoKeyRequest,https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.longrunning.Operation.html>` |   |

### deleteCryptoKeyOperationCallable()

    public final OperationCallable<DeleteCryptoKeyRequest,Empty,DeleteCryptoKeyMetadata> deleteCryptoKeyOperationCallable()

Permanently deletes the given CryptoKey. All child
CryptoKeyVersions must have been previously deleted
using
KeyManagementService.DeleteCryptoKeyVersion.
The specified crypto key will be immediately and permanently deleted upon calling this method.
This action cannot be undone.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       DeleteCryptoKeyRequest request =
           DeleteCryptoKeyRequest.newBuilder()
               .setName(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .build();
       OperationFuture<Empty, DeleteCryptoKeyMetadata> future =
           keyManagementServiceClient.deleteCryptoKeyOperationCallable().futureCall(request);
       // Do something.
       future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.OperationCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DeleteCryptoKeyRequest,https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Empty.html,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DeleteCryptoKeyMetadata>` |   |

### deleteCryptoKeyVersionAsync(CryptoKeyVersionName name)

    public final OperationFuture<Empty,DeleteCryptoKeyVersionMetadata> deleteCryptoKeyVersionAsync(CryptoKeyVersionName name)

Permanently deletes the given CryptoKeyVersion. Only
possible if the version has not been previously imported and if its
state is one of
DESTROYED,
IMPORT_FAILED, or
GENERATION_FAILED. Successfully imported
CryptoKeyVersions cannot be deleted at this time. The
specified version will be immediately and permanently deleted upon calling this method. This
action cannot be undone.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CryptoKeyVersionName name =
           CryptoKeyVersionName.of(
               "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
       keyManagementServiceClient.deleteCryptoKeyVersionAsync(name).get();
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersionName` Required. The name of the CryptoKeyVersion to delete. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.longrunning.OperationFuture.html<https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Empty.html,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DeleteCryptoKeyVersionMetadata>` |   |

### deleteCryptoKeyVersionAsync(DeleteCryptoKeyVersionRequest request)

    public final OperationFuture<Empty,DeleteCryptoKeyVersionMetadata> deleteCryptoKeyVersionAsync(DeleteCryptoKeyVersionRequest request)

Permanently deletes the given CryptoKeyVersion. Only
possible if the version has not been previously imported and if its
state is one of
DESTROYED,
IMPORT_FAILED, or
GENERATION_FAILED. Successfully imported
CryptoKeyVersions cannot be deleted at this time. The
specified version will be immediately and permanently deleted upon calling this method. This
action cannot be undone.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       DeleteCryptoKeyVersionRequest request =
           DeleteCryptoKeyVersionRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .build();
       keyManagementServiceClient.deleteCryptoKeyVersionAsync(request).get();
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.longrunning.OperationFuture.html<https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Empty.html,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DeleteCryptoKeyVersionMetadata>` |   |

### deleteCryptoKeyVersionAsync(String name)

    public final OperationFuture<Empty,DeleteCryptoKeyVersionMetadata> deleteCryptoKeyVersionAsync(String name)

Permanently deletes the given CryptoKeyVersion. Only
possible if the version has not been previously imported and if its
state is one of
DESTROYED,
IMPORT_FAILED, or
GENERATION_FAILED. Successfully imported
CryptoKeyVersions cannot be deleted at this time. The
specified version will be immediately and permanently deleted upon calling this method. This
action cannot be undone.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String name =
           CryptoKeyVersionName.of(
                   "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
               .toString();
       keyManagementServiceClient.deleteCryptoKeyVersionAsync(name).get();
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The name of the CryptoKeyVersion to delete. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.longrunning.OperationFuture.html<https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Empty.html,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DeleteCryptoKeyVersionMetadata>` |   |

### deleteCryptoKeyVersionCallable()

    public final UnaryCallable<DeleteCryptoKeyVersionRequest,Operation> deleteCryptoKeyVersionCallable()

Permanently deletes the given CryptoKeyVersion. Only
possible if the version has not been previously imported and if its
state is one of
DESTROYED,
IMPORT_FAILED, or
GENERATION_FAILED. Successfully imported
CryptoKeyVersions cannot be deleted at this time. The
specified version will be immediately and permanently deleted upon calling this method. This
action cannot be undone.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       DeleteCryptoKeyVersionRequest request =
           DeleteCryptoKeyVersionRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .build();
       ApiFuture<Operation> future =
           keyManagementServiceClient.deleteCryptoKeyVersionCallable().futureCall(request);
       // Do something.
       future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest,https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.longrunning.Operation.html>` |   |

### deleteCryptoKeyVersionOperationCallable()

    public final OperationCallable<DeleteCryptoKeyVersionRequest,Empty,DeleteCryptoKeyVersionMetadata> deleteCryptoKeyVersionOperationCallable()

Permanently deletes the given CryptoKeyVersion. Only
possible if the version has not been previously imported and if its
state is one of
DESTROYED,
IMPORT_FAILED, or
GENERATION_FAILED. Successfully imported
CryptoKeyVersions cannot be deleted at this time. The
specified version will be immediately and permanently deleted upon calling this method. This
action cannot be undone.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       DeleteCryptoKeyVersionRequest request =
           DeleteCryptoKeyVersionRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .build();
       OperationFuture<Empty, DeleteCryptoKeyVersionMetadata> future =
           keyManagementServiceClient.deleteCryptoKeyVersionOperationCallable().futureCall(request);
       // Do something.
       future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.OperationCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest,https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Empty.html,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DeleteCryptoKeyVersionMetadata>` |   |

### destroyCryptoKeyVersion(CryptoKeyVersionName name)

    public final CryptoKeyVersion destroyCryptoKeyVersion(CryptoKeyVersionName name)

Schedule a CryptoKeyVersion for destruction.

Upon calling this method,
CryptoKeyVersion.state will be set to
DESTROY_SCHEDULED,
and destroy_time will be set to the time
destroy_scheduled_duration in the
future. At that time, the state will
automatically change to
DESTROYED, and the key
material will be irrevocably destroyed.

Before the destroy_time is reached,
RestoreCryptoKeyVersion may
be called to reverse the process.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CryptoKeyVersionName name =
           CryptoKeyVersionName.of(
               "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
       CryptoKeyVersion response = keyManagementServiceClient.destroyCryptoKeyVersion(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersionName` Required. The resource name of the CryptoKeyVersion to destroy. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` |   |

### destroyCryptoKeyVersion(DestroyCryptoKeyVersionRequest request)

    public final CryptoKeyVersion destroyCryptoKeyVersion(DestroyCryptoKeyVersionRequest request)

Schedule a CryptoKeyVersion for destruction.

Upon calling this method,
CryptoKeyVersion.state will be set to
DESTROY_SCHEDULED,
and destroy_time will be set to the time
destroy_scheduled_duration in the
future. At that time, the state will
automatically change to
DESTROYED, and the key
material will be irrevocably destroyed.

Before the destroy_time is reached,
RestoreCryptoKeyVersion may
be called to reverse the process.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       DestroyCryptoKeyVersionRequest request =
           DestroyCryptoKeyVersionRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .build();
       CryptoKeyVersion response = keyManagementServiceClient.destroyCryptoKeyVersion(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` |   |

### destroyCryptoKeyVersion(String name)

    public final CryptoKeyVersion destroyCryptoKeyVersion(String name)

Schedule a CryptoKeyVersion for destruction.

Upon calling this method,
CryptoKeyVersion.state will be set to
DESTROY_SCHEDULED,
and destroy_time will be set to the time
destroy_scheduled_duration in the
future. At that time, the state will
automatically change to
DESTROYED, and the key
material will be irrevocably destroyed.

Before the destroy_time is reached,
RestoreCryptoKeyVersion may
be called to reverse the process.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String name =
           CryptoKeyVersionName.of(
                   "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
               .toString();
       CryptoKeyVersion response = keyManagementServiceClient.destroyCryptoKeyVersion(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The resource name of the CryptoKeyVersion to destroy. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` |   |

### destroyCryptoKeyVersionCallable()

    public final UnaryCallable<DestroyCryptoKeyVersionRequest,CryptoKeyVersion> destroyCryptoKeyVersionCallable()

Schedule a CryptoKeyVersion for destruction.

Upon calling this method,
CryptoKeyVersion.state will be set to
DESTROY_SCHEDULED,
and destroy_time will be set to the time
destroy_scheduled_duration in the
future. At that time, the state will
automatically change to
DESTROYED, and the key
material will be irrevocably destroyed.

Before the destroy_time is reached,
RestoreCryptoKeyVersion may
be called to reverse the process.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       DestroyCryptoKeyVersionRequest request =
           DestroyCryptoKeyVersionRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .build();
       ApiFuture<CryptoKeyVersion> future =
           keyManagementServiceClient.destroyCryptoKeyVersionCallable().futureCall(request);
       // Do something.
       CryptoKeyVersion response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion>` |   |

### encrypt(ResourceName name, ByteString plaintext)

    public final EncryptResponse encrypt(ResourceName name, ByteString plaintext)

Encrypts data, so that it can only be recovered by a call to
Decrypt. The
CryptoKey.purpose must be
ENCRYPT_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       ResourceName name = CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
       ByteString plaintext = ByteString.EMPTY;
       EncryptResponse response = keyManagementServiceClient.encrypt(name, plaintext);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `com.google.api.resourcenames.ResourceName` Required. The resource name of the CryptoKey or CryptoKeyVersion to use for encryption. If a CryptoKey is specified, the server will use its primary version. |
| `plaintext` | `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` Required. The data to encrypt. Must be no larger than 64KiB. The maximum size depends on the key version's protection_level. For SOFTWARE, EXTERNAL, and EXTERNAL_VPC keys, the plaintext must be no larger than 64KiB. For HSM keys, the combined length of the plaintext and additional_authenticated_data fields must be no larger than 8KiB. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.EncryptResponse` |   |

### encrypt(CryptoKeyPathName name, ByteString plaintext)

    public final EncryptResponse encrypt(CryptoKeyPathName name, ByteString plaintext)

Encrypts data, so that it can only be recovered by a call to
Decrypt. The
CryptoKey.purpose must be
ENCRYPT_DECRYPT.

Sample code:


     try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
       CryptoKeyPathName name = CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
       ByteString plaintext = ByteString.copyFromUtf8("");
       EncryptResponse response = keyManagementServiceClient.encrypt(name, plaintext);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyPathName` Required. The resource name of the CryptoKey or CryptoKeyVersion to use for encryption. If a CryptoKey is specified, the server will use its primary version. |
| `plaintext` | `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` Required. The data to encrypt. Must be no larger than 64KiB. The maximum size depends on the key version's protection_level. For SOFTWARE keys, the plaintext must be no larger than 64KiB. For HSM keys, the combined length of the plaintext and additional_authenticated_data fields must be no larger than 8KiB. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.EncryptResponse` |   |

### encrypt(EncryptRequest request)

    public final EncryptResponse encrypt(EncryptRequest request)

Encrypts data, so that it can only be recovered by a call to
Decrypt. The
CryptoKey.purpose must be
ENCRYPT_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       EncryptRequest request =
           EncryptRequest.newBuilder()
               .setName(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .setPlaintext(ByteString.EMPTY)
               .setAdditionalAuthenticatedData(ByteString.EMPTY)
               .setPlaintextCrc32C(Int64Value.newBuilder().build())
               .setAdditionalAuthenticatedDataCrc32C(Int64Value.newBuilder().build())
               .build();
       EncryptResponse response = keyManagementServiceClient.encrypt(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.EncryptRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.EncryptResponse` |   |

### encrypt(String name, ByteString plaintext)

    public final EncryptResponse encrypt(String name, ByteString plaintext)

Encrypts data, so that it can only be recovered by a call to
Decrypt. The
CryptoKey.purpose must be
ENCRYPT_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String name = AutokeyConfigName.ofFolderName("[FOLDER]").toString();
       ByteString plaintext = ByteString.EMPTY;
       EncryptResponse response = keyManagementServiceClient.encrypt(name, plaintext);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The resource name of the CryptoKey or CryptoKeyVersion to use for encryption. If a CryptoKey is specified, the server will use its primary version. |
| `plaintext` | `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` Required. The data to encrypt. Must be no larger than 64KiB. The maximum size depends on the key version's protection_level. For SOFTWARE, EXTERNAL, and EXTERNAL_VPC keys, the plaintext must be no larger than 64KiB. For HSM keys, the combined length of the plaintext and additional_authenticated_data fields must be no larger than 8KiB. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.EncryptResponse` |   |

### encryptCallable()

    public final UnaryCallable<EncryptRequest,EncryptResponse> encryptCallable()

Encrypts data, so that it can only be recovered by a call to
Decrypt. The
CryptoKey.purpose must be
ENCRYPT_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       EncryptRequest request =
           EncryptRequest.newBuilder()
               .setName(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .setPlaintext(ByteString.EMPTY)
               .setAdditionalAuthenticatedData(ByteString.EMPTY)
               .setPlaintextCrc32C(Int64Value.newBuilder().build())
               .setAdditionalAuthenticatedDataCrc32C(Int64Value.newBuilder().build())
               .build();
       ApiFuture<EncryptResponse> future =
           keyManagementServiceClient.encryptCallable().futureCall(request);
       // Do something.
       EncryptResponse response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.EncryptRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.EncryptResponse>` |   |

### generateRandomBytes(GenerateRandomBytesRequest request)

    public final GenerateRandomBytesResponse generateRandomBytes(GenerateRandomBytesRequest request)

Generate random bytes using the Cloud KMS randomness source in the provided location.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       GenerateRandomBytesRequest request =
           GenerateRandomBytesRequest.newBuilder()
               .setLocation("location1901043637")
               .setLengthBytes(-745661998)
               .setProtectionLevel(ProtectionLevel.forNumber(0))
               .build();
       GenerateRandomBytesResponse response =
           keyManagementServiceClient.generateRandomBytes(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.GenerateRandomBytesRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.GenerateRandomBytesResponse` |   |

### generateRandomBytes(String location, int lengthBytes, ProtectionLevel protectionLevel)

    public final GenerateRandomBytesResponse generateRandomBytes(String location, int lengthBytes, ProtectionLevel protectionLevel)

Generate random bytes using the Cloud KMS randomness source in the provided location.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String location = "location1901043637";
       int lengthBytes = -745661998;
       ProtectionLevel protectionLevel = ProtectionLevel.forNumber(0);
       GenerateRandomBytesResponse response =
           keyManagementServiceClient.generateRandomBytes(location, lengthBytes, protectionLevel);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `location` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` The project-specific location in which to generate random bytes. For example, "projects/my-project/locations/us-central1". |
| `lengthBytes` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` The length in bytes of the amount of randomness to retrieve. Minimum 8 bytes, maximum 1024 bytes. |
| `protectionLevel` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ProtectionLevel` The ProtectionLevel to use when generating the random data. Currently, only HSM protection level is supported. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.GenerateRandomBytesResponse` |   |

### generateRandomBytesCallable()

    public final UnaryCallable<GenerateRandomBytesRequest,GenerateRandomBytesResponse> generateRandomBytesCallable()

Generate random bytes using the Cloud KMS randomness source in the provided location.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       GenerateRandomBytesRequest request =
           GenerateRandomBytesRequest.newBuilder()
               .setLocation("location1901043637")
               .setLengthBytes(-745661998)
               .setProtectionLevel(ProtectionLevel.forNumber(0))
               .build();
       ApiFuture<GenerateRandomBytesResponse> future =
           keyManagementServiceClient.generateRandomBytesCallable().futureCall(request);
       // Do something.
       GenerateRandomBytesResponse response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.GenerateRandomBytesRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.GenerateRandomBytesResponse>` |   |

### getCryptoKey(CryptoKeyName name)

    public final CryptoKey getCryptoKey(CryptoKeyName name)

Returns metadata for a given CryptoKey, as well as its
primary
CryptoKeyVersion.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CryptoKeyName name =
           CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
       CryptoKey response = keyManagementServiceClient.getCryptoKey(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyName` Required. The name of the CryptoKey to get. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey` |   |

### getCryptoKey(GetCryptoKeyRequest request)

    public final CryptoKey getCryptoKey(GetCryptoKeyRequest request)

Returns metadata for a given CryptoKey, as well as its
primary
CryptoKeyVersion.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       GetCryptoKeyRequest request =
           GetCryptoKeyRequest.newBuilder()
               .setName(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .build();
       CryptoKey response = keyManagementServiceClient.getCryptoKey(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.GetCryptoKeyRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey` |   |

### getCryptoKey(String name)

    public final CryptoKey getCryptoKey(String name)

Returns metadata for a given CryptoKey, as well as its
primary
CryptoKeyVersion.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String name =
           CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString();
       CryptoKey response = keyManagementServiceClient.getCryptoKey(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The name of the CryptoKey to get. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey` |   |

### getCryptoKeyCallable()

    public final UnaryCallable<GetCryptoKeyRequest,CryptoKey> getCryptoKeyCallable()

Returns metadata for a given CryptoKey, as well as its
primary
CryptoKeyVersion.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       GetCryptoKeyRequest request =
           GetCryptoKeyRequest.newBuilder()
               .setName(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .build();
       ApiFuture<CryptoKey> future =
           keyManagementServiceClient.getCryptoKeyCallable().futureCall(request);
       // Do something.
       CryptoKey response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.GetCryptoKeyRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey>` |   |

### getCryptoKeyVersion(CryptoKeyVersionName name)

    public final CryptoKeyVersion getCryptoKeyVersion(CryptoKeyVersionName name)

Returns metadata for a given CryptoKeyVersion.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CryptoKeyVersionName name =
           CryptoKeyVersionName.of(
               "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
       CryptoKeyVersion response = keyManagementServiceClient.getCryptoKeyVersion(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersionName` Required. The name of the CryptoKeyVersion to get. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` |   |

### getCryptoKeyVersion(GetCryptoKeyVersionRequest request)

    public final CryptoKeyVersion getCryptoKeyVersion(GetCryptoKeyVersionRequest request)

Returns metadata for a given CryptoKeyVersion.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       GetCryptoKeyVersionRequest request =
           GetCryptoKeyVersionRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .build();
       CryptoKeyVersion response = keyManagementServiceClient.getCryptoKeyVersion(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.GetCryptoKeyVersionRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` |   |

### getCryptoKeyVersion(String name)

    public final CryptoKeyVersion getCryptoKeyVersion(String name)

Returns metadata for a given CryptoKeyVersion.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String name =
           CryptoKeyVersionName.of(
                   "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
               .toString();
       CryptoKeyVersion response = keyManagementServiceClient.getCryptoKeyVersion(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The name of the CryptoKeyVersion to get. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` |   |

### getCryptoKeyVersionCallable()

    public final UnaryCallable<GetCryptoKeyVersionRequest,CryptoKeyVersion> getCryptoKeyVersionCallable()

Returns metadata for a given CryptoKeyVersion.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       GetCryptoKeyVersionRequest request =
           GetCryptoKeyVersionRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .build();
       ApiFuture<CryptoKeyVersion> future =
           keyManagementServiceClient.getCryptoKeyVersionCallable().futureCall(request);
       // Do something.
       CryptoKeyVersion response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.GetCryptoKeyVersionRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion>` |   |

### getHttpJsonOperationsClient()

    public final OperationsClient getHttpJsonOperationsClient()

> [!WARNING]
> **Beta**
>
> This feature is covered by the [Pre-GA Offerings Terms](https://docs.cloud.google.com/terms/service-terms#1) of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see the launch stage descriptions.

Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.httpjson.longrunning.OperationsClient.html` |   |

### getIamPolicy(KeyName resource)

    public final Policy getIamPolicy(KeyName resource)

Gets the access control policy for a resource. Returns an empty policy if the resource exists
and does not have a policy set.

Sample code:


     try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
       KeyName resource = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
       Policy response = keyManagementServiceClient.getIamPolicy(resource);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `resource` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyName` REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `com.google.iam.v1.Policy` |   |

### getIamPolicy(GetIamPolicyRequest request)

    public final Policy getIamPolicy(GetIamPolicyRequest request)

Gets the access control policy for a resource. Returns an empty policyif the resource exists
and does not have a policy set.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       GetIamPolicyRequest request =
           GetIamPolicyRequest.newBuilder()
               .setResource(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .setOptions(GetPolicyOptions.newBuilder().build())
               .build();
       Policy response = keyManagementServiceClient.getIamPolicy(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `com.google.iam.v1.GetIamPolicyRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `com.google.iam.v1.Policy` |   |

### getIamPolicy(String resource)

    public final Policy getIamPolicy(String resource)

Gets the access control policy for a resource. Returns an empty policy if the resource exists
and does not have a policy set.

Sample code:


     try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
       KeyName resource = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
       Policy response = keyManagementServiceClient.getIamPolicy(resource.toString());
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `resource` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `com.google.iam.v1.Policy` |   |

### getIamPolicyCallable()

    public final UnaryCallable<GetIamPolicyRequest,Policy> getIamPolicyCallable()

Gets the access control policy for a resource. Returns an empty policyif the resource exists
and does not have a policy set.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       GetIamPolicyRequest request =
           GetIamPolicyRequest.newBuilder()
               .setResource(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .setOptions(GetPolicyOptions.newBuilder().build())
               .build();
       ApiFuture<Policy> future =
           keyManagementServiceClient.getIamPolicyCallable().futureCall(request);
       // Do something.
       Policy response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy>` |   |

### getImportJob(GetImportJobRequest request)

    public final ImportJob getImportJob(GetImportJobRequest request)

Returns metadata for a given ImportJob.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       GetImportJobRequest request =
           GetImportJobRequest.newBuilder()
               .setName(
                   ImportJobName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[IMPORT_JOB]")
                       .toString())
               .build();
       ImportJob response = keyManagementServiceClient.getImportJob(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.GetImportJobRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ImportJob` |   |

### getImportJob(ImportJobName name)

    public final ImportJob getImportJob(ImportJobName name)

Returns metadata for a given ImportJob.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       ImportJobName name =
           ImportJobName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[IMPORT_JOB]");
       ImportJob response = keyManagementServiceClient.getImportJob(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ImportJobName` Required. The name of the ImportJob to get. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ImportJob` |   |

### getImportJob(String name)

    public final ImportJob getImportJob(String name)

Returns metadata for a given ImportJob.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String name =
           ImportJobName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[IMPORT_JOB]").toString();
       ImportJob response = keyManagementServiceClient.getImportJob(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The name of the ImportJob to get. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ImportJob` |   |

### getImportJobCallable()

    public final UnaryCallable<GetImportJobRequest,ImportJob> getImportJobCallable()

Returns metadata for a given ImportJob.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       GetImportJobRequest request =
           GetImportJobRequest.newBuilder()
               .setName(
                   ImportJobName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[IMPORT_JOB]")
                       .toString())
               .build();
       ApiFuture<ImportJob> future =
           keyManagementServiceClient.getImportJobCallable().futureCall(request);
       // Do something.
       ImportJob response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.GetImportJobRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ImportJob>` |   |

### getKeyRing(GetKeyRingRequest request)

    public final KeyRing getKeyRing(GetKeyRingRequest request)

Returns metadata for a given KeyRing.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       GetKeyRingRequest request =
           GetKeyRingRequest.newBuilder()
               .setName(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
               .build();
       KeyRing response = keyManagementServiceClient.getKeyRing(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.GetKeyRingRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyRing` |   |

### getKeyRing(KeyRingName name)

    public final KeyRing getKeyRing(KeyRingName name)

Returns metadata for a given KeyRing.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       KeyRingName name = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
       KeyRing response = keyManagementServiceClient.getKeyRing(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyRingName` Required. The name of the KeyRing to get. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyRing` |   |

### getKeyRing(String name)

    public final KeyRing getKeyRing(String name)

Returns metadata for a given KeyRing.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String name = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString();
       KeyRing response = keyManagementServiceClient.getKeyRing(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The name of the KeyRing to get. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyRing` |   |

### getKeyRingCallable()

    public final UnaryCallable<GetKeyRingRequest,KeyRing> getKeyRingCallable()

Returns metadata for a given KeyRing.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       GetKeyRingRequest request =
           GetKeyRingRequest.newBuilder()
               .setName(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
               .build();
       ApiFuture<KeyRing> future =
           keyManagementServiceClient.getKeyRingCallable().futureCall(request);
       // Do something.
       KeyRing response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.GetKeyRingRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyRing>` |   |

### getLocation(GetLocationRequest request)

    public final Location getLocation(GetLocationRequest request)

Gets information about a location.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
       Location response = keyManagementServiceClient.getLocation(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `com.google.cloud.location.GetLocationRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `com.google.cloud.location.Location` |   |

### getLocationCallable()

    public final UnaryCallable<GetLocationRequest,Location> getLocationCallable()

Gets information about a location.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
       ApiFuture<Location> future =
           keyManagementServiceClient.getLocationCallable().futureCall(request);
       // Do something.
       Location response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location>` |   |

### getOperationsClient()

    public final OperationsClient getOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.longrunning.OperationsClient.html` |   |

### getPublicKey(CryptoKeyVersionName name)

    public final PublicKey getPublicKey(CryptoKeyVersionName name)

Returns the public key for the given CryptoKeyVersion.
The CryptoKey.purpose must be
ASYMMETRIC_SIGN or
ASYMMETRIC_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CryptoKeyVersionName name =
           CryptoKeyVersionName.of(
               "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
       PublicKey response = keyManagementServiceClient.getPublicKey(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersionName` Required. The name of the CryptoKeyVersion public key to get. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.PublicKey` |   |

### getPublicKey(GetPublicKeyRequest request)

    public final PublicKey getPublicKey(GetPublicKeyRequest request)

Returns the public key for the given CryptoKeyVersion.
The CryptoKey.purpose must be
ASYMMETRIC_SIGN or
ASYMMETRIC_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     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);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.GetPublicKeyRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.PublicKey` |   |

### getPublicKey(String name)

    public final PublicKey getPublicKey(String name)

Returns the public key for the given CryptoKeyVersion.
The CryptoKey.purpose must be
ASYMMETRIC_SIGN or
ASYMMETRIC_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String name =
           CryptoKeyVersionName.of(
                   "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
               .toString();
       PublicKey response = keyManagementServiceClient.getPublicKey(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The name of the CryptoKeyVersion public key to get. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.PublicKey` |   |

### getPublicKeyCallable()

    public final UnaryCallable<GetPublicKeyRequest,PublicKey> getPublicKeyCallable()

Returns the public key for the given CryptoKeyVersion.
The CryptoKey.purpose must be
ASYMMETRIC_SIGN or
ASYMMETRIC_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       GetPublicKeyRequest request =
           GetPublicKeyRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .build();
       ApiFuture<PublicKey> future =
           keyManagementServiceClient.getPublicKeyCallable().futureCall(request);
       // Do something.
       PublicKey response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.GetPublicKeyRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.PublicKey>` |   |

### getRetiredResource(GetRetiredResourceRequest request)

    public final RetiredResource getRetiredResource(GetRetiredResourceRequest request)

Retrieves a specific RetiredResource resource, which
represents the record of a deleted CryptoKey.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       GetRetiredResourceRequest request =
           GetRetiredResourceRequest.newBuilder()
               .setName(
                   RetiredResourceName.of("[PROJECT]", "[LOCATION]", "[RETIRED_RESOURCE]")
                       .toString())
               .build();
       RetiredResource response = keyManagementServiceClient.getRetiredResource(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.GetRetiredResourceRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.RetiredResource` |   |

### getRetiredResource(RetiredResourceName name)

    public final RetiredResource getRetiredResource(RetiredResourceName name)

Retrieves a specific RetiredResource resource, which
represents the record of a deleted CryptoKey.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       RetiredResourceName name =
           RetiredResourceName.of("[PROJECT]", "[LOCATION]", "[RETIRED_RESOURCE]");
       RetiredResource response = keyManagementServiceClient.getRetiredResource(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.RetiredResourceName` Required. The name of the RetiredResource to get. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.RetiredResource` |   |

### getRetiredResource(String name)

    public final RetiredResource getRetiredResource(String name)

Retrieves a specific RetiredResource resource, which
represents the record of a deleted CryptoKey.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String name =
           RetiredResourceName.of("[PROJECT]", "[LOCATION]", "[RETIRED_RESOURCE]").toString();
       RetiredResource response = keyManagementServiceClient.getRetiredResource(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The name of the RetiredResource to get. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.RetiredResource` |   |

### getRetiredResourceCallable()

    public final UnaryCallable<GetRetiredResourceRequest,RetiredResource> getRetiredResourceCallable()

Retrieves a specific RetiredResource resource, which
represents the record of a deleted CryptoKey.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       GetRetiredResourceRequest request =
           GetRetiredResourceRequest.newBuilder()
               .setName(
                   RetiredResourceName.of("[PROJECT]", "[LOCATION]", "[RETIRED_RESOURCE]")
                       .toString())
               .build();
       ApiFuture<RetiredResource> future =
           keyManagementServiceClient.getRetiredResourceCallable().futureCall(request);
       // Do something.
       RetiredResource response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.GetRetiredResourceRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.RetiredResource>` |   |

### getSettings()

    public final KeyManagementServiceSettings getSettings()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceSettings` |   |

### getStub()

    public KeyManagementServiceStub getStub()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.stub.KeyManagementServiceStub` |   |

### importCryptoKeyVersion(ImportCryptoKeyVersionRequest request)

    public final CryptoKeyVersion importCryptoKeyVersion(ImportCryptoKeyVersionRequest request)

Import wrapped key material into a CryptoKeyVersion.

All requests must specify a CryptoKey. If a
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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       ImportCryptoKeyVersionRequest request =
           ImportCryptoKeyVersionRequest.newBuilder()
               .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")
               .setWrappedKey(ByteString.EMPTY)
               .build();
       CryptoKeyVersion response = keyManagementServiceClient.importCryptoKeyVersion(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ImportCryptoKeyVersionRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` |   |

### importCryptoKeyVersionCallable()

    public final UnaryCallable<ImportCryptoKeyVersionRequest,CryptoKeyVersion> importCryptoKeyVersionCallable()

Import wrapped key material into a CryptoKeyVersion.

All requests must specify a CryptoKey. If a
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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       ImportCryptoKeyVersionRequest request =
           ImportCryptoKeyVersionRequest.newBuilder()
               .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")
               .setWrappedKey(ByteString.EMPTY)
               .build();
       ApiFuture<CryptoKeyVersion> future =
           keyManagementServiceClient.importCryptoKeyVersionCallable().futureCall(request);
       // Do something.
       CryptoKeyVersion response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ImportCryptoKeyVersionRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion>` |   |

### isShutdown()

    public boolean isShutdown()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### isTerminated()

    public boolean isTerminated()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### listCryptoKeyVersions(CryptoKeyName parent)

    public final KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse listCryptoKeyVersions(CryptoKeyName parent)

Lists CryptoKeyVersions.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CryptoKeyName parent =
           CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
       for (CryptoKeyVersion element :
           keyManagementServiceClient.listCryptoKeyVersions(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyName` Required. The resource name of the CryptoKey to list, in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse` |   |

### listCryptoKeyVersions(ListCryptoKeyVersionsRequest request)

    public final KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse listCryptoKeyVersions(ListCryptoKeyVersionsRequest request)

Lists CryptoKeyVersions.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       ListCryptoKeyVersionsRequest request =
           ListCryptoKeyVersionsRequest.newBuilder()
               .setParent(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .setFilter("filter-1274492040")
               .setOrderBy("orderBy-1207110587")
               .build();
       for (CryptoKeyVersion element :
           keyManagementServiceClient.listCryptoKeyVersions(request).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListCryptoKeyVersionsRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse` |   |

### listCryptoKeyVersions(String parent)

    public final KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse listCryptoKeyVersions(String parent)

Lists CryptoKeyVersions.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String parent =
           CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString();
       for (CryptoKeyVersion element :
           keyManagementServiceClient.listCryptoKeyVersions(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The resource name of the CryptoKey to list, in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse` |   |

### listCryptoKeyVersionsCallable()

    public final UnaryCallable<ListCryptoKeyVersionsRequest,ListCryptoKeyVersionsResponse> listCryptoKeyVersionsCallable()

Lists CryptoKeyVersions.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       ListCryptoKeyVersionsRequest request =
           ListCryptoKeyVersionsRequest.newBuilder()
               .setParent(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .setFilter("filter-1274492040")
               .setOrderBy("orderBy-1207110587")
               .build();
       while (true) {
         ListCryptoKeyVersionsResponse response =
             keyManagementServiceClient.listCryptoKeyVersionsCallable().call(request);
         for (CryptoKeyVersion element : response.getCryptoKeyVersionsList()) {
           // doThingsWith(element);
         }
         String nextPageToken = response.getNextPageToken();
         if (!Strings.isNullOrEmpty(nextPageToken)) {
           request = request.toBuilder().setPageToken(nextPageToken).build();
         } else {
           break;
         }
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListCryptoKeyVersionsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListCryptoKeyVersionsResponse>` |   |

### listCryptoKeyVersionsPagedCallable()

    public final UnaryCallable<ListCryptoKeyVersionsRequest,KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse> listCryptoKeyVersionsPagedCallable()

Lists CryptoKeyVersions.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       ListCryptoKeyVersionsRequest request =
           ListCryptoKeyVersionsRequest.newBuilder()
               .setParent(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .setFilter("filter-1274492040")
               .setOrderBy("orderBy-1207110587")
               .build();
       ApiFuture<CryptoKeyVersion> future =
           keyManagementServiceClient.listCryptoKeyVersionsPagedCallable().futureCall(request);
       // Do something.
       for (CryptoKeyVersion element : future.get().iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListCryptoKeyVersionsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse>` |   |

### listCryptoKeys(KeyRingName parent)

    public final KeyManagementServiceClient.ListCryptoKeysPagedResponse listCryptoKeys(KeyRingName parent)

Lists CryptoKeys.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       KeyRingName parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
       for (CryptoKey element : keyManagementServiceClient.listCryptoKeys(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyRingName` Required. The resource name of the KeyRing to list, in the format `projects/*/locations/*/keyRings/*`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeysPagedResponse` |   |

### listCryptoKeys(ListCryptoKeysRequest request)

    public final KeyManagementServiceClient.ListCryptoKeysPagedResponse listCryptoKeys(ListCryptoKeysRequest request)

Lists CryptoKeys.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     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();
       for (CryptoKey element : keyManagementServiceClient.listCryptoKeys(request).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListCryptoKeysRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeysPagedResponse` |   |

### listCryptoKeys(String parent)

    public final KeyManagementServiceClient.ListCryptoKeysPagedResponse listCryptoKeys(String parent)

Lists CryptoKeys.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString();
       for (CryptoKey element : keyManagementServiceClient.listCryptoKeys(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The resource name of the KeyRing to list, in the format `projects/*/locations/*/keyRings/*`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeysPagedResponse` |   |

### listCryptoKeysCallable()

    public final UnaryCallable<ListCryptoKeysRequest,ListCryptoKeysResponse> listCryptoKeysCallable()

Lists CryptoKeys.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     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();
       while (true) {
         ListCryptoKeysResponse response =
             keyManagementServiceClient.listCryptoKeysCallable().call(request);
         for (CryptoKey element : response.getCryptoKeysList()) {
           // doThingsWith(element);
         }
         String nextPageToken = response.getNextPageToken();
         if (!Strings.isNullOrEmpty(nextPageToken)) {
           request = request.toBuilder().setPageToken(nextPageToken).build();
         } else {
           break;
         }
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListCryptoKeysRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListCryptoKeysResponse>` |   |

### listCryptoKeysPagedCallable()

    public final UnaryCallable<ListCryptoKeysRequest,KeyManagementServiceClient.ListCryptoKeysPagedResponse> listCryptoKeysPagedCallable()

Lists CryptoKeys.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     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);
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListCryptoKeysRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeysPagedResponse>` |   |

### listImportJobs(KeyRingName parent)

    public final KeyManagementServiceClient.ListImportJobsPagedResponse listImportJobs(KeyRingName parent)

Lists ImportJobs.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       KeyRingName parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
       for (ImportJob element : keyManagementServiceClient.listImportJobs(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyRingName` Required. The resource name of the KeyRing to list, in the format `projects/*/locations/*/keyRings/*`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse` |   |

### listImportJobs(ListImportJobsRequest request)

    public final KeyManagementServiceClient.ListImportJobsPagedResponse listImportJobs(ListImportJobsRequest request)

Lists ImportJobs.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       ListImportJobsRequest request =
           ListImportJobsRequest.newBuilder()
               .setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .setFilter("filter-1274492040")
               .setOrderBy("orderBy-1207110587")
               .build();
       for (ImportJob element : keyManagementServiceClient.listImportJobs(request).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListImportJobsRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse` |   |

### listImportJobs(String parent)

    public final KeyManagementServiceClient.ListImportJobsPagedResponse listImportJobs(String parent)

Lists ImportJobs.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString();
       for (ImportJob element : keyManagementServiceClient.listImportJobs(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The resource name of the KeyRing to list, in the format `projects/*/locations/*/keyRings/*`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse` |   |

### listImportJobsCallable()

    public final UnaryCallable<ListImportJobsRequest,ListImportJobsResponse> listImportJobsCallable()

Lists ImportJobs.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       ListImportJobsRequest request =
           ListImportJobsRequest.newBuilder()
               .setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .setFilter("filter-1274492040")
               .setOrderBy("orderBy-1207110587")
               .build();
       while (true) {
         ListImportJobsResponse response =
             keyManagementServiceClient.listImportJobsCallable().call(request);
         for (ImportJob element : response.getImportJobsList()) {
           // doThingsWith(element);
         }
         String nextPageToken = response.getNextPageToken();
         if (!Strings.isNullOrEmpty(nextPageToken)) {
           request = request.toBuilder().setPageToken(nextPageToken).build();
         } else {
           break;
         }
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListImportJobsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListImportJobsResponse>` |   |

### listImportJobsPagedCallable()

    public final UnaryCallable<ListImportJobsRequest,KeyManagementServiceClient.ListImportJobsPagedResponse> listImportJobsPagedCallable()

Lists ImportJobs.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       ListImportJobsRequest request =
           ListImportJobsRequest.newBuilder()
               .setParent(KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .setFilter("filter-1274492040")
               .setOrderBy("orderBy-1207110587")
               .build();
       ApiFuture<ImportJob> future =
           keyManagementServiceClient.listImportJobsPagedCallable().futureCall(request);
       // Do something.
       for (ImportJob element : future.get().iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListImportJobsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse>` |   |

### listKeyRings(ListKeyRingsRequest request)

    public final KeyManagementServiceClient.ListKeyRingsPagedResponse listKeyRings(ListKeyRingsRequest request)

Lists KeyRings.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     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();
       for (KeyRing element : keyManagementServiceClient.listKeyRings(request).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListKeyRingsRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListKeyRingsPagedResponse` |   |

### listKeyRings(LocationName parent)

    public final KeyManagementServiceClient.ListKeyRingsPagedResponse listKeyRings(LocationName parent)

Lists KeyRings.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
       for (KeyRing element : keyManagementServiceClient.listKeyRings(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.LocationName` Required. The resource name of the location associated with the KeyRings, in the format `projects/*/locations/*`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListKeyRingsPagedResponse` |   |

### listKeyRings(String parent)

    public final KeyManagementServiceClient.ListKeyRingsPagedResponse listKeyRings(String parent)

Lists KeyRings.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
       for (KeyRing element : keyManagementServiceClient.listKeyRings(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The resource name of the location associated with the KeyRings, in the format `projects/*/locations/*`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListKeyRingsPagedResponse` |   |

### listKeyRingsCallable()

    public final UnaryCallable<ListKeyRingsRequest,ListKeyRingsResponse> listKeyRingsCallable()

Lists KeyRings.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     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.getKeyRingsList()) {
           // doThingsWith(element);
         }
         String nextPageToken = response.getNextPageToken();
         if (!Strings.isNullOrEmpty(nextPageToken)) {
           request = request.toBuilder().setPageToken(nextPageToken).build();
         } else {
           break;
         }
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListKeyRingsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListKeyRingsResponse>` |   |

### listKeyRingsPagedCallable()

    public final UnaryCallable<ListKeyRingsRequest,KeyManagementServiceClient.ListKeyRingsPagedResponse> listKeyRingsPagedCallable()

Lists KeyRings.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     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();
       ApiFuture<KeyRing> future =
           keyManagementServiceClient.listKeyRingsPagedCallable().futureCall(request);
       // Do something.
       for (KeyRing element : future.get().iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListKeyRingsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListKeyRingsPagedResponse>` |   |

### listLocations(ListLocationsRequest request)

    public final KeyManagementServiceClient.ListLocationsPagedResponse listLocations(ListLocationsRequest request)

Lists information about the supported locations for this service.

This method lists locations based on the resource scope provided inthe
\[ListLocationsRequest.name\] field:

\* \*\*Global locations\*\*: If `name` is empty, the method lists thepublic
locations available to all projects. \* \*\*Project-specificlocations\*\*: If
`name` follows the format`projects/{project}`, the method lists locations visible to
thatspecific project. This includes public, private, or otherproject-specific locations enabled
for the project.

For gRPC and client library implementations, the resource name ispassed as the `name` field.
For direct service calls, the resourcename isincorporated into the request path based on the
specific serviceimplementation and version.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       ListLocationsRequest request =
           ListLocationsRequest.newBuilder()
               .setName("name3373707")
               .setFilter("filter-1274492040")
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .build();
       for (Location element : keyManagementServiceClient.listLocations(request).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `com.google.cloud.location.ListLocationsRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListLocationsPagedResponse` |   |

### listLocationsCallable()

    public final UnaryCallable<ListLocationsRequest,ListLocationsResponse> listLocationsCallable()

Lists information about the supported locations for this service.

This method lists locations based on the resource scope provided inthe
\[ListLocationsRequest.name\] field:

\* \*\*Global locations\*\*: If `name` is empty, the method lists thepublic
locations available to all projects. \* \*\*Project-specificlocations\*\*: If
`name` follows the format`projects/{project}`, the method lists locations visible to
thatspecific project. This includes public, private, or otherproject-specific locations enabled
for the project.

For gRPC and client library implementations, the resource name ispassed as the `name` field.
For direct service calls, the resourcename isincorporated into the request path based on the
specific serviceimplementation and version.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       ListLocationsRequest request =
           ListLocationsRequest.newBuilder()
               .setName("name3373707")
               .setFilter("filter-1274492040")
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .build();
       while (true) {
         ListLocationsResponse response =
             keyManagementServiceClient.listLocationsCallable().call(request);
         for (Location element : response.getLocationsList()) {
           // doThingsWith(element);
         }
         String nextPageToken = response.getNextPageToken();
         if (!Strings.isNullOrEmpty(nextPageToken)) {
           request = request.toBuilder().setPageToken(nextPageToken).build();
         } else {
           break;
         }
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse>` |   |

### listLocationsPagedCallable()

    public final UnaryCallable<ListLocationsRequest,KeyManagementServiceClient.ListLocationsPagedResponse> listLocationsPagedCallable()

Lists information about the supported locations for this service.

This method lists locations based on the resource scope provided inthe
\[ListLocationsRequest.name\] field:

\* \*\*Global locations\*\*: If `name` is empty, the method lists thepublic
locations available to all projects. \* \*\*Project-specificlocations\*\*: If
`name` follows the format`projects/{project}`, the method lists locations visible to
thatspecific project. This includes public, private, or otherproject-specific locations enabled
for the project.

For gRPC and client library implementations, the resource name ispassed as the `name` field.
For direct service calls, the resourcename isincorporated into the request path based on the
specific serviceimplementation and version.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     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);
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<com.google.cloud.location.ListLocationsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListLocationsPagedResponse>` |   |

### listRetiredResources(ListRetiredResourcesRequest request)

    public final KeyManagementServiceClient.ListRetiredResourcesPagedResponse listRetiredResources(ListRetiredResourcesRequest request)

Lists the RetiredResources which are the records of
deleted CryptoKeys. RetiredResources prevent the reuse of
these resource names after deletion.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       ListRetiredResourcesRequest request =
           ListRetiredResourcesRequest.newBuilder()
               .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .build();
       for (RetiredResource element :
           keyManagementServiceClient.listRetiredResources(request).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListRetiredResourcesRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListRetiredResourcesPagedResponse` |   |

### listRetiredResources(LocationName parent)

    public final KeyManagementServiceClient.ListRetiredResourcesPagedResponse listRetiredResources(LocationName parent)

Lists the RetiredResources which are the records of
deleted CryptoKeys. RetiredResources prevent the reuse of
these resource names after deletion.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
       for (RetiredResource element :
           keyManagementServiceClient.listRetiredResources(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.LocationName` Required. The project-specific location holding the RetiredResources, in the format `projects/*/locations/*`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListRetiredResourcesPagedResponse` |   |

### listRetiredResources(String parent)

    public final KeyManagementServiceClient.ListRetiredResourcesPagedResponse listRetiredResources(String parent)

Lists the RetiredResources which are the records of
deleted CryptoKeys. RetiredResources prevent the reuse of
these resource names after deletion.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
       for (RetiredResource element :
           keyManagementServiceClient.listRetiredResources(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The project-specific location holding the RetiredResources, in the format `projects/*/locations/*`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListRetiredResourcesPagedResponse` |   |

### listRetiredResourcesCallable()

    public final UnaryCallable<ListRetiredResourcesRequest,ListRetiredResourcesResponse> listRetiredResourcesCallable()

Lists the RetiredResources which are the records of
deleted CryptoKeys. RetiredResources prevent the reuse of
these resource names after deletion.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       ListRetiredResourcesRequest request =
           ListRetiredResourcesRequest.newBuilder()
               .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .build();
       while (true) {
         ListRetiredResourcesResponse response =
             keyManagementServiceClient.listRetiredResourcesCallable().call(request);
         for (RetiredResource element : response.getRetiredResourcesList()) {
           // doThingsWith(element);
         }
         String nextPageToken = response.getNextPageToken();
         if (!Strings.isNullOrEmpty(nextPageToken)) {
           request = request.toBuilder().setPageToken(nextPageToken).build();
         } else {
           break;
         }
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListRetiredResourcesRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListRetiredResourcesResponse>` |   |

### listRetiredResourcesPagedCallable()

    public final UnaryCallable<ListRetiredResourcesRequest,KeyManagementServiceClient.ListRetiredResourcesPagedResponse> listRetiredResourcesPagedCallable()

Lists the RetiredResources which are the records of
deleted CryptoKeys. RetiredResources prevent the reuse of
these resource names after deletion.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       ListRetiredResourcesRequest request =
           ListRetiredResourcesRequest.newBuilder()
               .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .build();
       ApiFuture<RetiredResource> future =
           keyManagementServiceClient.listRetiredResourcesPagedCallable().futureCall(request);
       // Do something.
       for (RetiredResource element : future.get().iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.ListRetiredResourcesRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyManagementServiceClient.ListRetiredResourcesPagedResponse>` |   |

### macSign(CryptoKeyVersionName name, ByteString data)

    public final MacSignResponse macSign(CryptoKeyVersionName name, ByteString data)

Signs data using a CryptoKeyVersion with
CryptoKey.purpose MAC, producing a tag that can be
verified by another source with the same key.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CryptoKeyVersionName name =
           CryptoKeyVersionName.of(
               "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
       ByteString data = ByteString.EMPTY;
       MacSignResponse response = keyManagementServiceClient.macSign(name, data);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersionName` Required. The resource name of the CryptoKeyVersion to use for signing. |
| `data` | `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` Required. The data to sign. The MAC tag is computed over this data field based on the specific algorithm. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.MacSignResponse` |   |

### macSign(MacSignRequest request)

    public final MacSignResponse macSign(MacSignRequest request)

Signs data using a CryptoKeyVersion with
CryptoKey.purpose MAC, producing a tag that can be
verified by another source with the same key.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       MacSignRequest request =
           MacSignRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .setData(ByteString.EMPTY)
               .setDataCrc32C(Int64Value.newBuilder().build())
               .build();
       MacSignResponse response = keyManagementServiceClient.macSign(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.MacSignRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.MacSignResponse` |   |

### macSign(String name, ByteString data)

    public final MacSignResponse macSign(String name, ByteString data)

Signs data using a CryptoKeyVersion with
CryptoKey.purpose MAC, producing a tag that can be
verified by another source with the same key.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String name =
           CryptoKeyVersionName.of(
                   "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
               .toString();
       ByteString data = ByteString.EMPTY;
       MacSignResponse response = keyManagementServiceClient.macSign(name, data);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The resource name of the CryptoKeyVersion to use for signing. |
| `data` | `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` Required. The data to sign. The MAC tag is computed over this data field based on the specific algorithm. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.MacSignResponse` |   |

### macSignCallable()

    public final UnaryCallable<MacSignRequest,MacSignResponse> macSignCallable()

Signs data using a CryptoKeyVersion with
CryptoKey.purpose MAC, producing a tag that can be
verified by another source with the same key.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       MacSignRequest request =
           MacSignRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .setData(ByteString.EMPTY)
               .setDataCrc32C(Int64Value.newBuilder().build())
               .build();
       ApiFuture<MacSignResponse> future =
           keyManagementServiceClient.macSignCallable().futureCall(request);
       // Do something.
       MacSignResponse response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.MacSignRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.MacSignResponse>` |   |

### macVerify(CryptoKeyVersionName name, ByteString data, ByteString mac)

    public final MacVerifyResponse macVerify(CryptoKeyVersionName name, ByteString data, ByteString mac)

Verifies MAC tag using a CryptoKeyVersion with
CryptoKey.purpose MAC, and returns a response that
indicates whether or not the verification was successful.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CryptoKeyVersionName name =
           CryptoKeyVersionName.of(
               "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
       ByteString data = ByteString.EMPTY;
       ByteString mac = ByteString.EMPTY;
       MacVerifyResponse response = keyManagementServiceClient.macVerify(name, data, mac);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersionName` Required. The resource name of the CryptoKeyVersion to use for verification. |
| `data` | `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` Required. The data used previously as a MacSignRequest.data to generate the MAC tag. |
| `mac` | `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` Required. The signature to verify. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.MacVerifyResponse` |   |

### macVerify(MacVerifyRequest request)

    public final MacVerifyResponse macVerify(MacVerifyRequest request)

Verifies MAC tag using a CryptoKeyVersion with
CryptoKey.purpose MAC, and returns a response that
indicates whether or not the verification was successful.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       MacVerifyRequest request =
           MacVerifyRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .setData(ByteString.EMPTY)
               .setDataCrc32C(Int64Value.newBuilder().build())
               .setMac(ByteString.EMPTY)
               .setMacCrc32C(Int64Value.newBuilder().build())
               .build();
       MacVerifyResponse response = keyManagementServiceClient.macVerify(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.MacVerifyRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.MacVerifyResponse` |   |

### macVerify(String name, ByteString data, ByteString mac)

    public final MacVerifyResponse macVerify(String name, ByteString data, ByteString mac)

Verifies MAC tag using a CryptoKeyVersion with
CryptoKey.purpose MAC, and returns a response that
indicates whether or not the verification was successful.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String name =
           CryptoKeyVersionName.of(
                   "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
               .toString();
       ByteString data = ByteString.EMPTY;
       ByteString mac = ByteString.EMPTY;
       MacVerifyResponse response = keyManagementServiceClient.macVerify(name, data, mac);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The resource name of the CryptoKeyVersion to use for verification. |
| `data` | `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` Required. The data used previously as a MacSignRequest.data to generate the MAC tag. |
| `mac` | `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` Required. The signature to verify. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.MacVerifyResponse` |   |

### macVerifyCallable()

    public final UnaryCallable<MacVerifyRequest,MacVerifyResponse> macVerifyCallable()

Verifies MAC tag using a CryptoKeyVersion with
CryptoKey.purpose MAC, and returns a response that
indicates whether or not the verification was successful.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       MacVerifyRequest request =
           MacVerifyRequest.newBuilder()
               .setName(
                   CryptoKeyVersionName.of(
                           "[PROJECT]",
                           "[LOCATION]",
                           "[KEY_RING]",
                           "[CRYPTO_KEY]",
                           "[CRYPTO_KEY_VERSION]")
                       .toString())
               .setData(ByteString.EMPTY)
               .setDataCrc32C(Int64Value.newBuilder().build())
               .setMac(ByteString.EMPTY)
               .setMacCrc32C(Int64Value.newBuilder().build())
               .build();
       ApiFuture<MacVerifyResponse> future =
           keyManagementServiceClient.macVerifyCallable().futureCall(request);
       // Do something.
       MacVerifyResponse response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.MacVerifyRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.MacVerifyResponse>` |   |

### rawDecrypt(RawDecryptRequest request)

    public final RawDecryptResponse rawDecrypt(RawDecryptRequest request)

Decrypts data that was originally encrypted using a raw cryptographic mechanism. The
CryptoKey.purpose must be
RAW_ENCRYPT_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       RawDecryptRequest request =
           RawDecryptRequest.newBuilder()
               .setName("name3373707")
               .setCiphertext(ByteString.EMPTY)
               .setAdditionalAuthenticatedData(ByteString.EMPTY)
               .setInitializationVector(ByteString.EMPTY)
               .setTagLength(172791595)
               .setCiphertextCrc32C(Int64Value.newBuilder().build())
               .setAdditionalAuthenticatedDataCrc32C(Int64Value.newBuilder().build())
               .setInitializationVectorCrc32C(Int64Value.newBuilder().build())
               .build();
       RawDecryptResponse response = keyManagementServiceClient.rawDecrypt(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.RawDecryptRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.RawDecryptResponse` |   |

### rawDecryptCallable()

    public final UnaryCallable<RawDecryptRequest,RawDecryptResponse> rawDecryptCallable()

Decrypts data that was originally encrypted using a raw cryptographic mechanism. The
CryptoKey.purpose must be
RAW_ENCRYPT_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       RawDecryptRequest request =
           RawDecryptRequest.newBuilder()
               .setName("name3373707")
               .setCiphertext(ByteString.EMPTY)
               .setAdditionalAuthenticatedData(ByteString.EMPTY)
               .setInitializationVector(ByteString.EMPTY)
               .setTagLength(172791595)
               .setCiphertextCrc32C(Int64Value.newBuilder().build())
               .setAdditionalAuthenticatedDataCrc32C(Int64Value.newBuilder().build())
               .setInitializationVectorCrc32C(Int64Value.newBuilder().build())
               .build();
       ApiFuture<RawDecryptResponse> future =
           keyManagementServiceClient.rawDecryptCallable().futureCall(request);
       // Do something.
       RawDecryptResponse response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.RawDecryptRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.RawDecryptResponse>` |   |

### rawEncrypt(RawEncryptRequest request)

    public final RawEncryptResponse rawEncrypt(RawEncryptRequest request)

Encrypts data using portable cryptographic primitives. Most users should choose
Encrypt and
Decrypt rather than their raw counterparts.
The CryptoKey.purpose must be
RAW_ENCRYPT_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       RawEncryptRequest request =
           RawEncryptRequest.newBuilder()
               .setName("name3373707")
               .setPlaintext(ByteString.EMPTY)
               .setAdditionalAuthenticatedData(ByteString.EMPTY)
               .setPlaintextCrc32C(Int64Value.newBuilder().build())
               .setAdditionalAuthenticatedDataCrc32C(Int64Value.newBuilder().build())
               .setInitializationVector(ByteString.EMPTY)
               .setInitializationVectorCrc32C(Int64Value.newBuilder().build())
               .build();
       RawEncryptResponse response = keyManagementServiceClient.rawEncrypt(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.RawEncryptRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.RawEncryptResponse` |   |

### rawEncryptCallable()

    public final UnaryCallable<RawEncryptRequest,RawEncryptResponse> rawEncryptCallable()

Encrypts data using portable cryptographic primitives. Most users should choose
Encrypt and
Decrypt rather than their raw counterparts.
The CryptoKey.purpose must be
RAW_ENCRYPT_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       RawEncryptRequest request =
           RawEncryptRequest.newBuilder()
               .setName("name3373707")
               .setPlaintext(ByteString.EMPTY)
               .setAdditionalAuthenticatedData(ByteString.EMPTY)
               .setPlaintextCrc32C(Int64Value.newBuilder().build())
               .setAdditionalAuthenticatedDataCrc32C(Int64Value.newBuilder().build())
               .setInitializationVector(ByteString.EMPTY)
               .setInitializationVectorCrc32C(Int64Value.newBuilder().build())
               .build();
       ApiFuture<RawEncryptResponse> future =
           keyManagementServiceClient.rawEncryptCallable().futureCall(request);
       // Do something.
       RawEncryptResponse response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.RawEncryptRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.RawEncryptResponse>` |   |

### restoreCryptoKeyVersion(CryptoKeyVersionName name)

    public final CryptoKeyVersion restoreCryptoKeyVersion(CryptoKeyVersionName name)

Restore a CryptoKeyVersion in the
DESTROY_SCHEDULED
state.

Upon restoration of the CryptoKeyVersion,
state will be set to
DISABLED, and
destroy_time will be cleared.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CryptoKeyVersionName name =
           CryptoKeyVersionName.of(
               "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]");
       CryptoKeyVersion response = keyManagementServiceClient.restoreCryptoKeyVersion(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersionName` Required. The resource name of the CryptoKeyVersion to restore. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` |   |

### restoreCryptoKeyVersion(RestoreCryptoKeyVersionRequest request)

    public final CryptoKeyVersion restoreCryptoKeyVersion(RestoreCryptoKeyVersionRequest request)

Restore a CryptoKeyVersion in the
DESTROY_SCHEDULED
state.

Upon restoration of the CryptoKeyVersion,
state will be set to
DISABLED, and
destroy_time will be cleared.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     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);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` |   |

### restoreCryptoKeyVersion(String name)

    public final CryptoKeyVersion restoreCryptoKeyVersion(String name)

Restore a CryptoKeyVersion in the
DESTROY_SCHEDULED
state.

Upon restoration of the CryptoKeyVersion,
state will be set to
DISABLED, and
destroy_time will be cleared.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String name =
           CryptoKeyVersionName.of(
                   "[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
               .toString();
       CryptoKeyVersion response = keyManagementServiceClient.restoreCryptoKeyVersion(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The resource name of the CryptoKeyVersion to restore. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` |   |

### restoreCryptoKeyVersionCallable()

    public final UnaryCallable<RestoreCryptoKeyVersionRequest,CryptoKeyVersion> restoreCryptoKeyVersionCallable()

Restore a CryptoKeyVersion in the
DESTROY_SCHEDULED
state.

Upon restoration of the CryptoKeyVersion,
state will be set to
DISABLED, and
destroy_time will be cleared.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     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();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion>` |   |

### setIamPolicy(KeyName resource, Policy policy)

    public final Policy setIamPolicy(KeyName resource, Policy policy)

Sets the access control policy on the specified resource. Replaces any existing policy.

Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED

Sample code:


     try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
       KeyName resource = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
       Policy policy = Policy.newBuilder().build();
       Policy response = keyManagementServiceClient.setIamPolicy(resource, policy);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `resource` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyName` REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. |
| `policy` | `com.google.iam.v1.Policy` REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `com.google.iam.v1.Policy` |   |

### setIamPolicy(SetIamPolicyRequest request)

    public final Policy setIamPolicy(SetIamPolicyRequest request)

Sets the access control policy on the specified resource. Replacesany existing policy.

Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       SetIamPolicyRequest request =
           SetIamPolicyRequest.newBuilder()
               .setResource(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .setPolicy(Policy.newBuilder().build())
               .setUpdateMask(FieldMask.newBuilder().build())
               .build();
       Policy response = keyManagementServiceClient.setIamPolicy(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `com.google.iam.v1.SetIamPolicyRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `com.google.iam.v1.Policy` |   |

### setIamPolicy(String resource, Policy policy)

    public final Policy setIamPolicy(String resource, Policy policy)

Sets the access control policy on the specified resource. Replaces any existing policy.

Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED

Sample code:


     try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
       KeyName resource = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
       Policy policy = Policy.newBuilder().build();
       Policy response = keyManagementServiceClient.setIamPolicy(resource.toString(), policy);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `resource` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. |
| `policy` | `com.google.iam.v1.Policy` REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `com.google.iam.v1.Policy` |   |

### setIamPolicyCallable()

    public final UnaryCallable<SetIamPolicyRequest,Policy> setIamPolicyCallable()

Sets the access control policy on the specified resource. Replacesany existing policy.

Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       SetIamPolicyRequest request =
           SetIamPolicyRequest.newBuilder()
               .setResource(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .setPolicy(Policy.newBuilder().build())
               .setUpdateMask(FieldMask.newBuilder().build())
               .build();
       ApiFuture<Policy> future =
           keyManagementServiceClient.setIamPolicyCallable().futureCall(request);
       // Do something.
       Policy response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy>` |   |

### shutdown()

    public void shutdown()

### shutdownNow()

    public void shutdownNow()

### testIamPermissions(KeyName resource, List\<String\> permissions)

    public final TestIamPermissionsResponse testIamPermissions(KeyName resource, List<String> permissions)

Returns permissions that a caller has on the specified resource. If the resource does not
exist, this will return an empty set of permissions, not a NOT_FOUND error.

Note: This operation is designed to be used for building permission-aware UIs and
command-line tools, not for authorization checking. This operation may "fail open" without
warning.

Sample code:


     try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
       KeyName resource = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
       List<String> permissions = new ArrayList<>();
       TestIamPermissionsResponse response = keyManagementServiceClient.testIamPermissions(resource, permissions);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `resource` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.KeyName` REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. |
| `permissions` | `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>` The set of permissions to check for the `resource`. Permissions with wildcards (such as '\*' or 'storage.\*') are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `com.google.iam.v1.TestIamPermissionsResponse` |   |

### testIamPermissions(TestIamPermissionsRequest request)

    public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request)

Returns permissions that a caller has on the specified resource. If theresource does not exist,
this will return an empty set ofpermissions, not a `NOT_FOUND` error.

Note: This operation is designed to be used for buildingpermission-aware UIs and
command-line tools, not for authorizationchecking. This operation may "fail open" without
warning.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       TestIamPermissionsRequest request =
           TestIamPermissionsRequest.newBuilder()
               .setResource(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .addAllPermissions(new ArrayList<String>())
               .build();
       TestIamPermissionsResponse response = keyManagementServiceClient.testIamPermissions(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `com.google.iam.v1.TestIamPermissionsRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `com.google.iam.v1.TestIamPermissionsResponse` |   |

### testIamPermissions(String resource, List\<String\> permissions)

    public final TestIamPermissionsResponse testIamPermissions(String resource, List<String> permissions)

Returns permissions that a caller has on the specified resource. If the resource does not
exist, this will return an empty set of permissions, not a NOT_FOUND error.

Note: This operation is designed to be used for building permission-aware UIs and
command-line tools, not for authorization checking. This operation may "fail open" without
warning.

Sample code:


     try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
       KeyName resource = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
       List<String> permissions = new ArrayList<>();
       TestIamPermissionsResponse response = keyManagementServiceClient.testIamPermissions(resource.toString(), permissions);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `resource` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. |
| `permissions` | `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>` The set of permissions to check for the `resource`. Permissions with wildcards (such as '\*' or 'storage.\*') are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `com.google.iam.v1.TestIamPermissionsResponse` |   |

### testIamPermissionsCallable()

    public final UnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse> testIamPermissionsCallable()

Returns permissions that a caller has on the specified resource. If theresource does not exist,
this will return an empty set ofpermissions, not a `NOT_FOUND` error.

Note: This operation is designed to be used for buildingpermission-aware UIs and
command-line tools, not for authorizationchecking. This operation may "fail open" without
warning.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       TestIamPermissionsRequest request =
           TestIamPermissionsRequest.newBuilder()
               .setResource(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .addAllPermissions(new ArrayList<String>())
               .build();
       ApiFuture<TestIamPermissionsResponse> future =
           keyManagementServiceClient.testIamPermissionsCallable().futureCall(request);
       // Do something.
       TestIamPermissionsResponse response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse>` |   |

### updateCryptoKey(CryptoKey cryptoKey, FieldMask updateMask)

    public final CryptoKey updateCryptoKey(CryptoKey cryptoKey, FieldMask updateMask)

Update a CryptoKey.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CryptoKey cryptoKey = CryptoKey.newBuilder().build();
       FieldMask updateMask = FieldMask.newBuilder().build();
       CryptoKey response = keyManagementServiceClient.updateCryptoKey(cryptoKey, updateMask);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `cryptoKey` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey` Required. CryptoKey with updated values. |
| `updateMask` | `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.FieldMask.html` Required. List of fields to be updated in this request. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey` |   |

### updateCryptoKey(UpdateCryptoKeyRequest request)

    public final CryptoKey updateCryptoKey(UpdateCryptoKeyRequest request)

Update a CryptoKey.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       UpdateCryptoKeyRequest request =
           UpdateCryptoKeyRequest.newBuilder()
               .setCryptoKey(CryptoKey.newBuilder().build())
               .setUpdateMask(FieldMask.newBuilder().build())
               .build();
       CryptoKey response = keyManagementServiceClient.updateCryptoKey(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.UpdateCryptoKeyRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey` |   |

### updateCryptoKeyCallable()

    public final UnaryCallable<UpdateCryptoKeyRequest,CryptoKey> updateCryptoKeyCallable()

Update a CryptoKey.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       UpdateCryptoKeyRequest request =
           UpdateCryptoKeyRequest.newBuilder()
               .setCryptoKey(CryptoKey.newBuilder().build())
               .setUpdateMask(FieldMask.newBuilder().build())
               .build();
       ApiFuture<CryptoKey> future =
           keyManagementServiceClient.updateCryptoKeyCallable().futureCall(request);
       // Do something.
       CryptoKey response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.UpdateCryptoKeyRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey>` |   |

### updateCryptoKeyPrimaryVersion(CryptoKeyName name, String cryptoKeyVersionId)

    public final CryptoKey updateCryptoKeyPrimaryVersion(CryptoKeyName name, String cryptoKeyVersionId)

Update the version of a CryptoKey that will be used in
Encrypt.

Returns an error if called on a key whose purpose is not
ENCRYPT_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CryptoKeyName name =
           CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
       String cryptoKeyVersionId = "cryptoKeyVersionId987674581";
       CryptoKey response =
           keyManagementServiceClient.updateCryptoKeyPrimaryVersion(name, cryptoKeyVersionId);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyName` Required. The resource name of the CryptoKey to update. |
| `cryptoKeyVersionId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The id of the child CryptoKeyVersion to use as primary. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey` |   |

### updateCryptoKeyPrimaryVersion(UpdateCryptoKeyPrimaryVersionRequest request)

    public final CryptoKey updateCryptoKeyPrimaryVersion(UpdateCryptoKeyPrimaryVersionRequest request)

Update the version of a CryptoKey that will be used in
Encrypt.

Returns an error if called on a key whose purpose is not
ENCRYPT_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       UpdateCryptoKeyPrimaryVersionRequest request =
           UpdateCryptoKeyPrimaryVersionRequest.newBuilder()
               .setName(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .setCryptoKeyVersionId("cryptoKeyVersionId987674581")
               .build();
       CryptoKey response = keyManagementServiceClient.updateCryptoKeyPrimaryVersion(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey` |   |

### updateCryptoKeyPrimaryVersion(String name, String cryptoKeyVersionId)

    public final CryptoKey updateCryptoKeyPrimaryVersion(String name, String cryptoKeyVersionId)

Update the version of a CryptoKey that will be used in
Encrypt.

Returns an error if called on a key whose purpose is not
ENCRYPT_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       String name =
           CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString();
       String cryptoKeyVersionId = "cryptoKeyVersionId987674581";
       CryptoKey response =
           keyManagementServiceClient.updateCryptoKeyPrimaryVersion(name, cryptoKeyVersionId);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The resource name of the CryptoKey to update. |
| `cryptoKeyVersionId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The id of the child CryptoKeyVersion to use as primary. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey` |   |

### updateCryptoKeyPrimaryVersionCallable()

    public final UnaryCallable<UpdateCryptoKeyPrimaryVersionRequest,CryptoKey> updateCryptoKeyPrimaryVersionCallable()

Update the version of a CryptoKey that will be used in
Encrypt.

Returns an error if called on a key whose purpose is not
ENCRYPT_DECRYPT.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       UpdateCryptoKeyPrimaryVersionRequest request =
           UpdateCryptoKeyPrimaryVersionRequest.newBuilder()
               .setName(
                   CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                       .toString())
               .setCryptoKeyVersionId("cryptoKeyVersionId987674581")
               .build();
       ApiFuture<CryptoKey> future =
           keyManagementServiceClient.updateCryptoKeyPrimaryVersionCallable().futureCall(request);
       // Do something.
       CryptoKey response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKey>` |   |

### updateCryptoKeyVersion(CryptoKeyVersion cryptoKeyVersion, FieldMask updateMask)

    public final CryptoKeyVersion updateCryptoKeyVersion(CryptoKeyVersion cryptoKeyVersion, FieldMask updateMask)

Update a CryptoKeyVersion's metadata.

state may be changed between
ENABLED and
DISABLED using this
method. See
DestroyCryptoKeyVersion and
RestoreCryptoKeyVersion to
move between other states.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       CryptoKeyVersion cryptoKeyVersion = CryptoKeyVersion.newBuilder().build();
       FieldMask updateMask = FieldMask.newBuilder().build();
       CryptoKeyVersion response =
           keyManagementServiceClient.updateCryptoKeyVersion(cryptoKeyVersion, updateMask);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `cryptoKeyVersion` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` Required. CryptoKeyVersion with updated values. |
| `updateMask` | `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.FieldMask.html` Required. List of fields to be updated in this request. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` |   |

### updateCryptoKeyVersion(UpdateCryptoKeyVersionRequest request)

    public final CryptoKeyVersion updateCryptoKeyVersion(UpdateCryptoKeyVersionRequest request)

Update a CryptoKeyVersion's metadata.

state may be changed between
ENABLED and
DISABLED using this
method. See
DestroyCryptoKeyVersion and
RestoreCryptoKeyVersion to
move between other states.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       UpdateCryptoKeyVersionRequest request =
           UpdateCryptoKeyVersionRequest.newBuilder()
               .setCryptoKeyVersion(CryptoKeyVersion.newBuilder().build())
               .setUpdateMask(FieldMask.newBuilder().build())
               .build();
       CryptoKeyVersion response = keyManagementServiceClient.updateCryptoKeyVersion(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion` |   |

### updateCryptoKeyVersionCallable()

    public final UnaryCallable<UpdateCryptoKeyVersionRequest,CryptoKeyVersion> updateCryptoKeyVersionCallable()

Update a CryptoKeyVersion's metadata.

state may be changed between
ENABLED and
DISABLED using this
method. See
DestroyCryptoKeyVersion and
RestoreCryptoKeyVersion to
move between other states.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (KeyManagementServiceClient keyManagementServiceClient =
         KeyManagementServiceClient.create()) {
       UpdateCryptoKeyVersionRequest request =
           UpdateCryptoKeyVersionRequest.newBuilder()
               .setCryptoKeyVersion(CryptoKeyVersion.newBuilder().build())
               .setUpdateMask(FieldMask.newBuilder().build())
               .build();
       ApiFuture<CryptoKeyVersion> future =
           keyManagementServiceClient.updateCryptoKeyVersionCallable().futureCall(request);
       // Do something.
       CryptoKeyVersion response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-kms/latest/com.google.cloud.kms.v1.CryptoKeyVersion>` |   |