@Generated(value="by gapic-generator") @BetaApi public class AddressClient 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 (AddressClient addressClient = AddressClient.create()) {
ProjectRegionAddressName address = ProjectRegionAddressName.of("[PROJECT]", "[REGION]", "[ADDRESS]");
Operation response = addressClient.deleteAddress(address);
}
Note: close() needs to be called on the addressClient 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 AddressSettings to create(). For example:
To customize credentials:
AddressSettings addressSettings =
AddressSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
AddressClient addressClient =
AddressClient.create(addressSettings);
To customize the endpoint:
AddressSettings addressSettings =
AddressSettings.newBuilder().setEndpoint(myEndpoint).build();
AddressClient addressClient =
AddressClient.create(addressSettings);
Modifier and Type | Class and Description |
---|---|
static class |
AddressClient.AggregatedListAddressesFixedSizeCollection |
static class |
AddressClient.AggregatedListAddressesPage |
static class |
AddressClient.AggregatedListAddressesPagedResponse |
static class |
AddressClient.ListAddressesFixedSizeCollection |
static class |
AddressClient.ListAddressesPage |
static class |
AddressClient.ListAddressesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
AddressClient(AddressSettings settings)
Constructs an instance of AddressClient, using the given settings.
|
protected |
AddressClient(AddressStub stub) |
Modifier and Type | Method and Description |
---|---|
AddressClient.AggregatedListAddressesPagedResponse |
aggregatedListAddresses(AggregatedListAddressesHttpRequest request)
Retrieves an aggregated list of addresses.
|
AddressClient.AggregatedListAddressesPagedResponse |
aggregatedListAddresses(ProjectName project)
Retrieves an aggregated list of addresses.
|
AddressClient.AggregatedListAddressesPagedResponse |
aggregatedListAddresses(String project)
Retrieves an aggregated list of addresses.
|
UnaryCallable<AggregatedListAddressesHttpRequest,AddressAggregatedList> |
aggregatedListAddressesCallable()
Retrieves an aggregated list of addresses.
|
UnaryCallable<AggregatedListAddressesHttpRequest,AddressClient.AggregatedListAddressesPagedResponse> |
aggregatedListAddressesPagedCallable()
Retrieves an aggregated list of addresses.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static AddressClient |
create()
Constructs an instance of AddressClient with default settings.
|
static AddressClient |
create(AddressSettings settings)
Constructs an instance of AddressClient, using the given settings.
|
static AddressClient |
create(AddressStub stub)
Constructs an instance of AddressClient, using the given stub for making calls.
|
Operation |
deleteAddress(DeleteAddressHttpRequest request)
Deletes the specified address resource.
|
Operation |
deleteAddress(ProjectRegionAddressName address)
Deletes the specified address resource.
|
Operation |
deleteAddress(String address)
Deletes the specified address resource.
|
UnaryCallable<DeleteAddressHttpRequest,Operation> |
deleteAddressCallable()
Deletes the specified address resource.
|
Address |
getAddress(GetAddressHttpRequest request)
Returns the specified address resource.
|
Address |
getAddress(ProjectRegionAddressName address)
Returns the specified address resource.
|
Address |
getAddress(String address)
Returns the specified address resource.
|
UnaryCallable<GetAddressHttpRequest,Address> |
getAddressCallable()
Returns the specified address resource.
|
AddressSettings |
getSettings() |
AddressStub |
getStub() |
Operation |
insertAddress(InsertAddressHttpRequest request)
Creates an address resource in the specified project using the data included in the request.
|
Operation |
insertAddress(ProjectRegionName region,
Address addressResource)
Creates an address resource in the specified project using the data included in the request.
|
Operation |
insertAddress(String region,
Address addressResource)
Creates an address resource in the specified project using the data included in the request.
|
UnaryCallable<InsertAddressHttpRequest,Operation> |
insertAddressCallable()
Creates an address resource in the specified project using the data included in the request.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
AddressClient.ListAddressesPagedResponse |
listAddresses(ListAddressesHttpRequest request)
Retrieves a list of addresses contained within the specified region.
|
AddressClient.ListAddressesPagedResponse |
listAddresses(ProjectRegionName region)
Retrieves a list of addresses contained within the specified region.
|
AddressClient.ListAddressesPagedResponse |
listAddresses(String region)
Retrieves a list of addresses contained within the specified region.
|
UnaryCallable<ListAddressesHttpRequest,AddressList> |
listAddressesCallable()
Retrieves a list of addresses contained within the specified region.
|
UnaryCallable<ListAddressesHttpRequest,AddressClient.ListAddressesPagedResponse> |
listAddressesPagedCallable()
Retrieves a list of addresses contained within the specified region.
|
void |
shutdown() |
void |
shutdownNow() |
protected AddressClient(AddressSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected AddressClient(AddressStub stub)
public static final AddressClient create() throws IOException
IOException
public static final AddressClient create(AddressSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final AddressClient create(AddressStub stub)
public final AddressSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public AddressStub getStub()
@BetaApi public final AddressClient.AggregatedListAddressesPagedResponse aggregatedListAddresses(ProjectName project)
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (AddressesScopedList element : addressClient.aggregatedListAddresses(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final AddressClient.AggregatedListAddressesPagedResponse aggregatedListAddresses(String project)
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (AddressesScopedList element : addressClient.aggregatedListAddresses(project.toString()).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final AddressClient.AggregatedListAddressesPagedResponse aggregatedListAddresses(AggregatedListAddressesHttpRequest request)
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListAddressesHttpRequest request = AggregatedListAddressesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (AddressesScopedList element : addressClient.aggregatedListAddresses(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<AggregatedListAddressesHttpRequest,AddressClient.AggregatedListAddressesPagedResponse> aggregatedListAddressesPagedCallable()
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListAddressesHttpRequest request = AggregatedListAddressesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<AggregatedListAddressesPagedResponse> future = addressClient.aggregatedListAddressesPagedCallable().futureCall(request);
// Do something
for (AddressesScopedList element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<AggregatedListAddressesHttpRequest,AddressAggregatedList> aggregatedListAddressesCallable()
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListAddressesHttpRequest request = AggregatedListAddressesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
AddressAggregatedList response = addressClient.aggregatedListAddressesCallable().call(request);
for (AddressesScopedList 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 deleteAddress(ProjectRegionAddressName address)
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
ProjectRegionAddressName address = ProjectRegionAddressName.of("[PROJECT]", "[REGION]", "[ADDRESS]");
Operation response = addressClient.deleteAddress(address);
}
address
- Name of the address resource to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteAddress(String address)
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
ProjectRegionAddressName address = ProjectRegionAddressName.of("[PROJECT]", "[REGION]", "[ADDRESS]");
Operation response = addressClient.deleteAddress(address.toString());
}
address
- Name of the address resource to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteAddress(DeleteAddressHttpRequest request)
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
String formattedAddress = ProjectRegionAddressName.format("[PROJECT]", "[REGION]", "[ADDRESS]");
DeleteAddressHttpRequest request = DeleteAddressHttpRequest.newBuilder()
.setAddress(formattedAddress)
.build();
Operation response = addressClient.deleteAddress(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<DeleteAddressHttpRequest,Operation> deleteAddressCallable()
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
String formattedAddress = ProjectRegionAddressName.format("[PROJECT]", "[REGION]", "[ADDRESS]");
DeleteAddressHttpRequest request = DeleteAddressHttpRequest.newBuilder()
.setAddress(formattedAddress)
.build();
ApiFuture<Operation> future = addressClient.deleteAddressCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Address getAddress(ProjectRegionAddressName address)
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
ProjectRegionAddressName address = ProjectRegionAddressName.of("[PROJECT]", "[REGION]", "[ADDRESS]");
Address response = addressClient.getAddress(address);
}
address
- Name of the address resource to return.ApiException
- if the remote call fails@BetaApi public final Address getAddress(String address)
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
ProjectRegionAddressName address = ProjectRegionAddressName.of("[PROJECT]", "[REGION]", "[ADDRESS]");
Address response = addressClient.getAddress(address.toString());
}
address
- Name of the address resource to return.ApiException
- if the remote call fails@BetaApi public final Address getAddress(GetAddressHttpRequest request)
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
String formattedAddress = ProjectRegionAddressName.format("[PROJECT]", "[REGION]", "[ADDRESS]");
GetAddressHttpRequest request = GetAddressHttpRequest.newBuilder()
.setAddress(formattedAddress)
.build();
Address response = addressClient.getAddress(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<GetAddressHttpRequest,Address> getAddressCallable()
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
String formattedAddress = ProjectRegionAddressName.format("[PROJECT]", "[REGION]", "[ADDRESS]");
GetAddressHttpRequest request = GetAddressHttpRequest.newBuilder()
.setAddress(formattedAddress)
.build();
ApiFuture<Address> future = addressClient.getAddressCallable().futureCall(request);
// Do something
Address response = future.get();
}
@BetaApi public final Operation insertAddress(ProjectRegionName region, Address addressResource)
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
Address addressResource = Address.newBuilder().build();
Operation response = addressClient.insertAddress(region, addressResource);
}
region
- Name of the region for this request.addressResource
- A reserved address resource. (== resource_for beta.addresses ==) (==
resource_for v1.addresses ==) (== resource_for beta.globalAddresses ==) (== resource_for
v1.globalAddresses ==)ApiException
- if the remote call fails@BetaApi public final Operation insertAddress(String region, Address addressResource)
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
Address addressResource = Address.newBuilder().build();
Operation response = addressClient.insertAddress(region.toString(), addressResource);
}
region
- Name of the region for this request.addressResource
- A reserved address resource. (== resource_for beta.addresses ==) (==
resource_for v1.addresses ==) (== resource_for beta.globalAddresses ==) (== resource_for
v1.globalAddresses ==)ApiException
- if the remote call fails@BetaApi public final Operation insertAddress(InsertAddressHttpRequest request)
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
Address addressResource = Address.newBuilder().build();
InsertAddressHttpRequest request = InsertAddressHttpRequest.newBuilder()
.setRegion(formattedRegion)
.setAddressResource(addressResource)
.build();
Operation response = addressClient.insertAddress(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<InsertAddressHttpRequest,Operation> insertAddressCallable()
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
Address addressResource = Address.newBuilder().build();
InsertAddressHttpRequest request = InsertAddressHttpRequest.newBuilder()
.setRegion(formattedRegion)
.setAddressResource(addressResource)
.build();
ApiFuture<Operation> future = addressClient.insertAddressCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final AddressClient.ListAddressesPagedResponse listAddresses(ProjectRegionName region)
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (Address element : addressClient.listAddresses(region).iterateAll()) {
// doThingsWith(element);
}
}
region
- Name of the region for this request.ApiException
- if the remote call fails@BetaApi public final AddressClient.ListAddressesPagedResponse listAddresses(String region)
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (Address element : addressClient.listAddresses(region.toString()).iterateAll()) {
// doThingsWith(element);
}
}
region
- Name of the region for this request.ApiException
- if the remote call fails@BetaApi public final AddressClient.ListAddressesPagedResponse listAddresses(ListAddressesHttpRequest request)
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListAddressesHttpRequest request = ListAddressesHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
for (Address element : addressClient.listAddresses(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<ListAddressesHttpRequest,AddressClient.ListAddressesPagedResponse> listAddressesPagedCallable()
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListAddressesHttpRequest request = ListAddressesHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
ApiFuture<ListAddressesPagedResponse> future = addressClient.listAddressesPagedCallable().futureCall(request);
// Do something
for (Address element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<ListAddressesHttpRequest,AddressList> listAddressesCallable()
Sample code:
try (AddressClient addressClient = AddressClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListAddressesHttpRequest request = ListAddressesHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
while (true) {
AddressList response = addressClient.listAddressesCallable().call(request);
for (Address 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.