@Generated(value="by gapic-generator-java") public class GenAiCacheServiceClient extends Object implements com.google.api.gax.core.BackgroundResource
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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
CachedContent cachedContent = CachedContent.newBuilder().build();
CachedContent response = genAiCacheServiceClient.createCachedContent(parent, cachedContent);
}
Note: close() needs to be called on the GenAiCacheServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
CreateCachedContent |
Creates cached content, this call will initialize the cached content in the data storage, and users need to pay for the cache data storage. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetCachedContent |
Gets cached content configurations |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateCachedContent |
Updates cached content configurations |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteCachedContent |
Deletes cached content |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListCachedContents |
Lists cached contents in a project |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListLocations |
Lists information about the supported locations for this service. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetLocation |
Gets information about a location. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
SetIamPolicy |
Sets the access control policy on the specified resource. Replacesany existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetIamPolicy |
Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
TestIamPermissions |
Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return 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 GenAiCacheServiceSettings 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
GenAiCacheServiceSettings genAiCacheServiceSettings =
GenAiCacheServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
GenAiCacheServiceClient genAiCacheServiceClient =
GenAiCacheServiceClient.create(genAiCacheServiceSettings);
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
GenAiCacheServiceSettings genAiCacheServiceSettings =
GenAiCacheServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
GenAiCacheServiceClient genAiCacheServiceClient =
GenAiCacheServiceClient.create(genAiCacheServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
GenAiCacheServiceClient.ListCachedContentsFixedSizeCollection |
static class |
GenAiCacheServiceClient.ListCachedContentsPage |
static class |
GenAiCacheServiceClient.ListCachedContentsPagedResponse |
static class |
GenAiCacheServiceClient.ListLocationsFixedSizeCollection |
static class |
GenAiCacheServiceClient.ListLocationsPage |
static class |
GenAiCacheServiceClient.ListLocationsPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
GenAiCacheServiceClient(GenAiCacheServiceSettings settings)
Constructs an instance of GenAiCacheServiceClient, using the given settings.
|
protected |
GenAiCacheServiceClient(GenAiCacheServiceStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static GenAiCacheServiceClient |
create()
Constructs an instance of GenAiCacheServiceClient with default settings.
|
static GenAiCacheServiceClient |
create(GenAiCacheServiceSettings settings)
Constructs an instance of GenAiCacheServiceClient, using the given settings.
|
static GenAiCacheServiceClient |
create(GenAiCacheServiceStub stub)
Constructs an instance of GenAiCacheServiceClient, using the given stub for making calls.
|
CachedContent |
createCachedContent(CreateCachedContentRequest request)
Creates cached content, this call will initialize the cached content in the data storage, and
users need to pay for the cache data storage.
|
CachedContent |
createCachedContent(LocationName parent,
CachedContent cachedContent)
Creates cached content, this call will initialize the cached content in the data storage, and
users need to pay for the cache data storage.
|
CachedContent |
createCachedContent(String parent,
CachedContent cachedContent)
Creates cached content, this call will initialize the cached content in the data storage, and
users need to pay for the cache data storage.
|
com.google.api.gax.rpc.UnaryCallable<CreateCachedContentRequest,CachedContent> |
createCachedContentCallable()
Creates cached content, this call will initialize the cached content in the data storage, and
users need to pay for the cache data storage.
|
void |
deleteCachedContent(CachedContentName name)
Deletes cached content
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
CachedContentName name = CachedContentName.of("[PROJECT]", "[LOCATION]", "[CACHED_CONTENT]");
genAiCacheServiceClient.deleteCachedContent(name);
}
|
void |
deleteCachedContent(DeleteCachedContentRequest request)
Deletes cached content
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
DeleteCachedContentRequest request =
DeleteCachedContentRequest.newBuilder()
.setName(
CachedContentName.of("[PROJECT]", "[LOCATION]", "[CACHED_CONTENT]").toString())
.build();
genAiCacheServiceClient.deleteCachedContent(request);
}
|
void |
deleteCachedContent(String name)
Deletes cached content
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
String name = CachedContentName.of("[PROJECT]", "[LOCATION]", "[CACHED_CONTENT]").toString();
genAiCacheServiceClient.deleteCachedContent(name);
}
|
com.google.api.gax.rpc.UnaryCallable<DeleteCachedContentRequest,com.google.protobuf.Empty> |
deleteCachedContentCallable()
Deletes cached content
Sample code:
{@code
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
DeleteCachedContentRequest request =
DeleteCachedContentRequest.newBuilder()
.setName(
CachedContentName.of("[PROJECT]", "[LOCATION]", "[CACHED_CONTENT]").toString())
.build();
ApiFuture
|
CachedContent |
getCachedContent(CachedContentName name)
Gets cached content configurations
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
CachedContentName name = CachedContentName.of("[PROJECT]", "[LOCATION]", "[CACHED_CONTENT]");
CachedContent response = genAiCacheServiceClient.getCachedContent(name);
}
|
CachedContent |
getCachedContent(GetCachedContentRequest request)
Gets cached content configurations
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
GetCachedContentRequest request =
GetCachedContentRequest.newBuilder()
.setName(
CachedContentName.of("[PROJECT]", "[LOCATION]", "[CACHED_CONTENT]").toString())
.build();
CachedContent response = genAiCacheServiceClient.getCachedContent(request);
}
|
CachedContent |
getCachedContent(String name)
Gets cached content configurations
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
String name = CachedContentName.of("[PROJECT]", "[LOCATION]", "[CACHED_CONTENT]").toString();
CachedContent response = genAiCacheServiceClient.getCachedContent(name);
}
|
com.google.api.gax.rpc.UnaryCallable<GetCachedContentRequest,CachedContent> |
getCachedContentCallable()
Gets cached content configurations
Sample code:
{@code
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
GetCachedContentRequest request =
GetCachedContentRequest.newBuilder()
.setName(
CachedContentName.of("[PROJECT]", "[LOCATION]", "[CACHED_CONTENT]").toString())
.build();
ApiFuture
|
com.google.iam.v1.Policy |
getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
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.
|
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.
|
GenAiCacheServiceSettings |
getSettings() |
GenAiCacheServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
GenAiCacheServiceClient.ListCachedContentsPagedResponse |
listCachedContents(ListCachedContentsRequest request)
Lists cached contents in a project
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
ListCachedContentsRequest request =
ListCachedContentsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (CachedContent element :
genAiCacheServiceClient.listCachedContents(request).iterateAll()) {
// doThingsWith(element);
}
}
|
GenAiCacheServiceClient.ListCachedContentsPagedResponse |
listCachedContents(LocationName parent)
Lists cached contents in a project
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (CachedContent element :
genAiCacheServiceClient.listCachedContents(parent).iterateAll()) {
// doThingsWith(element);
}
}
|
GenAiCacheServiceClient.ListCachedContentsPagedResponse |
listCachedContents(String parent)
Lists cached contents in a project
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
for (CachedContent element :
genAiCacheServiceClient.listCachedContents(parent).iterateAll()) {
// doThingsWith(element);
}
}
|
com.google.api.gax.rpc.UnaryCallable<ListCachedContentsRequest,ListCachedContentsResponse> |
listCachedContentsCallable()
Lists cached contents in a project
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
ListCachedContentsRequest request =
ListCachedContentsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListCachedContentsResponse response =
genAiCacheServiceClient.listCachedContentsCallable().call(request);
for (CachedContent element : response.getCachedContentsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!
|
com.google.api.gax.rpc.UnaryCallable<ListCachedContentsRequest,GenAiCacheServiceClient.ListCachedContentsPagedResponse> |
listCachedContentsPagedCallable()
Lists cached contents in a project
Sample code:
{@code
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
ListCachedContentsRequest request =
ListCachedContentsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture
|
GenAiCacheServiceClient.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,GenAiCacheServiceClient.ListLocationsPagedResponse> |
listLocationsPagedCallable()
Lists information about the supported locations for this service.
|
com.google.iam.v1.Policy |
setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
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(com.google.iam.v1.TestIamPermissionsRequest request)
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.
|
CachedContent |
updateCachedContent(CachedContent cachedContent,
com.google.protobuf.FieldMask updateMask)
Updates cached content configurations
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
CachedContent cachedContent = CachedContent.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
CachedContent response =
genAiCacheServiceClient.updateCachedContent(cachedContent, updateMask);
}
|
CachedContent |
updateCachedContent(UpdateCachedContentRequest request)
Updates cached content configurations
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
UpdateCachedContentRequest request =
UpdateCachedContentRequest.newBuilder()
.setCachedContent(CachedContent.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
CachedContent response = genAiCacheServiceClient.updateCachedContent(request);
}
|
com.google.api.gax.rpc.UnaryCallable<UpdateCachedContentRequest,CachedContent> |
updateCachedContentCallable()
Updates cached content configurations
Sample code:
{@code
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
UpdateCachedContentRequest request =
UpdateCachedContentRequest.newBuilder()
.setCachedContent(CachedContent.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture
|
protected GenAiCacheServiceClient(GenAiCacheServiceSettings settings) throws IOException
IOExceptionprotected GenAiCacheServiceClient(GenAiCacheServiceStub stub)
public static final GenAiCacheServiceClient create() throws IOException
IOExceptionpublic static final GenAiCacheServiceClient create(GenAiCacheServiceSettings settings) throws IOException
IOExceptionpublic static final GenAiCacheServiceClient create(GenAiCacheServiceStub stub)
public final GenAiCacheServiceSettings getSettings()
public GenAiCacheServiceStub getStub()
public final CachedContent createCachedContent(LocationName parent, CachedContent cachedContent)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
CachedContent cachedContent = CachedContent.newBuilder().build();
CachedContent response = genAiCacheServiceClient.createCachedContent(parent, cachedContent);
}
parent - Required. The parent resource where the cached content will be createdcachedContent - Required. The cached content to createcom.google.api.gax.rpc.ApiException - if the remote call failspublic final CachedContent createCachedContent(String parent, CachedContent cachedContent)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
CachedContent cachedContent = CachedContent.newBuilder().build();
CachedContent response = genAiCacheServiceClient.createCachedContent(parent, cachedContent);
}
parent - Required. The parent resource where the cached content will be createdcachedContent - Required. The cached content to createcom.google.api.gax.rpc.ApiException - if the remote call failspublic final CachedContent createCachedContent(CreateCachedContentRequest 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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
CreateCachedContentRequest request =
CreateCachedContentRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setCachedContent(CachedContent.newBuilder().build())
.build();
CachedContent response = genAiCacheServiceClient.createCachedContent(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CreateCachedContentRequest,CachedContent> createCachedContentCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
CreateCachedContentRequest request =
CreateCachedContentRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setCachedContent(CachedContent.newBuilder().build())
.build();
ApiFuture<CachedContent> future =
genAiCacheServiceClient.createCachedContentCallable().futureCall(request);
// Do something.
CachedContent response = future.get();
}
public final CachedContent getCachedContent(CachedContentName 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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
CachedContentName name = CachedContentName.of("[PROJECT]", "[LOCATION]", "[CACHED_CONTENT]");
CachedContent response = genAiCacheServiceClient.getCachedContent(name);
}
name - Required. The resource name referring to the cached contentcom.google.api.gax.rpc.ApiException - if the remote call failspublic final CachedContent getCachedContent(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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
String name = CachedContentName.of("[PROJECT]", "[LOCATION]", "[CACHED_CONTENT]").toString();
CachedContent response = genAiCacheServiceClient.getCachedContent(name);
}
name - Required. The resource name referring to the cached contentcom.google.api.gax.rpc.ApiException - if the remote call failspublic final CachedContent getCachedContent(GetCachedContentRequest 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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
GetCachedContentRequest request =
GetCachedContentRequest.newBuilder()
.setName(
CachedContentName.of("[PROJECT]", "[LOCATION]", "[CACHED_CONTENT]").toString())
.build();
CachedContent response = genAiCacheServiceClient.getCachedContent(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetCachedContentRequest,CachedContent> getCachedContentCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
GetCachedContentRequest request =
GetCachedContentRequest.newBuilder()
.setName(
CachedContentName.of("[PROJECT]", "[LOCATION]", "[CACHED_CONTENT]").toString())
.build();
ApiFuture<CachedContent> future =
genAiCacheServiceClient.getCachedContentCallable().futureCall(request);
// Do something.
CachedContent response = future.get();
}
public final CachedContent updateCachedContent(CachedContent cachedContent, com.google.protobuf.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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
CachedContent cachedContent = CachedContent.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
CachedContent response =
genAiCacheServiceClient.updateCachedContent(cachedContent, updateMask);
}
cachedContent - Required. The cached content to updateupdateMask - Required. The list of fields to update.com.google.api.gax.rpc.ApiException - if the remote call failspublic final CachedContent updateCachedContent(UpdateCachedContentRequest 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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
UpdateCachedContentRequest request =
UpdateCachedContentRequest.newBuilder()
.setCachedContent(CachedContent.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
CachedContent response = genAiCacheServiceClient.updateCachedContent(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateCachedContentRequest,CachedContent> updateCachedContentCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
UpdateCachedContentRequest request =
UpdateCachedContentRequest.newBuilder()
.setCachedContent(CachedContent.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<CachedContent> future =
genAiCacheServiceClient.updateCachedContentCallable().futureCall(request);
// Do something.
CachedContent response = future.get();
}
public final void deleteCachedContent(CachedContentName 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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
CachedContentName name = CachedContentName.of("[PROJECT]", "[LOCATION]", "[CACHED_CONTENT]");
genAiCacheServiceClient.deleteCachedContent(name);
}
name - Required. The resource name referring to the cached contentcom.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteCachedContent(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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
String name = CachedContentName.of("[PROJECT]", "[LOCATION]", "[CACHED_CONTENT]").toString();
genAiCacheServiceClient.deleteCachedContent(name);
}
name - Required. The resource name referring to the cached contentcom.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteCachedContent(DeleteCachedContentRequest 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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
DeleteCachedContentRequest request =
DeleteCachedContentRequest.newBuilder()
.setName(
CachedContentName.of("[PROJECT]", "[LOCATION]", "[CACHED_CONTENT]").toString())
.build();
genAiCacheServiceClient.deleteCachedContent(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<DeleteCachedContentRequest,com.google.protobuf.Empty> deleteCachedContentCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
DeleteCachedContentRequest request =
DeleteCachedContentRequest.newBuilder()
.setName(
CachedContentName.of("[PROJECT]", "[LOCATION]", "[CACHED_CONTENT]").toString())
.build();
ApiFuture<Empty> future =
genAiCacheServiceClient.deleteCachedContentCallable().futureCall(request);
// Do something.
future.get();
}
public final GenAiCacheServiceClient.ListCachedContentsPagedResponse listCachedContents(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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (CachedContent element :
genAiCacheServiceClient.listCachedContents(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The parent, which owns this collection of cached contents.com.google.api.gax.rpc.ApiException - if the remote call failspublic final GenAiCacheServiceClient.ListCachedContentsPagedResponse listCachedContents(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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
for (CachedContent element :
genAiCacheServiceClient.listCachedContents(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The parent, which owns this collection of cached contents.com.google.api.gax.rpc.ApiException - if the remote call failspublic final GenAiCacheServiceClient.ListCachedContentsPagedResponse listCachedContents(ListCachedContentsRequest 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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
ListCachedContentsRequest request =
ListCachedContentsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (CachedContent element :
genAiCacheServiceClient.listCachedContents(request).iterateAll()) {
// doThingsWith(element);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListCachedContentsRequest,GenAiCacheServiceClient.ListCachedContentsPagedResponse> listCachedContentsPagedCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
ListCachedContentsRequest request =
ListCachedContentsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<CachedContent> future =
genAiCacheServiceClient.listCachedContentsPagedCallable().futureCall(request);
// Do something.
for (CachedContent element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListCachedContentsRequest,ListCachedContentsResponse> listCachedContentsCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
ListCachedContentsRequest request =
ListCachedContentsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListCachedContentsResponse response =
genAiCacheServiceClient.listCachedContentsCallable().call(request);
for (CachedContent element : response.getCachedContentsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final GenAiCacheServiceClient.ListLocationsPagedResponse listLocations(com.google.cloud.location.ListLocationsRequest 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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Location element : genAiCacheServiceClient.listLocations(request).iterateAll()) {
// doThingsWith(element);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,GenAiCacheServiceClient.ListLocationsPagedResponse> listLocationsPagedCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Location> future =
genAiCacheServiceClient.listLocationsPagedCallable().futureCall(request);
// Do something.
for (Location element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse> listLocationsCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListLocationsResponse response =
genAiCacheServiceClient.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;
}
}
}
public final com.google.cloud.location.Location getLocation(com.google.cloud.location.GetLocationRequest 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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
Location response = genAiCacheServiceClient.getLocation(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location> getLocationCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
ApiFuture<Location> future =
genAiCacheServiceClient.getLocationCallable().futureCall(request);
// Do something.
Location 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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(
EndpointName.ofProjectLocationEndpointName(
"[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Policy response = genAiCacheServiceClient.setIamPolicy(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(
EndpointName.ofProjectLocationEndpointName(
"[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Policy> future = genAiCacheServiceClient.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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(
EndpointName.ofProjectLocationEndpointName(
"[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
Policy response = genAiCacheServiceClient.getIamPolicy(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(
EndpointName.ofProjectLocationEndpointName(
"[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
ApiFuture<Policy> future = genAiCacheServiceClient.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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(
EndpointName.ofProjectLocationEndpointName(
"[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString())
.addAllPermissions(new ArrayList<String>())
.build();
TestIamPermissionsResponse response = genAiCacheServiceClient.testIamPermissions(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.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 (GenAiCacheServiceClient genAiCacheServiceClient = GenAiCacheServiceClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(
EndpointName.ofProjectLocationEndpointName(
"[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString())
.addAllPermissions(new ArrayList<String>())
.build();
ApiFuture<TestIamPermissionsResponse> future =
genAiCacheServiceClient.testIamPermissionsCallable().futureCall(request);
// Do something.
TestIamPermissionsResponse response = future.get();
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2025 Google LLC. All rights reserved.