Class DataA2AServiceClient (0.27.0)

GitHub RepositoryProduct ReferenceRPC Documentation

Service Description: DataA2AService defines the Agent-to-Agent (A2A) protocol service for Gemini Data Analytics.

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 (DataA2AServiceClient dataA2AServiceClient = DataA2AServiceClient.create()) {
   String tenant = "tenant-877336406";
   A2AMessage message = A2AMessage.newBuilder().build();
   SendMessageResponse response = dataA2AServiceClient.sendMessage(tenant, message);
 }
 

Note: close() needs to be called on the DataA2AServiceClient 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

SendMessage

Send a message to the agent. This is a blocking call that will return the task once it is completed.

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

  • sendMessage(SendMessageRequest request)

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

  • sendMessage(String tenant, A2AMessage message)

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

  • sendMessageCallable()

SendStreamingMessage

SendStreamingMessage is a streaming call that will return a stream of task update events until the Task is in an interrupted or terminal state.

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

  • sendStreamingMessageCallable()

GetAgentCard

GetAgentCard returns the agent card for the agent.

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

  • getAgentCard(GetAgentCardRequest request)

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

  • getAgentCard(String tenant)

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

  • getAgentCardCallable()

ListLocations

Lists information about the supported locations for this service.

This method lists locations based on the resource scope provided inthe ListLocationsRequest.name field: ***Global locations**: If name is empty, the method lists thepublic locations available to all projects. * **Project-specificlocations**: If name follows the formatprojects/{project}, the method lists locations visible to thatspecific project. This includes public, private, or otherproject-specific locations enabled for the project.

For gRPC and client library implementations, the resource name ispassed as the name field. For direct service calls, the resourcename isincorporated into the request path based on the specific serviceimplementation and version.

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

  • listLocations(ListLocationsRequest request)

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

  • listLocationsPagedCallable()

  • listLocationsCallable()

GetLocation

Gets information about a location.

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

  • getLocation(GetLocationRequest request)

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

  • getLocationCallable()

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 DataA2AServiceSettings 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
 DataA2AServiceSettings dataA2AServiceSettings =
     DataA2AServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 DataA2AServiceClient dataA2AServiceClient = DataA2AServiceClient.create(dataA2AServiceSettings);
 

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
 DataA2AServiceSettings dataA2AServiceSettings =
     DataA2AServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 DataA2AServiceClient dataA2AServiceClient = DataA2AServiceClient.create(dataA2AServiceSettings);
 

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:


 // 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
 DataA2AServiceSettings dataA2AServiceSettings =
     DataA2AServiceSettings.newHttpJsonBuilder().build();
 DataA2AServiceClient dataA2AServiceClient = DataA2AServiceClient.create(dataA2AServiceSettings);
 

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

Inheritance

java.lang.Object > DataA2AServiceClient

Static Methods

create()

public static final DataA2AServiceClient create()

Constructs an instance of DataA2AServiceClient with default settings.

Returns
Type Description
DataA2AServiceClient
Exceptions
Type Description
IOException

create(DataA2AServiceSettings settings)

public static final DataA2AServiceClient create(DataA2AServiceSettings settings)

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

create(DataA2AServiceStub stub)

public static final DataA2AServiceClient create(DataA2AServiceStub stub)

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

Parameter
Name Description
stub DataA2AServiceStub
Returns
Type Description
DataA2AServiceClient

Constructors

DataA2AServiceClient(DataA2AServiceSettings settings)

protected DataA2AServiceClient(DataA2AServiceSettings settings)

Constructs an instance of DataA2AServiceClient, 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 DataA2AServiceSettings

DataA2AServiceClient(DataA2AServiceStub stub)

protected DataA2AServiceClient(DataA2AServiceStub stub)
Parameter
Name Description
stub DataA2AServiceStub

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

getAgentCard(GetAgentCardRequest request)

public final AgentCard getAgentCard(GetAgentCardRequest request)

GetAgentCard returns the agent card for the agent.

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 (DataA2AServiceClient dataA2AServiceClient = DataA2AServiceClient.create()) {
   GetAgentCardRequest request =
       GetAgentCardRequest.newBuilder().setTenant("tenant-877336406").build();
   AgentCard response = dataA2AServiceClient.getAgentCard(request);
 }
 
Parameter
Name Description
request GetAgentCardRequest

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

