- 1.54.0 (latest)
- 1.53.0
- 1.52.0
- 1.50.0
- 1.49.0
- 1.48.0
- 1.47.0
- 1.46.0
- 1.45.0
- 1.44.0
- 1.43.0
- 1.42.0
- 1.41.0
- 1.40.0
- 1.38.0
- 1.37.0
- 1.36.0
- 1.35.0
- 1.34.0
- 1.33.0
- 1.32.0
- 1.31.0
- 1.30.0
- 1.29.0
- 1.28.0
- 1.25.0
- 1.24.0
- 1.23.0
- 1.22.0
- 1.21.0
- 1.20.0
- 1.19.0
- 1.18.0
- 1.17.0
- 1.16.0
- 1.15.0
- 1.14.0
- 1.13.0
- 1.12.0
- 1.10.0
- 1.9.0
- 1.8.0
- 1.7.0
- 1.6.0
- 1.5.0
- 1.1.10
public class ReachabilityServiceClient implements BackgroundResource
Service Description: The Reachability service in the Google Cloud Network Management API provides services that analyze the reachability within a single Google Virtual Private Cloud (VPC) network, between peered VPC networks, between VPC and on-premises networks, or between VPC networks and internet hosts. A reachability analysis is based on Google Cloud network configurations.
You can use the analysis results to verify these configurations and to troubleshoot connectivity issues.
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 (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
GetConnectivityTestRequest request =
GetConnectivityTestRequest.newBuilder().setName("name3373707").build();
ConnectivityTest response = reachabilityServiceClient.getConnectivityTest(request);
}
Note: close() needs to be called on the ReachabilityServiceClient 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:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of ReachabilityServiceSettings to create(). For example:
To customize credentials:
ReachabilityServiceSettings reachabilityServiceSettings =
ReachabilityServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ReachabilityServiceClient reachabilityServiceClient =
ReachabilityServiceClient.create(reachabilityServiceSettings);
To customize the endpoint:
ReachabilityServiceSettings reachabilityServiceSettings =
ReachabilityServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
ReachabilityServiceClient reachabilityServiceClient =
ReachabilityServiceClient.create(reachabilityServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceStatic Methods
create()
public static final ReachabilityServiceClient create()
Constructs an instance of ReachabilityServiceClient with default settings.
Type | Description |
ReachabilityServiceClient |
Type | Description |
IOException |
create(ReachabilityServiceSettings settings)
public static final ReachabilityServiceClient create(ReachabilityServiceSettings settings)
Constructs an instance of ReachabilityServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
Name | Description |
settings | ReachabilityServiceSettings |
Type | Description |
ReachabilityServiceClient |
Type | Description |
IOException |
create(ReachabilityServiceStub stub)
public static final ReachabilityServiceClient create(ReachabilityServiceStub stub)
Constructs an instance of ReachabilityServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(ReachabilityServiceSettings).
Name | Description |
stub | ReachabilityServiceStub |
Type | Description |
ReachabilityServiceClient |
Constructors
ReachabilityServiceClient(ReachabilityServiceSettings settings)
protected ReachabilityServiceClient(ReachabilityServiceSettings settings)
Constructs an instance of ReachabilityServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
Name | Description |
settings | ReachabilityServiceSettings |
ReachabilityServiceClient(ReachabilityServiceStub stub)
protected ReachabilityServiceClient(ReachabilityServiceStub stub)
Name | Description |
stub | ReachabilityServiceStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Name | Description |
duration | long |
unit | TimeUnit |
Type | Description |
boolean |
Type | Description |
InterruptedException |
close()
public final void close()
createConnectivityTestAsync(CreateConnectivityTestRequest request)
public final OperationFuture<ConnectivityTest,OperationMetadata> createConnectivityTestAsync(CreateConnectivityTestRequest request)
Creates a new Connectivity Test. After you create a test, the reachability analysis is performed as part of the long running operation, which completes when the analysis completes.
If the endpoint specifications in ConnectivityTest
are invalid (for example, containing
non-existent resources in the network, or you don't have read permissions to the network
configurations of listed projects), then the reachability result returns a value of UNKNOWN
.
If the endpoint specifications in ConnectivityTest
are incomplete, the reachability result
returns a value of <code>AMBIGUOUS</code>. For more information, see the
Connectivity Test documentation.
Sample code:
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
CreateConnectivityTestRequest request =
CreateConnectivityTestRequest.newBuilder()
.setParent("parent-995424086")
.setTestId("testId-877170355")
.setResource(ConnectivityTest.newBuilder().build())
.build();
ConnectivityTest response =
reachabilityServiceClient.createConnectivityTestAsync(request).get();
}
Name | Description |
request | CreateConnectivityTestRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<ConnectivityTest,OperationMetadata> |
createConnectivityTestCallable()
public final UnaryCallable<CreateConnectivityTestRequest,Operation> createConnectivityTestCallable()
Creates a new Connectivity Test. After you create a test, the reachability analysis is performed as part of the long running operation, which completes when the analysis completes.
If the endpoint specifications in ConnectivityTest
are invalid (for example, containing
non-existent resources in the network, or you don't have read permissions to the network
configurations of listed projects), then the reachability result returns a value of UNKNOWN
.
If the endpoint specifications in ConnectivityTest
are incomplete, the reachability result
returns a value of <code>AMBIGUOUS</code>. For more information, see the
Connectivity Test documentation.
Sample code:
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
CreateConnectivityTestRequest request =
CreateConnectivityTestRequest.newBuilder()
.setParent("parent-995424086")
.setTestId("testId-877170355")
.setResource(ConnectivityTest.newBuilder().build())
.build();
ApiFuture<Operation> future =
reachabilityServiceClient.createConnectivityTestCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
Type | Description |
UnaryCallable<CreateConnectivityTestRequest,Operation> |
createConnectivityTestOperationCallable()
public final OperationCallable<CreateConnectivityTestRequest,ConnectivityTest,OperationMetadata> createConnectivityTestOperationCallable()
Creates a new Connectivity Test. After you create a test, the reachability analysis is performed as part of the long running operation, which completes when the analysis completes.
If the endpoint specifications in ConnectivityTest
are invalid (for example, containing
non-existent resources in the network, or you don't have read permissions to the network
configurations of listed projects), then the reachability result returns a value of UNKNOWN
.
If the endpoint specifications in ConnectivityTest
are incomplete, the reachability result
returns a value of <code>AMBIGUOUS</code>. For more information, see the
Connectivity Test documentation.
Sample code:
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
CreateConnectivityTestRequest request =
CreateConnectivityTestRequest.newBuilder()
.setParent("parent-995424086")
.setTestId("testId-877170355")
.setResource(ConnectivityTest.newBuilder().build())
.build();
OperationFuture<ConnectivityTest, OperationMetadata> future =
reachabilityServiceClient.createConnectivityTestOperationCallable().futureCall(request);
// Do something.
ConnectivityTest response = future.get();
}
Type | Description |
OperationCallable<CreateConnectivityTestRequest,ConnectivityTest,OperationMetadata> |
deleteConnectivityTestAsync(DeleteConnectivityTestRequest request)
public final OperationFuture<Empty,OperationMetadata> deleteConnectivityTestAsync(DeleteConnectivityTestRequest request)
Deletes a specific ConnectivityTest
.
Sample code:
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
DeleteConnectivityTestRequest request =
DeleteConnectivityTestRequest.newBuilder().setName("name3373707").build();
reachabilityServiceClient.deleteConnectivityTestAsync(request).get();
}
Name | Description |
request | DeleteConnectivityTestRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Empty,OperationMetadata> |
deleteConnectivityTestCallable()
public final UnaryCallable<DeleteConnectivityTestRequest,Operation> deleteConnectivityTestCallable()
Deletes a specific ConnectivityTest
.
Sample code:
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
DeleteConnectivityTestRequest request =
DeleteConnectivityTestRequest.newBuilder().setName("name3373707").build();
ApiFuture<Operation> future =
reachabilityServiceClient.deleteConnectivityTestCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
UnaryCallable<DeleteConnectivityTestRequest,Operation> |
deleteConnectivityTestOperationCallable()
public final OperationCallable<DeleteConnectivityTestRequest,Empty,OperationMetadata> deleteConnectivityTestOperationCallable()
Deletes a specific ConnectivityTest
.
Sample code:
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
DeleteConnectivityTestRequest request =
DeleteConnectivityTestRequest.newBuilder().setName("name3373707").build();
OperationFuture<Empty, OperationMetadata> future =
reachabilityServiceClient.deleteConnectivityTestOperationCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
OperationCallable<DeleteConnectivityTestRequest,Empty,OperationMetadata> |
getConnectivityTest(GetConnectivityTestRequest request)
public final ConnectivityTest getConnectivityTest(GetConnectivityTestRequest request)
Gets the details of a specific Connectivity Test.
Sample code:
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
GetConnectivityTestRequest request =
GetConnectivityTestRequest.newBuilder().setName("name3373707").build();
ConnectivityTest response = reachabilityServiceClient.getConnectivityTest(request);
}
Name | Description |
request | GetConnectivityTestRequest The request object containing all of the parameters for the API call. |
Type | Description |
ConnectivityTest |
getConnectivityTestCallable()
public final UnaryCallable<GetConnectivityTestRequest,ConnectivityTest> getConnectivityTestCallable()
Gets the details of a specific Connectivity Test.
Sample code:
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
GetConnectivityTestRequest request =
GetConnectivityTestRequest.newBuilder().setName("name3373707").build();
ApiFuture<ConnectivityTest> future =
reachabilityServiceClient.getConnectivityTestCallable().futureCall(request);
// Do something.
ConnectivityTest response = future.get();
}
Type | Description |
UnaryCallable<GetConnectivityTestRequest,ConnectivityTest> |
getOperationsClient()
public final OperationsClient getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
Type | Description |
OperationsClient |
getSettings()
public final ReachabilityServiceSettings getSettings()
Type | Description |
ReachabilityServiceSettings |
getStub()
public ReachabilityServiceStub getStub()
Type | Description |
ReachabilityServiceStub |
isShutdown()
public boolean isShutdown()
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Type | Description |
boolean |
listConnectivityTests(ListConnectivityTestsRequest request)
public final ReachabilityServiceClient.ListConnectivityTestsPagedResponse listConnectivityTests(ListConnectivityTestsRequest request)
Lists all Connectivity Tests owned by a project.
Sample code:
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
ListConnectivityTestsRequest request =
ListConnectivityTestsRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.build();
for (ConnectivityTest element :
reachabilityServiceClient.listConnectivityTests(request).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
request | ListConnectivityTestsRequest The request object containing all of the parameters for the API call. |
Type | Description |
ReachabilityServiceClient.ListConnectivityTestsPagedResponse |
listConnectivityTestsCallable()
public final UnaryCallable<ListConnectivityTestsRequest,ListConnectivityTestsResponse> listConnectivityTestsCallable()
Lists all Connectivity Tests owned by a project.
Sample code:
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
ListConnectivityTestsRequest request =
ListConnectivityTestsRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.build();
while (true) {
ListConnectivityTestsResponse response =
reachabilityServiceClient.listConnectivityTestsCallable().call(request);
for (ConnectivityTest element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListConnectivityTestsRequest,ListConnectivityTestsResponse> |
listConnectivityTestsPagedCallable()
public final UnaryCallable<ListConnectivityTestsRequest,ReachabilityServiceClient.ListConnectivityTestsPagedResponse> listConnectivityTestsPagedCallable()
Lists all Connectivity Tests owned by a project.
Sample code:
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
ListConnectivityTestsRequest request =
ListConnectivityTestsRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.build();
ApiFuture<ConnectivityTest> future =
reachabilityServiceClient.listConnectivityTestsPagedCallable().futureCall(request);
// Do something.
for (ConnectivityTest element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Type | Description |
UnaryCallable<ListConnectivityTestsRequest,ListConnectivityTestsPagedResponse> |
rerunConnectivityTestAsync(RerunConnectivityTestRequest request)
public final OperationFuture<ConnectivityTest,OperationMetadata> rerunConnectivityTestAsync(RerunConnectivityTestRequest request)
Rerun an existing ConnectivityTest
. After the user triggers the rerun, the reachability
analysis is performed as part of the long running operation, which completes when the analysis
completes.
Even though the test configuration remains the same, the reachability result may change due to underlying network configuration changes.
If the endpoint specifications in ConnectivityTest
become invalid (for example, specified
resources are deleted in the network, or you lost read permissions to the network
configurations of listed projects), then the reachability result returns a value of UNKNOWN
.
Sample code:
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
RerunConnectivityTestRequest request =
RerunConnectivityTestRequest.newBuilder().setName("name3373707").build();
ConnectivityTest response =
reachabilityServiceClient.rerunConnectivityTestAsync(request).get();
}
Name | Description |
request | RerunConnectivityTestRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<ConnectivityTest,OperationMetadata> |
rerunConnectivityTestCallable()
public final UnaryCallable<RerunConnectivityTestRequest,Operation> rerunConnectivityTestCallable()
Rerun an existing ConnectivityTest
. After the user triggers the rerun, the reachability
analysis is performed as part of the long running operation, which completes when the analysis
completes.
Even though the test configuration remains the same, the reachability result may change due to underlying network configuration changes.
If the endpoint specifications in ConnectivityTest
become invalid (for example, specified
resources are deleted in the network, or you lost read permissions to the network
configurations of listed projects), then the reachability result returns a value of UNKNOWN
.
Sample code:
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
RerunConnectivityTestRequest request =
RerunConnectivityTestRequest.newBuilder().setName("name3373707").build();
ApiFuture<Operation> future =
reachabilityServiceClient.rerunConnectivityTestCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
Type | Description |
UnaryCallable<RerunConnectivityTestRequest,Operation> |
rerunConnectivityTestOperationCallable()
public final OperationCallable<RerunConnectivityTestRequest,ConnectivityTest,OperationMetadata> rerunConnectivityTestOperationCallable()
Rerun an existing ConnectivityTest
. After the user triggers the rerun, the reachability
analysis is performed as part of the long running operation, which completes when the analysis
completes.
Even though the test configuration remains the same, the reachability result may change due to underlying network configuration changes.
If the endpoint specifications in ConnectivityTest
become invalid (for example, specified
resources are deleted in the network, or you lost read permissions to the network
configurations of listed projects), then the reachability result returns a value of UNKNOWN
.
Sample code:
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
RerunConnectivityTestRequest request =
RerunConnectivityTestRequest.newBuilder().setName("name3373707").build();
OperationFuture<ConnectivityTest, OperationMetadata> future =
reachabilityServiceClient.rerunConnectivityTestOperationCallable().futureCall(request);
// Do something.
ConnectivityTest response = future.get();
}
Type | Description |
OperationCallable<RerunConnectivityTestRequest,ConnectivityTest,OperationMetadata> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()
updateConnectivityTestAsync(UpdateConnectivityTestRequest request)
public final OperationFuture<ConnectivityTest,OperationMetadata> updateConnectivityTestAsync(UpdateConnectivityTestRequest request)
Updates the configuration of an existing ConnectivityTest
. After you update a test, the
reachability analysis is performed as part of the long running operation, which completes when
the analysis completes. The Reachability state in the test resource is updated with the new
result.
If the endpoint specifications in ConnectivityTest
are invalid (for example, they contain
non-existent resources in the network, or the user does not have read permissions to the
network configurations of listed projects), then the reachability result returns a value of
<code>UNKNOWN</code>.
If the endpoint specifications in ConnectivityTest
are incomplete, the reachability result
returns a value of AMBIGUOUS
. See the documentation in ConnectivityTest
for for more
details.
Sample code:
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
UpdateConnectivityTestRequest request =
UpdateConnectivityTestRequest.newBuilder()
.setUpdateMask(FieldMask.newBuilder().build())
.setResource(ConnectivityTest.newBuilder().build())
.build();
ConnectivityTest response =
reachabilityServiceClient.updateConnectivityTestAsync(request).get();
}
Name | Description |
request | UpdateConnectivityTestRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<ConnectivityTest,OperationMetadata> |
updateConnectivityTestCallable()
public final UnaryCallable<UpdateConnectivityTestRequest,Operation> updateConnectivityTestCallable()
Updates the configuration of an existing ConnectivityTest
. After you update a test, the
reachability analysis is performed as part of the long running operation, which completes when
the analysis completes. The Reachability state in the test resource is updated with the new
result.
If the endpoint specifications in ConnectivityTest
are invalid (for example, they contain
non-existent resources in the network, or the user does not have read permissions to the
network configurations of listed projects), then the reachability result returns a value of
<code>UNKNOWN</code>.
If the endpoint specifications in ConnectivityTest
are incomplete, the reachability result
returns a value of AMBIGUOUS
. See the documentation in ConnectivityTest
for for more
details.
Sample code:
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
UpdateConnectivityTestRequest request =
UpdateConnectivityTestRequest.newBuilder()
.setUpdateMask(FieldMask.newBuilder().build())
.setResource(ConnectivityTest.newBuilder().build())
.build();
ApiFuture<Operation> future =
reachabilityServiceClient.updateConnectivityTestCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
Type | Description |
UnaryCallable<UpdateConnectivityTestRequest,Operation> |
updateConnectivityTestOperationCallable()
public final OperationCallable<UpdateConnectivityTestRequest,ConnectivityTest,OperationMetadata> updateConnectivityTestOperationCallable()
Updates the configuration of an existing ConnectivityTest
. After you update a test, the
reachability analysis is performed as part of the long running operation, which completes when
the analysis completes. The Reachability state in the test resource is updated with the new
result.
If the endpoint specifications in ConnectivityTest
are invalid (for example, they contain
non-existent resources in the network, or the user does not have read permissions to the
network configurations of listed projects), then the reachability result returns a value of
<code>UNKNOWN</code>.
If the endpoint specifications in ConnectivityTest
are incomplete, the reachability result
returns a value of AMBIGUOUS
. See the documentation in ConnectivityTest
for for more
details.
Sample code:
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
UpdateConnectivityTestRequest request =
UpdateConnectivityTestRequest.newBuilder()
.setUpdateMask(FieldMask.newBuilder().build())
.setResource(ConnectivityTest.newBuilder().build())
.build();
OperationFuture<ConnectivityTest, OperationMetadata> future =
reachabilityServiceClient.updateConnectivityTestOperationCallable().futureCall(request);
// Do something.
ConnectivityTest response = future.get();
}
Type | Description |
OperationCallable<UpdateConnectivityTestRequest,ConnectivityTest,OperationMetadata> |