@BetaApi @Generated(value="by gapic-generator-java") public class EnvironmentsClient extends Object implements 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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
GetEnvironmentRequest request =
GetEnvironmentRequest.newBuilder()
.setName(
EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString())
.build();
Environment response = environmentsClient.getEnvironment(request);
}
Note: close() needs to be called on the EnvironmentsClient 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 EnvironmentsSettings 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
EnvironmentsSettings environmentsSettings =
EnvironmentsSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings);
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
EnvironmentsSettings environmentsSettings =
EnvironmentsSettings.newBuilder().setEndpoint(myEndpoint).build();
EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings);
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
EnvironmentsSettings environmentsSettings =
EnvironmentsSettings.newBuilder()
.setTransportChannelProvider(
EnvironmentsSettings.defaultHttpJsonTransportProviderBuilder().build())
.build();
EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Modifier and Type | Class and Description |
---|---|
static class |
EnvironmentsClient.GetEnvironmentHistoryFixedSizeCollection |
static class |
EnvironmentsClient.GetEnvironmentHistoryPage |
static class |
EnvironmentsClient.GetEnvironmentHistoryPagedResponse |
static class |
EnvironmentsClient.ListEnvironmentsFixedSizeCollection |
static class |
EnvironmentsClient.ListEnvironmentsPage |
static class |
EnvironmentsClient.ListEnvironmentsPagedResponse |
static class |
EnvironmentsClient.ListLocationsFixedSizeCollection |
static class |
EnvironmentsClient.ListLocationsPage |
static class |
EnvironmentsClient.ListLocationsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
EnvironmentsClient(EnvironmentsSettings settings)
Constructs an instance of EnvironmentsClient, using the given settings.
|
protected |
EnvironmentsClient(EnvironmentsStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static EnvironmentsClient |
create()
Constructs an instance of EnvironmentsClient with default settings.
|
static EnvironmentsClient |
create(EnvironmentsSettings settings)
Constructs an instance of EnvironmentsClient, using the given settings.
|
static EnvironmentsClient |
create(EnvironmentsStub stub)
Constructs an instance of EnvironmentsClient, using the given stub for making calls.
|
Environment |
createEnvironment(CreateEnvironmentRequest request)
Creates an agent environment.
|
UnaryCallable<CreateEnvironmentRequest,Environment> |
createEnvironmentCallable()
Creates an agent environment.
|
void |
deleteEnvironment(DeleteEnvironmentRequest request)
Deletes the specified agent environment.
|
UnaryCallable<DeleteEnvironmentRequest,Empty> |
deleteEnvironmentCallable()
Deletes the specified agent environment.
|
Environment |
getEnvironment(GetEnvironmentRequest request)
Retrieves the specified agent environment.
|
UnaryCallable<GetEnvironmentRequest,Environment> |
getEnvironmentCallable()
Retrieves the specified agent environment.
|
EnvironmentsClient.GetEnvironmentHistoryPagedResponse |
getEnvironmentHistory(GetEnvironmentHistoryRequest request)
Gets the history of the specified environment.
|
UnaryCallable<GetEnvironmentHistoryRequest,EnvironmentHistory> |
getEnvironmentHistoryCallable()
Gets the history of the specified environment.
|
UnaryCallable<GetEnvironmentHistoryRequest,EnvironmentsClient.GetEnvironmentHistoryPagedResponse> |
getEnvironmentHistoryPagedCallable()
Gets the history of the specified environment.
|
com.google.cloud.location.Location |
getLocation(com.google.cloud.location.GetLocationRequest request)
Gets information about a location.
|
UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location> |
getLocationCallable()
Gets information about a location.
|
EnvironmentsSettings |
getSettings() |
EnvironmentsStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
EnvironmentsClient.ListEnvironmentsPagedResponse |
listEnvironments(AgentName parent)
Returns the list of all non-draft environments of the specified agent.
|
EnvironmentsClient.ListEnvironmentsPagedResponse |
listEnvironments(ListEnvironmentsRequest request)
Returns the list of all non-draft environments of the specified agent.
|
EnvironmentsClient.ListEnvironmentsPagedResponse |
listEnvironments(String parent)
Returns the list of all non-draft environments of the specified agent.
|
UnaryCallable<ListEnvironmentsRequest,ListEnvironmentsResponse> |
listEnvironmentsCallable()
Returns the list of all non-draft environments of the specified agent.
|
UnaryCallable<ListEnvironmentsRequest,EnvironmentsClient.ListEnvironmentsPagedResponse> |
listEnvironmentsPagedCallable()
Returns the list of all non-draft environments of the specified agent.
|
EnvironmentsClient.ListLocationsPagedResponse |
listLocations(com.google.cloud.location.ListLocationsRequest request)
Lists information about the supported locations for this service.
|
UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse> |
listLocationsCallable()
Lists information about the supported locations for this service.
|
UnaryCallable<com.google.cloud.location.ListLocationsRequest,EnvironmentsClient.ListLocationsPagedResponse> |
listLocationsPagedCallable()
Lists information about the supported locations for this service.
|
void |
shutdown() |
void |
shutdownNow() |
Environment |
updateEnvironment(UpdateEnvironmentRequest request)
Updates the specified agent environment.
|
UnaryCallable<UpdateEnvironmentRequest,Environment> |
updateEnvironmentCallable()
Updates the specified agent environment.
|
protected EnvironmentsClient(EnvironmentsSettings settings) throws IOException
IOException
protected EnvironmentsClient(EnvironmentsStub stub)
public static final EnvironmentsClient create() throws IOException
IOException
public static final EnvironmentsClient create(EnvironmentsSettings settings) throws IOException
IOException
public static final EnvironmentsClient create(EnvironmentsStub stub)
public final EnvironmentsSettings getSettings()
public EnvironmentsStub getStub()
public final EnvironmentsClient.ListEnvironmentsPagedResponse listEnvironments(AgentName 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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
AgentName parent = AgentName.ofProjectName("[PROJECT]");
for (Environment element : environmentsClient.listEnvironments(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The agent to list all environments from. Format: -
`projects/<Project Number / ID>/agent` - `projects/<Project Number /
ID>/locations/<Location ID>/agent`ApiException
- if the remote call failspublic final EnvironmentsClient.ListEnvironmentsPagedResponse listEnvironments(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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
String parent = AgentName.ofProjectName("[PROJECT]").toString();
for (Environment element : environmentsClient.listEnvironments(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The agent to list all environments from. Format: -
`projects/<Project Number / ID>/agent` - `projects/<Project Number /
ID>/locations/<Location ID>/agent`ApiException
- if the remote call failspublic final EnvironmentsClient.ListEnvironmentsPagedResponse listEnvironments(ListEnvironmentsRequest 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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
ListEnvironmentsRequest request =
ListEnvironmentsRequest.newBuilder()
.setParent(AgentName.ofProjectName("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Environment element : environmentsClient.listEnvironments(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<ListEnvironmentsRequest,EnvironmentsClient.ListEnvironmentsPagedResponse> listEnvironmentsPagedCallable()
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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
ListEnvironmentsRequest request =
ListEnvironmentsRequest.newBuilder()
.setParent(AgentName.ofProjectName("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Environment> future =
environmentsClient.listEnvironmentsPagedCallable().futureCall(request);
// Do something.
for (Environment element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<ListEnvironmentsRequest,ListEnvironmentsResponse> listEnvironmentsCallable()
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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
ListEnvironmentsRequest request =
ListEnvironmentsRequest.newBuilder()
.setParent(AgentName.ofProjectName("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListEnvironmentsResponse response =
environmentsClient.listEnvironmentsCallable().call(request);
for (Environment element : response.getEnvironmentsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final Environment getEnvironment(GetEnvironmentRequest 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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
GetEnvironmentRequest request =
GetEnvironmentRequest.newBuilder()
.setName(
EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString())
.build();
Environment response = environmentsClient.getEnvironment(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<GetEnvironmentRequest,Environment> getEnvironmentCallable()
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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
GetEnvironmentRequest request =
GetEnvironmentRequest.newBuilder()
.setName(
EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString())
.build();
ApiFuture<Environment> future =
environmentsClient.getEnvironmentCallable().futureCall(request);
// Do something.
Environment response = future.get();
}
public final Environment createEnvironment(CreateEnvironmentRequest 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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
CreateEnvironmentRequest request =
CreateEnvironmentRequest.newBuilder()
.setParent(AgentName.ofProjectName("[PROJECT]").toString())
.setEnvironment(Environment.newBuilder().build())
.setEnvironmentId("environmentId-950205810")
.build();
Environment response = environmentsClient.createEnvironment(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<CreateEnvironmentRequest,Environment> createEnvironmentCallable()
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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
CreateEnvironmentRequest request =
CreateEnvironmentRequest.newBuilder()
.setParent(AgentName.ofProjectName("[PROJECT]").toString())
.setEnvironment(Environment.newBuilder().build())
.setEnvironmentId("environmentId-950205810")
.build();
ApiFuture<Environment> future =
environmentsClient.createEnvironmentCallable().futureCall(request);
// Do something.
Environment response = future.get();
}
public final Environment updateEnvironment(UpdateEnvironmentRequest request)
This method allows you to deploy new agent versions into the environment. When an environment is pointed to a new agent version by setting `environment.agent_version`, the environment is temporarily set to the `LOADING` state. During that time, the environment keeps on serving the previous version of the agent. After the new agent version is done loading, the environment is set back to the `RUNNING` state. You can use "-" as Environment ID in environment name to update version in "draft" environment. WARNING: this will negate all recent changes to draft and can't be undone. You may want to save the draft to a version before calling this function.
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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
UpdateEnvironmentRequest request =
UpdateEnvironmentRequest.newBuilder()
.setEnvironment(Environment.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.setAllowLoadToDraftAndDiscardChanges(true)
.build();
Environment response = environmentsClient.updateEnvironment(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<UpdateEnvironmentRequest,Environment> updateEnvironmentCallable()
This method allows you to deploy new agent versions into the environment. When an environment is pointed to a new agent version by setting `environment.agent_version`, the environment is temporarily set to the `LOADING` state. During that time, the environment keeps on serving the previous version of the agent. After the new agent version is done loading, the environment is set back to the `RUNNING` state. You can use "-" as Environment ID in environment name to update version in "draft" environment. WARNING: this will negate all recent changes to draft and can't be undone. You may want to save the draft to a version before calling this function.
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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
UpdateEnvironmentRequest request =
UpdateEnvironmentRequest.newBuilder()
.setEnvironment(Environment.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.setAllowLoadToDraftAndDiscardChanges(true)
.build();
ApiFuture<Environment> future =
environmentsClient.updateEnvironmentCallable().futureCall(request);
// Do something.
Environment response = future.get();
}
public final void deleteEnvironment(DeleteEnvironmentRequest 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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
DeleteEnvironmentRequest request =
DeleteEnvironmentRequest.newBuilder()
.setName(
EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString())
.build();
environmentsClient.deleteEnvironment(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<DeleteEnvironmentRequest,Empty> deleteEnvironmentCallable()
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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
DeleteEnvironmentRequest request =
DeleteEnvironmentRequest.newBuilder()
.setName(
EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString())
.build();
ApiFuture<Empty> future = environmentsClient.deleteEnvironmentCallable().futureCall(request);
// Do something.
future.get();
}
public final EnvironmentsClient.GetEnvironmentHistoryPagedResponse getEnvironmentHistory(GetEnvironmentHistoryRequest 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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
GetEnvironmentHistoryRequest request =
GetEnvironmentHistoryRequest.newBuilder()
.setParent(
EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (EnvironmentHistory.Entry element :
environmentsClient.getEnvironmentHistory(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<GetEnvironmentHistoryRequest,EnvironmentsClient.GetEnvironmentHistoryPagedResponse> getEnvironmentHistoryPagedCallable()
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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
GetEnvironmentHistoryRequest request =
GetEnvironmentHistoryRequest.newBuilder()
.setParent(
EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<EnvironmentHistory.Entry> future =
environmentsClient.getEnvironmentHistoryPagedCallable().futureCall(request);
// Do something.
for (EnvironmentHistory.Entry element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<GetEnvironmentHistoryRequest,EnvironmentHistory> getEnvironmentHistoryCallable()
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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
GetEnvironmentHistoryRequest request =
GetEnvironmentHistoryRequest.newBuilder()
.setParent(
EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
EnvironmentHistory response =
environmentsClient.getEnvironmentHistoryCallable().call(request);
for (EnvironmentHistory.Entry element : response.getEntriesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final EnvironmentsClient.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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Location element : environmentsClient.listLocations(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.location.ListLocationsRequest,EnvironmentsClient.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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Location> future =
environmentsClient.listLocationsPagedCallable().futureCall(request);
// Do something.
for (Location element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final 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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListLocationsResponse response = environmentsClient.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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
Location response = environmentsClient.getLocation(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final 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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
ApiFuture<Location> future = environmentsClient.getLocationCallable().futureCall(request);
// Do something.
Location response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2022 Google LLC. All rights reserved.