Returns
Type Description
AgentCard

getAgentCard(String tenant)

public final AgentCard getAgentCard(String tenant)

GetAgentCard returns the agent card for the agent.

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 (DataA2AServiceClient dataA2AServiceClient = DataA2AServiceClient.create()) {
   String tenant = "tenant-877336406";
   AgentCard response = dataA2AServiceClient.getAgentCard(tenant);
 }
 
Parameter
Name Description
tenant String

Optional. Optional tenant, provided as a path parameter.

Returns
Type Description
AgentCard

getAgentCardCallable()

public final UnaryCallable<GetAgentCardRequest,AgentCard> getAgentCardCallable()

GetAgentCard returns the agent card for the agent.

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 (DataA2AServiceClient dataA2AServiceClient = DataA2AServiceClient.create()) {
   GetAgentCardRequest request =
       GetAgentCardRequest.newBuilder().setTenant("tenant-877336406").build();
   ApiFuture<AgentCard> future = dataA2AServiceClient.getAgentCardCallable().futureCall(request);
   // Do something.
   AgentCard response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetAgentCardRequest,AgentCard>

getLocation(GetLocationRequest request)

public final Location getLocation(GetLocationRequest request)

Gets information about a location.

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 (DataA2AServiceClient dataA2AServiceClient = DataA2AServiceClient.create()) {
   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
   Location response = dataA2AServiceClient.getLocation(request);
 }
 
Parameter
Name Description
request com.google.cloud.location.GetLocationRequest

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

Returns
Type Description
com.google.cloud.location.Location

getLocationCallable()

public final UnaryCallable<GetLocationRequest,Location> getLocationCallable()

Gets information about a location.

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 (DataA2AServiceClient dataA2AServiceClient = DataA2AServiceClient.create()) {
   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
   ApiFuture<Location> future = dataA2AServiceClient.getLocationCallable().futureCall(request);
   // Do something.
   Location response = future.get();
 }
 
Returns
Type Description
UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location>

getSettings()

public final @Nullable DataA2AServiceSettings getSettings()
Returns
Type Description
@org.jspecify.annotations.Nullable com.google.cloud.geminidataanalytics.v1beta.DataA2AServiceSettings

getStub()

public DataA2AServiceStub getStub()
Returns
Type Description
DataA2AServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listLocations(ListLocationsRequest request)

public final DataA2AServiceClient.ListLocationsPagedResponse listLocations(ListLocationsRequest request)

Lists information about the supported locations for this service.

This method lists locations based on the resource scope provided inthe ListLocationsRequest.name field: ***Global locations**: If name is empty, the method lists thepublic locations available to all projects. * **Project-specificlocations**: If name follows the formatprojects/{project}, the method lists locations visible to thatspecific project. This includes public, private, or otherproject-specific locations enabled for the project.

For gRPC and client library implementations, the resource name ispassed as the name field. For direct service calls, the resourcename isincorporated into the request path based on the specific serviceimplementation and version.

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 (DataA2AServiceClient dataA2AServiceClient = DataA2AServiceClient.create()) {
   ListLocationsRequest request =
       ListLocationsRequest.newBuilder()
           .setName("name3373707")
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Location element : dataA2AServiceClient.listLocations(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request com.google.cloud.location.ListLocationsRequest

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

Returns
Type Description
DataA2AServiceClient.ListLocationsPagedResponse

listLocationsCallable()

public final UnaryCallable<ListLocationsRequest,ListLocationsResponse> listLocationsCallable()

Lists information about the supported locations for this service.

This method lists locations based on the resource scope provided inthe ListLocationsRequest.name field: ***Global locations**: If name is empty, the method lists thepublic locations available to all projects. * **Project-specificlocations**: If name follows the formatprojects/{project}, the method lists locations visible to thatspecific project. This includes public, private, or otherproject-specific locations enabled for the project.

For gRPC and client library implementations, the resource name ispassed as the name field. For direct service calls, the resourcename isincorporated into the request path based on the specific serviceimplementation and version.

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 (DataA2AServiceClient dataA2AServiceClient = DataA2AServiceClient.create()) {
   ListLocationsRequest request =
       ListLocationsRequest.newBuilder()
           .setName("name3373707")
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListLocationsResponse response = dataA2AServiceClient.listLocationsCallable().call(request);
     for (Location element : response.getLocationsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse>

listLocationsPagedCallable()

public final UnaryCallable<ListLocationsRequest,DataA2AServiceClient.ListLocationsPagedResponse> listLocationsPagedCallable()

Lists information about the supported locations for this service.

This method lists locations based on the resource scope provided inthe ListLocationsRequest.name field: ***Global locations**: If name is empty, the method lists thepublic locations available to all projects. * **Project-specificlocations**: If name follows the formatprojects/{project}, the method lists locations visible to thatspecific project. This includes public, private, or otherproject-specific locations enabled for the project.

For gRPC and client library implementations, the resource name ispassed as the name field. For direct service calls, the resourcename isincorporated into the request path based on the specific serviceimplementation and version.

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 (DataA2AServiceClient dataA2AServiceClient = DataA2AServiceClient.create()) {
   ListLocationsRequest request =
       ListLocationsRequest.newBuilder()
           .setName("name3373707")
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Location> future =
       dataA2AServiceClient.listLocationsPagedCallable().futureCall(request);
   // Do something.
   for (Location element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<com.google.cloud.location.ListLocationsRequest,ListLocationsPagedResponse>

sendMessage(SendMessageRequest request)

public final SendMessageResponse sendMessage(SendMessageRequest request)

Send a message to the agent. This is a blocking call that will return the task once it is completed.

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 (DataA2AServiceClient dataA2AServiceClient = DataA2AServiceClient.create()) {
   SendMessageRequest request =
       SendMessageRequest.newBuilder()
           .setMessage(A2AMessage.newBuilder().build())
           .setConfiguration(SendMessageConfiguration.newBuilder().build())
           .setMetadata(Struct.newBuilder().build())
           .setTenant("tenant-877336406")
           .build();
   SendMessageResponse response = dataA2AServiceClient.sendMessage(request);
 }
 
Parameter
Name Description
request SendMessageRequest

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

Returns
Type Description
SendMessageResponse

sendMessage(String tenant, A2AMessage message)

public final SendMessageResponse sendMessage(String tenant, A2AMessage message)

Send a message to the agent. This is a blocking call that will return the task once it is completed.

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 (DataA2AServiceClient dataA2AServiceClient = DataA2AServiceClient.create()) {
   String tenant = "tenant-877336406";
   A2AMessage message = A2AMessage.newBuilder().build();
   SendMessageResponse response = dataA2AServiceClient.sendMessage(tenant, message);
 }
 
Parameters
Name Description
tenant String

Optional. Optional tenant, provided as a path parameter.

message A2AMessage

Required. The message to send to the agent.

Returns
Type Description
SendMessageResponse

sendMessageCallable()

public final UnaryCallable<SendMessageRequest,SendMessageResponse> sendMessageCallable()

Send a message to the agent. This is a blocking call that will return the task once it is completed.

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 (DataA2AServiceClient dataA2AServiceClient = DataA2AServiceClient.create()) {
   SendMessageRequest request =
       SendMessageRequest.newBuilder()
           .setMessage(A2AMessage.newBuilder().build())
           .setConfiguration(SendMessageConfiguration.newBuilder().build())
           .setMetadata(Struct.newBuilder().build())
           .setTenant("tenant-877336406")
           .build();
   ApiFuture<SendMessageResponse> future =
       dataA2AServiceClient.sendMessageCallable().futureCall(request);
   // Do something.
   SendMessageResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<SendMessageRequest,SendMessageResponse>

sendStreamingMessageCallable()

public final ServerStreamingCallable<SendMessageRequest,StreamResponse> sendStreamingMessageCallable()

SendStreamingMessage is a streaming call that will return a stream of task update events until the Task is in an interrupted or terminal state.

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 (DataA2AServiceClient dataA2AServiceClient = DataA2AServiceClient.create()) {
   SendMessageRequest request =
       SendMessageRequest.newBuilder()
           .setMessage(A2AMessage.newBuilder().build())
           .setConfiguration(SendMessageConfiguration.newBuilder().build())
           .setMetadata(Struct.newBuilder().build())
           .setTenant("tenant-877336406")
           .build();
   ServerStream<StreamResponse> stream =
       dataA2AServiceClient.sendStreamingMessageCallable().call(request);
   for (StreamResponse response : stream) {
     // Do something when a response is received.
   }
 }
 
Returns
Type Description
ServerStreamingCallable<SendMessageRequest,StreamResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()