@Generated(value="by gapic-generator") @BetaApi public class TargetPoolClient 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:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionTargetPoolName targetPool = ProjectRegionTargetPoolName.of("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPoolsAddHealthCheckRequest targetPoolsAddHealthCheckRequestResource = TargetPoolsAddHealthCheckRequest.newBuilder().build();
Operation response = targetPoolClient.addHealthCheckTargetPool(targetPool, targetPoolsAddHealthCheckRequestResource);
}
Note: close() needs to be called on the targetPoolClient 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 TargetPoolSettings to create(). For example:
To customize credentials:
TargetPoolSettings targetPoolSettings =
TargetPoolSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
TargetPoolClient targetPoolClient =
TargetPoolClient.create(targetPoolSettings);
To customize the endpoint:
TargetPoolSettings targetPoolSettings =
TargetPoolSettings.newBuilder().setEndpoint(myEndpoint).build();
TargetPoolClient targetPoolClient =
TargetPoolClient.create(targetPoolSettings);
Modifier and Type | Class and Description |
---|---|
static class |
TargetPoolClient.AggregatedListTargetPoolsFixedSizeCollection |
static class |
TargetPoolClient.AggregatedListTargetPoolsPage |
static class |
TargetPoolClient.AggregatedListTargetPoolsPagedResponse |
static class |
TargetPoolClient.ListTargetPoolsFixedSizeCollection |
static class |
TargetPoolClient.ListTargetPoolsPage |
static class |
TargetPoolClient.ListTargetPoolsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
TargetPoolClient(TargetPoolSettings settings)
Constructs an instance of TargetPoolClient, using the given settings.
|
protected |
TargetPoolClient(TargetPoolStub stub) |
Modifier and Type | Method and Description |
---|---|
Operation |
addHealthCheckTargetPool(AddHealthCheckTargetPoolHttpRequest request)
Adds health check URLs to a target pool.
|
Operation |
addHealthCheckTargetPool(ProjectRegionTargetPoolName targetPool,
TargetPoolsAddHealthCheckRequest targetPoolsAddHealthCheckRequestResource)
Adds health check URLs to a target pool.
|
Operation |
addHealthCheckTargetPool(String targetPool,
TargetPoolsAddHealthCheckRequest targetPoolsAddHealthCheckRequestResource)
Adds health check URLs to a target pool.
|
UnaryCallable<AddHealthCheckTargetPoolHttpRequest,Operation> |
addHealthCheckTargetPoolCallable()
Adds health check URLs to a target pool.
|
Operation |
addInstanceTargetPool(AddInstanceTargetPoolHttpRequest request)
Adds an instance to a target pool.
|
Operation |
addInstanceTargetPool(ProjectRegionTargetPoolName targetPool,
TargetPoolsAddInstanceRequest targetPoolsAddInstanceRequestResource)
Adds an instance to a target pool.
|
Operation |
addInstanceTargetPool(String targetPool,
TargetPoolsAddInstanceRequest targetPoolsAddInstanceRequestResource)
Adds an instance to a target pool.
|
UnaryCallable<AddInstanceTargetPoolHttpRequest,Operation> |
addInstanceTargetPoolCallable()
Adds an instance to a target pool.
|
TargetPoolClient.AggregatedListTargetPoolsPagedResponse |
aggregatedListTargetPools(AggregatedListTargetPoolsHttpRequest request)
Retrieves an aggregated list of target pools.
|
TargetPoolClient.AggregatedListTargetPoolsPagedResponse |
aggregatedListTargetPools(ProjectName project)
Retrieves an aggregated list of target pools.
|
TargetPoolClient.AggregatedListTargetPoolsPagedResponse |
aggregatedListTargetPools(String project)
Retrieves an aggregated list of target pools.
|
UnaryCallable<AggregatedListTargetPoolsHttpRequest,TargetPoolAggregatedList> |
aggregatedListTargetPoolsCallable()
Retrieves an aggregated list of target pools.
|
UnaryCallable<AggregatedListTargetPoolsHttpRequest,TargetPoolClient.AggregatedListTargetPoolsPagedResponse> |
aggregatedListTargetPoolsPagedCallable()
Retrieves an aggregated list of target pools.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static TargetPoolClient |
create()
Constructs an instance of TargetPoolClient with default settings.
|
static TargetPoolClient |
create(TargetPoolSettings settings)
Constructs an instance of TargetPoolClient, using the given settings.
|
static TargetPoolClient |
create(TargetPoolStub stub)
Constructs an instance of TargetPoolClient, using the given stub for making calls.
|
Operation |
deleteTargetPool(DeleteTargetPoolHttpRequest request)
Deletes the specified target pool.
|
Operation |
deleteTargetPool(ProjectRegionTargetPoolName targetPool)
Deletes the specified target pool.
|
Operation |
deleteTargetPool(String targetPool)
Deletes the specified target pool.
|
UnaryCallable<DeleteTargetPoolHttpRequest,Operation> |
deleteTargetPoolCallable()
Deletes the specified target pool.
|
TargetPoolInstanceHealth |
getHealthTargetPool(GetHealthTargetPoolHttpRequest request)
Gets the most recent health check results for each IP for the instance that is referenced by
the given target pool.
|
TargetPoolInstanceHealth |
getHealthTargetPool(ProjectRegionTargetPoolName targetPool,
InstanceReference instanceReferenceResource)
Gets the most recent health check results for each IP for the instance that is referenced by
the given target pool.
|
TargetPoolInstanceHealth |
getHealthTargetPool(String targetPool,
InstanceReference instanceReferenceResource)
Gets the most recent health check results for each IP for the instance that is referenced by
the given target pool.
|
UnaryCallable<GetHealthTargetPoolHttpRequest,TargetPoolInstanceHealth> |
getHealthTargetPoolCallable()
Gets the most recent health check results for each IP for the instance that is referenced by
the given target pool.
|
TargetPoolSettings |
getSettings() |
TargetPoolStub |
getStub() |
TargetPool |
getTargetPool(GetTargetPoolHttpRequest request)
Returns the specified target pool.
|
TargetPool |
getTargetPool(ProjectRegionTargetPoolName targetPool)
Returns the specified target pool.
|
TargetPool |
getTargetPool(String targetPool)
Returns the specified target pool.
|
UnaryCallable<GetTargetPoolHttpRequest,TargetPool> |
getTargetPoolCallable()
Returns the specified target pool.
|
Operation |
insertTargetPool(InsertTargetPoolHttpRequest request)
Creates a target pool in the specified project and region using the data included in the
request.
|
Operation |
insertTargetPool(ProjectRegionName region,
TargetPool targetPoolResource)
Creates a target pool in the specified project and region using the data included in the
request.
|
Operation |
insertTargetPool(String region,
TargetPool targetPoolResource)
Creates a target pool in the specified project and region using the data included in the
request.
|
UnaryCallable<InsertTargetPoolHttpRequest,Operation> |
insertTargetPoolCallable()
Creates a target pool in the specified project and region using the data included in the
request.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
TargetPoolClient.ListTargetPoolsPagedResponse |
listTargetPools(ListTargetPoolsHttpRequest request)
Retrieves a list of target pools available to the specified project and region.
|
TargetPoolClient.ListTargetPoolsPagedResponse |
listTargetPools(ProjectRegionName region)
Retrieves a list of target pools available to the specified project and region.
|
TargetPoolClient.ListTargetPoolsPagedResponse |
listTargetPools(String region)
Retrieves a list of target pools available to the specified project and region.
|
UnaryCallable<ListTargetPoolsHttpRequest,TargetPoolList> |
listTargetPoolsCallable()
Retrieves a list of target pools available to the specified project and region.
|
UnaryCallable<ListTargetPoolsHttpRequest,TargetPoolClient.ListTargetPoolsPagedResponse> |
listTargetPoolsPagedCallable()
Retrieves a list of target pools available to the specified project and region.
|
Operation |
removeHealthCheckTargetPool(ProjectRegionTargetPoolName targetPool,
TargetPoolsRemoveHealthCheckRequest targetPoolsRemoveHealthCheckRequestResource)
Removes health check URL from a target pool.
|
Operation |
removeHealthCheckTargetPool(RemoveHealthCheckTargetPoolHttpRequest request)
Removes health check URL from a target pool.
|
Operation |
removeHealthCheckTargetPool(String targetPool,
TargetPoolsRemoveHealthCheckRequest targetPoolsRemoveHealthCheckRequestResource)
Removes health check URL from a target pool.
|
UnaryCallable<RemoveHealthCheckTargetPoolHttpRequest,Operation> |
removeHealthCheckTargetPoolCallable()
Removes health check URL from a target pool.
|
Operation |
removeInstanceTargetPool(ProjectRegionTargetPoolName targetPool,
TargetPoolsRemoveInstanceRequest targetPoolsRemoveInstanceRequestResource)
Removes instance URL from a target pool.
|
Operation |
removeInstanceTargetPool(RemoveInstanceTargetPoolHttpRequest request)
Removes instance URL from a target pool.
|
Operation |
removeInstanceTargetPool(String targetPool,
TargetPoolsRemoveInstanceRequest targetPoolsRemoveInstanceRequestResource)
Removes instance URL from a target pool.
|
UnaryCallable<RemoveInstanceTargetPoolHttpRequest,Operation> |
removeInstanceTargetPoolCallable()
Removes instance URL from a target pool.
|
Operation |
setBackupTargetPool(ProjectRegionTargetPoolName targetPool,
Float failoverRatio,
TargetReference targetReferenceResource)
Changes a backup target pool's configurations.
|
Operation |
setBackupTargetPool(SetBackupTargetPoolHttpRequest request)
Changes a backup target pool's configurations.
|
Operation |
setBackupTargetPool(String targetPool,
Float failoverRatio,
TargetReference targetReferenceResource)
Changes a backup target pool's configurations.
|
UnaryCallable<SetBackupTargetPoolHttpRequest,Operation> |
setBackupTargetPoolCallable()
Changes a backup target pool's configurations.
|
void |
shutdown() |
void |
shutdownNow() |
protected TargetPoolClient(TargetPoolSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected TargetPoolClient(TargetPoolStub stub)
public static final TargetPoolClient create() throws IOException
IOException
public static final TargetPoolClient create(TargetPoolSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final TargetPoolClient create(TargetPoolStub stub)
public final TargetPoolSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public TargetPoolStub getStub()
@BetaApi public final Operation addHealthCheckTargetPool(ProjectRegionTargetPoolName targetPool, TargetPoolsAddHealthCheckRequest targetPoolsAddHealthCheckRequestResource)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionTargetPoolName targetPool = ProjectRegionTargetPoolName.of("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPoolsAddHealthCheckRequest targetPoolsAddHealthCheckRequestResource = TargetPoolsAddHealthCheckRequest.newBuilder().build();
Operation response = targetPoolClient.addHealthCheckTargetPool(targetPool, targetPoolsAddHealthCheckRequestResource);
}
targetPool
- Name of the target pool to add a health check to.targetPoolsAddHealthCheckRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation addHealthCheckTargetPool(String targetPool, TargetPoolsAddHealthCheckRequest targetPoolsAddHealthCheckRequestResource)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionTargetPoolName targetPool = ProjectRegionTargetPoolName.of("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPoolsAddHealthCheckRequest targetPoolsAddHealthCheckRequestResource = TargetPoolsAddHealthCheckRequest.newBuilder().build();
Operation response = targetPoolClient.addHealthCheckTargetPool(targetPool.toString(), targetPoolsAddHealthCheckRequestResource);
}
targetPool
- Name of the target pool to add a health check to.targetPoolsAddHealthCheckRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation addHealthCheckTargetPool(AddHealthCheckTargetPoolHttpRequest request)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedTargetPool = ProjectRegionTargetPoolName.format("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPoolsAddHealthCheckRequest targetPoolsAddHealthCheckRequestResource = TargetPoolsAddHealthCheckRequest.newBuilder().build();
AddHealthCheckTargetPoolHttpRequest request = AddHealthCheckTargetPoolHttpRequest.newBuilder()
.setTargetPool(formattedTargetPool)
.setTargetPoolsAddHealthCheckRequestResource(targetPoolsAddHealthCheckRequestResource)
.build();
Operation response = targetPoolClient.addHealthCheckTargetPool(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<AddHealthCheckTargetPoolHttpRequest,Operation> addHealthCheckTargetPoolCallable()
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedTargetPool = ProjectRegionTargetPoolName.format("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPoolsAddHealthCheckRequest targetPoolsAddHealthCheckRequestResource = TargetPoolsAddHealthCheckRequest.newBuilder().build();
AddHealthCheckTargetPoolHttpRequest request = AddHealthCheckTargetPoolHttpRequest.newBuilder()
.setTargetPool(formattedTargetPool)
.setTargetPoolsAddHealthCheckRequestResource(targetPoolsAddHealthCheckRequestResource)
.build();
ApiFuture<Operation> future = targetPoolClient.addHealthCheckTargetPoolCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Operation addInstanceTargetPool(ProjectRegionTargetPoolName targetPool, TargetPoolsAddInstanceRequest targetPoolsAddInstanceRequestResource)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionTargetPoolName targetPool = ProjectRegionTargetPoolName.of("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPoolsAddInstanceRequest targetPoolsAddInstanceRequestResource = TargetPoolsAddInstanceRequest.newBuilder().build();
Operation response = targetPoolClient.addInstanceTargetPool(targetPool, targetPoolsAddInstanceRequestResource);
}
targetPool
- Name of the TargetPool resource to add instances to.targetPoolsAddInstanceRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation addInstanceTargetPool(String targetPool, TargetPoolsAddInstanceRequest targetPoolsAddInstanceRequestResource)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionTargetPoolName targetPool = ProjectRegionTargetPoolName.of("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPoolsAddInstanceRequest targetPoolsAddInstanceRequestResource = TargetPoolsAddInstanceRequest.newBuilder().build();
Operation response = targetPoolClient.addInstanceTargetPool(targetPool.toString(), targetPoolsAddInstanceRequestResource);
}
targetPool
- Name of the TargetPool resource to add instances to.targetPoolsAddInstanceRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation addInstanceTargetPool(AddInstanceTargetPoolHttpRequest request)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedTargetPool = ProjectRegionTargetPoolName.format("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPoolsAddInstanceRequest targetPoolsAddInstanceRequestResource = TargetPoolsAddInstanceRequest.newBuilder().build();
AddInstanceTargetPoolHttpRequest request = AddInstanceTargetPoolHttpRequest.newBuilder()
.setTargetPool(formattedTargetPool)
.setTargetPoolsAddInstanceRequestResource(targetPoolsAddInstanceRequestResource)
.build();
Operation response = targetPoolClient.addInstanceTargetPool(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<AddInstanceTargetPoolHttpRequest,Operation> addInstanceTargetPoolCallable()
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedTargetPool = ProjectRegionTargetPoolName.format("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPoolsAddInstanceRequest targetPoolsAddInstanceRequestResource = TargetPoolsAddInstanceRequest.newBuilder().build();
AddInstanceTargetPoolHttpRequest request = AddInstanceTargetPoolHttpRequest.newBuilder()
.setTargetPool(formattedTargetPool)
.setTargetPoolsAddInstanceRequestResource(targetPoolsAddInstanceRequestResource)
.build();
ApiFuture<Operation> future = targetPoolClient.addInstanceTargetPoolCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final TargetPoolClient.AggregatedListTargetPoolsPagedResponse aggregatedListTargetPools(ProjectName project)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (TargetPoolsScopedList element : targetPoolClient.aggregatedListTargetPools(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final TargetPoolClient.AggregatedListTargetPoolsPagedResponse aggregatedListTargetPools(String project)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (TargetPoolsScopedList element : targetPoolClient.aggregatedListTargetPools(project.toString()).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final TargetPoolClient.AggregatedListTargetPoolsPagedResponse aggregatedListTargetPools(AggregatedListTargetPoolsHttpRequest request)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListTargetPoolsHttpRequest request = AggregatedListTargetPoolsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (TargetPoolsScopedList element : targetPoolClient.aggregatedListTargetPools(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<AggregatedListTargetPoolsHttpRequest,TargetPoolClient.AggregatedListTargetPoolsPagedResponse> aggregatedListTargetPoolsPagedCallable()
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListTargetPoolsHttpRequest request = AggregatedListTargetPoolsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<AggregatedListTargetPoolsPagedResponse> future = targetPoolClient.aggregatedListTargetPoolsPagedCallable().futureCall(request);
// Do something
for (TargetPoolsScopedList element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<AggregatedListTargetPoolsHttpRequest,TargetPoolAggregatedList> aggregatedListTargetPoolsCallable()
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListTargetPoolsHttpRequest request = AggregatedListTargetPoolsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
TargetPoolAggregatedList response = targetPoolClient.aggregatedListTargetPoolsCallable().call(request);
for (TargetPoolsScopedList element : response.getItemsMap()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
@BetaApi public final Operation deleteTargetPool(ProjectRegionTargetPoolName targetPool)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionTargetPoolName targetPool = ProjectRegionTargetPoolName.of("[PROJECT]", "[REGION]", "[TARGET_POOL]");
Operation response = targetPoolClient.deleteTargetPool(targetPool);
}
targetPool
- Name of the TargetPool resource to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteTargetPool(String targetPool)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionTargetPoolName targetPool = ProjectRegionTargetPoolName.of("[PROJECT]", "[REGION]", "[TARGET_POOL]");
Operation response = targetPoolClient.deleteTargetPool(targetPool.toString());
}
targetPool
- Name of the TargetPool resource to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteTargetPool(DeleteTargetPoolHttpRequest request)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedTargetPool = ProjectRegionTargetPoolName.format("[PROJECT]", "[REGION]", "[TARGET_POOL]");
DeleteTargetPoolHttpRequest request = DeleteTargetPoolHttpRequest.newBuilder()
.setTargetPool(formattedTargetPool)
.build();
Operation response = targetPoolClient.deleteTargetPool(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<DeleteTargetPoolHttpRequest,Operation> deleteTargetPoolCallable()
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedTargetPool = ProjectRegionTargetPoolName.format("[PROJECT]", "[REGION]", "[TARGET_POOL]");
DeleteTargetPoolHttpRequest request = DeleteTargetPoolHttpRequest.newBuilder()
.setTargetPool(formattedTargetPool)
.build();
ApiFuture<Operation> future = targetPoolClient.deleteTargetPoolCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final TargetPool getTargetPool(ProjectRegionTargetPoolName targetPool)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionTargetPoolName targetPool = ProjectRegionTargetPoolName.of("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPool response = targetPoolClient.getTargetPool(targetPool);
}
targetPool
- Name of the TargetPool resource to return.ApiException
- if the remote call fails@BetaApi public final TargetPool getTargetPool(String targetPool)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionTargetPoolName targetPool = ProjectRegionTargetPoolName.of("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPool response = targetPoolClient.getTargetPool(targetPool.toString());
}
targetPool
- Name of the TargetPool resource to return.ApiException
- if the remote call fails@BetaApi public final TargetPool getTargetPool(GetTargetPoolHttpRequest request)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedTargetPool = ProjectRegionTargetPoolName.format("[PROJECT]", "[REGION]", "[TARGET_POOL]");
GetTargetPoolHttpRequest request = GetTargetPoolHttpRequest.newBuilder()
.setTargetPool(formattedTargetPool)
.build();
TargetPool response = targetPoolClient.getTargetPool(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<GetTargetPoolHttpRequest,TargetPool> getTargetPoolCallable()
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedTargetPool = ProjectRegionTargetPoolName.format("[PROJECT]", "[REGION]", "[TARGET_POOL]");
GetTargetPoolHttpRequest request = GetTargetPoolHttpRequest.newBuilder()
.setTargetPool(formattedTargetPool)
.build();
ApiFuture<TargetPool> future = targetPoolClient.getTargetPoolCallable().futureCall(request);
// Do something
TargetPool response = future.get();
}
@BetaApi public final TargetPoolInstanceHealth getHealthTargetPool(ProjectRegionTargetPoolName targetPool, InstanceReference instanceReferenceResource)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionTargetPoolName targetPool = ProjectRegionTargetPoolName.of("[PROJECT]", "[REGION]", "[TARGET_POOL]");
InstanceReference instanceReferenceResource = InstanceReference.newBuilder().build();
TargetPoolInstanceHealth response = targetPoolClient.getHealthTargetPool(targetPool, instanceReferenceResource);
}
targetPool
- Name of the TargetPool resource to which the queried instance belongs.instanceReferenceResource
- ApiException
- if the remote call fails@BetaApi public final TargetPoolInstanceHealth getHealthTargetPool(String targetPool, InstanceReference instanceReferenceResource)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionTargetPoolName targetPool = ProjectRegionTargetPoolName.of("[PROJECT]", "[REGION]", "[TARGET_POOL]");
InstanceReference instanceReferenceResource = InstanceReference.newBuilder().build();
TargetPoolInstanceHealth response = targetPoolClient.getHealthTargetPool(targetPool.toString(), instanceReferenceResource);
}
targetPool
- Name of the TargetPool resource to which the queried instance belongs.instanceReferenceResource
- ApiException
- if the remote call fails@BetaApi public final TargetPoolInstanceHealth getHealthTargetPool(GetHealthTargetPoolHttpRequest request)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedTargetPool = ProjectRegionTargetPoolName.format("[PROJECT]", "[REGION]", "[TARGET_POOL]");
InstanceReference instanceReferenceResource = InstanceReference.newBuilder().build();
GetHealthTargetPoolHttpRequest request = GetHealthTargetPoolHttpRequest.newBuilder()
.setTargetPool(formattedTargetPool)
.setInstanceReferenceResource(instanceReferenceResource)
.build();
TargetPoolInstanceHealth response = targetPoolClient.getHealthTargetPool(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<GetHealthTargetPoolHttpRequest,TargetPoolInstanceHealth> getHealthTargetPoolCallable()
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedTargetPool = ProjectRegionTargetPoolName.format("[PROJECT]", "[REGION]", "[TARGET_POOL]");
InstanceReference instanceReferenceResource = InstanceReference.newBuilder().build();
GetHealthTargetPoolHttpRequest request = GetHealthTargetPoolHttpRequest.newBuilder()
.setTargetPool(formattedTargetPool)
.setInstanceReferenceResource(instanceReferenceResource)
.build();
ApiFuture<TargetPoolInstanceHealth> future = targetPoolClient.getHealthTargetPoolCallable().futureCall(request);
// Do something
TargetPoolInstanceHealth response = future.get();
}
@BetaApi public final Operation insertTargetPool(ProjectRegionName region, TargetPool targetPoolResource)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
TargetPool targetPoolResource = TargetPool.newBuilder().build();
Operation response = targetPoolClient.insertTargetPool(region, targetPoolResource);
}
region
- Name of the region scoping this request.targetPoolResource
- A TargetPool resource. This resource defines a pool of instances, an
associated HttpHealthCheck resource, and the fallback target pool. (== resource_for
beta.targetPools ==) (== resource_for v1.targetPools ==)ApiException
- if the remote call fails@BetaApi public final Operation insertTargetPool(String region, TargetPool targetPoolResource)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
TargetPool targetPoolResource = TargetPool.newBuilder().build();
Operation response = targetPoolClient.insertTargetPool(region.toString(), targetPoolResource);
}
region
- Name of the region scoping this request.targetPoolResource
- A TargetPool resource. This resource defines a pool of instances, an
associated HttpHealthCheck resource, and the fallback target pool. (== resource_for
beta.targetPools ==) (== resource_for v1.targetPools ==)ApiException
- if the remote call fails@BetaApi public final Operation insertTargetPool(InsertTargetPoolHttpRequest request)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
TargetPool targetPoolResource = TargetPool.newBuilder().build();
InsertTargetPoolHttpRequest request = InsertTargetPoolHttpRequest.newBuilder()
.setRegion(formattedRegion)
.setTargetPoolResource(targetPoolResource)
.build();
Operation response = targetPoolClient.insertTargetPool(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<InsertTargetPoolHttpRequest,Operation> insertTargetPoolCallable()
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
TargetPool targetPoolResource = TargetPool.newBuilder().build();
InsertTargetPoolHttpRequest request = InsertTargetPoolHttpRequest.newBuilder()
.setRegion(formattedRegion)
.setTargetPoolResource(targetPoolResource)
.build();
ApiFuture<Operation> future = targetPoolClient.insertTargetPoolCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final TargetPoolClient.ListTargetPoolsPagedResponse listTargetPools(ProjectRegionName region)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (TargetPool element : targetPoolClient.listTargetPools(region).iterateAll()) {
// doThingsWith(element);
}
}
region
- Name of the region scoping this request.ApiException
- if the remote call fails@BetaApi public final TargetPoolClient.ListTargetPoolsPagedResponse listTargetPools(String region)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (TargetPool element : targetPoolClient.listTargetPools(region.toString()).iterateAll()) {
// doThingsWith(element);
}
}
region
- Name of the region scoping this request.ApiException
- if the remote call fails@BetaApi public final TargetPoolClient.ListTargetPoolsPagedResponse listTargetPools(ListTargetPoolsHttpRequest request)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListTargetPoolsHttpRequest request = ListTargetPoolsHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
for (TargetPool element : targetPoolClient.listTargetPools(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<ListTargetPoolsHttpRequest,TargetPoolClient.ListTargetPoolsPagedResponse> listTargetPoolsPagedCallable()
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListTargetPoolsHttpRequest request = ListTargetPoolsHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
ApiFuture<ListTargetPoolsPagedResponse> future = targetPoolClient.listTargetPoolsPagedCallable().futureCall(request);
// Do something
for (TargetPool element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<ListTargetPoolsHttpRequest,TargetPoolList> listTargetPoolsCallable()
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListTargetPoolsHttpRequest request = ListTargetPoolsHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
while (true) {
TargetPoolList response = targetPoolClient.listTargetPoolsCallable().call(request);
for (TargetPool element : response.getItemsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
@BetaApi public final Operation removeHealthCheckTargetPool(ProjectRegionTargetPoolName targetPool, TargetPoolsRemoveHealthCheckRequest targetPoolsRemoveHealthCheckRequestResource)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionTargetPoolName targetPool = ProjectRegionTargetPoolName.of("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPoolsRemoveHealthCheckRequest targetPoolsRemoveHealthCheckRequestResource = TargetPoolsRemoveHealthCheckRequest.newBuilder().build();
Operation response = targetPoolClient.removeHealthCheckTargetPool(targetPool, targetPoolsRemoveHealthCheckRequestResource);
}
targetPool
- Name of the target pool to remove health checks from.targetPoolsRemoveHealthCheckRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation removeHealthCheckTargetPool(String targetPool, TargetPoolsRemoveHealthCheckRequest targetPoolsRemoveHealthCheckRequestResource)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionTargetPoolName targetPool = ProjectRegionTargetPoolName.of("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPoolsRemoveHealthCheckRequest targetPoolsRemoveHealthCheckRequestResource = TargetPoolsRemoveHealthCheckRequest.newBuilder().build();
Operation response = targetPoolClient.removeHealthCheckTargetPool(targetPool.toString(), targetPoolsRemoveHealthCheckRequestResource);
}
targetPool
- Name of the target pool to remove health checks from.targetPoolsRemoveHealthCheckRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation removeHealthCheckTargetPool(RemoveHealthCheckTargetPoolHttpRequest request)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedTargetPool = ProjectRegionTargetPoolName.format("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPoolsRemoveHealthCheckRequest targetPoolsRemoveHealthCheckRequestResource = TargetPoolsRemoveHealthCheckRequest.newBuilder().build();
RemoveHealthCheckTargetPoolHttpRequest request = RemoveHealthCheckTargetPoolHttpRequest.newBuilder()
.setTargetPool(formattedTargetPool)
.setTargetPoolsRemoveHealthCheckRequestResource(targetPoolsRemoveHealthCheckRequestResource)
.build();
Operation response = targetPoolClient.removeHealthCheckTargetPool(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<RemoveHealthCheckTargetPoolHttpRequest,Operation> removeHealthCheckTargetPoolCallable()
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedTargetPool = ProjectRegionTargetPoolName.format("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPoolsRemoveHealthCheckRequest targetPoolsRemoveHealthCheckRequestResource = TargetPoolsRemoveHealthCheckRequest.newBuilder().build();
RemoveHealthCheckTargetPoolHttpRequest request = RemoveHealthCheckTargetPoolHttpRequest.newBuilder()
.setTargetPool(formattedTargetPool)
.setTargetPoolsRemoveHealthCheckRequestResource(targetPoolsRemoveHealthCheckRequestResource)
.build();
ApiFuture<Operation> future = targetPoolClient.removeHealthCheckTargetPoolCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Operation removeInstanceTargetPool(ProjectRegionTargetPoolName targetPool, TargetPoolsRemoveInstanceRequest targetPoolsRemoveInstanceRequestResource)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionTargetPoolName targetPool = ProjectRegionTargetPoolName.of("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPoolsRemoveInstanceRequest targetPoolsRemoveInstanceRequestResource = TargetPoolsRemoveInstanceRequest.newBuilder().build();
Operation response = targetPoolClient.removeInstanceTargetPool(targetPool, targetPoolsRemoveInstanceRequestResource);
}
targetPool
- Name of the TargetPool resource to remove instances from.targetPoolsRemoveInstanceRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation removeInstanceTargetPool(String targetPool, TargetPoolsRemoveInstanceRequest targetPoolsRemoveInstanceRequestResource)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionTargetPoolName targetPool = ProjectRegionTargetPoolName.of("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPoolsRemoveInstanceRequest targetPoolsRemoveInstanceRequestResource = TargetPoolsRemoveInstanceRequest.newBuilder().build();
Operation response = targetPoolClient.removeInstanceTargetPool(targetPool.toString(), targetPoolsRemoveInstanceRequestResource);
}
targetPool
- Name of the TargetPool resource to remove instances from.targetPoolsRemoveInstanceRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation removeInstanceTargetPool(RemoveInstanceTargetPoolHttpRequest request)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedTargetPool = ProjectRegionTargetPoolName.format("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPoolsRemoveInstanceRequest targetPoolsRemoveInstanceRequestResource = TargetPoolsRemoveInstanceRequest.newBuilder().build();
RemoveInstanceTargetPoolHttpRequest request = RemoveInstanceTargetPoolHttpRequest.newBuilder()
.setTargetPool(formattedTargetPool)
.setTargetPoolsRemoveInstanceRequestResource(targetPoolsRemoveInstanceRequestResource)
.build();
Operation response = targetPoolClient.removeInstanceTargetPool(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<RemoveInstanceTargetPoolHttpRequest,Operation> removeInstanceTargetPoolCallable()
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedTargetPool = ProjectRegionTargetPoolName.format("[PROJECT]", "[REGION]", "[TARGET_POOL]");
TargetPoolsRemoveInstanceRequest targetPoolsRemoveInstanceRequestResource = TargetPoolsRemoveInstanceRequest.newBuilder().build();
RemoveInstanceTargetPoolHttpRequest request = RemoveInstanceTargetPoolHttpRequest.newBuilder()
.setTargetPool(formattedTargetPool)
.setTargetPoolsRemoveInstanceRequestResource(targetPoolsRemoveInstanceRequestResource)
.build();
ApiFuture<Operation> future = targetPoolClient.removeInstanceTargetPoolCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Operation setBackupTargetPool(ProjectRegionTargetPoolName targetPool, Float failoverRatio, TargetReference targetReferenceResource)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionTargetPoolName targetPool = ProjectRegionTargetPoolName.of("[PROJECT]", "[REGION]", "[TARGET_POOL]");
Float failoverRatio = 0;
TargetReference targetReferenceResource = TargetReference.newBuilder().build();
Operation response = targetPoolClient.setBackupTargetPool(targetPool, failoverRatio, targetReferenceResource);
}
targetPool
- Name of the TargetPool resource to set a backup pool for.failoverRatio
- New failoverRatio value for the target pool.targetReferenceResource
- ApiException
- if the remote call fails@BetaApi public final Operation setBackupTargetPool(String targetPool, Float failoverRatio, TargetReference targetReferenceResource)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
ProjectRegionTargetPoolName targetPool = ProjectRegionTargetPoolName.of("[PROJECT]", "[REGION]", "[TARGET_POOL]");
Float failoverRatio = 0;
TargetReference targetReferenceResource = TargetReference.newBuilder().build();
Operation response = targetPoolClient.setBackupTargetPool(targetPool.toString(), failoverRatio, targetReferenceResource);
}
targetPool
- Name of the TargetPool resource to set a backup pool for.failoverRatio
- New failoverRatio value for the target pool.targetReferenceResource
- ApiException
- if the remote call fails@BetaApi public final Operation setBackupTargetPool(SetBackupTargetPoolHttpRequest request)
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedTargetPool = ProjectRegionTargetPoolName.format("[PROJECT]", "[REGION]", "[TARGET_POOL]");
Float failoverRatio = 0;
TargetReference targetReferenceResource = TargetReference.newBuilder().build();
SetBackupTargetPoolHttpRequest request = SetBackupTargetPoolHttpRequest.newBuilder()
.setTargetPool(formattedTargetPool)
.setFailoverRatio(failoverRatio)
.setTargetReferenceResource(targetReferenceResource)
.build();
Operation response = targetPoolClient.setBackupTargetPool(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<SetBackupTargetPoolHttpRequest,Operation> setBackupTargetPoolCallable()
Sample code:
try (TargetPoolClient targetPoolClient = TargetPoolClient.create()) {
String formattedTargetPool = ProjectRegionTargetPoolName.format("[PROJECT]", "[REGION]", "[TARGET_POOL]");
Float failoverRatio = 0;
TargetReference targetReferenceResource = TargetReference.newBuilder().build();
SetBackupTargetPoolHttpRequest request = SetBackupTargetPoolHttpRequest.newBuilder()
.setTargetPool(formattedTargetPool)
.setFailoverRatio(failoverRatio)
.setTargetReferenceResource(targetReferenceResource)
.build();
ApiFuture<Operation> future = targetPoolClient.setBackupTargetPoolCallable().futureCall(request);
// Do something
Operation 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 © 2019 Google LLC. All rights reserved.