@Generated(value="by gapic-generator-java") public class LlmUtilityServiceClient 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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
EndpointName endpoint =
EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]");
List<Value> instances = new ArrayList<>();
CountTokensResponse response = llmUtilityServiceClient.countTokens(endpoint, instances);
}
Note: close() needs to be called on the LlmUtilityServiceClient 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 LlmUtilityServiceSettings 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
LlmUtilityServiceSettings llmUtilityServiceSettings =
LlmUtilityServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
LlmUtilityServiceClient llmUtilityServiceClient =
LlmUtilityServiceClient.create(llmUtilityServiceSettings);
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
LlmUtilityServiceSettings llmUtilityServiceSettings =
LlmUtilityServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
LlmUtilityServiceClient llmUtilityServiceClient =
LlmUtilityServiceClient.create(llmUtilityServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
LlmUtilityServiceClient.ListLocationsFixedSizeCollection |
static class |
LlmUtilityServiceClient.ListLocationsPage |
static class |
LlmUtilityServiceClient.ListLocationsPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
LlmUtilityServiceClient(LlmUtilityServiceSettings settings)
Constructs an instance of LlmUtilityServiceClient, using the given settings.
|
protected |
LlmUtilityServiceClient(LlmUtilityServiceStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
ComputeTokensResponse |
computeTokens(ComputeTokensRequest request)
Return a list of tokens based on the input text.
|
ComputeTokensResponse |
computeTokens(EndpointName endpoint,
List<com.google.protobuf.Value> instances)
Return a list of tokens based on the input text.
|
ComputeTokensResponse |
computeTokens(String endpoint,
List<com.google.protobuf.Value> instances)
Return a list of tokens based on the input text.
|
com.google.api.gax.rpc.UnaryCallable<ComputeTokensRequest,ComputeTokensResponse> |
computeTokensCallable()
Return a list of tokens based on the input text.
|
CountTokensResponse |
countTokens(CountTokensRequest request)
Perform a token counting.
|
CountTokensResponse |
countTokens(EndpointName endpoint,
List<com.google.protobuf.Value> instances)
Perform a token counting.
|
CountTokensResponse |
countTokens(String endpoint,
List<com.google.protobuf.Value> instances)
Perform a token counting.
|
com.google.api.gax.rpc.UnaryCallable<CountTokensRequest,CountTokensResponse> |
countTokensCallable()
Perform a token counting.
|
static LlmUtilityServiceClient |
create()
Constructs an instance of LlmUtilityServiceClient with default settings.
|
static LlmUtilityServiceClient |
create(LlmUtilityServiceSettings settings)
Constructs an instance of LlmUtilityServiceClient, using the given settings.
|
static LlmUtilityServiceClient |
create(LlmUtilityServiceStub stub)
Constructs an instance of LlmUtilityServiceClient, using the given stub for making calls.
|
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.
|
LlmUtilityServiceSettings |
getSettings() |
LlmUtilityServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
LlmUtilityServiceClient.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,LlmUtilityServiceClient.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.
|
protected LlmUtilityServiceClient(LlmUtilityServiceSettings settings) throws IOException
IOExceptionprotected LlmUtilityServiceClient(LlmUtilityServiceStub stub)
public static final LlmUtilityServiceClient create() throws IOException
IOExceptionpublic static final LlmUtilityServiceClient create(LlmUtilityServiceSettings settings) throws IOException
IOExceptionpublic static final LlmUtilityServiceClient create(LlmUtilityServiceStub stub)
public final LlmUtilityServiceSettings getSettings()
public LlmUtilityServiceStub getStub()
public final CountTokensResponse countTokens(EndpointName endpoint, List<com.google.protobuf.Value> instances)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
EndpointName endpoint =
EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]");
List<Value> instances = new ArrayList<>();
CountTokensResponse response = llmUtilityServiceClient.countTokens(endpoint, instances);
}
endpoint - Required. The name of the Endpoint requested to perform token counting. Format:
`projects/{project}/locations/{location}/endpoints/{endpoint}`instances - Required. The instances that are the input to token counting call. Schema is
identical to the prediction schema of the underlying model.com.google.api.gax.rpc.ApiException - if the remote call failspublic final CountTokensResponse countTokens(String endpoint, List<com.google.protobuf.Value> instances)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
String endpoint =
EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString();
List<Value> instances = new ArrayList<>();
CountTokensResponse response = llmUtilityServiceClient.countTokens(endpoint, instances);
}
endpoint - Required. The name of the Endpoint requested to perform token counting. Format:
`projects/{project}/locations/{location}/endpoints/{endpoint}`instances - Required. The instances that are the input to token counting call. Schema is
identical to the prediction schema of the underlying model.com.google.api.gax.rpc.ApiException - if the remote call failspublic final CountTokensResponse countTokens(CountTokensRequest 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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
CountTokensRequest request =
CountTokensRequest.newBuilder()
.setEndpoint(
EndpointName.ofProjectLocationEndpointName(
"[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString())
.setModel("model104069929")
.addAllInstances(new ArrayList<Value>())
.addAllContents(new ArrayList<Content>())
.build();
CountTokensResponse response = llmUtilityServiceClient.countTokens(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<CountTokensRequest,CountTokensResponse> countTokensCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
CountTokensRequest request =
CountTokensRequest.newBuilder()
.setEndpoint(
EndpointName.ofProjectLocationEndpointName(
"[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString())
.setModel("model104069929")
.addAllInstances(new ArrayList<Value>())
.addAllContents(new ArrayList<Content>())
.build();
ApiFuture<CountTokensResponse> future =
llmUtilityServiceClient.countTokensCallable().futureCall(request);
// Do something.
CountTokensResponse response = future.get();
}
public final ComputeTokensResponse computeTokens(EndpointName endpoint, List<com.google.protobuf.Value> instances)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
EndpointName endpoint =
EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]");
List<Value> instances = new ArrayList<>();
ComputeTokensResponse response = llmUtilityServiceClient.computeTokens(endpoint, instances);
}
endpoint - Required. The name of the Endpoint requested to get lists of tokens and token
ids.instances - Required. The instances that are the input to token computing API call. Schema
is identical to the prediction schema of the text model, even for the non-text models, like
chat models, or Codey models.com.google.api.gax.rpc.ApiException - if the remote call failspublic final ComputeTokensResponse computeTokens(String endpoint, List<com.google.protobuf.Value> instances)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
String endpoint =
EndpointName.ofProjectLocationEndpointName("[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString();
List<Value> instances = new ArrayList<>();
ComputeTokensResponse response = llmUtilityServiceClient.computeTokens(endpoint, instances);
}
endpoint - Required. The name of the Endpoint requested to get lists of tokens and token
ids.instances - Required. The instances that are the input to token computing API call. Schema
is identical to the prediction schema of the text model, even for the non-text models, like
chat models, or Codey models.com.google.api.gax.rpc.ApiException - if the remote call failspublic final ComputeTokensResponse computeTokens(ComputeTokensRequest 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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
ComputeTokensRequest request =
ComputeTokensRequest.newBuilder()
.setEndpoint(
EndpointName.ofProjectLocationEndpointName(
"[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString())
.addAllInstances(new ArrayList<Value>())
.build();
ComputeTokensResponse response = llmUtilityServiceClient.computeTokens(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<ComputeTokensRequest,ComputeTokensResponse> computeTokensCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
ComputeTokensRequest request =
ComputeTokensRequest.newBuilder()
.setEndpoint(
EndpointName.ofProjectLocationEndpointName(
"[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString())
.addAllInstances(new ArrayList<Value>())
.build();
ApiFuture<ComputeTokensResponse> future =
llmUtilityServiceClient.computeTokensCallable().futureCall(request);
// Do something.
ComputeTokensResponse response = future.get();
}
public final LlmUtilityServiceClient.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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Location element : llmUtilityServiceClient.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,LlmUtilityServiceClient.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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Location> future =
llmUtilityServiceClient.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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListLocationsResponse response =
llmUtilityServiceClient.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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
Location response = llmUtilityServiceClient.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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
ApiFuture<Location> future =
llmUtilityServiceClient.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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(
EndpointName.ofProjectLocationEndpointName(
"[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Policy response = llmUtilityServiceClient.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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(
EndpointName.ofProjectLocationEndpointName(
"[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Policy> future = llmUtilityServiceClient.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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(
EndpointName.ofProjectLocationEndpointName(
"[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
Policy response = llmUtilityServiceClient.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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(
EndpointName.ofProjectLocationEndpointName(
"[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
ApiFuture<Policy> future = llmUtilityServiceClient.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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(
EndpointName.ofProjectLocationEndpointName(
"[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString())
.addAllPermissions(new ArrayList<String>())
.build();
TestIamPermissionsResponse response = llmUtilityServiceClient.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 (LlmUtilityServiceClient llmUtilityServiceClient = LlmUtilityServiceClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(
EndpointName.ofProjectLocationEndpointName(
"[PROJECT]", "[LOCATION]", "[ENDPOINT]")
.toString())
.addAllPermissions(new ArrayList<String>())
.build();
ApiFuture<TestIamPermissionsResponse> future =
llmUtilityServiceClient.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 © 2023 Google LLC. All rights reserved.