@Generated(value="by gapic-generator") @BetaApi public class TargetVpnGatewayClient 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 (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
ProjectRegionTargetVpnGatewayName targetVpnGateway = ProjectRegionTargetVpnGatewayName.of("[PROJECT]", "[REGION]", "[TARGET_VPN_GATEWAY]");
Operation response = targetVpnGatewayClient.deleteTargetVpnGateway(targetVpnGateway);
}
Note: close() needs to be called on the targetVpnGatewayClient 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 TargetVpnGatewaySettings to create(). For example:
To customize credentials:
TargetVpnGatewaySettings targetVpnGatewaySettings =
TargetVpnGatewaySettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
TargetVpnGatewayClient targetVpnGatewayClient =
TargetVpnGatewayClient.create(targetVpnGatewaySettings);
To customize the endpoint:
TargetVpnGatewaySettings targetVpnGatewaySettings =
TargetVpnGatewaySettings.newBuilder().setEndpoint(myEndpoint).build();
TargetVpnGatewayClient targetVpnGatewayClient =
TargetVpnGatewayClient.create(targetVpnGatewaySettings);
Modifier and Type | Class and Description |
---|---|
static class |
TargetVpnGatewayClient.AggregatedListTargetVpnGatewaysFixedSizeCollection |
static class |
TargetVpnGatewayClient.AggregatedListTargetVpnGatewaysPage |
static class |
TargetVpnGatewayClient.AggregatedListTargetVpnGatewaysPagedResponse |
static class |
TargetVpnGatewayClient.ListTargetVpnGatewaysFixedSizeCollection |
static class |
TargetVpnGatewayClient.ListTargetVpnGatewaysPage |
static class |
TargetVpnGatewayClient.ListTargetVpnGatewaysPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
TargetVpnGatewayClient(TargetVpnGatewaySettings settings)
Constructs an instance of TargetVpnGatewayClient, using the given settings.
|
protected |
TargetVpnGatewayClient(TargetVpnGatewayStub stub) |
protected TargetVpnGatewayClient(TargetVpnGatewaySettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected TargetVpnGatewayClient(TargetVpnGatewayStub stub)
public static final TargetVpnGatewayClient create() throws IOException
IOException
public static final TargetVpnGatewayClient create(TargetVpnGatewaySettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final TargetVpnGatewayClient create(TargetVpnGatewayStub stub)
public final TargetVpnGatewaySettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public TargetVpnGatewayStub getStub()
@BetaApi public final TargetVpnGatewayClient.AggregatedListTargetVpnGatewaysPagedResponse aggregatedListTargetVpnGateways(ProjectName project)
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (TargetVpnGatewaysScopedList element : targetVpnGatewayClient.aggregatedListTargetVpnGateways(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final TargetVpnGatewayClient.AggregatedListTargetVpnGatewaysPagedResponse aggregatedListTargetVpnGateways(String project)
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (TargetVpnGatewaysScopedList element : targetVpnGatewayClient.aggregatedListTargetVpnGateways(project.toString()).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final TargetVpnGatewayClient.AggregatedListTargetVpnGatewaysPagedResponse aggregatedListTargetVpnGateways(AggregatedListTargetVpnGatewaysHttpRequest request)
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListTargetVpnGatewaysHttpRequest request = AggregatedListTargetVpnGatewaysHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (TargetVpnGatewaysScopedList element : targetVpnGatewayClient.aggregatedListTargetVpnGateways(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<AggregatedListTargetVpnGatewaysHttpRequest,TargetVpnGatewayClient.AggregatedListTargetVpnGatewaysPagedResponse> aggregatedListTargetVpnGatewaysPagedCallable()
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListTargetVpnGatewaysHttpRequest request = AggregatedListTargetVpnGatewaysHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<AggregatedListTargetVpnGatewaysPagedResponse> future = targetVpnGatewayClient.aggregatedListTargetVpnGatewaysPagedCallable().futureCall(request);
// Do something
for (TargetVpnGatewaysScopedList element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<AggregatedListTargetVpnGatewaysHttpRequest,TargetVpnGatewayAggregatedList> aggregatedListTargetVpnGatewaysCallable()
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListTargetVpnGatewaysHttpRequest request = AggregatedListTargetVpnGatewaysHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
TargetVpnGatewayAggregatedList response = targetVpnGatewayClient.aggregatedListTargetVpnGatewaysCallable().call(request);
for (TargetVpnGatewaysScopedList 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 deleteTargetVpnGateway(ProjectRegionTargetVpnGatewayName targetVpnGateway)
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
ProjectRegionTargetVpnGatewayName targetVpnGateway = ProjectRegionTargetVpnGatewayName.of("[PROJECT]", "[REGION]", "[TARGET_VPN_GATEWAY]");
Operation response = targetVpnGatewayClient.deleteTargetVpnGateway(targetVpnGateway);
}
targetVpnGateway
- Name of the target VPN gateway to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteTargetVpnGateway(String targetVpnGateway)
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
ProjectRegionTargetVpnGatewayName targetVpnGateway = ProjectRegionTargetVpnGatewayName.of("[PROJECT]", "[REGION]", "[TARGET_VPN_GATEWAY]");
Operation response = targetVpnGatewayClient.deleteTargetVpnGateway(targetVpnGateway.toString());
}
targetVpnGateway
- Name of the target VPN gateway to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteTargetVpnGateway(DeleteTargetVpnGatewayHttpRequest request)
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
String formattedTargetVpnGateway = ProjectRegionTargetVpnGatewayName.format("[PROJECT]", "[REGION]", "[TARGET_VPN_GATEWAY]");
DeleteTargetVpnGatewayHttpRequest request = DeleteTargetVpnGatewayHttpRequest.newBuilder()
.setTargetVpnGateway(formattedTargetVpnGateway)
.build();
Operation response = targetVpnGatewayClient.deleteTargetVpnGateway(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<DeleteTargetVpnGatewayHttpRequest,Operation> deleteTargetVpnGatewayCallable()
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
String formattedTargetVpnGateway = ProjectRegionTargetVpnGatewayName.format("[PROJECT]", "[REGION]", "[TARGET_VPN_GATEWAY]");
DeleteTargetVpnGatewayHttpRequest request = DeleteTargetVpnGatewayHttpRequest.newBuilder()
.setTargetVpnGateway(formattedTargetVpnGateway)
.build();
ApiFuture<Operation> future = targetVpnGatewayClient.deleteTargetVpnGatewayCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final TargetVpnGateway getTargetVpnGateway(ProjectRegionTargetVpnGatewayName targetVpnGateway)
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
ProjectRegionTargetVpnGatewayName targetVpnGateway = ProjectRegionTargetVpnGatewayName.of("[PROJECT]", "[REGION]", "[TARGET_VPN_GATEWAY]");
TargetVpnGateway response = targetVpnGatewayClient.getTargetVpnGateway(targetVpnGateway);
}
targetVpnGateway
- Name of the target VPN gateway to return.ApiException
- if the remote call fails@BetaApi public final TargetVpnGateway getTargetVpnGateway(String targetVpnGateway)
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
ProjectRegionTargetVpnGatewayName targetVpnGateway = ProjectRegionTargetVpnGatewayName.of("[PROJECT]", "[REGION]", "[TARGET_VPN_GATEWAY]");
TargetVpnGateway response = targetVpnGatewayClient.getTargetVpnGateway(targetVpnGateway.toString());
}
targetVpnGateway
- Name of the target VPN gateway to return.ApiException
- if the remote call fails@BetaApi public final TargetVpnGateway getTargetVpnGateway(GetTargetVpnGatewayHttpRequest request)
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
String formattedTargetVpnGateway = ProjectRegionTargetVpnGatewayName.format("[PROJECT]", "[REGION]", "[TARGET_VPN_GATEWAY]");
GetTargetVpnGatewayHttpRequest request = GetTargetVpnGatewayHttpRequest.newBuilder()
.setTargetVpnGateway(formattedTargetVpnGateway)
.build();
TargetVpnGateway response = targetVpnGatewayClient.getTargetVpnGateway(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<GetTargetVpnGatewayHttpRequest,TargetVpnGateway> getTargetVpnGatewayCallable()
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
String formattedTargetVpnGateway = ProjectRegionTargetVpnGatewayName.format("[PROJECT]", "[REGION]", "[TARGET_VPN_GATEWAY]");
GetTargetVpnGatewayHttpRequest request = GetTargetVpnGatewayHttpRequest.newBuilder()
.setTargetVpnGateway(formattedTargetVpnGateway)
.build();
ApiFuture<TargetVpnGateway> future = targetVpnGatewayClient.getTargetVpnGatewayCallable().futureCall(request);
// Do something
TargetVpnGateway response = future.get();
}
@BetaApi public final Operation insertTargetVpnGateway(ProjectRegionName region, TargetVpnGateway targetVpnGatewayResource)
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
TargetVpnGateway targetVpnGatewayResource = TargetVpnGateway.newBuilder().build();
Operation response = targetVpnGatewayClient.insertTargetVpnGateway(region, targetVpnGatewayResource);
}
region
- Name of the region for this request.targetVpnGatewayResource
- Represents a Target VPN gateway resource. (== resource_for
beta.targetVpnGateways ==) (== resource_for v1.targetVpnGateways ==)ApiException
- if the remote call fails@BetaApi public final Operation insertTargetVpnGateway(String region, TargetVpnGateway targetVpnGatewayResource)
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
TargetVpnGateway targetVpnGatewayResource = TargetVpnGateway.newBuilder().build();
Operation response = targetVpnGatewayClient.insertTargetVpnGateway(region.toString(), targetVpnGatewayResource);
}
region
- Name of the region for this request.targetVpnGatewayResource
- Represents a Target VPN gateway resource. (== resource_for
beta.targetVpnGateways ==) (== resource_for v1.targetVpnGateways ==)ApiException
- if the remote call fails@BetaApi public final Operation insertTargetVpnGateway(InsertTargetVpnGatewayHttpRequest request)
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
TargetVpnGateway targetVpnGatewayResource = TargetVpnGateway.newBuilder().build();
InsertTargetVpnGatewayHttpRequest request = InsertTargetVpnGatewayHttpRequest.newBuilder()
.setRegion(formattedRegion)
.setTargetVpnGatewayResource(targetVpnGatewayResource)
.build();
Operation response = targetVpnGatewayClient.insertTargetVpnGateway(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<InsertTargetVpnGatewayHttpRequest,Operation> insertTargetVpnGatewayCallable()
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
TargetVpnGateway targetVpnGatewayResource = TargetVpnGateway.newBuilder().build();
InsertTargetVpnGatewayHttpRequest request = InsertTargetVpnGatewayHttpRequest.newBuilder()
.setRegion(formattedRegion)
.setTargetVpnGatewayResource(targetVpnGatewayResource)
.build();
ApiFuture<Operation> future = targetVpnGatewayClient.insertTargetVpnGatewayCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final TargetVpnGatewayClient.ListTargetVpnGatewaysPagedResponse listTargetVpnGateways(ProjectRegionName region)
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (TargetVpnGateway element : targetVpnGatewayClient.listTargetVpnGateways(region).iterateAll()) {
// doThingsWith(element);
}
}
region
- Name of the region for this request.ApiException
- if the remote call fails@BetaApi public final TargetVpnGatewayClient.ListTargetVpnGatewaysPagedResponse listTargetVpnGateways(String region)
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (TargetVpnGateway element : targetVpnGatewayClient.listTargetVpnGateways(region.toString()).iterateAll()) {
// doThingsWith(element);
}
}
region
- Name of the region for this request.ApiException
- if the remote call fails@BetaApi public final TargetVpnGatewayClient.ListTargetVpnGatewaysPagedResponse listTargetVpnGateways(ListTargetVpnGatewaysHttpRequest request)
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListTargetVpnGatewaysHttpRequest request = ListTargetVpnGatewaysHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
for (TargetVpnGateway element : targetVpnGatewayClient.listTargetVpnGateways(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<ListTargetVpnGatewaysHttpRequest,TargetVpnGatewayClient.ListTargetVpnGatewaysPagedResponse> listTargetVpnGatewaysPagedCallable()
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListTargetVpnGatewaysHttpRequest request = ListTargetVpnGatewaysHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
ApiFuture<ListTargetVpnGatewaysPagedResponse> future = targetVpnGatewayClient.listTargetVpnGatewaysPagedCallable().futureCall(request);
// Do something
for (TargetVpnGateway element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<ListTargetVpnGatewaysHttpRequest,TargetVpnGatewayList> listTargetVpnGatewaysCallable()
Sample code:
try (TargetVpnGatewayClient targetVpnGatewayClient = TargetVpnGatewayClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListTargetVpnGatewaysHttpRequest request = ListTargetVpnGatewaysHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
while (true) {
TargetVpnGatewayList response = targetVpnGatewayClient.listTargetVpnGatewaysCallable().call(request);
for (TargetVpnGateway element : response.getItemsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
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.