GitHub Repository | Product Reference |
Service Description: Provides methods for handling GeoTarget
objects.
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:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GeoTargetServiceClient geoTargetServiceClient = GeoTargetServiceClient.create()) {
GeoTargetName name = GeoTargetName.of("[NETWORK_CODE]", "[GEO_TARGET]");
GeoTarget response = geoTargetServiceClient.getGeoTarget(name);
}
Note: close() needs to be called on the GeoTargetServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
Method | Description | Method Variants |
---|---|---|
GetGeoTarget |
API to retrieve a |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListGeoTargets |
API to retrieve a list of |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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 GeoTargetServiceSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
GeoTargetServiceSettings geoTargetServiceSettings =
GeoTargetServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
GeoTargetServiceClient geoTargetServiceClient =
GeoTargetServiceClient.create(geoTargetServiceSettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
GeoTargetServiceSettings geoTargetServiceSettings =
GeoTargetServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
GeoTargetServiceClient geoTargetServiceClient =
GeoTargetServiceClient.create(geoTargetServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Static Methods
create()
public static final GeoTargetServiceClient create()
Constructs an instance of GeoTargetServiceClient with default settings.
Returns | |
---|---|
Type | Description |
GeoTargetServiceClient |
Exceptions | |
---|---|
Type | Description |
IOException |
create(GeoTargetServiceSettings settings)
public static final GeoTargetServiceClient create(GeoTargetServiceSettings settings)
Constructs an instance of GeoTargetServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
Parameter | |
---|---|
Name | Description |
settings |
GeoTargetServiceSettings |
Returns | |
---|---|
Type | Description |
GeoTargetServiceClient |
Exceptions | |
---|---|
Type | Description |
IOException |
create(GeoTargetServiceStub stub)
public static final GeoTargetServiceClient create(GeoTargetServiceStub stub)
Constructs an instance of GeoTargetServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(GeoTargetServiceSettings).
Parameter | |
---|---|
Name | Description |
stub |
GeoTargetServiceStub |
Returns | |
---|---|
Type | Description |
GeoTargetServiceClient |
Constructors
GeoTargetServiceClient(GeoTargetServiceSettings settings)
protected GeoTargetServiceClient(GeoTargetServiceSettings settings)
Constructs an instance of GeoTargetServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
Parameter | |
---|---|
Name | Description |
settings |
GeoTargetServiceSettings |
GeoTargetServiceClient(GeoTargetServiceStub stub)
protected GeoTargetServiceClient(GeoTargetServiceStub stub)
Parameter | |
---|---|
Name | Description |
stub |
GeoTargetServiceStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Parameters | |
---|---|
Name | Description |
duration |
long |
unit |
TimeUnit |
Returns | |
---|---|
Type | Description |
boolean |
Exceptions | |
---|---|
Type | Description |
InterruptedException |
close()
public final void close()
getGeoTarget(GeoTargetName name)
public final GeoTarget getGeoTarget(GeoTargetName name)
API to retrieve a GeoTarget
object.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GeoTargetServiceClient geoTargetServiceClient = GeoTargetServiceClient.create()) {
GeoTargetName name = GeoTargetName.of("[NETWORK_CODE]", "[GEO_TARGET]");
GeoTarget response = geoTargetServiceClient.getGeoTarget(name);
}
Parameter | |
---|---|
Name | Description |
name |
GeoTargetName Required. The resource name of the GeoTarget. Format:
|
Returns | |
---|---|
Type | Description |
GeoTarget |
getGeoTarget(GetGeoTargetRequest request)
public final GeoTarget getGeoTarget(GetGeoTargetRequest request)
API to retrieve a GeoTarget
object.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GeoTargetServiceClient geoTargetServiceClient = GeoTargetServiceClient.create()) {
GetGeoTargetRequest request =
GetGeoTargetRequest.newBuilder()
.setName(GeoTargetName.of("[NETWORK_CODE]", "[GEO_TARGET]").toString())
.build();
GeoTarget response = geoTargetServiceClient.getGeoTarget(request);
}
Parameter | |
---|---|
Name | Description |
request |
GetGeoTargetRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
GeoTarget |
getGeoTarget(String name)
public final GeoTarget getGeoTarget(String name)
API to retrieve a GeoTarget
object.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GeoTargetServiceClient geoTargetServiceClient = GeoTargetServiceClient.create()) {
String name = GeoTargetName.of("[NETWORK_CODE]", "[GEO_TARGET]").toString();
GeoTarget response = geoTargetServiceClient.getGeoTarget(name);
}
Parameter | |
---|---|
Name | Description |
name |
String Required. The resource name of the GeoTarget. Format:
|
Returns | |
---|---|
Type | Description |
GeoTarget |
getGeoTargetCallable()
public final UnaryCallable<GetGeoTargetRequest,GeoTarget> getGeoTargetCallable()
API to retrieve a GeoTarget
object.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GeoTargetServiceClient geoTargetServiceClient = GeoTargetServiceClient.create()) {
GetGeoTargetRequest request =
GetGeoTargetRequest.newBuilder()
.setName(GeoTargetName.of("[NETWORK_CODE]", "[GEO_TARGET]").toString())
.build();
ApiFuture<GeoTarget> future =
geoTargetServiceClient.getGeoTargetCallable().futureCall(request);
// Do something.
GeoTarget response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<GetGeoTargetRequest,GeoTarget> |
getSettings()
public final GeoTargetServiceSettings getSettings()
Returns | |
---|---|
Type | Description |
GeoTargetServiceSettings |
getStub()
public GeoTargetServiceStub getStub()
Returns | |
---|---|
Type | Description |
GeoTargetServiceStub |
isShutdown()
public boolean isShutdown()
Returns | |
---|---|
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Returns | |
---|---|
Type | Description |
boolean |
listGeoTargets(ListGeoTargetsRequest request)
public final GeoTargetServiceClient.ListGeoTargetsPagedResponse listGeoTargets(ListGeoTargetsRequest request)
API to retrieve a list of GeoTarget
objects.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GeoTargetServiceClient geoTargetServiceClient = GeoTargetServiceClient.create()) {
ListGeoTargetsRequest request =
ListGeoTargetsRequest.newBuilder()
.setParent(NetworkName.of("[NETWORK_CODE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
for (GeoTarget element : geoTargetServiceClient.listGeoTargets(request).iterateAll()) {
// doThingsWith(element);
}
}
Parameter | |
---|---|
Name | Description |
request |
ListGeoTargetsRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
GeoTargetServiceClient.ListGeoTargetsPagedResponse |
listGeoTargets(NetworkName parent)
public final GeoTargetServiceClient.ListGeoTargetsPagedResponse listGeoTargets(NetworkName parent)
API to retrieve a list of GeoTarget
objects.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GeoTargetServiceClient geoTargetServiceClient = GeoTargetServiceClient.create()) {
NetworkName parent = NetworkName.of("[NETWORK_CODE]");
for (GeoTarget element : geoTargetServiceClient.listGeoTargets(parent).iterateAll()) {
// doThingsWith(element);
}
}
Parameter | |
---|---|
Name | Description |
parent |
NetworkName Required. The parent, which owns this collection of GeoTargets. Format:
|
Returns | |
---|---|
Type | Description |
GeoTargetServiceClient.ListGeoTargetsPagedResponse |
listGeoTargets(String parent)
public final GeoTargetServiceClient.ListGeoTargetsPagedResponse listGeoTargets(String parent)
API to retrieve a list of GeoTarget
objects.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GeoTargetServiceClient geoTargetServiceClient = GeoTargetServiceClient.create()) {
String parent = NetworkName.of("[NETWORK_CODE]").toString();
for (GeoTarget element : geoTargetServiceClient.listGeoTargets(parent).iterateAll()) {
// doThingsWith(element);
}
}
Parameter | |
---|---|
Name | Description |
parent |
String Required. The parent, which owns this collection of GeoTargets. Format:
|
Returns | |
---|---|
Type | Description |
GeoTargetServiceClient.ListGeoTargetsPagedResponse |
listGeoTargetsCallable()
public final UnaryCallable<ListGeoTargetsRequest,ListGeoTargetsResponse> listGeoTargetsCallable()
API to retrieve a list of GeoTarget
objects.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GeoTargetServiceClient geoTargetServiceClient = GeoTargetServiceClient.create()) {
ListGeoTargetsRequest request =
ListGeoTargetsRequest.newBuilder()
.setParent(NetworkName.of("[NETWORK_CODE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
while (true) {
ListGeoTargetsResponse response =
geoTargetServiceClient.listGeoTargetsCallable().call(request);
for (GeoTarget element : response.getGeoTargetsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Returns | |
---|---|
Type | Description |
UnaryCallable<ListGeoTargetsRequest,ListGeoTargetsResponse> |
listGeoTargetsPagedCallable()
public final UnaryCallable<ListGeoTargetsRequest,GeoTargetServiceClient.ListGeoTargetsPagedResponse> listGeoTargetsPagedCallable()
API to retrieve a list of GeoTarget
objects.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GeoTargetServiceClient geoTargetServiceClient = GeoTargetServiceClient.create()) {
ListGeoTargetsRequest request =
ListGeoTargetsRequest.newBuilder()
.setParent(NetworkName.of("[NETWORK_CODE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
ApiFuture<GeoTarget> future =
geoTargetServiceClient.listGeoTargetsPagedCallable().futureCall(request);
// Do something.
for (GeoTarget element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Returns | |
---|---|
Type | Description |
UnaryCallable<ListGeoTargetsRequest,ListGeoTargetsPagedResponse> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()