@Generated(value="by gapic-generator") @BetaApi public class AddressClient extends Object implements com.google.api.gax.core.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.
|
com.google.api.gax.rpc.UnaryCallable<AggregatedListAddressesHttpRequest,AddressAggregatedList> |
aggregatedListAddressesCallable()
Retrieves an aggregated list of addresses.
|
com.google.api.gax.rpc.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.
|
com.google.api.gax.rpc.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.
|
com.google.api.gax.rpc.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 by using the data included in the request.
|
Operation |
insertAddress(ProjectRegionName region,
Address addressResource)
Creates an address resource in the specified project by using the data included in the request.
|
Operation |
insertAddress(String region,
Address addressResource)
Creates an address resource in the specified project by using the data included in the request.
|
com.google.api.gax.rpc.UnaryCallable<InsertAddressHttpRequest,Operation> |
insertAddressCallable()
Creates an address resource in the specified project by 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.
|
com.google.api.gax.rpc.UnaryCallable<ListAddressesHttpRequest,AddressList> |
listAddressesCallable()
Retrieves a list of addresses contained within the specified region.
|
com.google.api.gax.rpc.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.com.google.api.gax.rpc.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.com.google.api.gax.rpc.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.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.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 com.google.api.gax.rpc.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.com.google.api.gax.rpc.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.com.google.api.gax.rpc.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.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.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.com.google.api.gax.rpc.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.com.google.api.gax.rpc.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.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.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
- Represents an IP Address resource.
An address resource represents a regional internal IP address. Regional internal IP addresses are RFC 1918 addresses that come from either a primary or secondary IP range of a subnet in a VPC network. Regional external IP addresses can be assigned to GCP VM instances, Cloud VPN gateways, regional external forwarding rules for network load balancers (in either Standard or Premium Tier), and regional external forwarding rules for HTTP(S), SSL Proxy, and TCP Proxy load balancers in Standard Tier. For more information, read IP addresses.
A globalAddresses resource represent a global external IP address. Global external IP addresses are IPv4 or IPv6 addresses. They can only be assigned to global forwarding rules for HTTP(S), SSL Proxy, or TCP Proxy load balancers in Premium Tier. For more information, read Global resources. (== resource_for beta.addresses ==) (== resource_for v1.addresses ==) (== resource_for beta.globalAddresses ==) (== resource_for v1.globalAddresses ==)
com.google.api.gax.rpc.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
- Represents an IP Address resource.
An address resource represents a regional internal IP address. Regional internal IP addresses are RFC 1918 addresses that come from either a primary or secondary IP range of a subnet in a VPC network. Regional external IP addresses can be assigned to GCP VM instances, Cloud VPN gateways, regional external forwarding rules for network load balancers (in either Standard or Premium Tier), and regional external forwarding rules for HTTP(S), SSL Proxy, and TCP Proxy load balancers in Standard Tier. For more information, read IP addresses.
A globalAddresses resource represent a global external IP address. Global external IP addresses are IPv4 or IPv6 addresses. They can only be assigned to global forwarding rules for HTTP(S), SSL Proxy, or TCP Proxy load balancers in Premium Tier. For more information, read Global resources. (== resource_for beta.addresses ==) (== resource_for v1.addresses ==) (== resource_for beta.globalAddresses ==) (== resource_for v1.globalAddresses ==)
com.google.api.gax.rpc.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.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.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.com.google.api.gax.rpc.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.com.google.api.gax.rpc.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.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.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 com.google.api.gax.rpc.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 com.google.api.gax.core.BackgroundResource
public boolean isShutdown()
isShutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isTerminated()
isTerminated
in interface com.google.api.gax.core.BackgroundResource
public void shutdownNow()
shutdownNow
in interface com.google.api.gax.core.BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface com.google.api.gax.core.BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.