Class KeyManagementServiceClient
- java.lang.Object
-
- com.google.cloud.kms.v1.KeyManagementServiceClient
-
- All Implemented Interfaces:
com.google.api.gax.core.BackgroundResource
,AutoCloseable
@Generated("by gapic-generator-java") public class KeyManagementServiceClient extends Object implements com.google.api.gax.core.BackgroundResource
Service Description: Google Cloud Key Management ServiceManages cryptographic keys and operations using those keys. Implements a REST model with the following objects:
- [KeyRing][google.cloud.kms.v1.KeyRing]
- [CryptoKey][google.cloud.kms.v1.CryptoKey]
- [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]
- [ImportJob][google.cloud.kms.v1.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().
The surface of this class includes several types of Java methods for each of the API's methods:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
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.
-
-
Nested Class Summary
-
Constructor Summary
Constructors Modifier Constructor Description protected
KeyManagementServiceClient(KeyManagementServiceSettings settings)
Constructs an instance of KeyManagementServiceClient, using the given settings.protected
KeyManagementServiceClient(KeyManagementServiceStub stub)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AsymmetricDecryptResponse
asymmetricDecrypt(AsymmetricDecryptRequest request)
Decrypts data that was encrypted with a public key retrieved from [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey] corresponding to a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_DECRYPT.AsymmetricDecryptResponse
asymmetricDecrypt(CryptoKeyVersionName name, com.google.protobuf.ByteString ciphertext)
Decrypts data that was encrypted with a public key retrieved from [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey] corresponding to a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_DECRYPT.AsymmetricDecryptResponse
asymmetricDecrypt(String name, com.google.protobuf.ByteString ciphertext)
Decrypts data that was encrypted with a public key retrieved from [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey] corresponding to a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_DECRYPT.com.google.api.gax.rpc.UnaryCallable<AsymmetricDecryptRequest,AsymmetricDecryptResponse>
asymmetricDecryptCallable()
Decrypts data that was encrypted with a public key retrieved from [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey] corresponding to a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_DECRYPT.AsymmetricSignResponse
asymmetricSign(AsymmetricSignRequest request)
Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_SIGN, producing a signature that can be verified with the public key retrieved from [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey].AsymmetricSignResponse
asymmetricSign(CryptoKeyVersionName name, Digest digest)
Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_SIGN, producing a signature that can be verified with the public key retrieved from [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey].AsymmetricSignResponse
asymmetricSign(String name, Digest digest)
Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_SIGN, producing a signature that can be verified with the public key retrieved from [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey].com.google.api.gax.rpc.UnaryCallable<AsymmetricSignRequest,AsymmetricSignResponse>
asymmetricSignCallable()
Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_SIGN, producing a signature that can be verified with the public key retrieved from [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey].boolean
awaitTermination(long duration, TimeUnit unit)
void
close()
static KeyManagementServiceClient
create()
Constructs an instance of KeyManagementServiceClient with default settings.static KeyManagementServiceClient
create(KeyManagementServiceSettings settings)
Constructs an instance of KeyManagementServiceClient, using the given settings.static KeyManagementServiceClient
create(KeyManagementServiceStub stub)
Constructs an instance of KeyManagementServiceClient, using the given stub for making calls.CryptoKey
createCryptoKey(CreateCryptoKeyRequest request)
Create a new [CryptoKey][google.cloud.kms.v1.CryptoKey] within a [KeyRing][google.cloud.kms.v1.KeyRing].CryptoKey
createCryptoKey(KeyRingName parent, String cryptoKeyId, CryptoKey cryptoKey)
Create a new [CryptoKey][google.cloud.kms.v1.CryptoKey] within a [KeyRing][google.cloud.kms.v1.KeyRing].CryptoKey
createCryptoKey(String parent, String cryptoKeyId, CryptoKey cryptoKey)
Create a new [CryptoKey][google.cloud.kms.v1.CryptoKey] within a [KeyRing][google.cloud.kms.v1.KeyRing].com.google.api.gax.rpc.UnaryCallable<CreateCryptoKeyRequest,CryptoKey>
createCryptoKeyCallable()
Create a new [CryptoKey][google.cloud.kms.v1.CryptoKey] within a [KeyRing][google.cloud.kms.v1.KeyRing].CryptoKeyVersion
createCryptoKeyVersion(CreateCryptoKeyVersionRequest request)
Create a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in a [CryptoKey][google.cloud.kms.v1.CryptoKey].CryptoKeyVersion
createCryptoKeyVersion(CryptoKeyName parent, CryptoKeyVersion cryptoKeyVersion)
Create a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in a [CryptoKey][google.cloud.kms.v1.CryptoKey].CryptoKeyVersion
createCryptoKeyVersion(String parent, CryptoKeyVersion cryptoKeyVersion)
Create a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in a [CryptoKey][google.cloud.kms.v1.CryptoKey].com.google.api.gax.rpc.UnaryCallable<CreateCryptoKeyVersionRequest,CryptoKeyVersion>
createCryptoKeyVersionCallable()
Create a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in a [CryptoKey][google.cloud.kms.v1.CryptoKey].ImportJob
createImportJob(CreateImportJobRequest request)
Create a new [ImportJob][google.cloud.kms.v1.ImportJob] within a [KeyRing][google.cloud.kms.v1.KeyRing].ImportJob
createImportJob(KeyRingName parent, String importJobId, ImportJob importJob)
Create a new [ImportJob][google.cloud.kms.v1.ImportJob] within a [KeyRing][google.cloud.kms.v1.KeyRing].ImportJob
createImportJob(String parent, String importJobId, ImportJob importJob)
Create a new [ImportJob][google.cloud.kms.v1.ImportJob] within a [KeyRing][google.cloud.kms.v1.KeyRing].com.google.api.gax.rpc.UnaryCallable<CreateImportJobRequest,ImportJob>
createImportJobCallable()
Create a new [ImportJob][google.cloud.kms.v1.ImportJob] within a [KeyRing][google.cloud.kms.v1.KeyRing].KeyRing
createKeyRing(CreateKeyRingRequest request)
Create a new [KeyRing][google.cloud.kms.v1.KeyRing] in a given Project and Location.KeyRing
createKeyRing(LocationName parent, String keyRingId, KeyRing keyRing)
Create a new [KeyRing][google.cloud.kms.v1.KeyRing] in a given Project and Location.KeyRing
createKeyRing(String parent, String keyRingId, KeyRing keyRing)
Create a new [KeyRing][google.cloud.kms.v1.KeyRing] in a given Project and Location.com.google.api.gax.rpc.UnaryCallable<CreateKeyRingRequest,KeyRing>
createKeyRingCallable()
Create a new [KeyRing][google.cloud.kms.v1.KeyRing] in a given Project and Location.DecryptResponse
decrypt(CryptoKeyName name, com.google.protobuf.ByteString ciphertext)
Decrypts data that was protected by [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt].DecryptResponse
decrypt(DecryptRequest request)
Decrypts data that was protected by [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt].DecryptResponse
decrypt(String name, com.google.protobuf.ByteString ciphertext)
Decrypts data that was protected by [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt].com.google.api.gax.rpc.UnaryCallable<DecryptRequest,DecryptResponse>
decryptCallable()
Decrypts data that was protected by [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt].CryptoKeyVersion
destroyCryptoKeyVersion(CryptoKeyVersionName name)
Schedule a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] for destruction.CryptoKeyVersion
destroyCryptoKeyVersion(DestroyCryptoKeyVersionRequest request)
Schedule a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] for destruction.CryptoKeyVersion
destroyCryptoKeyVersion(String name)
Schedule a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] for destruction.com.google.api.gax.rpc.UnaryCallable<DestroyCryptoKeyVersionRequest,CryptoKeyVersion>
destroyCryptoKeyVersionCallable()
Schedule a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] for destruction.EncryptResponse
encrypt(com.google.api.resourcenames.ResourceName name, com.google.protobuf.ByteString plaintext)
Encrypts data, so that it can only be recovered by a call to [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt].EncryptResponse
encrypt(CryptoKeyPathName name, com.google.protobuf.ByteString plaintext)
Encrypts data, so that it can only be recovered by a call to [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt].EncryptResponse
encrypt(EncryptRequest request)
Encrypts data, so that it can only be recovered by a call to [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt].EncryptResponse
encrypt(String name, com.google.protobuf.ByteString plaintext)
Encrypts data, so that it can only be recovered by a call to [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt].com.google.api.gax.rpc.UnaryCallable<EncryptRequest,EncryptResponse>
encryptCallable()
Encrypts data, so that it can only be recovered by a call to [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt].GenerateRandomBytesResponse
generateRandomBytes(GenerateRandomBytesRequest request)
Generate random bytes using the Cloud KMS randomness source in the provided location.GenerateRandomBytesResponse
generateRandomBytes(String location, int lengthBytes, ProtectionLevel protectionLevel)
Generate random bytes using the Cloud KMS randomness source in the provided location.com.google.api.gax.rpc.UnaryCallable<GenerateRandomBytesRequest,GenerateRandomBytesResponse>
generateRandomBytesCallable()
Generate random bytes using the Cloud KMS randomness source in the provided location.CryptoKey
getCryptoKey(CryptoKeyName name)
Returns metadata for a given [CryptoKey][google.cloud.kms.v1.CryptoKey], as well as its [primary][google.cloud.kms.v1.CryptoKey.primary] [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].CryptoKey
getCryptoKey(GetCryptoKeyRequest request)
Returns metadata for a given [CryptoKey][google.cloud.kms.v1.CryptoKey], as well as its [primary][google.cloud.kms.v1.CryptoKey.primary] [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].CryptoKey
getCryptoKey(String name)
Returns metadata for a given [CryptoKey][google.cloud.kms.v1.CryptoKey], as well as its [primary][google.cloud.kms.v1.CryptoKey.primary] [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].com.google.api.gax.rpc.UnaryCallable<GetCryptoKeyRequest,CryptoKey>
getCryptoKeyCallable()
Returns metadata for a given [CryptoKey][google.cloud.kms.v1.CryptoKey], as well as its [primary][google.cloud.kms.v1.CryptoKey.primary] [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].CryptoKeyVersion
getCryptoKeyVersion(CryptoKeyVersionName name)
Returns metadata for a given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].CryptoKeyVersion
getCryptoKeyVersion(GetCryptoKeyVersionRequest request)
Returns metadata for a given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].CryptoKeyVersion
getCryptoKeyVersion(String name)
Returns metadata for a given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].com.google.api.gax.rpc.UnaryCallable<GetCryptoKeyVersionRequest,CryptoKeyVersion>
getCryptoKeyVersionCallable()
Returns metadata for a given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].com.google.iam.v1.Policy
getIamPolicy(KeyName resource)
Gets the access control policy for a resource.com.google.iam.v1.Policy
getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Gets the access control policy for a resource.com.google.iam.v1.Policy
getIamPolicy(String resource)
Gets the access control policy for a resource.com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy>
getIamPolicyCallable()
Gets the access control policy for a resource.ImportJob
getImportJob(GetImportJobRequest request)
Returns metadata for a given [ImportJob][google.cloud.kms.v1.ImportJob].ImportJob
getImportJob(ImportJobName name)
Returns metadata for a given [ImportJob][google.cloud.kms.v1.ImportJob].ImportJob
getImportJob(String name)
Returns metadata for a given [ImportJob][google.cloud.kms.v1.ImportJob].com.google.api.gax.rpc.UnaryCallable<GetImportJobRequest,ImportJob>
getImportJobCallable()
Returns metadata for a given [ImportJob][google.cloud.kms.v1.ImportJob].KeyRing
getKeyRing(GetKeyRingRequest request)
Returns metadata for a given [KeyRing][google.cloud.kms.v1.KeyRing].KeyRing
getKeyRing(KeyRingName name)
Returns metadata for a given [KeyRing][google.cloud.kms.v1.KeyRing].KeyRing
getKeyRing(String name)
Returns metadata for a given [KeyRing][google.cloud.kms.v1.KeyRing].com.google.api.gax.rpc.UnaryCallable<GetKeyRingRequest,KeyRing>
getKeyRingCallable()
Returns metadata for a given [KeyRing][google.cloud.kms.v1.KeyRing].com.google.cloud.location.Location
getLocation(com.google.cloud.location.GetLocationRequest request)
Gets information about a location.com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location>
getLocationCallable()
Gets information about a location.PublicKey
getPublicKey(CryptoKeyVersionName name)
Returns the public key for the given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].PublicKey
getPublicKey(GetPublicKeyRequest request)
Returns the public key for the given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].PublicKey
getPublicKey(String name)
Returns the public key for the given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].com.google.api.gax.rpc.UnaryCallable<GetPublicKeyRequest,PublicKey>
getPublicKeyCallable()
Returns the public key for the given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].KeyManagementServiceSettings
getSettings()
KeyManagementServiceStub
getStub()
CryptoKeyVersion
importCryptoKeyVersion(ImportCryptoKeyVersionRequest request)
Import wrapped key material into a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].com.google.api.gax.rpc.UnaryCallable<ImportCryptoKeyVersionRequest,CryptoKeyVersion>
importCryptoKeyVersionCallable()
Import wrapped key material into a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].boolean
isShutdown()
boolean
isTerminated()
KeyManagementServiceClient.ListCryptoKeysPagedResponse
listCryptoKeys(KeyRingName parent)
Lists [CryptoKeys][google.cloud.kms.v1.CryptoKey].KeyManagementServiceClient.ListCryptoKeysPagedResponse
listCryptoKeys(ListCryptoKeysRequest request)
Lists [CryptoKeys][google.cloud.kms.v1.CryptoKey].KeyManagementServiceClient.ListCryptoKeysPagedResponse
listCryptoKeys(String parent)
Lists [CryptoKeys][google.cloud.kms.v1.CryptoKey].com.google.api.gax.rpc.UnaryCallable<ListCryptoKeysRequest,ListCryptoKeysResponse>
listCryptoKeysCallable()
Lists [CryptoKeys][google.cloud.kms.v1.CryptoKey].com.google.api.gax.rpc.UnaryCallable<ListCryptoKeysRequest,KeyManagementServiceClient.ListCryptoKeysPagedResponse>
listCryptoKeysPagedCallable()
Lists [CryptoKeys][google.cloud.kms.v1.CryptoKey].KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse
listCryptoKeyVersions(CryptoKeyName parent)
Lists [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion].KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse
listCryptoKeyVersions(ListCryptoKeyVersionsRequest request)
Lists [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion].KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse
listCryptoKeyVersions(String parent)
Lists [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion].com.google.api.gax.rpc.UnaryCallable<ListCryptoKeyVersionsRequest,ListCryptoKeyVersionsResponse>
listCryptoKeyVersionsCallable()
Lists [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion].com.google.api.gax.rpc.UnaryCallable<ListCryptoKeyVersionsRequest,KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse>
listCryptoKeyVersionsPagedCallable()
Lists [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion].KeyManagementServiceClient.ListImportJobsPagedResponse
listImportJobs(KeyRingName parent)
Lists [ImportJobs][google.cloud.kms.v1.ImportJob].KeyManagementServiceClient.ListImportJobsPagedResponse
listImportJobs(ListImportJobsRequest request)
Lists [ImportJobs][google.cloud.kms.v1.ImportJob].KeyManagementServiceClient.ListImportJobsPagedResponse
listImportJobs(String parent)
Lists [ImportJobs][google.cloud.kms.v1.ImportJob].com.google.api.gax.rpc.UnaryCallable<ListImportJobsRequest,ListImportJobsResponse>
listImportJobsCallable()
Lists [ImportJobs][google.cloud.kms.v1.ImportJob].com.google.api.gax.rpc.UnaryCallable<ListImportJobsRequest,KeyManagementServiceClient.ListImportJobsPagedResponse>
listImportJobsPagedCallable()
Lists [ImportJobs][google.cloud.kms.v1.ImportJob].KeyManagementServiceClient.ListKeyRingsPagedResponse
listKeyRings(ListKeyRingsRequest request)
Lists [KeyRings][google.cloud.kms.v1.KeyRing].KeyManagementServiceClient.ListKeyRingsPagedResponse
listKeyRings(LocationName parent)
Lists [KeyRings][google.cloud.kms.v1.KeyRing].KeyManagementServiceClient.ListKeyRingsPagedResponse
listKeyRings(String parent)
Lists [KeyRings][google.cloud.kms.v1.KeyRing].com.google.api.gax.rpc.UnaryCallable<ListKeyRingsRequest,ListKeyRingsResponse>
listKeyRingsCallable()
Lists [KeyRings][google.cloud.kms.v1.KeyRing].com.google.api.gax.rpc.UnaryCallable<ListKeyRingsRequest,KeyManagementServiceClient.ListKeyRingsPagedResponse>
listKeyRingsPagedCallable()
Lists [KeyRings][google.cloud.kms.v1.KeyRing].KeyManagementServiceClient.ListLocationsPagedResponse
listLocations(com.google.cloud.location.ListLocationsRequest request)
Lists information about the supported locations for this service.com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse>
listLocationsCallable()
Lists information about the supported locations for this service.com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,KeyManagementServiceClient.ListLocationsPagedResponse>
listLocationsPagedCallable()
Lists information about the supported locations for this service.MacSignResponse
macSign(CryptoKeyVersionName name, com.google.protobuf.ByteString data)
Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, producing a tag that can be verified by another source with the same key.MacSignResponse
macSign(MacSignRequest request)
Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, producing a tag that can be verified by another source with the same key.MacSignResponse
macSign(String name, com.google.protobuf.ByteString data)
Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, producing a tag that can be verified by another source with the same key.com.google.api.gax.rpc.UnaryCallable<MacSignRequest,MacSignResponse>
macSignCallable()
Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, producing a tag that can be verified by another source with the same key.MacVerifyResponse
macVerify(CryptoKeyVersionName name, com.google.protobuf.ByteString data, com.google.protobuf.ByteString mac)
Verifies MAC tag using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, and returns a response that indicates whether or not the verification was successful.MacVerifyResponse
macVerify(MacVerifyRequest request)
Verifies MAC tag using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, and returns a response that indicates whether or not the verification was successful.MacVerifyResponse
macVerify(String name, com.google.protobuf.ByteString data, com.google.protobuf.ByteString mac)
Verifies MAC tag using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, and returns a response that indicates whether or not the verification was successful.com.google.api.gax.rpc.UnaryCallable<MacVerifyRequest,MacVerifyResponse>
macVerifyCallable()
Verifies MAC tag using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, and returns a response that indicates whether or not the verification was successful.RawDecryptResponse
rawDecrypt(RawDecryptRequest request)
Decrypts data that was originally encrypted using a raw cryptographic mechanism.com.google.api.gax.rpc.UnaryCallable<RawDecryptRequest,RawDecryptResponse>
rawDecryptCallable()
Decrypts data that was originally encrypted using a raw cryptographic mechanism.RawEncryptResponse
rawEncrypt(RawEncryptRequest request)
Encrypts data using portable cryptographic primitives.com.google.api.gax.rpc.UnaryCallable<RawEncryptRequest,RawEncryptResponse>
rawEncryptCallable()
Encrypts data using portable cryptographic primitives.CryptoKeyVersion
restoreCryptoKeyVersion(CryptoKeyVersionName name)
Restore a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in the [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED] state.CryptoKeyVersion
restoreCryptoKeyVersion(RestoreCryptoKeyVersionRequest request)
Restore a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in the [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED] state.CryptoKeyVersion
restoreCryptoKeyVersion(String name)
Restore a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in the [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED] state.com.google.api.gax.rpc.UnaryCallable<RestoreCryptoKeyVersionRequest,CryptoKeyVersion>
restoreCryptoKeyVersionCallable()
Restore a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in the [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED] state.com.google.iam.v1.Policy
setIamPolicy(KeyName resource, com.google.iam.v1.Policy policy)
Sets the access control policy on the specified resource.com.google.iam.v1.Policy
setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Sets the access control policy on the specified resource.com.google.iam.v1.Policy
setIamPolicy(String resource, com.google.iam.v1.Policy policy)
Sets the access control policy on the specified resource.com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy>
setIamPolicyCallable()
Sets the access control policy on the specified resource.void
shutdown()
void
shutdownNow()
com.google.iam.v1.TestIamPermissionsResponse
testIamPermissions(KeyName resource, List<String> permissions)
Returns permissions that a caller has on the specified resource.com.google.iam.v1.TestIamPermissionsResponse
testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
Returns permissions that a caller has on the specified resource.com.google.iam.v1.TestIamPermissionsResponse
testIamPermissions(String resource, List<String> permissions)
Returns permissions that a caller has on the specified resource.com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse>
testIamPermissionsCallable()
Returns permissions that a caller has on the specified resource.CryptoKey
updateCryptoKey(CryptoKey cryptoKey, com.google.protobuf.FieldMask updateMask)
Update a [CryptoKey][google.cloud.kms.v1.CryptoKey].CryptoKey
updateCryptoKey(UpdateCryptoKeyRequest request)
Update a [CryptoKey][google.cloud.kms.v1.CryptoKey].com.google.api.gax.rpc.UnaryCallable<UpdateCryptoKeyRequest,CryptoKey>
updateCryptoKeyCallable()
Update a [CryptoKey][google.cloud.kms.v1.CryptoKey].CryptoKey
updateCryptoKeyPrimaryVersion(CryptoKeyName name, String cryptoKeyVersionId)
Update the version of a [CryptoKey][google.cloud.kms.v1.CryptoKey] that will be used in [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt].CryptoKey
updateCryptoKeyPrimaryVersion(UpdateCryptoKeyPrimaryVersionRequest request)
Update the version of a [CryptoKey][google.cloud.kms.v1.CryptoKey] that will be used in [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt].CryptoKey
updateCryptoKeyPrimaryVersion(String name, String cryptoKeyVersionId)
Update the version of a [CryptoKey][google.cloud.kms.v1.CryptoKey] that will be used in [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt].com.google.api.gax.rpc.UnaryCallable<UpdateCryptoKeyPrimaryVersionRequest,CryptoKey>
updateCryptoKeyPrimaryVersionCallable()
Update the version of a [CryptoKey][google.cloud.kms.v1.CryptoKey] that will be used in [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt].CryptoKeyVersion
updateCryptoKeyVersion(CryptoKeyVersion cryptoKeyVersion, com.google.protobuf.FieldMask updateMask)
Update a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]'s metadata.CryptoKeyVersion
updateCryptoKeyVersion(UpdateCryptoKeyVersionRequest request)
Update a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]'s metadata.com.google.api.gax.rpc.UnaryCallable<UpdateCryptoKeyVersionRequest,CryptoKeyVersion>
updateCryptoKeyVersionCallable()
Update a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]'s metadata.
-
-
-
Constructor Detail
-
KeyManagementServiceClient
protected KeyManagementServiceClient(KeyManagementServiceSettings settings) throws IOException
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.- Throws:
IOException
-
KeyManagementServiceClient
protected KeyManagementServiceClient(KeyManagementServiceStub stub)
-
-
Method Detail
-
create
public static final KeyManagementServiceClient create() throws IOException
Constructs an instance of KeyManagementServiceClient with default settings.- Throws:
IOException
-
create
public static final KeyManagementServiceClient create(KeyManagementServiceSettings settings) throws IOException
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.- Throws:
IOException
-
create
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).
-
getSettings
public final KeyManagementServiceSettings getSettings()
-
getStub
public KeyManagementServiceStub getStub()
-
listKeyRings
public final KeyManagementServiceClient.ListKeyRingsPagedResponse listKeyRings(LocationName parent)
Lists [KeyRings][google.cloud.kms.v1.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()) { LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); for (KeyRing element : keyManagementServiceClient.listKeyRings(parent).iterateAll()) { // doThingsWith(element); } }
- Parameters:
parent
- Required. The resource name of the location associated with the [KeyRings][google.cloud.kms.v1.KeyRing], in the format `projects/*/locations/*`.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listKeyRings
public final KeyManagementServiceClient.ListKeyRingsPagedResponse listKeyRings(String parent)
Lists [KeyRings][google.cloud.kms.v1.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 parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); for (KeyRing element : keyManagementServiceClient.listKeyRings(parent).iterateAll()) { // doThingsWith(element); } }
- Parameters:
parent
- Required. The resource name of the location associated with the [KeyRings][google.cloud.kms.v1.KeyRing], in the format `projects/*/locations/*`.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listKeyRings
public final KeyManagementServiceClient.ListKeyRingsPagedResponse listKeyRings(ListKeyRingsRequest request)
Lists [KeyRings][google.cloud.kms.v1.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()) { 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); } }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listKeyRingsPagedCallable
public final com.google.api.gax.rpc.UnaryCallable<ListKeyRingsRequest,KeyManagementServiceClient.ListKeyRingsPagedResponse> listKeyRingsPagedCallable()
Lists [KeyRings][google.cloud.kms.v1.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()) { 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); } }
-
listKeyRingsCallable
public final com.google.api.gax.rpc.UnaryCallable<ListKeyRingsRequest,ListKeyRingsResponse> listKeyRingsCallable()
Lists [KeyRings][google.cloud.kms.v1.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()) { 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; } } }
-
listCryptoKeys
public final KeyManagementServiceClient.ListCryptoKeysPagedResponse listCryptoKeys(KeyRingName parent)
Lists [CryptoKeys][google.cloud.kms.v1.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()) { KeyRingName parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]"); for (CryptoKey element : keyManagementServiceClient.listCryptoKeys(parent).iterateAll()) { // doThingsWith(element); } }
- Parameters:
parent
- Required. The resource name of the [KeyRing][google.cloud.kms.v1.KeyRing] to list, in the format `projects/*/locations/*/keyRings/*`.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listCryptoKeys
public final KeyManagementServiceClient.ListCryptoKeysPagedResponse listCryptoKeys(String parent)
Lists [CryptoKeys][google.cloud.kms.v1.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 parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString(); for (CryptoKey element : keyManagementServiceClient.listCryptoKeys(parent).iterateAll()) { // doThingsWith(element); } }
- Parameters:
parent
- Required. The resource name of the [KeyRing][google.cloud.kms.v1.KeyRing] to list, in the format `projects/*/locations/*/keyRings/*`.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listCryptoKeys
public final KeyManagementServiceClient.ListCryptoKeysPagedResponse listCryptoKeys(ListCryptoKeysRequest request)
Lists [CryptoKeys][google.cloud.kms.v1.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()) { 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); } }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listCryptoKeysPagedCallable
public final com.google.api.gax.rpc.UnaryCallable<ListCryptoKeysRequest,KeyManagementServiceClient.ListCryptoKeysPagedResponse> listCryptoKeysPagedCallable()
Lists [CryptoKeys][google.cloud.kms.v1.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()) { 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); } }
-
listCryptoKeysCallable
public final com.google.api.gax.rpc.UnaryCallable<ListCryptoKeysRequest,ListCryptoKeysResponse> listCryptoKeysCallable()
Lists [CryptoKeys][google.cloud.kms.v1.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()) { 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; } } }
-
listCryptoKeyVersions
public final KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse listCryptoKeyVersions(CryptoKeyName parent)
Lists [CryptoKeyVersions][google.cloud.kms.v1.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 parent = CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]"); for (CryptoKeyVersion element : keyManagementServiceClient.listCryptoKeyVersions(parent).iterateAll()) { // doThingsWith(element); } }
- Parameters:
parent
- Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to list, in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*`.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listCryptoKeyVersions
public final KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse listCryptoKeyVersions(String parent)
Lists [CryptoKeyVersions][google.cloud.kms.v1.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 parent = CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString(); for (CryptoKeyVersion element : keyManagementServiceClient.listCryptoKeyVersions(parent).iterateAll()) { // doThingsWith(element); } }
- Parameters:
parent
- Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to list, in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*`.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listCryptoKeyVersions
public final KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse listCryptoKeyVersions(ListCryptoKeyVersionsRequest request)
Lists [CryptoKeyVersions][google.cloud.kms.v1.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()) { 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); } }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listCryptoKeyVersionsPagedCallable
public final com.google.api.gax.rpc.UnaryCallable<ListCryptoKeyVersionsRequest,KeyManagementServiceClient.ListCryptoKeyVersionsPagedResponse> listCryptoKeyVersionsPagedCallable()
Lists [CryptoKeyVersions][google.cloud.kms.v1.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()) { 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); } }
-
listCryptoKeyVersionsCallable
public final com.google.api.gax.rpc.UnaryCallable<ListCryptoKeyVersionsRequest,ListCryptoKeyVersionsResponse> listCryptoKeyVersionsCallable()
Lists [CryptoKeyVersions][google.cloud.kms.v1.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()) { 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; } } }
-
listImportJobs
public final KeyManagementServiceClient.ListImportJobsPagedResponse listImportJobs(KeyRingName parent)
Lists [ImportJobs][google.cloud.kms.v1.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()) { KeyRingName parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]"); for (ImportJob element : keyManagementServiceClient.listImportJobs(parent).iterateAll()) { // doThingsWith(element); } }
- Parameters:
parent
- Required. The resource name of the [KeyRing][google.cloud.kms.v1.KeyRing] to list, in the format `projects/*/locations/*/keyRings/*`.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listImportJobs
public final KeyManagementServiceClient.ListImportJobsPagedResponse listImportJobs(String parent)
Lists [ImportJobs][google.cloud.kms.v1.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 parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]").toString(); for (ImportJob element : keyManagementServiceClient.listImportJobs(parent).iterateAll()) { // doThingsWith(element); } }
- Parameters:
parent
- Required. The resource name of the [KeyRing][google.cloud.kms.v1.KeyRing] to list, in the format `projects/*/locations/*/keyRings/*`.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listImportJobs
public final KeyManagementServiceClient.ListImportJobsPagedResponse listImportJobs(ListImportJobsRequest request)
Lists [ImportJobs][google.cloud.kms.v1.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()) { 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); } }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listImportJobsPagedCallable
public final com.google.api.gax.rpc.UnaryCallable<ListImportJobsRequest,KeyManagementServiceClient.ListImportJobsPagedResponse> listImportJobsPagedCallable()
Lists [ImportJobs][google.cloud.kms.v1.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()) { 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); } }
-
listImportJobsCallable
public final com.google.api.gax.rpc.UnaryCallable<ListImportJobsRequest,ListImportJobsResponse> listImportJobsCallable()
Lists [ImportJobs][google.cloud.kms.v1.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()) { 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; } } }
-
getKeyRing
public final KeyRing getKeyRing(KeyRingName name)
Returns metadata for a given [KeyRing][google.cloud.kms.v1.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); }
- Parameters:
name
- Required. The [name][google.cloud.kms.v1.KeyRing.name] of the [KeyRing][google.cloud.kms.v1.KeyRing] to get.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getKeyRing
public final KeyRing getKeyRing(String name)
Returns metadata for a given [KeyRing][google.cloud.kms.v1.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); }
- Parameters:
name
- Required. The [name][google.cloud.kms.v1.KeyRing.name] of the [KeyRing][google.cloud.kms.v1.KeyRing] to get.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getKeyRing
public final KeyRing getKeyRing(GetKeyRingRequest request)
Returns metadata for a given [KeyRing][google.cloud.kms.v1.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getKeyRingCallable
public final com.google.api.gax.rpc.UnaryCallable<GetKeyRingRequest,KeyRing> getKeyRingCallable()
Returns metadata for a given [KeyRing][google.cloud.kms.v1.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(); }
-
getCryptoKey
public final CryptoKey getCryptoKey(CryptoKeyName name)
Returns metadata for a given [CryptoKey][google.cloud.kms.v1.CryptoKey], as well as its [primary][google.cloud.kms.v1.CryptoKey.primary] [CryptoKeyVersion][google.cloud.kms.v1.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); }
- Parameters:
name
- Required. The [name][google.cloud.kms.v1.CryptoKey.name] of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to get.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getCryptoKey
public final CryptoKey getCryptoKey(String name)
Returns metadata for a given [CryptoKey][google.cloud.kms.v1.CryptoKey], as well as its [primary][google.cloud.kms.v1.CryptoKey.primary] [CryptoKeyVersion][google.cloud.kms.v1.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); }
- Parameters:
name
- Required. The [name][google.cloud.kms.v1.CryptoKey.name] of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to get.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getCryptoKey
public final CryptoKey getCryptoKey(GetCryptoKeyRequest request)
Returns metadata for a given [CryptoKey][google.cloud.kms.v1.CryptoKey], as well as its [primary][google.cloud.kms.v1.CryptoKey.primary] [CryptoKeyVersion][google.cloud.kms.v1.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getCryptoKeyCallable
public final com.google.api.gax.rpc.UnaryCallable<GetCryptoKeyRequest,CryptoKey> getCryptoKeyCallable()
Returns metadata for a given [CryptoKey][google.cloud.kms.v1.CryptoKey], as well as its [primary][google.cloud.kms.v1.CryptoKey.primary] [CryptoKeyVersion][google.cloud.kms.v1.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(); }
-
getCryptoKeyVersion
public final CryptoKeyVersion getCryptoKeyVersion(CryptoKeyVersionName name)
Returns metadata for a given [CryptoKeyVersion][google.cloud.kms.v1.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); }
- Parameters:
name
- Required. The [name][google.cloud.kms.v1.CryptoKeyVersion.name] of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to get.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getCryptoKeyVersion
public final CryptoKeyVersion getCryptoKeyVersion(String name)
Returns metadata for a given [CryptoKeyVersion][google.cloud.kms.v1.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); }
- Parameters:
name
- Required. The [name][google.cloud.kms.v1.CryptoKeyVersion.name] of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to get.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getCryptoKeyVersion
public final CryptoKeyVersion getCryptoKeyVersion(GetCryptoKeyVersionRequest request)
Returns metadata for a given [CryptoKeyVersion][google.cloud.kms.v1.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getCryptoKeyVersionCallable
public final com.google.api.gax.rpc.UnaryCallable<GetCryptoKeyVersionRequest,CryptoKeyVersion> getCryptoKeyVersionCallable()
Returns metadata for a given [CryptoKeyVersion][google.cloud.kms.v1.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(); }
-
getPublicKey
public final PublicKey getPublicKey(CryptoKeyVersionName name)
Returns the public key for the given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be [ASYMMETRIC_SIGN][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_SIGN] or [ASYMMETRIC_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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); }
- Parameters:
name
- Required. The [name][google.cloud.kms.v1.CryptoKeyVersion.name] of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] public key to get.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getPublicKey
public final PublicKey getPublicKey(String name)
Returns the public key for the given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be [ASYMMETRIC_SIGN][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_SIGN] or [ASYMMETRIC_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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); }
- Parameters:
name
- Required. The [name][google.cloud.kms.v1.CryptoKeyVersion.name] of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] public key to get.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getPublicKey
public final PublicKey getPublicKey(GetPublicKeyRequest request)
Returns the public key for the given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be [ASYMMETRIC_SIGN][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_SIGN] or [ASYMMETRIC_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getPublicKeyCallable
public final com.google.api.gax.rpc.UnaryCallable<GetPublicKeyRequest,PublicKey> getPublicKeyCallable()
Returns the public key for the given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be [ASYMMETRIC_SIGN][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_SIGN] or [ASYMMETRIC_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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(); }
-
getImportJob
public final ImportJob getImportJob(ImportJobName name)
Returns metadata for a given [ImportJob][google.cloud.kms.v1.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); }
- Parameters:
name
- Required. The [name][google.cloud.kms.v1.ImportJob.name] of the [ImportJob][google.cloud.kms.v1.ImportJob] to get.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getImportJob
public final ImportJob getImportJob(String name)
Returns metadata for a given [ImportJob][google.cloud.kms.v1.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); }
- Parameters:
name
- Required. The [name][google.cloud.kms.v1.ImportJob.name] of the [ImportJob][google.cloud.kms.v1.ImportJob] to get.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getImportJob
public final ImportJob getImportJob(GetImportJobRequest request)
Returns metadata for a given [ImportJob][google.cloud.kms.v1.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getImportJobCallable
public final com.google.api.gax.rpc.UnaryCallable<GetImportJobRequest,ImportJob> getImportJobCallable()
Returns metadata for a given [ImportJob][google.cloud.kms.v1.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(); }
-
createKeyRing
public final KeyRing createKeyRing(LocationName parent, String keyRingId, KeyRing keyRing)
Create a new [KeyRing][google.cloud.kms.v1.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:
parent
- Required. The resource name of the location associated with the [KeyRings][google.cloud.kms.v1.KeyRing], in the format `projects/*/locations/*`.keyRingId
- Required. It must be unique within a location and match the regular expression `[a-zA-Z0-9_-]{1,63}`keyRing
- Required. A [KeyRing][google.cloud.kms.v1.KeyRing] with initial field values.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
createKeyRing
public final KeyRing createKeyRing(String parent, String keyRingId, KeyRing keyRing)
Create a new [KeyRing][google.cloud.kms.v1.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:
parent
- Required. The resource name of the location associated with the [KeyRings][google.cloud.kms.v1.KeyRing], in the format `projects/*/locations/*`.keyRingId
- Required. It must be unique within a location and match the regular expression `[a-zA-Z0-9_-]{1,63}`keyRing
- Required. A [KeyRing][google.cloud.kms.v1.KeyRing] with initial field values.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
createKeyRing
public final KeyRing createKeyRing(CreateKeyRingRequest request)
Create a new [KeyRing][google.cloud.kms.v1.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
createKeyRingCallable
public final com.google.api.gax.rpc.UnaryCallable<CreateKeyRingRequest,KeyRing> createKeyRingCallable()
Create a new [KeyRing][google.cloud.kms.v1.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(); }
-
createCryptoKey
public final CryptoKey createCryptoKey(KeyRingName parent, String cryptoKeyId, CryptoKey cryptoKey)
Create a new [CryptoKey][google.cloud.kms.v1.CryptoKey] within a [KeyRing][google.cloud.kms.v1.KeyRing].[CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] and [CryptoKey.version_template.algorithm][google.cloud.kms.v1.CryptoKeyVersionTemplate.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:
parent
- Required. The [name][google.cloud.kms.v1.KeyRing.name] of the KeyRing associated with the [CryptoKeys][google.cloud.kms.v1.CryptoKey].cryptoKeyId
- Required. It must be unique within a KeyRing and match the regular expression `[a-zA-Z0-9_-]{1,63}`cryptoKey
- Required. A [CryptoKey][google.cloud.kms.v1.CryptoKey] with initial field values.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
createCryptoKey
public final CryptoKey createCryptoKey(String parent, String cryptoKeyId, CryptoKey cryptoKey)
Create a new [CryptoKey][google.cloud.kms.v1.CryptoKey] within a [KeyRing][google.cloud.kms.v1.KeyRing].[CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] and [CryptoKey.version_template.algorithm][google.cloud.kms.v1.CryptoKeyVersionTemplate.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:
parent
- Required. The [name][google.cloud.kms.v1.KeyRing.name] of the KeyRing associated with the [CryptoKeys][google.cloud.kms.v1.CryptoKey].cryptoKeyId
- Required. It must be unique within a KeyRing and match the regular expression `[a-zA-Z0-9_-]{1,63}`cryptoKey
- Required. A [CryptoKey][google.cloud.kms.v1.CryptoKey] with initial field values.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
createCryptoKey
public final CryptoKey createCryptoKey(CreateCryptoKeyRequest request)
Create a new [CryptoKey][google.cloud.kms.v1.CryptoKey] within a [KeyRing][google.cloud.kms.v1.KeyRing].[CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] and [CryptoKey.version_template.algorithm][google.cloud.kms.v1.CryptoKeyVersionTemplate.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
createCryptoKeyCallable
public final com.google.api.gax.rpc.UnaryCallable<CreateCryptoKeyRequest,CryptoKey> createCryptoKeyCallable()
Create a new [CryptoKey][google.cloud.kms.v1.CryptoKey] within a [KeyRing][google.cloud.kms.v1.KeyRing].[CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] and [CryptoKey.version_template.algorithm][google.cloud.kms.v1.CryptoKeyVersionTemplate.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(); }
-
createCryptoKeyVersion
public final CryptoKeyVersion createCryptoKeyVersion(CryptoKeyName parent, CryptoKeyVersion cryptoKeyVersion)
Create a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in a [CryptoKey][google.cloud.kms.v1.CryptoKey].The server will assign the next sequential id. If unset, [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.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:
parent
- Required. The [name][google.cloud.kms.v1.CryptoKey.name] of the [CryptoKey][google.cloud.kms.v1.CryptoKey] associated with the [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion].cryptoKeyVersion
- Required. A [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with initial field values.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
createCryptoKeyVersion
public final CryptoKeyVersion createCryptoKeyVersion(String parent, CryptoKeyVersion cryptoKeyVersion)
Create a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in a [CryptoKey][google.cloud.kms.v1.CryptoKey].The server will assign the next sequential id. If unset, [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.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:
parent
- Required. The [name][google.cloud.kms.v1.CryptoKey.name] of the [CryptoKey][google.cloud.kms.v1.CryptoKey] associated with the [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion].cryptoKeyVersion
- Required. A [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with initial field values.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
createCryptoKeyVersion
public final CryptoKeyVersion createCryptoKeyVersion(CreateCryptoKeyVersionRequest request)
Create a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in a [CryptoKey][google.cloud.kms.v1.CryptoKey].The server will assign the next sequential id. If unset, [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
createCryptoKeyVersionCallable
public final com.google.api.gax.rpc.UnaryCallable<CreateCryptoKeyVersionRequest,CryptoKeyVersion> createCryptoKeyVersionCallable()
Create a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in a [CryptoKey][google.cloud.kms.v1.CryptoKey].The server will assign the next sequential id. If unset, [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.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(); }
-
importCryptoKeyVersion
public final CryptoKeyVersion importCryptoKeyVersion(ImportCryptoKeyVersionRequest request)
Import wrapped key material into a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].All requests must specify a [CryptoKey][google.cloud.kms.v1.CryptoKey]. If a [CryptoKeyVersion][google.cloud.kms.v1.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][google.cloud.kms.v1.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
importCryptoKeyVersionCallable
public final com.google.api.gax.rpc.UnaryCallable<ImportCryptoKeyVersionRequest,CryptoKeyVersion> importCryptoKeyVersionCallable()
Import wrapped key material into a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].All requests must specify a [CryptoKey][google.cloud.kms.v1.CryptoKey]. If a [CryptoKeyVersion][google.cloud.kms.v1.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][google.cloud.kms.v1.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(); }
-
createImportJob
public final ImportJob createImportJob(KeyRingName parent, String importJobId, ImportJob importJob)
Create a new [ImportJob][google.cloud.kms.v1.ImportJob] within a [KeyRing][google.cloud.kms.v1.KeyRing].[ImportJob.import_method][google.cloud.kms.v1.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:
parent
- Required. The [name][google.cloud.kms.v1.KeyRing.name] of the [KeyRing][google.cloud.kms.v1.KeyRing] associated with the [ImportJobs][google.cloud.kms.v1.ImportJob].importJobId
- Required. It must be unique within a KeyRing and match the regular expression `[a-zA-Z0-9_-]{1,63}`importJob
- Required. An [ImportJob][google.cloud.kms.v1.ImportJob] with initial field values.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
createImportJob
public final ImportJob createImportJob(String parent, String importJobId, ImportJob importJob)
Create a new [ImportJob][google.cloud.kms.v1.ImportJob] within a [KeyRing][google.cloud.kms.v1.KeyRing].[ImportJob.import_method][google.cloud.kms.v1.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:
parent
- Required. The [name][google.cloud.kms.v1.KeyRing.name] of the [KeyRing][google.cloud.kms.v1.KeyRing] associated with the [ImportJobs][google.cloud.kms.v1.ImportJob].importJobId
- Required. It must be unique within a KeyRing and match the regular expression `[a-zA-Z0-9_-]{1,63}`importJob
- Required. An [ImportJob][google.cloud.kms.v1.ImportJob] with initial field values.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
createImportJob
public final ImportJob createImportJob(CreateImportJobRequest request)
Create a new [ImportJob][google.cloud.kms.v1.ImportJob] within a [KeyRing][google.cloud.kms.v1.KeyRing].[ImportJob.import_method][google.cloud.kms.v1.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
createImportJobCallable
public final com.google.api.gax.rpc.UnaryCallable<CreateImportJobRequest,ImportJob> createImportJobCallable()
Create a new [ImportJob][google.cloud.kms.v1.ImportJob] within a [KeyRing][google.cloud.kms.v1.KeyRing].[ImportJob.import_method][google.cloud.kms.v1.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(); }
-
updateCryptoKey
public final CryptoKey updateCryptoKey(CryptoKey cryptoKey, com.google.protobuf.FieldMask updateMask)
Update a [CryptoKey][google.cloud.kms.v1.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:
cryptoKey
- Required. [CryptoKey][google.cloud.kms.v1.CryptoKey] with updated values.updateMask
- Required. List of fields to be updated in this request.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
updateCryptoKey
public final CryptoKey updateCryptoKey(UpdateCryptoKeyRequest request)
Update a [CryptoKey][google.cloud.kms.v1.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
updateCryptoKeyCallable
public final com.google.api.gax.rpc.UnaryCallable<UpdateCryptoKeyRequest,CryptoKey> updateCryptoKeyCallable()
Update a [CryptoKey][google.cloud.kms.v1.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(); }
-
updateCryptoKeyVersion
public final CryptoKeyVersion updateCryptoKeyVersion(CryptoKeyVersion cryptoKeyVersion, com.google.protobuf.FieldMask updateMask)
Update a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]'s metadata.[state][google.cloud.kms.v1.CryptoKeyVersion.state] may be changed between [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED] and [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED] using this method. See [DestroyCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.DestroyCryptoKeyVersion] and [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.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:
cryptoKeyVersion
- Required. [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with updated values.updateMask
- Required. List of fields to be updated in this request.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
updateCryptoKeyVersion
public final CryptoKeyVersion updateCryptoKeyVersion(UpdateCryptoKeyVersionRequest request)
Update a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]'s metadata.[state][google.cloud.kms.v1.CryptoKeyVersion.state] may be changed between [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED] and [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED] using this method. See [DestroyCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.DestroyCryptoKeyVersion] and [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
updateCryptoKeyVersionCallable
public final com.google.api.gax.rpc.UnaryCallable<UpdateCryptoKeyVersionRequest,CryptoKeyVersion> updateCryptoKeyVersionCallable()
Update a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]'s metadata.[state][google.cloud.kms.v1.CryptoKeyVersion.state] may be changed between [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED] and [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED] using this method. See [DestroyCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.DestroyCryptoKeyVersion] and [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.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(); }
-
updateCryptoKeyPrimaryVersion
public final CryptoKey updateCryptoKeyPrimaryVersion(CryptoKeyName name, String cryptoKeyVersionId)
Update the version of a [CryptoKey][google.cloud.kms.v1.CryptoKey] that will be used in [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt].Returns an error if called on a key whose purpose is not [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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
- Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to update.cryptoKeyVersionId
- Required. The id of the child [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use as primary.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
updateCryptoKeyPrimaryVersion
public final CryptoKey updateCryptoKeyPrimaryVersion(String name, String cryptoKeyVersionId)
Update the version of a [CryptoKey][google.cloud.kms.v1.CryptoKey] that will be used in [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt].Returns an error if called on a key whose purpose is not [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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
- Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to update.cryptoKeyVersionId
- Required. The id of the child [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use as primary.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
updateCryptoKeyPrimaryVersion
public final CryptoKey updateCryptoKeyPrimaryVersion(UpdateCryptoKeyPrimaryVersionRequest request)
Update the version of a [CryptoKey][google.cloud.kms.v1.CryptoKey] that will be used in [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt].Returns an error if called on a key whose purpose is not [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
updateCryptoKeyPrimaryVersionCallable
public final com.google.api.gax.rpc.UnaryCallable<UpdateCryptoKeyPrimaryVersionRequest,CryptoKey> updateCryptoKeyPrimaryVersionCallable()
Update the version of a [CryptoKey][google.cloud.kms.v1.CryptoKey] that will be used in [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt].Returns an error if called on a key whose purpose is not [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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(); }
-
destroyCryptoKeyVersion
public final CryptoKeyVersion destroyCryptoKeyVersion(CryptoKeyVersionName name)
Schedule a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] for destruction.Upon calling this method, [CryptoKeyVersion.state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED], and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be set to the time [destroy_scheduled_duration][google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration] in the future. At that time, the [state][google.cloud.kms.v1.CryptoKeyVersion.state] will automatically change to [DESTROYED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED], and the key material will be irrevocably destroyed.
Before the [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] is reached, [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.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); }
- Parameters:
name
- Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to destroy.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
destroyCryptoKeyVersion
public final CryptoKeyVersion destroyCryptoKeyVersion(String name)
Schedule a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] for destruction.Upon calling this method, [CryptoKeyVersion.state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED], and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be set to the time [destroy_scheduled_duration][google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration] in the future. At that time, the [state][google.cloud.kms.v1.CryptoKeyVersion.state] will automatically change to [DESTROYED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED], and the key material will be irrevocably destroyed.
Before the [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] is reached, [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.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); }
- Parameters:
name
- Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to destroy.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
destroyCryptoKeyVersion
public final CryptoKeyVersion destroyCryptoKeyVersion(DestroyCryptoKeyVersionRequest request)
Schedule a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] for destruction.Upon calling this method, [CryptoKeyVersion.state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED], and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be set to the time [destroy_scheduled_duration][google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration] in the future. At that time, the [state][google.cloud.kms.v1.CryptoKeyVersion.state] will automatically change to [DESTROYED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED], and the key material will be irrevocably destroyed.
Before the [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] is reached, [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
destroyCryptoKeyVersionCallable
public final com.google.api.gax.rpc.UnaryCallable<DestroyCryptoKeyVersionRequest,CryptoKeyVersion> destroyCryptoKeyVersionCallable()
Schedule a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] for destruction.Upon calling this method, [CryptoKeyVersion.state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED], and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will be set to the time [destroy_scheduled_duration][google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration] in the future. At that time, the [state][google.cloud.kms.v1.CryptoKeyVersion.state] will automatically change to [DESTROYED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED], and the key material will be irrevocably destroyed.
Before the [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] is reached, [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.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(); }
-
restoreCryptoKeyVersion
public final CryptoKeyVersion restoreCryptoKeyVersion(CryptoKeyVersionName name)
Restore a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in the [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED] state.Upon restoration of the CryptoKeyVersion, [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED], and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.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); }
- Parameters:
name
- Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to restore.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
restoreCryptoKeyVersion
public final CryptoKeyVersion restoreCryptoKeyVersion(String name)
Restore a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in the [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED] state.Upon restoration of the CryptoKeyVersion, [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED], and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.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); }
- Parameters:
name
- Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to restore.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
restoreCryptoKeyVersion
public final CryptoKeyVersion restoreCryptoKeyVersion(RestoreCryptoKeyVersionRequest request)
Restore a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in the [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED] state.Upon restoration of the CryptoKeyVersion, [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED], and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
restoreCryptoKeyVersionCallable
public final com.google.api.gax.rpc.UnaryCallable<RestoreCryptoKeyVersionRequest,CryptoKeyVersion> restoreCryptoKeyVersionCallable()
Restore a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in the [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED] state.Upon restoration of the CryptoKeyVersion, [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED], and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.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(); }
-
encrypt
public final EncryptResponse encrypt(com.google.api.resourcenames.ResourceName name, com.google.protobuf.ByteString plaintext)
Encrypts data, so that it can only be recovered by a call to [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt]. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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
- Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] or [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for encryption.If a [CryptoKey][google.cloud.kms.v1.CryptoKey] is specified, the server will use its [primary version][google.cloud.kms.v1.CryptoKey.primary].
plaintext
- Required. The data to encrypt. Must be no larger than 64KiB.The maximum size depends on the key version's [protection_level][google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level]. For [SOFTWARE][google.cloud.kms.v1.ProtectionLevel.SOFTWARE], [EXTERNAL][google.cloud.kms.v1.ProtectionLevel.EXTERNAL], and [EXTERNAL_VPC][google.cloud.kms.v1.ProtectionLevel.EXTERNAL_VPC] keys, the plaintext must be no larger than 64KiB. For [HSM][google.cloud.kms.v1.ProtectionLevel.HSM] keys, the combined length of the plaintext and additional_authenticated_data fields must be no larger than 8KiB.
- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
encrypt
public final EncryptResponse encrypt(CryptoKeyPathName name, com.google.protobuf.ByteString plaintext)
Encrypts data, so that it can only be recovered by a call to [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt]. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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
- Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] or [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for encryption.If a [CryptoKey][google.cloud.kms.v1.CryptoKey] is specified, the server will use its [primary version][google.cloud.kms.v1.CryptoKey.primary].
plaintext
- Required. The data to encrypt. Must be no larger than 64KiB.The maximum size depends on the key version's [protection_level][google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level]. For [SOFTWARE][google.cloud.kms.v1.ProtectionLevel.SOFTWARE] keys, the plaintext must be no larger than 64KiB. For [HSM][google.cloud.kms.v1.ProtectionLevel.HSM] keys, the combined length of the plaintext and additional_authenticated_data fields must be no larger than 8KiB.
- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
encrypt
public final EncryptResponse encrypt(String name, com.google.protobuf.ByteString plaintext)
Encrypts data, so that it can only be recovered by a call to [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt]. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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 plaintext = ByteString.EMPTY; EncryptResponse response = keyManagementServiceClient.encrypt(name, plaintext); }
- Parameters:
name
- Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] or [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for encryption.If a [CryptoKey][google.cloud.kms.v1.CryptoKey] is specified, the server will use its [primary version][google.cloud.kms.v1.CryptoKey.primary].
plaintext
- Required. The data to encrypt. Must be no larger than 64KiB.The maximum size depends on the key version's [protection_level][google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level]. For [SOFTWARE][google.cloud.kms.v1.ProtectionLevel.SOFTWARE], [EXTERNAL][google.cloud.kms.v1.ProtectionLevel.EXTERNAL], and [EXTERNAL_VPC][google.cloud.kms.v1.ProtectionLevel.EXTERNAL_VPC] keys, the plaintext must be no larger than 64KiB. For [HSM][google.cloud.kms.v1.ProtectionLevel.HSM] keys, the combined length of the plaintext and additional_authenticated_data fields must be no larger than 8KiB.
- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
encrypt
public final EncryptResponse encrypt(EncryptRequest request)
Encrypts data, so that it can only be recovered by a call to [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt]. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
encryptCallable
public final com.google.api.gax.rpc.UnaryCallable<EncryptRequest,EncryptResponse> encryptCallable()
Encrypts data, so that it can only be recovered by a call to [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt]. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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(); }
-
decrypt
public final DecryptResponse decrypt(CryptoKeyName name, com.google.protobuf.ByteString ciphertext)
Decrypts data that was protected by [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt]. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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
- Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to use for decryption. The server will choose the appropriate version.ciphertext
- Required. The encrypted data originally returned in [EncryptResponse.ciphertext][google.cloud.kms.v1.EncryptResponse.ciphertext].- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
decrypt
public final DecryptResponse decrypt(String name, com.google.protobuf.ByteString ciphertext)
Decrypts data that was protected by [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt]. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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
- Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to use for decryption. The server will choose the appropriate version.ciphertext
- Required. The encrypted data originally returned in [EncryptResponse.ciphertext][google.cloud.kms.v1.EncryptResponse.ciphertext].- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
decrypt
public final DecryptResponse decrypt(DecryptRequest request)
Decrypts data that was protected by [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt]. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
decryptCallable
public final com.google.api.gax.rpc.UnaryCallable<DecryptRequest,DecryptResponse> decryptCallable()
Decrypts data that was protected by [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt]. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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(); }
-
rawEncrypt
public final RawEncryptResponse rawEncrypt(RawEncryptRequest request)
Encrypts data using portable cryptographic primitives. Most users should choose [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt] and [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt] rather than their raw counterparts. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be [RAW_ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
rawEncryptCallable
public final com.google.api.gax.rpc.UnaryCallable<RawEncryptRequest,RawEncryptResponse> rawEncryptCallable()
Encrypts data using portable cryptographic primitives. Most users should choose [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt] and [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt] rather than their raw counterparts. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be [RAW_ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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(); }
-
rawDecrypt
public final RawDecryptResponse rawDecrypt(RawDecryptRequest request)
Decrypts data that was originally encrypted using a raw cryptographic mechanism. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be [RAW_ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
rawDecryptCallable
public final com.google.api.gax.rpc.UnaryCallable<RawDecryptRequest,RawDecryptResponse> rawDecryptCallable()
Decrypts data that was originally encrypted using a raw cryptographic mechanism. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be [RAW_ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.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(); }
-
asymmetricSign
public final AsymmetricSignResponse asymmetricSign(CryptoKeyVersionName name, Digest digest)
Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_SIGN, producing a signature that can be verified with the public key retrieved from [GetPublicKey][google.cloud.kms.v1.KeyManagementService.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
- Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for signing.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][google.cloud.kms.v1.CryptoKeyVersion.algorithm].This field may not be supplied if [AsymmetricSignRequest.data][google.cloud.kms.v1.AsymmetricSignRequest.data] is supplied.
- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
asymmetricSign
public final AsymmetricSignResponse asymmetricSign(String name, Digest digest)
Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_SIGN, producing a signature that can be verified with the public key retrieved from [GetPublicKey][google.cloud.kms.v1.KeyManagementService.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
- Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for signing.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][google.cloud.kms.v1.CryptoKeyVersion.algorithm].This field may not be supplied if [AsymmetricSignRequest.data][google.cloud.kms.v1.AsymmetricSignRequest.data] is supplied.
- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
asymmetricSign
public final AsymmetricSignResponse asymmetricSign(AsymmetricSignRequest request)
Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_SIGN, producing a signature that can be verified with the public key retrieved from [GetPublicKey][google.cloud.kms.v1.KeyManagementService.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
asymmetricSignCallable
public final com.google.api.gax.rpc.UnaryCallable<AsymmetricSignRequest,AsymmetricSignResponse> asymmetricSignCallable()
Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] ASYMMETRIC_SIGN, producing a signature that can be verified with the public key retrieved from [GetPublicKey][google.cloud.kms.v1.KeyManagementService.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(); }
-
asymmetricDecrypt
public final AsymmetricDecryptResponse asymmetricDecrypt(CryptoKeyVersionName name, com.google.protobuf.ByteString ciphertext)
Decrypts data that was encrypted with a public key retrieved from [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey] corresponding to a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.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
- Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for decryption.ciphertext
- Required. The data encrypted with the named [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]'s public key using OAEP.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
asymmetricDecrypt
public final AsymmetricDecryptResponse asymmetricDecrypt(String name, com.google.protobuf.ByteString ciphertext)
Decrypts data that was encrypted with a public key retrieved from [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey] corresponding to a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.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
- Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for decryption.ciphertext
- Required. The data encrypted with the named [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]'s public key using OAEP.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
asymmetricDecrypt
public final AsymmetricDecryptResponse asymmetricDecrypt(AsymmetricDecryptRequest request)
Decrypts data that was encrypted with a public key retrieved from [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey] corresponding to a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
asymmetricDecryptCallable
public final com.google.api.gax.rpc.UnaryCallable<AsymmetricDecryptRequest,AsymmetricDecryptResponse> asymmetricDecryptCallable()
Decrypts data that was encrypted with a public key retrieved from [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey] corresponding to a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.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(); }
-
macSign
public final MacSignResponse macSign(CryptoKeyVersionName name, com.google.protobuf.ByteString data)
Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.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
- Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for signing.data
- Required. The data to sign. The MAC tag is computed over this data field based on the specific algorithm.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
macSign
public final MacSignResponse macSign(String name, com.google.protobuf.ByteString data)
Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.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
- Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for signing.data
- Required. The data to sign. The MAC tag is computed over this data field based on the specific algorithm.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
macSign
public final MacSignResponse macSign(MacSignRequest request)
Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
macSignCallable
public final com.google.api.gax.rpc.UnaryCallable<MacSignRequest,MacSignResponse> macSignCallable()
Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.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(); }
-
macVerify
public final MacVerifyResponse macVerify(CryptoKeyVersionName name, com.google.protobuf.ByteString data, com.google.protobuf.ByteString mac)
Verifies MAC tag using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.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
- Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for verification.data
- Required. The data used previously as a [MacSignRequest.data][google.cloud.kms.v1.MacSignRequest.data] to generate the MAC tag.mac
- Required. The signature to verify.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
macVerify
public final MacVerifyResponse macVerify(String name, com.google.protobuf.ByteString data, com.google.protobuf.ByteString mac)
Verifies MAC tag using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.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
- Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for verification.data
- Required. The data used previously as a [MacSignRequest.data][google.cloud.kms.v1.MacSignRequest.data] to generate the MAC tag.mac
- Required. The signature to verify.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
macVerify
public final MacVerifyResponse macVerify(MacVerifyRequest request)
Verifies MAC tag using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
macVerifyCallable
public final com.google.api.gax.rpc.UnaryCallable<MacVerifyRequest,MacVerifyResponse> macVerifyCallable()
Verifies MAC tag using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with [CryptoKey.purpose][google.cloud.kms.v1.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(); }
-
generateRandomBytes
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:
location
- The project-specific location in which to generate random bytes. For example, "projects/my-project/locations/us-central1".lengthBytes
- The length in bytes of the amount of randomness to retrieve. Minimum 8 bytes, maximum 1024 bytes.protectionLevel
- The [ProtectionLevel][google.cloud.kms.v1.ProtectionLevel] to use when generating the random data. Currently, only [HSM][google.cloud.kms.v1.ProtectionLevel.HSM] protection level is supported.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
generateRandomBytes
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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
generateRandomBytesCallable
public final com.google.api.gax.rpc.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(); }
-
listLocations
public final KeyManagementServiceClient.ListLocationsPagedResponse listLocations(com.google.cloud.location.ListLocationsRequest request)
Lists information about the supported locations for this service.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); } }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listLocationsPagedCallable
public final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,KeyManagementServiceClient.ListLocationsPagedResponse> listLocationsPagedCallable()
Lists information about the supported locations for this service.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); } }
-
listLocationsCallable
public final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse> listLocationsCallable()
Lists information about the supported locations for this service.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; } } }
-
getLocation
public final com.google.cloud.location.Location getLocation(com.google.cloud.location.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getLocationCallable
public final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.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(); }
-
setIamPolicy
public final com.google.iam.v1.Policy setIamPolicy(com.google.iam.v1.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
setIamPolicy
public final com.google.iam.v1.Policy setIamPolicy(KeyName resource, com.google.iam.v1.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:
resource
- REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.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.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
setIamPolicy
public final com.google.iam.v1.Policy setIamPolicy(String resource, com.google.iam.v1.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:
resource
- REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.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.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
setIamPolicyCallable
public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.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(); }
-
getIamPolicy
public final com.google.iam.v1.Policy getIamPolicy(com.google.iam.v1.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getIamPolicy
public final com.google.iam.v1.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); }
- Parameters:
resource
- REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getIamPolicy
public final com.google.iam.v1.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()); }
- Parameters:
resource
- REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getIamPolicyCallable
public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.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(); }
-
testIamPermissions
public final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(com.google.iam.v1.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); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
testIamPermissions
public final com.google.iam.v1.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:
resource
- REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.permissions
- 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).- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
testIamPermissions
public final com.google.iam.v1.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:
resource
- REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.permissions
- 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).- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
testIamPermissionsCallable
public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.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(); }
-
close
public final void close()
- Specified by:
close
in interfaceAutoCloseable
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfacecom.google.api.gax.core.BackgroundResource
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdown
in interfacecom.google.api.gax.core.BackgroundResource
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminated
in interfacecom.google.api.gax.core.BackgroundResource
-
shutdownNow
public void shutdownNow()
- Specified by:
shutdownNow
in interfacecom.google.api.gax.core.BackgroundResource
-
awaitTermination
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
- Specified by:
awaitTermination
in interfacecom.google.api.gax.core.BackgroundResource
- Throws:
InterruptedException
-
-