| GitHub Repository | Product Reference |
Service Description: Provides methods for handling AudienceSegment 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 (AudienceSegmentServiceClient audienceSegmentServiceClient =
AudienceSegmentServiceClient.create()) {
AudienceSegmentName name = AudienceSegmentName.of("[NETWORK_CODE]", "[AUDIENCE_SEGMENT]");
AudienceSegment response = audienceSegmentServiceClient.getAudienceSegment(name);
}
Note: close() needs to be called on the AudienceSegmentServiceClient 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 |
|---|---|---|
GetAudienceSegment |
API to retrieve an |
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.
|
ListAudienceSegments |
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 AudienceSegmentServiceSettings 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
AudienceSegmentServiceSettings audienceSegmentServiceSettings =
AudienceSegmentServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
AudienceSegmentServiceClient audienceSegmentServiceClient =
AudienceSegmentServiceClient.create(audienceSegmentServiceSettings);
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
AudienceSegmentServiceSettings audienceSegmentServiceSettings =
AudienceSegmentServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
AudienceSegmentServiceClient audienceSegmentServiceClient =
AudienceSegmentServiceClient.create(audienceSegmentServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Static Methods
create()
public static final AudienceSegmentServiceClient create()Constructs an instance of AudienceSegmentServiceClient with default settings.
| Returns | |
|---|---|
| Type | Description |
AudienceSegmentServiceClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(AudienceSegmentServiceSettings settings)
public static final AudienceSegmentServiceClient create(AudienceSegmentServiceSettings settings)Constructs an instance of AudienceSegmentServiceClient, 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 |
AudienceSegmentServiceSettings |
| Returns | |
|---|---|
| Type | Description |
AudienceSegmentServiceClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(AudienceSegmentServiceStub stub)
public static final AudienceSegmentServiceClient create(AudienceSegmentServiceStub stub)Constructs an instance of AudienceSegmentServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(AudienceSegmentServiceSettings).
| Parameter | |
|---|---|
| Name | Description |
stub |
AudienceSegmentServiceStub |
| Returns | |
|---|---|
| Type | Description |
AudienceSegmentServiceClient |
|
Constructors
AudienceSegmentServiceClient(AudienceSegmentServiceSettings settings)
protected AudienceSegmentServiceClient(AudienceSegmentServiceSettings settings)Constructs an instance of AudienceSegmentServiceClient, 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 |
AudienceSegmentServiceSettings |
AudienceSegmentServiceClient(AudienceSegmentServiceStub stub)
protected AudienceSegmentServiceClient(AudienceSegmentServiceStub stub)| Parameter | |
|---|---|
| Name | Description |
stub |
AudienceSegmentServiceStub |
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()getAudienceSegment(AudienceSegmentName name)
public final AudienceSegment getAudienceSegment(AudienceSegmentName name)API to retrieve an AudienceSegment 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 (AudienceSegmentServiceClient audienceSegmentServiceClient =
AudienceSegmentServiceClient.create()) {
AudienceSegmentName name = AudienceSegmentName.of("[NETWORK_CODE]", "[AUDIENCE_SEGMENT]");
AudienceSegment response = audienceSegmentServiceClient.getAudienceSegment(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
AudienceSegmentNameRequired. The resource name of the AudienceSegment. Format:
|
| Returns | |
|---|---|
| Type | Description |
AudienceSegment |
|
getAudienceSegment(GetAudienceSegmentRequest request)
public final AudienceSegment getAudienceSegment(GetAudienceSegmentRequest request)API to retrieve an AudienceSegment 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 (AudienceSegmentServiceClient audienceSegmentServiceClient =
AudienceSegmentServiceClient.create()) {
GetAudienceSegmentRequest request =
GetAudienceSegmentRequest.newBuilder()
.setName(AudienceSegmentName.of("[NETWORK_CODE]", "[AUDIENCE_SEGMENT]").toString())
.build();
AudienceSegment response = audienceSegmentServiceClient.getAudienceSegment(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
GetAudienceSegmentRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
AudienceSegment |
|
getAudienceSegment(String name)
public final AudienceSegment getAudienceSegment(String name)API to retrieve an AudienceSegment 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 (AudienceSegmentServiceClient audienceSegmentServiceClient =
AudienceSegmentServiceClient.create()) {
String name = AudienceSegmentName.of("[NETWORK_CODE]", "[AUDIENCE_SEGMENT]").toString();
AudienceSegment response = audienceSegmentServiceClient.getAudienceSegment(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
StringRequired. The resource name of the AudienceSegment. Format:
|
| Returns | |
|---|---|
| Type | Description |
AudienceSegment |
|
getAudienceSegmentCallable()
public final UnaryCallable<GetAudienceSegmentRequest,AudienceSegment> getAudienceSegmentCallable()API to retrieve an AudienceSegment 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 (AudienceSegmentServiceClient audienceSegmentServiceClient =
AudienceSegmentServiceClient.create()) {
GetAudienceSegmentRequest request =
GetAudienceSegmentRequest.newBuilder()
.setName(AudienceSegmentName.of("[NETWORK_CODE]", "[AUDIENCE_SEGMENT]").toString())
.build();
ApiFuture<AudienceSegment> future =
audienceSegmentServiceClient.getAudienceSegmentCallable().futureCall(request);
// Do something.
AudienceSegment response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<GetAudienceSegmentRequest,AudienceSegment> |
|
getSettings()
public final AudienceSegmentServiceSettings getSettings()| Returns | |
|---|---|
| Type | Description |
AudienceSegmentServiceSettings |
|
getStub()
public AudienceSegmentServiceStub getStub()| Returns | |
|---|---|
| Type | Description |
AudienceSegmentServiceStub |
|
isShutdown()
public boolean isShutdown()| Returns | |
|---|---|
| Type | Description |
boolean |
|
isTerminated()
public boolean isTerminated()| Returns | |
|---|---|
| Type | Description |
boolean |
|
listAudienceSegments(ListAudienceSegmentsRequest request)
public final AudienceSegmentServiceClient.ListAudienceSegmentsPagedResponse listAudienceSegments(ListAudienceSegmentsRequest request)API to retrieve a list of AudienceSegment 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 (AudienceSegmentServiceClient audienceSegmentServiceClient =
AudienceSegmentServiceClient.create()) {
ListAudienceSegmentsRequest request =
ListAudienceSegmentsRequest.newBuilder()
.setParent(NetworkName.of("[NETWORK_CODE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
for (AudienceSegment element :
audienceSegmentServiceClient.listAudienceSegments(request).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
request |
ListAudienceSegmentsRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
AudienceSegmentServiceClient.ListAudienceSegmentsPagedResponse |
|
listAudienceSegments(NetworkName parent)
public final AudienceSegmentServiceClient.ListAudienceSegmentsPagedResponse listAudienceSegments(NetworkName parent)API to retrieve a list of AudienceSegment 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 (AudienceSegmentServiceClient audienceSegmentServiceClient =
AudienceSegmentServiceClient.create()) {
NetworkName parent = NetworkName.of("[NETWORK_CODE]");
for (AudienceSegment element :
audienceSegmentServiceClient.listAudienceSegments(parent).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
parent |
NetworkNameRequired. The parent publisher network associated with these audience segments.
Format: |
| Returns | |
|---|---|
| Type | Description |
AudienceSegmentServiceClient.ListAudienceSegmentsPagedResponse |
|
listAudienceSegments(String parent)
public final AudienceSegmentServiceClient.ListAudienceSegmentsPagedResponse listAudienceSegments(String parent)API to retrieve a list of AudienceSegment 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 (AudienceSegmentServiceClient audienceSegmentServiceClient =
AudienceSegmentServiceClient.create()) {
String parent = NetworkName.of("[NETWORK_CODE]").toString();
for (AudienceSegment element :
audienceSegmentServiceClient.listAudienceSegments(parent).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
parent |
StringRequired. The parent publisher network associated with these audience segments.
Format: |
| Returns | |
|---|---|
| Type | Description |
AudienceSegmentServiceClient.ListAudienceSegmentsPagedResponse |
|
listAudienceSegmentsCallable()
public final UnaryCallable<ListAudienceSegmentsRequest,ListAudienceSegmentsResponse> listAudienceSegmentsCallable()API to retrieve a list of AudienceSegment 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 (AudienceSegmentServiceClient audienceSegmentServiceClient =
AudienceSegmentServiceClient.create()) {
ListAudienceSegmentsRequest request =
ListAudienceSegmentsRequest.newBuilder()
.setParent(NetworkName.of("[NETWORK_CODE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
while (true) {
ListAudienceSegmentsResponse response =
audienceSegmentServiceClient.listAudienceSegmentsCallable().call(request);
for (AudienceSegment element : response.getAudienceSegmentsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListAudienceSegmentsRequest,ListAudienceSegmentsResponse> |
|
listAudienceSegmentsPagedCallable()
public final UnaryCallable<ListAudienceSegmentsRequest,AudienceSegmentServiceClient.ListAudienceSegmentsPagedResponse> listAudienceSegmentsPagedCallable()API to retrieve a list of AudienceSegment 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 (AudienceSegmentServiceClient audienceSegmentServiceClient =
AudienceSegmentServiceClient.create()) {
ListAudienceSegmentsRequest request =
ListAudienceSegmentsRequest.newBuilder()
.setParent(NetworkName.of("[NETWORK_CODE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
ApiFuture<AudienceSegment> future =
audienceSegmentServiceClient.listAudienceSegmentsPagedCallable().futureCall(request);
// Do something.
for (AudienceSegment element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListAudienceSegmentsRequest,ListAudienceSegmentsPagedResponse> |
|
shutdown()
public void shutdown()shutdownNow()
public void shutdownNow()