Class ReachabilityServiceClient
- All Implemented Interfaces:
BackgroundResource,AutoCloseable
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:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) {
GetConnectivityTestRequest request =
GetConnectivityTestRequest.newBuilder()
.setName(ConnectivityTestName.of("[PROJECT]", "[TEST]").toString())
.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().
| Method | Description | Method Variants |
|---|---|---|
ListConnectivityTests |
Lists all Connectivity Tests owned by a project. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetConnectivityTest |
Gets the details of a specific Connectivity Test. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
CreateConnectivityTest |
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. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateConnectivityTest |
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 more details. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
RerunConnectivityTest |
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`. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteConnectivityTest |
Deletes a specific `ConnectivityTest`. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListLocations |
Lists information about the supported locations for this service.This method can be called in two ways: * **List all public locations:** Use the path `GET /v1/locations`.* **List project-visible locations:** Use the path`GET /v1/projects/{project_id}/locations`. This may include publiclocations as well as private or other locations specifically visibleto the project. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetLocation |
Gets information about a location. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
SetIamPolicy |
Sets the access control policy on the specified resource. Replacesany existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetIamPolicy |
Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
TestIamPermissions |
Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return 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:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ReachabilityServiceSettings reachabilityServiceSettings =
ReachabilityServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ReachabilityServiceClient reachabilityServiceClient =
ReachabilityServiceClient.create(reachabilityServiceSettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ReachabilityServiceSettings reachabilityServiceSettings =
ReachabilityServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
ReachabilityServiceClient reachabilityServiceClient =
ReachabilityServiceClient.create(reachabilityServiceSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ReachabilityServiceSettings reachabilityServiceSettings =
ReachabilityServiceSettings.newHttpJsonBuilder().build();
ReachabilityServiceClient reachabilityServiceClient =
ReachabilityServiceClient.create(reachabilityServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classstatic class -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs an instance of ReachabilityServiceClient, using the given settings.protected -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long duration, TimeUnit unit) final voidclose()static final ReachabilityServiceClientcreate()Constructs an instance of ReachabilityServiceClient with default settings.static final ReachabilityServiceClientcreate(ReachabilityServiceSettings settings) Constructs an instance of ReachabilityServiceClient, using the given settings.static final ReachabilityServiceClientConstructs an instance of ReachabilityServiceClient, using the given stub for making calls.Creates a new Connectivity Test.Creates a new Connectivity Test.Creates a new Connectivity Test.final OperationFuture<com.google.protobuf.Empty,OperationMetadata> Deletes a specific `ConnectivityTest`.Deletes a specific `ConnectivityTest`.final OperationCallable<DeleteConnectivityTestRequest,com.google.protobuf.Empty, OperationMetadata> Deletes a specific `ConnectivityTest`.final ConnectivityTestGets the details of a specific Connectivity Test.Gets the details of a specific Connectivity Test.final OperationsClientReturns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.final PolicygetIamPolicy(GetIamPolicyRequest request) Gets the access control policy for a resource.Gets the access control policy for a resource.final LocationgetLocation(GetLocationRequest request) Gets information about a location.Gets information about a location.final OperationsClientReturns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.getStub()booleanbooleanLists all Connectivity Tests owned by a project.Lists all Connectivity Tests owned by a project.final UnaryCallable<ListConnectivityTestsRequest,ReachabilityServiceClient.ListConnectivityTestsPagedResponse> Lists all Connectivity Tests owned by a project.listLocations(ListLocationsRequest request) Lists information about the supported locations for this service.This method can be called in two ways:Lists information about the supported locations for this service.This method can be called in two ways:Lists information about the supported locations for this service.This method can be called in two ways:Rerun an existing `ConnectivityTest`.Rerun an existing `ConnectivityTest`.Rerun an existing `ConnectivityTest`.final PolicysetIamPolicy(SetIamPolicyRequest request) Sets the access control policy on the specified resource.Sets the access control policy on the specified resource.voidshutdown()voidReturns permissions that a caller has on the specified resource.Returns permissions that a caller has on the specified resource.Updates the configuration of an existing `ConnectivityTest`.Updates the configuration of an existing `ConnectivityTest`.Updates the configuration of an existing `ConnectivityTest`.
-
Constructor Details
-
ReachabilityServiceClient
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.- Throws:
IOException
-
ReachabilityServiceClient
-
-
Method Details
-
create
Constructs an instance of ReachabilityServiceClient with default settings.- Throws:
IOException
-
create
public static final ReachabilityServiceClient create(ReachabilityServiceSettings settings) throws IOException 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.- Throws:
IOException
-
create
Constructs an instance of ReachabilityServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(ReachabilityServiceSettings). -
getSettings
-
getStub
-
getOperationsClient
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call. -
getHttpJsonOperationsClient
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call. -
listConnectivityTests
public final ReachabilityServiceClient.ListConnectivityTestsPagedResponse listConnectivityTests(ListConnectivityTestsRequest request) Lists all Connectivity Tests owned by a project.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { ListConnectivityTestsRequest request = ListConnectivityTestsRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .setFilter("filter-1274492040") .setOrderBy("orderBy-1207110587") .build(); for (ConnectivityTest element : reachabilityServiceClient.listConnectivityTests(request).iterateAll()) { // doThingsWith(element); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listConnectivityTestsPagedCallable
public final UnaryCallable<ListConnectivityTestsRequest,ReachabilityServiceClient.ListConnectivityTestsPagedResponse> listConnectivityTestsPagedCallable()Lists all Connectivity Tests owned by a project.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { ListConnectivityTestsRequest request = ListConnectivityTestsRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .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); } } -
listConnectivityTestsCallable
public final UnaryCallable<ListConnectivityTestsRequest,ListConnectivityTestsResponse> listConnectivityTestsCallable()Lists all Connectivity Tests owned by a project.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { ListConnectivityTestsRequest request = ListConnectivityTestsRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .setFilter("filter-1274492040") .setOrderBy("orderBy-1207110587") .build(); while (true) { ListConnectivityTestsResponse response = reachabilityServiceClient.listConnectivityTestsCallable().call(request); for (ConnectivityTest element : response.getResourcesList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
getConnectivityTest
Gets the details of a specific Connectivity Test.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { GetConnectivityTestRequest request = GetConnectivityTestRequest.newBuilder() .setName(ConnectivityTestName.of("[PROJECT]", "[TEST]").toString()) .build(); ConnectivityTest response = reachabilityServiceClient.getConnectivityTest(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getConnectivityTestCallable
public final UnaryCallable<GetConnectivityTestRequest,ConnectivityTest> getConnectivityTestCallable()Gets the details of a specific Connectivity Test.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { GetConnectivityTestRequest request = GetConnectivityTestRequest.newBuilder() .setName(ConnectivityTestName.of("[PROJECT]", "[TEST]").toString()) .build(); ApiFuture<ConnectivityTest> future = reachabilityServiceClient.getConnectivityTestCallable().futureCall(request); // Do something. ConnectivityTest response = future.get(); } -
createConnectivityTestAsync
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:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { CreateConnectivityTestRequest request = CreateConnectivityTestRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .setTestId("testId-877170355") .setResource(ConnectivityTest.newBuilder().build()) .build(); ConnectivityTest response = reachabilityServiceClient.createConnectivityTestAsync(request).get(); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
createConnectivityTestOperationCallable
public final OperationCallable<CreateConnectivityTestRequest,ConnectivityTest, createConnectivityTestOperationCallable()OperationMetadata> 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:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { CreateConnectivityTestRequest request = CreateConnectivityTestRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .setTestId("testId-877170355") .setResource(ConnectivityTest.newBuilder().build()) .build(); OperationFuture<ConnectivityTest, OperationMetadata> future = reachabilityServiceClient.createConnectivityTestOperationCallable().futureCall(request); // Do something. ConnectivityTest response = future.get(); } -
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:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { CreateConnectivityTestRequest request = CreateConnectivityTestRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .setTestId("testId-877170355") .setResource(ConnectivityTest.newBuilder().build()) .build(); ApiFuture<Operation> future = reachabilityServiceClient.createConnectivityTestCallable().futureCall(request); // Do something. Operation response = future.get(); } -
updateConnectivityTestAsync
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 more details.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { UpdateConnectivityTestRequest request = UpdateConnectivityTestRequest.newBuilder() .setUpdateMask(FieldMask.newBuilder().build()) .setResource(ConnectivityTest.newBuilder().build()) .build(); ConnectivityTest response = reachabilityServiceClient.updateConnectivityTestAsync(request).get(); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
updateConnectivityTestOperationCallable
public final OperationCallable<UpdateConnectivityTestRequest,ConnectivityTest, updateConnectivityTestOperationCallable()OperationMetadata> 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 more details.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (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(); } -
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 more details.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (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(); } -
rerunConnectivityTestAsync
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:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { RerunConnectivityTestRequest request = RerunConnectivityTestRequest.newBuilder() .setName(ConnectivityTestName.of("[PROJECT]", "[TEST]").toString()) .build(); ConnectivityTest response = reachabilityServiceClient.rerunConnectivityTestAsync(request).get(); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
rerunConnectivityTestOperationCallable
public final OperationCallable<RerunConnectivityTestRequest,ConnectivityTest, rerunConnectivityTestOperationCallable()OperationMetadata> 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:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { RerunConnectivityTestRequest request = RerunConnectivityTestRequest.newBuilder() .setName(ConnectivityTestName.of("[PROJECT]", "[TEST]").toString()) .build(); OperationFuture<ConnectivityTest, OperationMetadata> future = reachabilityServiceClient.rerunConnectivityTestOperationCallable().futureCall(request); // Do something. ConnectivityTest response = future.get(); } -
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:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { RerunConnectivityTestRequest request = RerunConnectivityTestRequest.newBuilder() .setName(ConnectivityTestName.of("[PROJECT]", "[TEST]").toString()) .build(); ApiFuture<Operation> future = reachabilityServiceClient.rerunConnectivityTestCallable().futureCall(request); // Do something. Operation response = future.get(); } -
deleteConnectivityTestAsync
public final OperationFuture<com.google.protobuf.Empty,OperationMetadata> deleteConnectivityTestAsync(DeleteConnectivityTestRequest request) Deletes a specific `ConnectivityTest`.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { DeleteConnectivityTestRequest request = DeleteConnectivityTestRequest.newBuilder() .setName(ConnectivityTestName.of("[PROJECT]", "[TEST]").toString()) .build(); reachabilityServiceClient.deleteConnectivityTestAsync(request).get(); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
deleteConnectivityTestOperationCallable
public final OperationCallable<DeleteConnectivityTestRequest,com.google.protobuf.Empty, deleteConnectivityTestOperationCallable()OperationMetadata> Deletes a specific `ConnectivityTest`.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { DeleteConnectivityTestRequest request = DeleteConnectivityTestRequest.newBuilder() .setName(ConnectivityTestName.of("[PROJECT]", "[TEST]").toString()) .build(); OperationFuture<Empty, OperationMetadata> future = reachabilityServiceClient.deleteConnectivityTestOperationCallable().futureCall(request); // Do something. future.get(); } -
deleteConnectivityTestCallable
public final UnaryCallable<DeleteConnectivityTestRequest,Operation> deleteConnectivityTestCallable()Deletes a specific `ConnectivityTest`.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { DeleteConnectivityTestRequest request = DeleteConnectivityTestRequest.newBuilder() .setName(ConnectivityTestName.of("[PROJECT]", "[TEST]").toString()) .build(); ApiFuture<Operation> future = reachabilityServiceClient.deleteConnectivityTestCallable().futureCall(request); // Do something. future.get(); } -
listLocations
public final ReachabilityServiceClient.ListLocationsPagedResponse listLocations(ListLocationsRequest request) Lists information about the supported locations for this service.This method can be called in two ways:* **List all public locations:** Use the path `GET /v1/locations`.* **List project-visible locations:** Use the path`GET /v1/projects/{project_id}/locations`. This may include publiclocations as well as private or other locations specifically visibleto the project.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { ListLocationsRequest request = ListLocationsRequest.newBuilder() .setName("name3373707") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); for (Location element : reachabilityServiceClient.listLocations(request).iterateAll()) { // doThingsWith(element); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listLocationsPagedCallable
public final UnaryCallable<ListLocationsRequest,ReachabilityServiceClient.ListLocationsPagedResponse> listLocationsPagedCallable()Lists information about the supported locations for this service.This method can be called in two ways:* **List all public locations:** Use the path `GET /v1/locations`.* **List project-visible locations:** Use the path`GET /v1/projects/{project_id}/locations`. This may include publiclocations as well as private or other locations specifically visibleto the project.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { ListLocationsRequest request = ListLocationsRequest.newBuilder() .setName("name3373707") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); ApiFuture<Location> future = reachabilityServiceClient.listLocationsPagedCallable().futureCall(request); // Do something. for (Location element : future.get().iterateAll()) { // doThingsWith(element); } } -
listLocationsCallable
Lists information about the supported locations for this service.This method can be called in two ways:* **List all public locations:** Use the path `GET /v1/locations`.* **List project-visible locations:** Use the path`GET /v1/projects/{project_id}/locations`. This may include publiclocations as well as private or other locations specifically visibleto the project.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { ListLocationsRequest request = ListLocationsRequest.newBuilder() .setName("name3373707") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); while (true) { ListLocationsResponse response = reachabilityServiceClient.listLocationsCallable().call(request); for (Location element : response.getLocationsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
getLocation
Gets information about a location.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); Location response = reachabilityServiceClient.getLocation(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getLocationCallable
Gets information about a location.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); ApiFuture<Location> future = reachabilityServiceClient.getLocationCallable().futureCall(request); // Do something. Location response = future.get(); } -
setIamPolicy
Sets the access control policy on the specified resource. Replacesany existing policy.Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() .setResource(ConnectivityTestName.of("[PROJECT]", "[TEST]").toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); Policy response = reachabilityServiceClient.setIamPolicy(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
setIamPolicyCallable
Sets the access control policy on the specified resource. Replacesany existing policy.Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() .setResource(ConnectivityTestName.of("[PROJECT]", "[TEST]").toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); ApiFuture<Policy> future = reachabilityServiceClient.setIamPolicyCallable().futureCall(request); // Do something. Policy response = future.get(); } -
getIamPolicy
Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() .setResource(ConnectivityTestName.of("[PROJECT]", "[TEST]").toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); Policy response = reachabilityServiceClient.getIamPolicy(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getIamPolicyCallable
Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() .setResource(ConnectivityTestName.of("[PROJECT]", "[TEST]").toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); ApiFuture<Policy> future = reachabilityServiceClient.getIamPolicyCallable().futureCall(request); // Do something. Policy response = future.get(); } -
testIamPermissions
Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error.Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() .setResource(ConnectivityTestName.of("[PROJECT]", "[TEST]").toString()) .addAllPermissions(new ArrayList<String>()) .build(); TestIamPermissionsResponse response = reachabilityServiceClient.testIamPermissions(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
testIamPermissionsCallable
public final UnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse> testIamPermissionsCallable()Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error.Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() .setResource(ConnectivityTestName.of("[PROJECT]", "[TEST]").toString()) .addAllPermissions(new ArrayList<String>()) .build(); ApiFuture<TestIamPermissionsResponse> future = reachabilityServiceClient.testIamPermissionsCallable().futureCall(request); // Do something. TestIamPermissionsResponse response = future.get(); } -
close
public final void close()- Specified by:
closein interfaceAutoCloseable
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceBackgroundResource
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceBackgroundResource
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceBackgroundResource
-
shutdownNow
public void shutdownNow()- Specified by:
shutdownNowin interfaceBackgroundResource
-
awaitTermination
- Specified by:
awaitTerminationin interfaceBackgroundResource- Throws:
InterruptedException
-