@BetaApi @Generated(value="by gapic-generator-java") public class ExamplesClient 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 (ExamplesClient examplesClient = ExamplesClient.create()) {
PlaybookName parent = PlaybookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]");
Example example = Example.newBuilder().build();
Example response = examplesClient.createExample(parent, example);
}
Note: close() needs to be called on the ExamplesClient 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 |
|---|---|---|
CreateExample |
Creates an example in the specified playbook. |
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.
|
DeleteExample |
Deletes the specified example. |
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.
|
ListExamples |
Returns a list of examples in the specified playbook. |
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.
|
GetExample |
Retrieves the specified example. |
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.
|
UpdateExample |
Update the specified example. |
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.
|
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 ExamplesSettings 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
ExamplesSettings examplesSettings =
ExamplesSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ExamplesClient examplesClient = ExamplesClient.create(examplesSettings);
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
ExamplesSettings examplesSettings =
ExamplesSettings.newBuilder().setEndpoint(myEndpoint).build();
ExamplesClient examplesClient = ExamplesClient.create(examplesSettings);
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
ExamplesSettings examplesSettings = ExamplesSettings.newHttpJsonBuilder().build();
ExamplesClient examplesClient = ExamplesClient.create(examplesSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
ExamplesClient.ListExamplesFixedSizeCollection |
static class |
ExamplesClient.ListExamplesPage |
static class |
ExamplesClient.ListExamplesPagedResponse |
static class |
ExamplesClient.ListLocationsFixedSizeCollection |
static class |
ExamplesClient.ListLocationsPage |
static class |
ExamplesClient.ListLocationsPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
ExamplesClient(ExamplesSettings settings)
Constructs an instance of ExamplesClient, using the given settings.
|
protected |
ExamplesClient(ExamplesStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static ExamplesClient |
create()
Constructs an instance of ExamplesClient with default settings.
|
static ExamplesClient |
create(ExamplesSettings settings)
Constructs an instance of ExamplesClient, using the given settings.
|
static ExamplesClient |
create(ExamplesStub stub)
Constructs an instance of ExamplesClient, using the given stub for making calls.
|
Example |
createExample(CreateExampleRequest request)
Creates an example in the specified playbook.
|
Example |
createExample(PlaybookName parent,
Example example)
Creates an example in the specified playbook.
|
Example |
createExample(String parent,
Example example)
Creates an example in the specified playbook.
|
com.google.api.gax.rpc.UnaryCallable<CreateExampleRequest,Example> |
createExampleCallable()
Creates an example in the specified playbook.
|
void |
deleteExample(DeleteExampleRequest request)
Deletes the specified example.
|
void |
deleteExample(ExampleName name)
Deletes the specified example.
|
void |
deleteExample(String name)
Deletes the specified example.
|
com.google.api.gax.rpc.UnaryCallable<DeleteExampleRequest,com.google.protobuf.Empty> |
deleteExampleCallable()
Deletes the specified example.
|
Example |
getExample(ExampleName name)
Retrieves the specified example.
|
Example |
getExample(GetExampleRequest request)
Retrieves the specified example.
|
Example |
getExample(String name)
Retrieves the specified example.
|
com.google.api.gax.rpc.UnaryCallable<GetExampleRequest,Example> |
getExampleCallable()
Retrieves the specified example.
|
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.
|
ExamplesSettings |
getSettings() |
ExamplesStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
ExamplesClient.ListExamplesPagedResponse |
listExamples(ListExamplesRequest request)
Returns a list of examples in the specified playbook.
|
ExamplesClient.ListExamplesPagedResponse |
listExamples(PlaybookName parent)
Returns a list of examples in the specified playbook.
|
ExamplesClient.ListExamplesPagedResponse |
listExamples(String parent)
Returns a list of examples in the specified playbook.
|
com.google.api.gax.rpc.UnaryCallable<ListExamplesRequest,ListExamplesResponse> |
listExamplesCallable()
Returns a list of examples in the specified playbook.
|
com.google.api.gax.rpc.UnaryCallable<ListExamplesRequest,ExamplesClient.ListExamplesPagedResponse> |
listExamplesPagedCallable()
Returns a list of examples in the specified playbook.
|
ExamplesClient.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,ExamplesClient.ListLocationsPagedResponse> |
listLocationsPagedCallable()
Lists information about the supported locations for this service.
|
void |
shutdown() |
void |
shutdownNow() |
Example |
updateExample(Example example,
com.google.protobuf.FieldMask updateMask)
Update the specified example.
|
Example |
updateExample(UpdateExampleRequest request)
Update the specified example.
|
com.google.api.gax.rpc.UnaryCallable<UpdateExampleRequest,Example> |
updateExampleCallable()
Update the specified example.
|
protected ExamplesClient(ExamplesSettings settings) throws IOException
IOExceptionprotected ExamplesClient(ExamplesStub stub)
public static final ExamplesClient create() throws IOException
IOExceptionpublic static final ExamplesClient create(ExamplesSettings settings) throws IOException
IOExceptionpublic static final ExamplesClient create(ExamplesStub stub)
public final ExamplesSettings getSettings()
public ExamplesStub getStub()
public final Example createExample(PlaybookName parent, Example example)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ExamplesClient examplesClient = ExamplesClient.create()) {
PlaybookName parent = PlaybookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]");
Example example = Example.newBuilder().build();
Example response = examplesClient.createExample(parent, example);
}
parent - Required. The playbook to create an example for. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/playbooks/<PlaybookID>`.example - Required. The example to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Example createExample(String parent, Example example)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ExamplesClient examplesClient = ExamplesClient.create()) {
String parent =
PlaybookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]").toString();
Example example = Example.newBuilder().build();
Example response = examplesClient.createExample(parent, example);
}
parent - Required. The playbook to create an example for. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/playbooks/<PlaybookID>`.example - Required. The example to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Example createExample(CreateExampleRequest 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 (ExamplesClient examplesClient = ExamplesClient.create()) {
CreateExampleRequest request =
CreateExampleRequest.newBuilder()
.setParent(
PlaybookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]").toString())
.setExample(Example.newBuilder().build())
.build();
Example response = examplesClient.createExample(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<CreateExampleRequest,Example> createExampleCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ExamplesClient examplesClient = ExamplesClient.create()) {
CreateExampleRequest request =
CreateExampleRequest.newBuilder()
.setParent(
PlaybookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]").toString())
.setExample(Example.newBuilder().build())
.build();
ApiFuture<Example> future = examplesClient.createExampleCallable().futureCall(request);
// Do something.
Example response = future.get();
}
public final void deleteExample(ExampleName 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 (ExamplesClient examplesClient = ExamplesClient.create()) {
ExampleName name =
ExampleName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]", "[EXAMPLE]");
examplesClient.deleteExample(name);
}
name - Required. The name of the example to delete. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/playbooks/<PlaybookID>/examples/<ExampleID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteExample(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 (ExamplesClient examplesClient = ExamplesClient.create()) {
String name =
ExampleName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]", "[EXAMPLE]")
.toString();
examplesClient.deleteExample(name);
}
name - Required. The name of the example to delete. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/playbooks/<PlaybookID>/examples/<ExampleID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteExample(DeleteExampleRequest 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 (ExamplesClient examplesClient = ExamplesClient.create()) {
DeleteExampleRequest request =
DeleteExampleRequest.newBuilder()
.setName(
ExampleName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]", "[EXAMPLE]")
.toString())
.build();
examplesClient.deleteExample(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<DeleteExampleRequest,com.google.protobuf.Empty> deleteExampleCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ExamplesClient examplesClient = ExamplesClient.create()) {
DeleteExampleRequest request =
DeleteExampleRequest.newBuilder()
.setName(
ExampleName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]", "[EXAMPLE]")
.toString())
.build();
ApiFuture<Empty> future = examplesClient.deleteExampleCallable().futureCall(request);
// Do something.
future.get();
}
public final ExamplesClient.ListExamplesPagedResponse listExamples(PlaybookName 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 (ExamplesClient examplesClient = ExamplesClient.create()) {
PlaybookName parent = PlaybookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]");
for (Example element : examplesClient.listExamples(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The playbook to list the examples from. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/playbooks/<PlaybookID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final ExamplesClient.ListExamplesPagedResponse listExamples(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 (ExamplesClient examplesClient = ExamplesClient.create()) {
String parent =
PlaybookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]").toString();
for (Example element : examplesClient.listExamples(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The playbook to list the examples from. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/playbooks/<PlaybookID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final ExamplesClient.ListExamplesPagedResponse listExamples(ListExamplesRequest 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 (ExamplesClient examplesClient = ExamplesClient.create()) {
ListExamplesRequest request =
ListExamplesRequest.newBuilder()
.setParent(
PlaybookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setLanguageCode("languageCode-2092349083")
.build();
for (Example element : examplesClient.listExamples(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<ListExamplesRequest,ExamplesClient.ListExamplesPagedResponse> listExamplesPagedCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ExamplesClient examplesClient = ExamplesClient.create()) {
ListExamplesRequest request =
ListExamplesRequest.newBuilder()
.setParent(
PlaybookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setLanguageCode("languageCode-2092349083")
.build();
ApiFuture<Example> future = examplesClient.listExamplesPagedCallable().futureCall(request);
// Do something.
for (Example element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListExamplesRequest,ListExamplesResponse> listExamplesCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ExamplesClient examplesClient = ExamplesClient.create()) {
ListExamplesRequest request =
ListExamplesRequest.newBuilder()
.setParent(
PlaybookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setLanguageCode("languageCode-2092349083")
.build();
while (true) {
ListExamplesResponse response = examplesClient.listExamplesCallable().call(request);
for (Example element : response.getExamplesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final Example getExample(ExampleName 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 (ExamplesClient examplesClient = ExamplesClient.create()) {
ExampleName name =
ExampleName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]", "[EXAMPLE]");
Example response = examplesClient.getExample(name);
}
name - Required. The name of the example. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/playbooks/<PlaybookID>/examples/<ExampleID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Example getExample(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 (ExamplesClient examplesClient = ExamplesClient.create()) {
String name =
ExampleName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]", "[EXAMPLE]")
.toString();
Example response = examplesClient.getExample(name);
}
name - Required. The name of the example. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/playbooks/<PlaybookID>/examples/<ExampleID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Example getExample(GetExampleRequest 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 (ExamplesClient examplesClient = ExamplesClient.create()) {
GetExampleRequest request =
GetExampleRequest.newBuilder()
.setName(
ExampleName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]", "[EXAMPLE]")
.toString())
.build();
Example response = examplesClient.getExample(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<GetExampleRequest,Example> getExampleCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ExamplesClient examplesClient = ExamplesClient.create()) {
GetExampleRequest request =
GetExampleRequest.newBuilder()
.setName(
ExampleName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[PLAYBOOK]", "[EXAMPLE]")
.toString())
.build();
ApiFuture<Example> future = examplesClient.getExampleCallable().futureCall(request);
// Do something.
Example response = future.get();
}
public final Example updateExample(Example example, 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 (ExamplesClient examplesClient = ExamplesClient.create()) {
Example example = Example.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Example response = examplesClient.updateExample(example, updateMask);
}
example - Required. The example to update.updateMask - Optional. The mask to control which fields get updated. If the mask is not
present, all fields will be updated.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Example updateExample(UpdateExampleRequest 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 (ExamplesClient examplesClient = ExamplesClient.create()) {
UpdateExampleRequest request =
UpdateExampleRequest.newBuilder()
.setExample(Example.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Example response = examplesClient.updateExample(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<UpdateExampleRequest,Example> updateExampleCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ExamplesClient examplesClient = ExamplesClient.create()) {
UpdateExampleRequest request =
UpdateExampleRequest.newBuilder()
.setExample(Example.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Example> future = examplesClient.updateExampleCallable().futureCall(request);
// Do something.
Example response = future.get();
}
public final ExamplesClient.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 (ExamplesClient examplesClient = ExamplesClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Location element : examplesClient.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,ExamplesClient.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 (ExamplesClient examplesClient = ExamplesClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Location> future = examplesClient.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 (ExamplesClient examplesClient = ExamplesClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListLocationsResponse response = examplesClient.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 (ExamplesClient examplesClient = ExamplesClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
Location response = examplesClient.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 (ExamplesClient examplesClient = ExamplesClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
ApiFuture<Location> future = examplesClient.getLocationCallable().futureCall(request);
// Do something.
Location 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.