| GitHub Repository | Product Reference |
Service Description: Provides methods for handling SuggestedAdUnit 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 (SuggestedAdUnitServiceClient suggestedAdUnitServiceClient =
SuggestedAdUnitServiceClient.create()) {
SuggestedAdUnitName name = SuggestedAdUnitName.of("[NETWORK_CODE]", "[SUGGESTED_AD_UNIT]");
SuggestedAdUnit response = suggestedAdUnitServiceClient.getSuggestedAdUnit(name);
}
Note: close() needs to be called on the SuggestedAdUnitServiceClient 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 |
|---|---|---|
GetSuggestedAdUnit |
Get 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.
|
ListSuggestedAdUnits |
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.
|
BatchApproveSuggestedAdUnits |
Bulk approve |
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 SuggestedAdUnitServiceSettings 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
SuggestedAdUnitServiceSettings suggestedAdUnitServiceSettings =
SuggestedAdUnitServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
SuggestedAdUnitServiceClient suggestedAdUnitServiceClient =
SuggestedAdUnitServiceClient.create(suggestedAdUnitServiceSettings);
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
SuggestedAdUnitServiceSettings suggestedAdUnitServiceSettings =
SuggestedAdUnitServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
SuggestedAdUnitServiceClient suggestedAdUnitServiceClient =
SuggestedAdUnitServiceClient.create(suggestedAdUnitServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Static Methods
create()
public static final SuggestedAdUnitServiceClient create()Constructs an instance of SuggestedAdUnitServiceClient with default settings.
| Returns | |
|---|---|
| Type | Description |
SuggestedAdUnitServiceClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(SuggestedAdUnitServiceSettings settings)
public static final SuggestedAdUnitServiceClient create(SuggestedAdUnitServiceSettings settings)Constructs an instance of SuggestedAdUnitServiceClient, 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 |
SuggestedAdUnitServiceSettings |
| Returns | |
|---|---|
| Type | Description |
SuggestedAdUnitServiceClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(SuggestedAdUnitServiceStub stub)
public static final SuggestedAdUnitServiceClient create(SuggestedAdUnitServiceStub stub)Constructs an instance of SuggestedAdUnitServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(SuggestedAdUnitServiceSettings).
| Parameter | |
|---|---|
| Name | Description |
stub |
SuggestedAdUnitServiceStub |
| Returns | |
|---|---|
| Type | Description |
SuggestedAdUnitServiceClient |
|
Constructors
SuggestedAdUnitServiceClient(SuggestedAdUnitServiceSettings settings)
protected SuggestedAdUnitServiceClient(SuggestedAdUnitServiceSettings settings)Constructs an instance of SuggestedAdUnitServiceClient, 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 |
SuggestedAdUnitServiceSettings |
SuggestedAdUnitServiceClient(SuggestedAdUnitServiceStub stub)
protected SuggestedAdUnitServiceClient(SuggestedAdUnitServiceStub stub)| Parameter | |
|---|---|
| Name | Description |
stub |
SuggestedAdUnitServiceStub |
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 |
|
batchApproveSuggestedAdUnits(@Nullable NetworkName parent, List<String> names)
public final BatchApproveSuggestedAdUnitsResponse batchApproveSuggestedAdUnits(@Nullable NetworkName parent, List<String> names)Bulk approve SuggestedAdUnit 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 (SuggestedAdUnitServiceClient suggestedAdUnitServiceClient =
SuggestedAdUnitServiceClient.create()) {
NetworkName parent = NetworkName.of("[NETWORK_CODE]");
List<String> names = new ArrayList<>();
BatchApproveSuggestedAdUnitsResponse response =
suggestedAdUnitServiceClient.batchApproveSuggestedAdUnits(parent, names);
}
| Parameters | |
|---|---|
| Name | Description |
parent |
@org.jspecify.annotations.Nullable com.google.ads.admanager.v1.NetworkNameRequired. Format: |
names |
List<String>Required. Resource names for the |
| Returns | |
|---|---|
| Type | Description |
BatchApproveSuggestedAdUnitsResponse |
|
batchApproveSuggestedAdUnits(BatchApproveSuggestedAdUnitsRequest request)
public final BatchApproveSuggestedAdUnitsResponse batchApproveSuggestedAdUnits(BatchApproveSuggestedAdUnitsRequest request)Bulk approve SuggestedAdUnit 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 (SuggestedAdUnitServiceClient suggestedAdUnitServiceClient =
SuggestedAdUnitServiceClient.create()) {
BatchApproveSuggestedAdUnitsRequest request =
BatchApproveSuggestedAdUnitsRequest.newBuilder()
.setParent(NetworkName.of("[NETWORK_CODE]").toString())
.addAllNames(new ArrayList<String>())
.build();
BatchApproveSuggestedAdUnitsResponse response =
suggestedAdUnitServiceClient.batchApproveSuggestedAdUnits(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
BatchApproveSuggestedAdUnitsRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
BatchApproveSuggestedAdUnitsResponse |
|
batchApproveSuggestedAdUnits(String parent, List<String> names)
public final BatchApproveSuggestedAdUnitsResponse batchApproveSuggestedAdUnits(String parent, List<String> names)Bulk approve SuggestedAdUnit 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 (SuggestedAdUnitServiceClient suggestedAdUnitServiceClient =
SuggestedAdUnitServiceClient.create()) {
String parent = NetworkName.of("[NETWORK_CODE]").toString();
List<String> names = new ArrayList<>();
BatchApproveSuggestedAdUnitsResponse response =
suggestedAdUnitServiceClient.batchApproveSuggestedAdUnits(parent, names);
}
| Parameters | |
|---|---|
| Name | Description |
parent |
StringRequired. Format: |
names |
List<String>Required. Resource names for the |
| Returns | |
|---|---|
| Type | Description |
BatchApproveSuggestedAdUnitsResponse |
|
batchApproveSuggestedAdUnitsCallable()
public final UnaryCallable<BatchApproveSuggestedAdUnitsRequest,BatchApproveSuggestedAdUnitsResponse> batchApproveSuggestedAdUnitsCallable()Bulk approve SuggestedAdUnit 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 (SuggestedAdUnitServiceClient suggestedAdUnitServiceClient =
SuggestedAdUnitServiceClient.create()) {
BatchApproveSuggestedAdUnitsRequest request =
BatchApproveSuggestedAdUnitsRequest.newBuilder()
.setParent(NetworkName.of("[NETWORK_CODE]").toString())
.addAllNames(new ArrayList<String>())
.build();
ApiFuture<BatchApproveSuggestedAdUnitsResponse> future =
suggestedAdUnitServiceClient.batchApproveSuggestedAdUnitsCallable().futureCall(request);
// Do something.
BatchApproveSuggestedAdUnitsResponse response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<BatchApproveSuggestedAdUnitsRequest,BatchApproveSuggestedAdUnitsResponse> |
|
close()
public final void close()getSettings()
public final @Nullable SuggestedAdUnitServiceSettings getSettings()| Returns | |
|---|---|
| Type | Description |
@org.jspecify.annotations.Nullable com.google.ads.admanager.v1.SuggestedAdUnitServiceSettings |
|
getStub()
public SuggestedAdUnitServiceStub getStub()| Returns | |
|---|---|
| Type | Description |
SuggestedAdUnitServiceStub |
|
getSuggestedAdUnit(@Nullable SuggestedAdUnitName name)
public final SuggestedAdUnit getSuggestedAdUnit(@Nullable SuggestedAdUnitName name)Get a SuggestedAdUnit 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 (SuggestedAdUnitServiceClient suggestedAdUnitServiceClient =
SuggestedAdUnitServiceClient.create()) {
SuggestedAdUnitName name = SuggestedAdUnitName.of("[NETWORK_CODE]", "[SUGGESTED_AD_UNIT]");
SuggestedAdUnit response = suggestedAdUnitServiceClient.getSuggestedAdUnit(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
@org.jspecify.annotations.Nullable com.google.ads.admanager.v1.SuggestedAdUnitNameRequired. The resource name of the |
| Returns | |
|---|---|
| Type | Description |
SuggestedAdUnit |
|
getSuggestedAdUnit(GetSuggestedAdUnitRequest request)
public final SuggestedAdUnit getSuggestedAdUnit(GetSuggestedAdUnitRequest request)Get a SuggestedAdUnit 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 (SuggestedAdUnitServiceClient suggestedAdUnitServiceClient =
SuggestedAdUnitServiceClient.create()) {
GetSuggestedAdUnitRequest request =
GetSuggestedAdUnitRequest.newBuilder()
.setName(SuggestedAdUnitName.of("[NETWORK_CODE]", "[SUGGESTED_AD_UNIT]").toString())
.build();
SuggestedAdUnit response = suggestedAdUnitServiceClient.getSuggestedAdUnit(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
GetSuggestedAdUnitRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
SuggestedAdUnit |
|
getSuggestedAdUnit(String name)
public final SuggestedAdUnit getSuggestedAdUnit(String name)Get a SuggestedAdUnit 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 (SuggestedAdUnitServiceClient suggestedAdUnitServiceClient =
SuggestedAdUnitServiceClient.create()) {
String name = SuggestedAdUnitName.of("[NETWORK_CODE]", "[SUGGESTED_AD_UNIT]").toString();
SuggestedAdUnit response = suggestedAdUnitServiceClient.getSuggestedAdUnit(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
StringRequired. The resource name of the |
| Returns | |
|---|---|
| Type | Description |
SuggestedAdUnit |
|
getSuggestedAdUnitCallable()
public final UnaryCallable<GetSuggestedAdUnitRequest,SuggestedAdUnit> getSuggestedAdUnitCallable()Get a SuggestedAdUnit 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 (SuggestedAdUnitServiceClient suggestedAdUnitServiceClient =
SuggestedAdUnitServiceClient.create()) {
GetSuggestedAdUnitRequest request =
GetSuggestedAdUnitRequest.newBuilder()
.setName(SuggestedAdUnitName.of("[NETWORK_CODE]", "[SUGGESTED_AD_UNIT]").toString())
.build();
ApiFuture<SuggestedAdUnit> future =
suggestedAdUnitServiceClient.getSuggestedAdUnitCallable().futureCall(request);
// Do something.
SuggestedAdUnit response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<GetSuggestedAdUnitRequest,SuggestedAdUnit> |
|
isShutdown()
public boolean isShutdown()| Returns | |
|---|---|
| Type | Description |
boolean |
|
isTerminated()
public boolean isTerminated()| Returns | |
|---|---|
| Type | Description |
boolean |
|
listSuggestedAdUnits(@Nullable NetworkName parent)
public final SuggestedAdUnitServiceClient.ListSuggestedAdUnitsPagedResponse listSuggestedAdUnits(@Nullable NetworkName parent)Retrieve a list of SuggestedAdUnit 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 (SuggestedAdUnitServiceClient suggestedAdUnitServiceClient =
SuggestedAdUnitServiceClient.create()) {
NetworkName parent = NetworkName.of("[NETWORK_CODE]");
for (SuggestedAdUnit element :
suggestedAdUnitServiceClient.listSuggestedAdUnits(parent).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
parent |
@org.jspecify.annotations.Nullable com.google.ads.admanager.v1.NetworkNameRequired. The parent, which owns this collection of SuggestedAdUnits. Format:
|
| Returns | |
|---|---|
| Type | Description |
SuggestedAdUnitServiceClient.ListSuggestedAdUnitsPagedResponse |
|
listSuggestedAdUnits(ListSuggestedAdUnitsRequest request)
public final SuggestedAdUnitServiceClient.ListSuggestedAdUnitsPagedResponse listSuggestedAdUnits(ListSuggestedAdUnitsRequest request)Retrieve a list of SuggestedAdUnit 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 (SuggestedAdUnitServiceClient suggestedAdUnitServiceClient =
SuggestedAdUnitServiceClient.create()) {
ListSuggestedAdUnitsRequest request =
ListSuggestedAdUnitsRequest.newBuilder()
.setParent(NetworkName.of("[NETWORK_CODE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
for (SuggestedAdUnit element :
suggestedAdUnitServiceClient.listSuggestedAdUnits(request).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
request |
ListSuggestedAdUnitsRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
SuggestedAdUnitServiceClient.ListSuggestedAdUnitsPagedResponse |
|
listSuggestedAdUnits(String parent)
public final SuggestedAdUnitServiceClient.ListSuggestedAdUnitsPagedResponse listSuggestedAdUnits(String parent)Retrieve a list of SuggestedAdUnit 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 (SuggestedAdUnitServiceClient suggestedAdUnitServiceClient =
SuggestedAdUnitServiceClient.create()) {
String parent = NetworkName.of("[NETWORK_CODE]").toString();
for (SuggestedAdUnit element :
suggestedAdUnitServiceClient.listSuggestedAdUnits(parent).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
parent |
StringRequired. The parent, which owns this collection of SuggestedAdUnits. Format:
|
| Returns | |
|---|---|
| Type | Description |
SuggestedAdUnitServiceClient.ListSuggestedAdUnitsPagedResponse |
|
listSuggestedAdUnitsCallable()
public final UnaryCallable<ListSuggestedAdUnitsRequest,ListSuggestedAdUnitsResponse> listSuggestedAdUnitsCallable()Retrieve a list of SuggestedAdUnit 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 (SuggestedAdUnitServiceClient suggestedAdUnitServiceClient =
SuggestedAdUnitServiceClient.create()) {
ListSuggestedAdUnitsRequest request =
ListSuggestedAdUnitsRequest.newBuilder()
.setParent(NetworkName.of("[NETWORK_CODE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
while (true) {
ListSuggestedAdUnitsResponse response =
suggestedAdUnitServiceClient.listSuggestedAdUnitsCallable().call(request);
for (SuggestedAdUnit element : response.getSuggestedAdUnitsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListSuggestedAdUnitsRequest,ListSuggestedAdUnitsResponse> |
|
listSuggestedAdUnitsPagedCallable()
public final UnaryCallable<ListSuggestedAdUnitsRequest,SuggestedAdUnitServiceClient.ListSuggestedAdUnitsPagedResponse> listSuggestedAdUnitsPagedCallable()Retrieve a list of SuggestedAdUnit 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 (SuggestedAdUnitServiceClient suggestedAdUnitServiceClient =
SuggestedAdUnitServiceClient.create()) {
ListSuggestedAdUnitsRequest request =
ListSuggestedAdUnitsRequest.newBuilder()
.setParent(NetworkName.of("[NETWORK_CODE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
ApiFuture<SuggestedAdUnit> future =
suggestedAdUnitServiceClient.listSuggestedAdUnitsPagedCallable().futureCall(request);
// Do something.
for (SuggestedAdUnit element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListSuggestedAdUnitsRequest,ListSuggestedAdUnitsPagedResponse> |
|
shutdown()
public void shutdown()shutdownNow()
public void shutdownNow()