@Generated(value="by gapic-generator") @BetaApi public class InterconnectLocationClient 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 (InterconnectLocationClient interconnectLocationClient = InterconnectLocationClient.create()) {
ProjectGlobalInterconnectLocationName interconnectLocation = ProjectGlobalInterconnectLocationName.of("[PROJECT]", "[INTERCONNECT_LOCATION]");
InterconnectLocation response = interconnectLocationClient.getInterconnectLocation(interconnectLocation);
}
Note: close() needs to be called on the interconnectLocationClient 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 InterconnectLocationSettings to create(). For example:
To customize credentials:
InterconnectLocationSettings interconnectLocationSettings =
InterconnectLocationSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
InterconnectLocationClient interconnectLocationClient =
InterconnectLocationClient.create(interconnectLocationSettings);
To customize the endpoint:
InterconnectLocationSettings interconnectLocationSettings =
InterconnectLocationSettings.newBuilder().setEndpoint(myEndpoint).build();
InterconnectLocationClient interconnectLocationClient =
InterconnectLocationClient.create(interconnectLocationSettings);
Modifier and Type | Class and Description |
---|---|
static class |
InterconnectLocationClient.ListInterconnectLocationsFixedSizeCollection |
static class |
InterconnectLocationClient.ListInterconnectLocationsPage |
static class |
InterconnectLocationClient.ListInterconnectLocationsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
InterconnectLocationClient(InterconnectLocationSettings settings)
Constructs an instance of InterconnectLocationClient, using the given settings.
|
protected |
InterconnectLocationClient(InterconnectLocationStub stub) |
protected InterconnectLocationClient(InterconnectLocationSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected InterconnectLocationClient(InterconnectLocationStub stub)
public static final InterconnectLocationClient create() throws IOException
IOException
public static final InterconnectLocationClient create(InterconnectLocationSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final InterconnectLocationClient create(InterconnectLocationStub stub)
public final InterconnectLocationSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public InterconnectLocationStub getStub()
@BetaApi public final InterconnectLocation getInterconnectLocation(ProjectGlobalInterconnectLocationName interconnectLocation)
Sample code:
try (InterconnectLocationClient interconnectLocationClient = InterconnectLocationClient.create()) {
ProjectGlobalInterconnectLocationName interconnectLocation = ProjectGlobalInterconnectLocationName.of("[PROJECT]", "[INTERCONNECT_LOCATION]");
InterconnectLocation response = interconnectLocationClient.getInterconnectLocation(interconnectLocation);
}
interconnectLocation
- Name of the interconnect location to return.ApiException
- if the remote call fails@BetaApi public final InterconnectLocation getInterconnectLocation(String interconnectLocation)
Sample code:
try (InterconnectLocationClient interconnectLocationClient = InterconnectLocationClient.create()) {
ProjectGlobalInterconnectLocationName interconnectLocation = ProjectGlobalInterconnectLocationName.of("[PROJECT]", "[INTERCONNECT_LOCATION]");
InterconnectLocation response = interconnectLocationClient.getInterconnectLocation(interconnectLocation.toString());
}
interconnectLocation
- Name of the interconnect location to return.ApiException
- if the remote call fails@BetaApi public final InterconnectLocation getInterconnectLocation(GetInterconnectLocationHttpRequest request)
Sample code:
try (InterconnectLocationClient interconnectLocationClient = InterconnectLocationClient.create()) {
String formattedInterconnectLocation = ProjectGlobalInterconnectLocationName.format("[PROJECT]", "[INTERCONNECT_LOCATION]");
GetInterconnectLocationHttpRequest request = GetInterconnectLocationHttpRequest.newBuilder()
.setInterconnectLocation(formattedInterconnectLocation)
.build();
InterconnectLocation response = interconnectLocationClient.getInterconnectLocation(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<GetInterconnectLocationHttpRequest,InterconnectLocation> getInterconnectLocationCallable()
Sample code:
try (InterconnectLocationClient interconnectLocationClient = InterconnectLocationClient.create()) {
String formattedInterconnectLocation = ProjectGlobalInterconnectLocationName.format("[PROJECT]", "[INTERCONNECT_LOCATION]");
GetInterconnectLocationHttpRequest request = GetInterconnectLocationHttpRequest.newBuilder()
.setInterconnectLocation(formattedInterconnectLocation)
.build();
ApiFuture<InterconnectLocation> future = interconnectLocationClient.getInterconnectLocationCallable().futureCall(request);
// Do something
InterconnectLocation response = future.get();
}
@BetaApi public final InterconnectLocationClient.ListInterconnectLocationsPagedResponse listInterconnectLocations(ProjectName project)
Sample code:
try (InterconnectLocationClient interconnectLocationClient = InterconnectLocationClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (InterconnectLocation element : interconnectLocationClient.listInterconnectLocations(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final InterconnectLocationClient.ListInterconnectLocationsPagedResponse listInterconnectLocations(String project)
Sample code:
try (InterconnectLocationClient interconnectLocationClient = InterconnectLocationClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (InterconnectLocation element : interconnectLocationClient.listInterconnectLocations(project.toString()).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final InterconnectLocationClient.ListInterconnectLocationsPagedResponse listInterconnectLocations(ListInterconnectLocationsHttpRequest request)
Sample code:
try (InterconnectLocationClient interconnectLocationClient = InterconnectLocationClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListInterconnectLocationsHttpRequest request = ListInterconnectLocationsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (InterconnectLocation element : interconnectLocationClient.listInterconnectLocations(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<ListInterconnectLocationsHttpRequest,InterconnectLocationClient.ListInterconnectLocationsPagedResponse> listInterconnectLocationsPagedCallable()
Sample code:
try (InterconnectLocationClient interconnectLocationClient = InterconnectLocationClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListInterconnectLocationsHttpRequest request = ListInterconnectLocationsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<ListInterconnectLocationsPagedResponse> future = interconnectLocationClient.listInterconnectLocationsPagedCallable().futureCall(request);
// Do something
for (InterconnectLocation element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<ListInterconnectLocationsHttpRequest,InterconnectLocationList> listInterconnectLocationsCallable()
Sample code:
try (InterconnectLocationClient interconnectLocationClient = InterconnectLocationClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListInterconnectLocationsHttpRequest request = ListInterconnectLocationsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
InterconnectLocationList response = interconnectLocationClient.listInterconnectLocationsCallable().call(request);
for (InterconnectLocation 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.