Class ChangeEventServiceClient (0.62.0)

GitHub RepositoryProduct Reference

Service Description: Provides methods for handling ChangeEvent 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 (ChangeEventServiceClient changeEventServiceClient = ChangeEventServiceClient.create()) {
   ChangeEventName name = ChangeEventName.of("[NETWORK_CODE]", "[CHANGE_EVENT]");
   ChangeEvent response = changeEventServiceClient.getChangeEvent(name);
 }
 

Note: close() needs to be called on the ChangeEventServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

Methods
Method Description Method Variants

GetChangeEvent

Retrieves a ChangeEvent object.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getChangeEvent(GetChangeEventRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getChangeEvent(ChangeEventName name)

  • getChangeEvent(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getChangeEventCallable()

ListChangeEvents

Lists ChangeEvent objects.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listChangeEvents(ListChangeEventsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listChangeEvents(NetworkName parent)

  • listChangeEvents(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listChangeEventsPagedCallable()

  • listChangeEventsCallable()

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 ChangeEventServiceSettings 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
 ChangeEventServiceSettings changeEventServiceSettings =
     ChangeEventServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 ChangeEventServiceClient changeEventServiceClient =
     ChangeEventServiceClient.create(changeEventServiceSettings);
 

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
 ChangeEventServiceSettings changeEventServiceSettings =
     ChangeEventServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 ChangeEventServiceClient changeEventServiceClient =
     ChangeEventServiceClient.create(changeEventServiceSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > ChangeEventServiceClient

Static Methods

create()

public static final ChangeEventServiceClient create()

Constructs an instance of ChangeEventServiceClient with default settings.

Returns
Type Description
ChangeEventServiceClient
Exceptions
Type Description
IOException

create(ChangeEventServiceSettings settings)

public static final ChangeEventServiceClient create(ChangeEventServiceSettings settings)

Constructs an instance of ChangeEventServiceClient, 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 ChangeEventServiceSettings
Returns
Type Description
ChangeEventServiceClient
Exceptions
Type Description
IOException

create(ChangeEventServiceStub stub)

public static final ChangeEventServiceClient create(ChangeEventServiceStub stub)

Constructs an instance of ChangeEventServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(ChangeEventServiceSettings).

Parameter
Name Description
stub ChangeEventServiceStub
Returns
Type Description
ChangeEventServiceClient

Constructors

ChangeEventServiceClient(ChangeEventServiceSettings settings)

protected ChangeEventServiceClient(ChangeEventServiceSettings settings)

Constructs an instance of ChangeEventServiceClient, 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 ChangeEventServiceSettings

ChangeEventServiceClient(ChangeEventServiceStub stub)

protected ChangeEventServiceClient(ChangeEventServiceStub stub)
Parameter
Name Description
stub ChangeEventServiceStub

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()

getChangeEvent(@Nullable ChangeEventName name)

public final ChangeEvent getChangeEvent(@Nullable ChangeEventName name)

Retrieves a ChangeEvent 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 (ChangeEventServiceClient changeEventServiceClient = ChangeEventServiceClient.create()) {
   ChangeEventName name = ChangeEventName.of("[NETWORK_CODE]", "[CHANGE_EVENT]");
   ChangeEvent response = changeEventServiceClient.getChangeEvent(name);
 }
 
Parameter
Name Description
name @org.jspecify.annotations.Nullable com.google.ads.admanager.v1.ChangeEventName

Required. The resource name of the ChangeEvent. Format: networks/{network_code}/changeEvents/{change_event_id}

Returns
Type Description
ChangeEvent

getChangeEvent(GetChangeEventRequest request)

public final ChangeEvent getChangeEvent(GetChangeEventRequest request)

Retrieves a ChangeEvent 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 (ChangeEventServiceClient changeEventServiceClient = ChangeEventServiceClient.create()) {
   GetChangeEventRequest request =
       GetChangeEventRequest.newBuilder()
           .setName(ChangeEventName.of("[NETWORK_CODE]", "[CHANGE_EVENT]").toString())
           .build();
   ChangeEvent response = changeEventServiceClient.getChangeEvent(request);
 }
 
Parameter
Name Description
request GetChangeEventRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
ChangeEvent

getChangeEvent(String name)

public final ChangeEvent getChangeEvent(String name)

Retrieves a ChangeEvent 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 (ChangeEventServiceClient changeEventServiceClient = ChangeEventServiceClient.create()) {
   String name = ChangeEventName.of("[NETWORK_CODE]", "[CHANGE_EVENT]").toString();
   ChangeEvent response = changeEventServiceClient.getChangeEvent(name);
 }
 
Parameter
Name Description
name String

Required. The resource name of the ChangeEvent. Format: networks/{network_code}/changeEvents/{change_event_id}

Returns
Type Description
ChangeEvent

getChangeEventCallable()

public final UnaryCallable<GetChangeEventRequest,ChangeEvent> getChangeEventCallable()

Retrieves a ChangeEvent 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 (ChangeEventServiceClient changeEventServiceClient = ChangeEventServiceClient.create()) {
   GetChangeEventRequest request =
       GetChangeEventRequest.newBuilder()
           .setName(ChangeEventName.of("[NETWORK_CODE]", "[CHANGE_EVENT]").toString())
           .build();
   ApiFuture<ChangeEvent> future =
       changeEventServiceClient.getChangeEventCallable().futureCall(request);
   // Do something.
   ChangeEvent response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetChangeEventRequest,ChangeEvent>

getSettings()

public final @Nullable ChangeEventServiceSettings getSettings()
Returns
Type Description
@org.jspecify.annotations.Nullable com.google.ads.admanager.v1.ChangeEventServiceSettings

getStub()

public ChangeEventServiceStub getStub()
Returns
Type Description
ChangeEventServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listChangeEvents(@Nullable NetworkName parent)

public final ChangeEventServiceClient.ListChangeEventsPagedResponse listChangeEvents(@Nullable NetworkName parent)

Lists ChangeEvent 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 (ChangeEventServiceClient changeEventServiceClient = ChangeEventServiceClient.create()) {
   NetworkName parent = NetworkName.of("[NETWORK_CODE]");
   for (ChangeEvent element : changeEventServiceClient.listChangeEvents(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent @org.jspecify.annotations.Nullable com.google.ads.admanager.v1.NetworkName

Required. The parent, which owns this collection of ChangeEvents. Format: networks/{network_code}

Returns
Type Description
ChangeEventServiceClient.ListChangeEventsPagedResponse

listChangeEvents(ListChangeEventsRequest request)

public final ChangeEventServiceClient.ListChangeEventsPagedResponse listChangeEvents(ListChangeEventsRequest request)

Lists ChangeEvent 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 (ChangeEventServiceClient changeEventServiceClient = ChangeEventServiceClient.create()) {
   ListChangeEventsRequest request =
       ListChangeEventsRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   for (ChangeEvent element : changeEventServiceClient.listChangeEvents(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListChangeEventsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
ChangeEventServiceClient.ListChangeEventsPagedResponse

listChangeEvents(String parent)

public final ChangeEventServiceClient.ListChangeEventsPagedResponse listChangeEvents(String parent)

Lists ChangeEvent 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 (ChangeEventServiceClient changeEventServiceClient = ChangeEventServiceClient.create()) {
   String parent = NetworkName.of("[NETWORK_CODE]").toString();
   for (ChangeEvent element : changeEventServiceClient.listChangeEvents(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. The parent, which owns this collection of ChangeEvents. Format: networks/{network_code}

Returns
Type Description
ChangeEventServiceClient.ListChangeEventsPagedResponse

listChangeEventsCallable()

public final UnaryCallable<ListChangeEventsRequest,ListChangeEventsResponse> listChangeEventsCallable()

Lists ChangeEvent 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 (ChangeEventServiceClient changeEventServiceClient = ChangeEventServiceClient.create()) {
   ListChangeEventsRequest request =
       ListChangeEventsRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   while (true) {
     ListChangeEventsResponse response =
         changeEventServiceClient.listChangeEventsCallable().call(request);
     for (ChangeEvent element : response.getChangeEventsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListChangeEventsRequest,ListChangeEventsResponse>

listChangeEventsPagedCallable()

public final UnaryCallable<ListChangeEventsRequest,ChangeEventServiceClient.ListChangeEventsPagedResponse> listChangeEventsPagedCallable()

Lists ChangeEvent 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 (ChangeEventServiceClient changeEventServiceClient = ChangeEventServiceClient.create()) {
   ListChangeEventsRequest request =
       ListChangeEventsRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   ApiFuture<ChangeEvent> future =
       changeEventServiceClient.listChangeEventsPagedCallable().futureCall(request);
   // Do something.
   for (ChangeEvent element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListChangeEventsRequest,ListChangeEventsPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()