@Generated(value="by gapic-generator-java") public class EkmServiceClient extends Object implements BackgroundResource
Manages external cryptographic keys and operations using those keys. Implements a REST model with the following objects:
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 (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
EkmConnectionName name = EkmConnectionName.of("[PROJECT]", "[LOCATION]", "[EKM_CONNECTION]");
EkmConnection response = ekmServiceClient.getEkmConnection(name);
}
Note: close() needs to be called on the EkmServiceClient 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:
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 EkmServiceSettings 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
EkmServiceSettings ekmServiceSettings =
EkmServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
EkmServiceClient ekmServiceClient = EkmServiceClient.create(ekmServiceSettings);
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
EkmServiceSettings ekmServiceSettings =
EkmServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
EkmServiceClient ekmServiceClient = EkmServiceClient.create(ekmServiceSettings);
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
EkmServiceSettings ekmServiceSettings =
EkmServiceSettings.newBuilder()
.setTransportChannelProvider(
EkmServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
.build();
EkmServiceClient ekmServiceClient = EkmServiceClient.create(ekmServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Modifier and Type | Class and Description |
---|---|
static class |
EkmServiceClient.ListEkmConnectionsFixedSizeCollection |
static class |
EkmServiceClient.ListEkmConnectionsPage |
static class |
EkmServiceClient.ListEkmConnectionsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
EkmServiceClient(EkmServiceSettings settings)
Constructs an instance of EkmServiceClient, using the given settings.
|
protected |
EkmServiceClient(EkmServiceStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static EkmServiceClient |
create()
Constructs an instance of EkmServiceClient with default settings.
|
static EkmServiceClient |
create(EkmServiceSettings settings)
Constructs an instance of EkmServiceClient, using the given settings.
|
static EkmServiceClient |
create(EkmServiceStub stub)
Constructs an instance of EkmServiceClient, using the given stub for making calls.
|
EkmConnection |
createEkmConnection(CreateEkmConnectionRequest request)
Creates a new [EkmConnection][google.cloud.kms.v1.EkmConnection] in a given Project and
Location.
|
EkmConnection |
createEkmConnection(LocationName parent,
String ekmConnectionId,
EkmConnection ekmConnection)
Creates a new [EkmConnection][google.cloud.kms.v1.EkmConnection] in a given Project and
Location.
|
EkmConnection |
createEkmConnection(String parent,
String ekmConnectionId,
EkmConnection ekmConnection)
Creates a new [EkmConnection][google.cloud.kms.v1.EkmConnection] in a given Project and
Location.
|
UnaryCallable<CreateEkmConnectionRequest,EkmConnection> |
createEkmConnectionCallable()
Creates a new [EkmConnection][google.cloud.kms.v1.EkmConnection] in a given Project and
Location.
|
EkmConnection |
getEkmConnection(EkmConnectionName name)
Returns metadata for a given [EkmConnection][google.cloud.kms.v1.EkmConnection].
|
EkmConnection |
getEkmConnection(GetEkmConnectionRequest request)
Returns metadata for a given [EkmConnection][google.cloud.kms.v1.EkmConnection].
|
EkmConnection |
getEkmConnection(String name)
Returns metadata for a given [EkmConnection][google.cloud.kms.v1.EkmConnection].
|
UnaryCallable<GetEkmConnectionRequest,EkmConnection> |
getEkmConnectionCallable()
Returns metadata for a given [EkmConnection][google.cloud.kms.v1.EkmConnection].
|
com.google.iam.v1.Policy |
getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Gets the access control policy for a resource.
|
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> |
getIamPolicyCallable()
Gets the access control policy for a resource.
|
EkmServiceSettings |
getSettings() |
EkmServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
EkmServiceClient.ListEkmConnectionsPagedResponse |
listEkmConnections(ListEkmConnectionsRequest request)
Lists [EkmConnections][google.cloud.kms.v1.EkmConnection].
|
EkmServiceClient.ListEkmConnectionsPagedResponse |
listEkmConnections(LocationName parent)
Lists [EkmConnections][google.cloud.kms.v1.EkmConnection].
|
EkmServiceClient.ListEkmConnectionsPagedResponse |
listEkmConnections(String parent)
Lists [EkmConnections][google.cloud.kms.v1.EkmConnection].
|
UnaryCallable<ListEkmConnectionsRequest,ListEkmConnectionsResponse> |
listEkmConnectionsCallable()
Lists [EkmConnections][google.cloud.kms.v1.EkmConnection].
|
UnaryCallable<ListEkmConnectionsRequest,EkmServiceClient.ListEkmConnectionsPagedResponse> |
listEkmConnectionsPagedCallable()
Lists [EkmConnections][google.cloud.kms.v1.EkmConnection].
|
com.google.iam.v1.Policy |
setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Sets the access control policy on the specified resource.
|
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(com.google.iam.v1.TestIamPermissionsRequest request)
Returns permissions that a caller has on the specified resource.
|
UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> |
testIamPermissionsCallable()
Returns permissions that a caller has on the specified resource.
|
EkmConnection |
updateEkmConnection(EkmConnection ekmConnection,
FieldMask updateMask)
Updates an [EkmConnection][google.cloud.kms.v1.EkmConnection]'s metadata.
|
EkmConnection |
updateEkmConnection(UpdateEkmConnectionRequest request)
Updates an [EkmConnection][google.cloud.kms.v1.EkmConnection]'s metadata.
|
UnaryCallable<UpdateEkmConnectionRequest,EkmConnection> |
updateEkmConnectionCallable()
Updates an [EkmConnection][google.cloud.kms.v1.EkmConnection]'s metadata.
|
protected EkmServiceClient(EkmServiceSettings settings) throws IOException
IOException
protected EkmServiceClient(EkmServiceStub stub)
public static final EkmServiceClient create() throws IOException
IOException
public static final EkmServiceClient create(EkmServiceSettings settings) throws IOException
IOException
public static final EkmServiceClient create(EkmServiceStub stub)
public final EkmServiceSettings getSettings()
public EkmServiceStub getStub()
public final EkmServiceClient.ListEkmConnectionsPagedResponse listEkmConnections(LocationName parent)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (EkmConnection element : ekmServiceClient.listEkmConnections(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The resource name of the location associated with the
[EkmConnections][google.cloud.kms.v1.EkmConnection] to list, in the format
`projects/*/locations/*`.ApiException
- if the remote call failspublic final EkmServiceClient.ListEkmConnectionsPagedResponse listEkmConnections(String parent)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
for (EkmConnection element : ekmServiceClient.listEkmConnections(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The resource name of the location associated with the
[EkmConnections][google.cloud.kms.v1.EkmConnection] to list, in the format
`projects/*/locations/*`.ApiException
- if the remote call failspublic final EkmServiceClient.ListEkmConnectionsPagedResponse listEkmConnections(ListEkmConnectionsRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
ListEkmConnectionsRequest request =
ListEkmConnectionsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.build();
for (EkmConnection element : ekmServiceClient.listEkmConnections(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<ListEkmConnectionsRequest,EkmServiceClient.ListEkmConnectionsPagedResponse> listEkmConnectionsPagedCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
ListEkmConnectionsRequest request =
ListEkmConnectionsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.build();
ApiFuture<EkmConnection> future =
ekmServiceClient.listEkmConnectionsPagedCallable().futureCall(request);
// Do something.
for (EkmConnection element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<ListEkmConnectionsRequest,ListEkmConnectionsResponse> listEkmConnectionsCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
ListEkmConnectionsRequest request =
ListEkmConnectionsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.build();
while (true) {
ListEkmConnectionsResponse response =
ekmServiceClient.listEkmConnectionsCallable().call(request);
for (EkmConnection element : response.getEkmConnectionsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final EkmConnection getEkmConnection(EkmConnectionName name)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
EkmConnectionName name = EkmConnectionName.of("[PROJECT]", "[LOCATION]", "[EKM_CONNECTION]");
EkmConnection response = ekmServiceClient.getEkmConnection(name);
}
name
- Required. The [name][google.cloud.kms.v1.EkmConnection.name] of the
[EkmConnection][google.cloud.kms.v1.EkmConnection] to get.ApiException
- if the remote call failspublic final EkmConnection getEkmConnection(String name)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
String name = EkmConnectionName.of("[PROJECT]", "[LOCATION]", "[EKM_CONNECTION]").toString();
EkmConnection response = ekmServiceClient.getEkmConnection(name);
}
name
- Required. The [name][google.cloud.kms.v1.EkmConnection.name] of the
[EkmConnection][google.cloud.kms.v1.EkmConnection] to get.ApiException
- if the remote call failspublic final EkmConnection getEkmConnection(GetEkmConnectionRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
GetEkmConnectionRequest request =
GetEkmConnectionRequest.newBuilder()
.setName(
EkmConnectionName.of("[PROJECT]", "[LOCATION]", "[EKM_CONNECTION]").toString())
.build();
EkmConnection response = ekmServiceClient.getEkmConnection(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<GetEkmConnectionRequest,EkmConnection> getEkmConnectionCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
GetEkmConnectionRequest request =
GetEkmConnectionRequest.newBuilder()
.setName(
EkmConnectionName.of("[PROJECT]", "[LOCATION]", "[EKM_CONNECTION]").toString())
.build();
ApiFuture<EkmConnection> future =
ekmServiceClient.getEkmConnectionCallable().futureCall(request);
// Do something.
EkmConnection response = future.get();
}
public final EkmConnection createEkmConnection(LocationName parent, String ekmConnectionId, EkmConnection ekmConnection)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
String ekmConnectionId = "ekmConnectionId-445017408";
EkmConnection ekmConnection = EkmConnection.newBuilder().build();
EkmConnection response =
ekmServiceClient.createEkmConnection(parent, ekmConnectionId, ekmConnection);
}
parent
- Required. The resource name of the location associated with the
[EkmConnection][google.cloud.kms.v1.EkmConnection], in the format
`projects/*/locations/*`.ekmConnectionId
- Required. It must be unique within a location and match the regular
expression `[a-zA-Z0-9_-]{1,63}`.ekmConnection
- Required. An [EkmConnection][google.cloud.kms.v1.EkmConnection] with
initial field values.ApiException
- if the remote call failspublic final EkmConnection createEkmConnection(String parent, String ekmConnectionId, EkmConnection ekmConnection)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
String ekmConnectionId = "ekmConnectionId-445017408";
EkmConnection ekmConnection = EkmConnection.newBuilder().build();
EkmConnection response =
ekmServiceClient.createEkmConnection(parent, ekmConnectionId, ekmConnection);
}
parent
- Required. The resource name of the location associated with the
[EkmConnection][google.cloud.kms.v1.EkmConnection], in the format
`projects/*/locations/*`.ekmConnectionId
- Required. It must be unique within a location and match the regular
expression `[a-zA-Z0-9_-]{1,63}`.ekmConnection
- Required. An [EkmConnection][google.cloud.kms.v1.EkmConnection] with
initial field values.ApiException
- if the remote call failspublic final EkmConnection createEkmConnection(CreateEkmConnectionRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
CreateEkmConnectionRequest request =
CreateEkmConnectionRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setEkmConnectionId("ekmConnectionId-445017408")
.setEkmConnection(EkmConnection.newBuilder().build())
.build();
EkmConnection response = ekmServiceClient.createEkmConnection(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<CreateEkmConnectionRequest,EkmConnection> createEkmConnectionCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
CreateEkmConnectionRequest request =
CreateEkmConnectionRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setEkmConnectionId("ekmConnectionId-445017408")
.setEkmConnection(EkmConnection.newBuilder().build())
.build();
ApiFuture<EkmConnection> future =
ekmServiceClient.createEkmConnectionCallable().futureCall(request);
// Do something.
EkmConnection response = future.get();
}
public final EkmConnection updateEkmConnection(EkmConnection ekmConnection, FieldMask updateMask)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
EkmConnection ekmConnection = EkmConnection.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
EkmConnection response = ekmServiceClient.updateEkmConnection(ekmConnection, updateMask);
}
ekmConnection
- Required. [EkmConnection][google.cloud.kms.v1.EkmConnection] with updated
values.updateMask
- Required. List of fields to be updated in this request.ApiException
- if the remote call failspublic final EkmConnection updateEkmConnection(UpdateEkmConnectionRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
UpdateEkmConnectionRequest request =
UpdateEkmConnectionRequest.newBuilder()
.setEkmConnection(EkmConnection.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
EkmConnection response = ekmServiceClient.updateEkmConnection(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<UpdateEkmConnectionRequest,EkmConnection> updateEkmConnectionCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
UpdateEkmConnectionRequest request =
UpdateEkmConnectionRequest.newBuilder()
.setEkmConnection(EkmConnection.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<EkmConnection> future =
ekmServiceClient.updateEkmConnectionCallable().futureCall(request);
// Do something.
EkmConnection response = future.get();
}
public final com.google.iam.v1.Policy setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
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 (EkmServiceClient ekmServiceClient = EkmServiceClient.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 = ekmServiceClient.setIamPolicy(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> setIamPolicyCallable()
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 (EkmServiceClient ekmServiceClient = EkmServiceClient.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 = ekmServiceClient.setIamPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
public final com.google.iam.v1.Policy getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
Policy response = ekmServiceClient.getIamPolicy(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> getIamPolicyCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
ApiFuture<Policy> future = ekmServiceClient.getIamPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
public final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
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 (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.addAllPermissions(new ArrayList<String>())
.build();
TestIamPermissionsResponse response = ekmServiceClient.testIamPermissions(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> testIamPermissionsCallable()
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 (EkmServiceClient ekmServiceClient = EkmServiceClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.addAllPermissions(new ArrayList<String>())
.build();
ApiFuture<TestIamPermissionsResponse> future =
ekmServiceClient.testIamPermissionsCallable().futureCall(request);
// Do something.
TestIamPermissionsResponse response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2022 Google LLC. All rights reserved.