@Generated(value="by gapic-generator") @BetaApi public class VpnTunnelClient 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 (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
ProjectRegionVpnTunnelName vpnTunnel = ProjectRegionVpnTunnelName.of("[PROJECT]", "[REGION]", "[VPN_TUNNEL]");
Operation response = vpnTunnelClient.deleteVpnTunnel(vpnTunnel);
}
Note: close() needs to be called on the vpnTunnelClient 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 VpnTunnelSettings to create(). For example:
To customize credentials:
VpnTunnelSettings vpnTunnelSettings =
VpnTunnelSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
VpnTunnelClient vpnTunnelClient =
VpnTunnelClient.create(vpnTunnelSettings);
To customize the endpoint:
VpnTunnelSettings vpnTunnelSettings =
VpnTunnelSettings.newBuilder().setEndpoint(myEndpoint).build();
VpnTunnelClient vpnTunnelClient =
VpnTunnelClient.create(vpnTunnelSettings);
Modifier and Type | Class and Description |
---|---|
static class |
VpnTunnelClient.AggregatedListVpnTunnelsFixedSizeCollection |
static class |
VpnTunnelClient.AggregatedListVpnTunnelsPage |
static class |
VpnTunnelClient.AggregatedListVpnTunnelsPagedResponse |
static class |
VpnTunnelClient.ListVpnTunnelsFixedSizeCollection |
static class |
VpnTunnelClient.ListVpnTunnelsPage |
static class |
VpnTunnelClient.ListVpnTunnelsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
VpnTunnelClient(VpnTunnelSettings settings)
Constructs an instance of VpnTunnelClient, using the given settings.
|
protected |
VpnTunnelClient(VpnTunnelStub stub) |
Modifier and Type | Method and Description |
---|---|
VpnTunnelClient.AggregatedListVpnTunnelsPagedResponse |
aggregatedListVpnTunnels(AggregatedListVpnTunnelsHttpRequest request)
Retrieves an aggregated list of VPN tunnels.
|
VpnTunnelClient.AggregatedListVpnTunnelsPagedResponse |
aggregatedListVpnTunnels(ProjectName project)
Retrieves an aggregated list of VPN tunnels.
|
VpnTunnelClient.AggregatedListVpnTunnelsPagedResponse |
aggregatedListVpnTunnels(String project)
Retrieves an aggregated list of VPN tunnels.
|
UnaryCallable<AggregatedListVpnTunnelsHttpRequest,VpnTunnelAggregatedList> |
aggregatedListVpnTunnelsCallable()
Retrieves an aggregated list of VPN tunnels.
|
UnaryCallable<AggregatedListVpnTunnelsHttpRequest,VpnTunnelClient.AggregatedListVpnTunnelsPagedResponse> |
aggregatedListVpnTunnelsPagedCallable()
Retrieves an aggregated list of VPN tunnels.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static VpnTunnelClient |
create()
Constructs an instance of VpnTunnelClient with default settings.
|
static VpnTunnelClient |
create(VpnTunnelSettings settings)
Constructs an instance of VpnTunnelClient, using the given settings.
|
static VpnTunnelClient |
create(VpnTunnelStub stub)
Constructs an instance of VpnTunnelClient, using the given stub for making calls.
|
Operation |
deleteVpnTunnel(DeleteVpnTunnelHttpRequest request)
Deletes the specified VpnTunnel resource.
|
Operation |
deleteVpnTunnel(ProjectRegionVpnTunnelName vpnTunnel)
Deletes the specified VpnTunnel resource.
|
Operation |
deleteVpnTunnel(String vpnTunnel)
Deletes the specified VpnTunnel resource.
|
UnaryCallable<DeleteVpnTunnelHttpRequest,Operation> |
deleteVpnTunnelCallable()
Deletes the specified VpnTunnel resource.
|
VpnTunnelSettings |
getSettings() |
VpnTunnelStub |
getStub() |
VpnTunnel |
getVpnTunnel(GetVpnTunnelHttpRequest request)
Returns the specified VpnTunnel resource.
|
VpnTunnel |
getVpnTunnel(ProjectRegionVpnTunnelName vpnTunnel)
Returns the specified VpnTunnel resource.
|
VpnTunnel |
getVpnTunnel(String vpnTunnel)
Returns the specified VpnTunnel resource.
|
UnaryCallable<GetVpnTunnelHttpRequest,VpnTunnel> |
getVpnTunnelCallable()
Returns the specified VpnTunnel resource.
|
Operation |
insertVpnTunnel(InsertVpnTunnelHttpRequest request)
Creates a VpnTunnel resource in the specified project and region using the data included in the
request.
|
Operation |
insertVpnTunnel(ProjectRegionName region,
VpnTunnel vpnTunnelResource)
Creates a VpnTunnel resource in the specified project and region using the data included in the
request.
|
Operation |
insertVpnTunnel(String region,
VpnTunnel vpnTunnelResource)
Creates a VpnTunnel resource in the specified project and region using the data included in the
request.
|
UnaryCallable<InsertVpnTunnelHttpRequest,Operation> |
insertVpnTunnelCallable()
Creates a VpnTunnel resource in the specified project and region using the data included in the
request.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
VpnTunnelClient.ListVpnTunnelsPagedResponse |
listVpnTunnels(ListVpnTunnelsHttpRequest request)
Retrieves a list of VpnTunnel resources contained in the specified project and region.
|
VpnTunnelClient.ListVpnTunnelsPagedResponse |
listVpnTunnels(ProjectRegionName region)
Retrieves a list of VpnTunnel resources contained in the specified project and region.
|
VpnTunnelClient.ListVpnTunnelsPagedResponse |
listVpnTunnels(String region)
Retrieves a list of VpnTunnel resources contained in the specified project and region.
|
UnaryCallable<ListVpnTunnelsHttpRequest,VpnTunnelList> |
listVpnTunnelsCallable()
Retrieves a list of VpnTunnel resources contained in the specified project and region.
|
UnaryCallable<ListVpnTunnelsHttpRequest,VpnTunnelClient.ListVpnTunnelsPagedResponse> |
listVpnTunnelsPagedCallable()
Retrieves a list of VpnTunnel resources contained in the specified project and region.
|
void |
shutdown() |
void |
shutdownNow() |
protected VpnTunnelClient(VpnTunnelSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected VpnTunnelClient(VpnTunnelStub stub)
public static final VpnTunnelClient create() throws IOException
IOException
public static final VpnTunnelClient create(VpnTunnelSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final VpnTunnelClient create(VpnTunnelStub stub)
public final VpnTunnelSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public VpnTunnelStub getStub()
@BetaApi public final VpnTunnelClient.AggregatedListVpnTunnelsPagedResponse aggregatedListVpnTunnels(ProjectName project)
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (VpnTunnelsScopedList element : vpnTunnelClient.aggregatedListVpnTunnels(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final VpnTunnelClient.AggregatedListVpnTunnelsPagedResponse aggregatedListVpnTunnels(String project)
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (VpnTunnelsScopedList element : vpnTunnelClient.aggregatedListVpnTunnels(project.toString()).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final VpnTunnelClient.AggregatedListVpnTunnelsPagedResponse aggregatedListVpnTunnels(AggregatedListVpnTunnelsHttpRequest request)
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListVpnTunnelsHttpRequest request = AggregatedListVpnTunnelsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (VpnTunnelsScopedList element : vpnTunnelClient.aggregatedListVpnTunnels(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<AggregatedListVpnTunnelsHttpRequest,VpnTunnelClient.AggregatedListVpnTunnelsPagedResponse> aggregatedListVpnTunnelsPagedCallable()
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListVpnTunnelsHttpRequest request = AggregatedListVpnTunnelsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<AggregatedListVpnTunnelsPagedResponse> future = vpnTunnelClient.aggregatedListVpnTunnelsPagedCallable().futureCall(request);
// Do something
for (VpnTunnelsScopedList element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<AggregatedListVpnTunnelsHttpRequest,VpnTunnelAggregatedList> aggregatedListVpnTunnelsCallable()
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListVpnTunnelsHttpRequest request = AggregatedListVpnTunnelsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
VpnTunnelAggregatedList response = vpnTunnelClient.aggregatedListVpnTunnelsCallable().call(request);
for (VpnTunnelsScopedList 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 deleteVpnTunnel(ProjectRegionVpnTunnelName vpnTunnel)
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
ProjectRegionVpnTunnelName vpnTunnel = ProjectRegionVpnTunnelName.of("[PROJECT]", "[REGION]", "[VPN_TUNNEL]");
Operation response = vpnTunnelClient.deleteVpnTunnel(vpnTunnel);
}
vpnTunnel
- Name of the VpnTunnel resource to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteVpnTunnel(String vpnTunnel)
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
ProjectRegionVpnTunnelName vpnTunnel = ProjectRegionVpnTunnelName.of("[PROJECT]", "[REGION]", "[VPN_TUNNEL]");
Operation response = vpnTunnelClient.deleteVpnTunnel(vpnTunnel.toString());
}
vpnTunnel
- Name of the VpnTunnel resource to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteVpnTunnel(DeleteVpnTunnelHttpRequest request)
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
String formattedVpnTunnel = ProjectRegionVpnTunnelName.format("[PROJECT]", "[REGION]", "[VPN_TUNNEL]");
DeleteVpnTunnelHttpRequest request = DeleteVpnTunnelHttpRequest.newBuilder()
.setVpnTunnel(formattedVpnTunnel)
.build();
Operation response = vpnTunnelClient.deleteVpnTunnel(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<DeleteVpnTunnelHttpRequest,Operation> deleteVpnTunnelCallable()
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
String formattedVpnTunnel = ProjectRegionVpnTunnelName.format("[PROJECT]", "[REGION]", "[VPN_TUNNEL]");
DeleteVpnTunnelHttpRequest request = DeleteVpnTunnelHttpRequest.newBuilder()
.setVpnTunnel(formattedVpnTunnel)
.build();
ApiFuture<Operation> future = vpnTunnelClient.deleteVpnTunnelCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final VpnTunnel getVpnTunnel(ProjectRegionVpnTunnelName vpnTunnel)
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
ProjectRegionVpnTunnelName vpnTunnel = ProjectRegionVpnTunnelName.of("[PROJECT]", "[REGION]", "[VPN_TUNNEL]");
VpnTunnel response = vpnTunnelClient.getVpnTunnel(vpnTunnel);
}
vpnTunnel
- Name of the VpnTunnel resource to return.ApiException
- if the remote call fails@BetaApi public final VpnTunnel getVpnTunnel(String vpnTunnel)
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
ProjectRegionVpnTunnelName vpnTunnel = ProjectRegionVpnTunnelName.of("[PROJECT]", "[REGION]", "[VPN_TUNNEL]");
VpnTunnel response = vpnTunnelClient.getVpnTunnel(vpnTunnel.toString());
}
vpnTunnel
- Name of the VpnTunnel resource to return.ApiException
- if the remote call fails@BetaApi public final VpnTunnel getVpnTunnel(GetVpnTunnelHttpRequest request)
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
String formattedVpnTunnel = ProjectRegionVpnTunnelName.format("[PROJECT]", "[REGION]", "[VPN_TUNNEL]");
GetVpnTunnelHttpRequest request = GetVpnTunnelHttpRequest.newBuilder()
.setVpnTunnel(formattedVpnTunnel)
.build();
VpnTunnel response = vpnTunnelClient.getVpnTunnel(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<GetVpnTunnelHttpRequest,VpnTunnel> getVpnTunnelCallable()
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
String formattedVpnTunnel = ProjectRegionVpnTunnelName.format("[PROJECT]", "[REGION]", "[VPN_TUNNEL]");
GetVpnTunnelHttpRequest request = GetVpnTunnelHttpRequest.newBuilder()
.setVpnTunnel(formattedVpnTunnel)
.build();
ApiFuture<VpnTunnel> future = vpnTunnelClient.getVpnTunnelCallable().futureCall(request);
// Do something
VpnTunnel response = future.get();
}
@BetaApi public final Operation insertVpnTunnel(ProjectRegionName region, VpnTunnel vpnTunnelResource)
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
VpnTunnel vpnTunnelResource = VpnTunnel.newBuilder().build();
Operation response = vpnTunnelClient.insertVpnTunnel(region, vpnTunnelResource);
}
region
- Name of the region for this request.vpnTunnelResource
- VPN tunnel resource. (== resource_for beta.vpnTunnels ==) (==
resource_for v1.vpnTunnels ==)ApiException
- if the remote call fails@BetaApi public final Operation insertVpnTunnel(String region, VpnTunnel vpnTunnelResource)
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
VpnTunnel vpnTunnelResource = VpnTunnel.newBuilder().build();
Operation response = vpnTunnelClient.insertVpnTunnel(region.toString(), vpnTunnelResource);
}
region
- Name of the region for this request.vpnTunnelResource
- VPN tunnel resource. (== resource_for beta.vpnTunnels ==) (==
resource_for v1.vpnTunnels ==)ApiException
- if the remote call fails@BetaApi public final Operation insertVpnTunnel(InsertVpnTunnelHttpRequest request)
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
VpnTunnel vpnTunnelResource = VpnTunnel.newBuilder().build();
InsertVpnTunnelHttpRequest request = InsertVpnTunnelHttpRequest.newBuilder()
.setRegion(formattedRegion)
.setVpnTunnelResource(vpnTunnelResource)
.build();
Operation response = vpnTunnelClient.insertVpnTunnel(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<InsertVpnTunnelHttpRequest,Operation> insertVpnTunnelCallable()
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
VpnTunnel vpnTunnelResource = VpnTunnel.newBuilder().build();
InsertVpnTunnelHttpRequest request = InsertVpnTunnelHttpRequest.newBuilder()
.setRegion(formattedRegion)
.setVpnTunnelResource(vpnTunnelResource)
.build();
ApiFuture<Operation> future = vpnTunnelClient.insertVpnTunnelCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final VpnTunnelClient.ListVpnTunnelsPagedResponse listVpnTunnels(ProjectRegionName region)
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (VpnTunnel element : vpnTunnelClient.listVpnTunnels(region).iterateAll()) {
// doThingsWith(element);
}
}
region
- Name of the region for this request.ApiException
- if the remote call fails@BetaApi public final VpnTunnelClient.ListVpnTunnelsPagedResponse listVpnTunnels(String region)
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (VpnTunnel element : vpnTunnelClient.listVpnTunnels(region.toString()).iterateAll()) {
// doThingsWith(element);
}
}
region
- Name of the region for this request.ApiException
- if the remote call fails@BetaApi public final VpnTunnelClient.ListVpnTunnelsPagedResponse listVpnTunnels(ListVpnTunnelsHttpRequest request)
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListVpnTunnelsHttpRequest request = ListVpnTunnelsHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
for (VpnTunnel element : vpnTunnelClient.listVpnTunnels(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<ListVpnTunnelsHttpRequest,VpnTunnelClient.ListVpnTunnelsPagedResponse> listVpnTunnelsPagedCallable()
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListVpnTunnelsHttpRequest request = ListVpnTunnelsHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
ApiFuture<ListVpnTunnelsPagedResponse> future = vpnTunnelClient.listVpnTunnelsPagedCallable().futureCall(request);
// Do something
for (VpnTunnel element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<ListVpnTunnelsHttpRequest,VpnTunnelList> listVpnTunnelsCallable()
Sample code:
try (VpnTunnelClient vpnTunnelClient = VpnTunnelClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListVpnTunnelsHttpRequest request = ListVpnTunnelsHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
while (true) {
VpnTunnelList response = vpnTunnelClient.listVpnTunnelsCallable().call(request);
for (VpnTunnel 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.