@Generated(value="by gapic-generator") @BetaApi public class GlobalAddressClient 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 (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.
|
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.
|
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 using the data included in the request.
|
Operation |
insertGlobalAddress(ProjectName project,
Address addressResource)
Creates an address resource in the specified project using the data included in the request.
|
Operation |
insertGlobalAddress(String project,
Address addressResource)
Creates an address resource in the specified project using the data included in the request.
|
UnaryCallable<InsertGlobalAddressHttpRequest,Operation> |
insertGlobalAddressCallable()
Creates an address resource in the specified project 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.
|
UnaryCallable<ListGlobalAddressesHttpRequest,AddressList> |
listGlobalAddressesCallable()
Retrieves a list of global addresses.
|
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.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.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.ApiException
- if the remote call fails@BetaApi public final 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.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.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.ApiException
- if the remote call fails@BetaApi public final 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
- 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 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
- 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 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.ApiException
- if the remote call fails@BetaApi public final 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.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.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.ApiException
- if the remote call fails@BetaApi public final 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 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 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.