GitHub Repository | Product Reference |
Service Description: Provides methods for handling Creative 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 (CreativeServiceClient creativeServiceClient = CreativeServiceClient.create()) {
CreativeName name = CreativeName.of("[NETWORK_CODE]", "[CREATIVE]");
Creative response = creativeServiceClient.getCreative(name);
}
Note: close() needs to be called on the CreativeServiceClient 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 |
---|---|---|
GetCreative |
API to retrieve a Creative object. |
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.
|
ListCreatives |
API to retrieve a list of Creative objects. |
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 CreativeServiceSettings 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
CreativeServiceSettings creativeServiceSettings =
CreativeServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
CreativeServiceClient creativeServiceClient =
CreativeServiceClient.create(creativeServiceSettings);
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
CreativeServiceSettings creativeServiceSettings =
CreativeServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
CreativeServiceClient creativeServiceClient =
CreativeServiceClient.create(creativeServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Static Methods
create()
public static final CreativeServiceClient create()
Constructs an instance of CreativeServiceClient with default settings.
Returns | |
---|---|
Type | Description |
CreativeServiceClient |
Exceptions | |
---|---|
Type | Description |
IOException |
create(CreativeServiceSettings settings)
public static final CreativeServiceClient create(CreativeServiceSettings settings)
Constructs an instance of CreativeServiceClient, 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 |
CreativeServiceSettings |
Returns | |
---|---|
Type | Description |
CreativeServiceClient |
Exceptions | |
---|---|
Type | Description |
IOException |
create(CreativeServiceStub stub)
public static final CreativeServiceClient create(CreativeServiceStub stub)
Constructs an instance of CreativeServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(CreativeServiceSettings).
Parameter | |
---|---|
Name | Description |
stub |
CreativeServiceStub |
Returns | |
---|---|
Type | Description |
CreativeServiceClient |
Constructors
CreativeServiceClient(CreativeServiceSettings settings)
protected CreativeServiceClient(CreativeServiceSettings settings)
Constructs an instance of CreativeServiceClient, 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 |
CreativeServiceSettings |
CreativeServiceClient(CreativeServiceStub stub)
protected CreativeServiceClient(CreativeServiceStub stub)
Parameter | |
---|---|
Name | Description |
stub |
CreativeServiceStub |
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()
getCreative(CreativeName name)
public final Creative getCreative(CreativeName name)
API to retrieve a Creative 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 (CreativeServiceClient creativeServiceClient = CreativeServiceClient.create()) {
CreativeName name = CreativeName.of("[NETWORK_CODE]", "[CREATIVE]");
Creative response = creativeServiceClient.getCreative(name);
}
Parameter | |
---|---|
Name | Description |
name |
CreativeName Required. The resource name of the Creative. Format:
|
Returns | |
---|---|
Type | Description |
Creative |
getCreative(GetCreativeRequest request)
public final Creative getCreative(GetCreativeRequest request)
API to retrieve a Creative 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 (CreativeServiceClient creativeServiceClient = CreativeServiceClient.create()) {
GetCreativeRequest request =
GetCreativeRequest.newBuilder()
.setName(CreativeName.of("[NETWORK_CODE]", "[CREATIVE]").toString())
.build();
Creative response = creativeServiceClient.getCreative(request);
}
Parameter | |
---|---|
Name | Description |
request |
GetCreativeRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
Creative |
getCreative(String name)
public final Creative getCreative(String name)
API to retrieve a Creative 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 (CreativeServiceClient creativeServiceClient = CreativeServiceClient.create()) {
String name = CreativeName.of("[NETWORK_CODE]", "[CREATIVE]").toString();
Creative response = creativeServiceClient.getCreative(name);
}
Parameter | |
---|---|
Name | Description |
name |
String Required. The resource name of the Creative. Format:
|
Returns | |
---|---|
Type | Description |
Creative |
getCreativeCallable()
public final UnaryCallable<GetCreativeRequest,Creative> getCreativeCallable()
API to retrieve a Creative 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 (CreativeServiceClient creativeServiceClient = CreativeServiceClient.create()) {
GetCreativeRequest request =
GetCreativeRequest.newBuilder()
.setName(CreativeName.of("[NETWORK_CODE]", "[CREATIVE]").toString())
.build();
ApiFuture<Creative> future = creativeServiceClient.getCreativeCallable().futureCall(request);
// Do something.
Creative response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<GetCreativeRequest,Creative> |
getSettings()
public final CreativeServiceSettings getSettings()
Returns | |
---|---|
Type | Description |
CreativeServiceSettings |
getStub()
public CreativeServiceStub getStub()
Returns | |
---|---|
Type | Description |
CreativeServiceStub |
isShutdown()
public boolean isShutdown()
Returns | |
---|---|
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Returns | |
---|---|
Type | Description |
boolean |
listCreatives(ListCreativesRequest request)
public final CreativeServiceClient.ListCreativesPagedResponse listCreatives(ListCreativesRequest request)
API to retrieve a list of Creative 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 (CreativeServiceClient creativeServiceClient = CreativeServiceClient.create()) {
ListCreativesRequest request =
ListCreativesRequest.newBuilder()
.setParent(NetworkName.of("[NETWORK_CODE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
for (Creative element : creativeServiceClient.listCreatives(request).iterateAll()) {
// doThingsWith(element);
}
}
Parameter | |
---|---|
Name | Description |
request |
ListCreativesRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
CreativeServiceClient.ListCreativesPagedResponse |
listCreatives(NetworkName parent)
public final CreativeServiceClient.ListCreativesPagedResponse listCreatives(NetworkName parent)
API to retrieve a list of Creative 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 (CreativeServiceClient creativeServiceClient = CreativeServiceClient.create()) {
NetworkName parent = NetworkName.of("[NETWORK_CODE]");
for (Creative element : creativeServiceClient.listCreatives(parent).iterateAll()) {
// doThingsWith(element);
}
}
Parameter | |
---|---|
Name | Description |
parent |
NetworkName Required. The parent, which owns this collection of Creatives. Format: networks/{network_code} |
Returns | |
---|---|
Type | Description |
CreativeServiceClient.ListCreativesPagedResponse |
listCreatives(String parent)
public final CreativeServiceClient.ListCreativesPagedResponse listCreatives(String parent)
API to retrieve a list of Creative 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 (CreativeServiceClient creativeServiceClient = CreativeServiceClient.create()) {
String parent = NetworkName.of("[NETWORK_CODE]").toString();
for (Creative element : creativeServiceClient.listCreatives(parent).iterateAll()) {
// doThingsWith(element);
}
}
Parameter | |
---|---|
Name | Description |
parent |
String Required. The parent, which owns this collection of Creatives. Format: networks/{network_code} |
Returns | |
---|---|
Type | Description |
CreativeServiceClient.ListCreativesPagedResponse |
listCreativesCallable()
public final UnaryCallable<ListCreativesRequest,ListCreativesResponse> listCreativesCallable()
API to retrieve a list of Creative 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 (CreativeServiceClient creativeServiceClient = CreativeServiceClient.create()) {
ListCreativesRequest request =
ListCreativesRequest.newBuilder()
.setParent(NetworkName.of("[NETWORK_CODE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
while (true) {
ListCreativesResponse response =
creativeServiceClient.listCreativesCallable().call(request);
for (Creative element : response.getCreativesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Returns | |
---|---|
Type | Description |
UnaryCallable<ListCreativesRequest,ListCreativesResponse> |
listCreativesPagedCallable()
public final UnaryCallable<ListCreativesRequest,CreativeServiceClient.ListCreativesPagedResponse> listCreativesPagedCallable()
API to retrieve a list of Creative 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 (CreativeServiceClient creativeServiceClient = CreativeServiceClient.create()) {
ListCreativesRequest request =
ListCreativesRequest.newBuilder()
.setParent(NetworkName.of("[NETWORK_CODE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
ApiFuture<Creative> future =
creativeServiceClient.listCreativesPagedCallable().futureCall(request);
// Do something.
for (Creative element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Returns | |
---|---|
Type | Description |
UnaryCallable<ListCreativesRequest,ListCreativesPagedResponse> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()