@Generated(value="by gapic-generator") @BetaApi public class GlobalAddressClient 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 (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
ProjectGlobalAddressName address = ProjectGlobalAddressName.of("[PROJECT]", "[ADDRESS]");
Operation response = globalAddressClient.deleteGlobalAddress(address);
}
Note: close() needs to be called on the globalAddressClient 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 GlobalAddressSettings to create(). For example:
To customize credentials:
GlobalAddressSettings globalAddressSettings =
GlobalAddressSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
GlobalAddressClient globalAddressClient =
GlobalAddressClient.create(globalAddressSettings);
To customize the endpoint:
GlobalAddressSettings globalAddressSettings =
GlobalAddressSettings.newBuilder().setEndpoint(myEndpoint).build();
GlobalAddressClient globalAddressClient =
GlobalAddressClient.create(globalAddressSettings);
Modifier and Type | Class and Description |
---|---|
static class |
GlobalAddressClient.ListGlobalAddressesFixedSizeCollection |
static class |
GlobalAddressClient.ListGlobalAddressesPage |
static class |
GlobalAddressClient.ListGlobalAddressesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
GlobalAddressClient(GlobalAddressSettings settings)
Constructs an instance of GlobalAddressClient, using the given settings.
|
protected |
GlobalAddressClient(GlobalAddressStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static GlobalAddressClient |
create()
Constructs an instance of GlobalAddressClient with default settings.
|
static GlobalAddressClient |
create(GlobalAddressSettings settings)
Constructs an instance of GlobalAddressClient, using the given settings.
|
static GlobalAddressClient |
create(GlobalAddressStub stub)
Constructs an instance of GlobalAddressClient, using the given stub for making calls.
|
Operation |
deleteGlobalAddress(DeleteGlobalAddressHttpRequest request)
Deletes the specified address resource.
|
Operation |
deleteGlobalAddress(ProjectGlobalAddressName address)
Deletes the specified address resource.
|
Operation |
deleteGlobalAddress(String address)
Deletes the specified address resource.
|
com.google.api.gax.rpc.UnaryCallable<DeleteGlobalAddressHttpRequest,Operation> |
deleteGlobalAddressCallable()
Deletes the specified address resource.
|
Address |
getGlobalAddress(GetGlobalAddressHttpRequest request)
Returns the specified address resource.
|
Address |
getGlobalAddress(ProjectGlobalAddressName address)
Returns the specified address resource.
|
Address |
getGlobalAddress(String address)
Returns the specified address resource.
|
com.google.api.gax.rpc.UnaryCallable<GetGlobalAddressHttpRequest,Address> |
getGlobalAddressCallable()
Returns the specified address resource.
|
GlobalAddressSettings |
getSettings() |
GlobalAddressStub |
getStub() |
Operation |
insertGlobalAddress(InsertGlobalAddressHttpRequest request)
Creates an address resource in the specified project by using the data included in the request.
|
Operation |
insertGlobalAddress(ProjectName project,
Address addressResource)
Creates an address resource in the specified project by using the data included in the request.
|
Operation |
insertGlobalAddress(String project,
Address addressResource)
Creates an address resource in the specified project by using the data included in the request.
|
com.google.api.gax.rpc.UnaryCallable<InsertGlobalAddressHttpRequest,Operation> |
insertGlobalAddressCallable()
Creates an address resource in the specified project by using the data included in the request.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
GlobalAddressClient.ListGlobalAddressesPagedResponse |
listGlobalAddresses(ListGlobalAddressesHttpRequest request)
Retrieves a list of global addresses.
|
GlobalAddressClient.ListGlobalAddressesPagedResponse |
listGlobalAddresses(ProjectName project)
Retrieves a list of global addresses.
|
GlobalAddressClient.ListGlobalAddressesPagedResponse |
listGlobalAddresses(String project)
Retrieves a list of global addresses.
|
com.google.api.gax.rpc.UnaryCallable<ListGlobalAddressesHttpRequest,AddressList> |
listGlobalAddressesCallable()
Retrieves a list of global addresses.
|
com.google.api.gax.rpc.UnaryCallable<ListGlobalAddressesHttpRequest,GlobalAddressClient.ListGlobalAddressesPagedResponse> |
listGlobalAddressesPagedCallable()
Retrieves a list of global addresses.
|
void |
shutdown() |
void |
shutdownNow() |
protected GlobalAddressClient(GlobalAddressSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected GlobalAddressClient(GlobalAddressStub stub)
public static final GlobalAddressClient create() throws IOException
IOException
public static final GlobalAddressClient create(GlobalAddressSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final GlobalAddressClient create(GlobalAddressStub stub)
public final GlobalAddressSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public GlobalAddressStub getStub()
@BetaApi public final Operation deleteGlobalAddress(ProjectGlobalAddressName address)
Sample code:
try (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
ProjectGlobalAddressName address = ProjectGlobalAddressName.of("[PROJECT]", "[ADDRESS]");
Operation response = globalAddressClient.deleteGlobalAddress(address);
}
address
- Name of the address resource to delete.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation deleteGlobalAddress(String address)
Sample code:
try (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
ProjectGlobalAddressName address = ProjectGlobalAddressName.of("[PROJECT]", "[ADDRESS]");
Operation response = globalAddressClient.deleteGlobalAddress(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 deleteGlobalAddress(DeleteGlobalAddressHttpRequest request)
Sample code:
try (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
String formattedAddress = ProjectGlobalAddressName.format("[PROJECT]", "[ADDRESS]");
DeleteGlobalAddressHttpRequest request = DeleteGlobalAddressHttpRequest.newBuilder()
.setAddress(formattedAddress)
.build();
Operation response = globalAddressClient.deleteGlobalAddress(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<DeleteGlobalAddressHttpRequest,Operation> deleteGlobalAddressCallable()
Sample code:
try (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
String formattedAddress = ProjectGlobalAddressName.format("[PROJECT]", "[ADDRESS]");
DeleteGlobalAddressHttpRequest request = DeleteGlobalAddressHttpRequest.newBuilder()
.setAddress(formattedAddress)
.build();
ApiFuture<Operation> future = globalAddressClient.deleteGlobalAddressCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Address getGlobalAddress(ProjectGlobalAddressName address)
Sample code:
try (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
ProjectGlobalAddressName address = ProjectGlobalAddressName.of("[PROJECT]", "[ADDRESS]");
Address response = globalAddressClient.getGlobalAddress(address);
}
address
- Name of the address resource to return.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Address getGlobalAddress(String address)
Sample code:
try (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
ProjectGlobalAddressName address = ProjectGlobalAddressName.of("[PROJECT]", "[ADDRESS]");
Address response = globalAddressClient.getGlobalAddress(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 getGlobalAddress(GetGlobalAddressHttpRequest request)
Sample code:
try (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
String formattedAddress = ProjectGlobalAddressName.format("[PROJECT]", "[ADDRESS]");
GetGlobalAddressHttpRequest request = GetGlobalAddressHttpRequest.newBuilder()
.setAddress(formattedAddress)
.build();
Address response = globalAddressClient.getGlobalAddress(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<GetGlobalAddressHttpRequest,Address> getGlobalAddressCallable()
Sample code:
try (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
String formattedAddress = ProjectGlobalAddressName.format("[PROJECT]", "[ADDRESS]");
GetGlobalAddressHttpRequest request = GetGlobalAddressHttpRequest.newBuilder()
.setAddress(formattedAddress)
.build();
ApiFuture<Address> future = globalAddressClient.getGlobalAddressCallable().futureCall(request);
// Do something
Address response = future.get();
}
@BetaApi public final Operation insertGlobalAddress(ProjectName project, Address addressResource)
Sample code:
try (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
Address addressResource = Address.newBuilder().build();
Operation response = globalAddressClient.insertGlobalAddress(project, addressResource);
}
project
- Project ID 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 insertGlobalAddress(String project, Address addressResource)
Sample code:
try (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
Address addressResource = Address.newBuilder().build();
Operation response = globalAddressClient.insertGlobalAddress(project.toString(), addressResource);
}
project
- Project ID 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 insertGlobalAddress(InsertGlobalAddressHttpRequest request)
Sample code:
try (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
Address addressResource = Address.newBuilder().build();
InsertGlobalAddressHttpRequest request = InsertGlobalAddressHttpRequest.newBuilder()
.setProject(formattedProject)
.setAddressResource(addressResource)
.build();
Operation response = globalAddressClient.insertGlobalAddress(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<InsertGlobalAddressHttpRequest,Operation> insertGlobalAddressCallable()
Sample code:
try (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
Address addressResource = Address.newBuilder().build();
InsertGlobalAddressHttpRequest request = InsertGlobalAddressHttpRequest.newBuilder()
.setProject(formattedProject)
.setAddressResource(addressResource)
.build();
ApiFuture<Operation> future = globalAddressClient.insertGlobalAddressCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final GlobalAddressClient.ListGlobalAddressesPagedResponse listGlobalAddresses(ProjectName project)
Sample code:
try (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (Address element : globalAddressClient.listGlobalAddresses(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final GlobalAddressClient.ListGlobalAddressesPagedResponse listGlobalAddresses(String project)
Sample code:
try (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (Address element : globalAddressClient.listGlobalAddresses(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 GlobalAddressClient.ListGlobalAddressesPagedResponse listGlobalAddresses(ListGlobalAddressesHttpRequest request)
Sample code:
try (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListGlobalAddressesHttpRequest request = ListGlobalAddressesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (Address element : globalAddressClient.listGlobalAddresses(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<ListGlobalAddressesHttpRequest,GlobalAddressClient.ListGlobalAddressesPagedResponse> listGlobalAddressesPagedCallable()
Sample code:
try (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListGlobalAddressesHttpRequest request = ListGlobalAddressesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<ListGlobalAddressesPagedResponse> future = globalAddressClient.listGlobalAddressesPagedCallable().futureCall(request);
// Do something
for (Address element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final com.google.api.gax.rpc.UnaryCallable<ListGlobalAddressesHttpRequest,AddressList> listGlobalAddressesCallable()
Sample code:
try (GlobalAddressClient globalAddressClient = GlobalAddressClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListGlobalAddressesHttpRequest request = ListGlobalAddressesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
AddressList response = globalAddressClient.listGlobalAddressesCallable().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.