Class DashboardQueryServiceClient (0.31.0)

GitHub RepositoryProduct Reference

Service Description: A service providing functionality for managing dashboards' queries.

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 (DashboardQueryServiceClient dashboardQueryServiceClient =
     DashboardQueryServiceClient.create()) {
   DashboardQueryName name =
       DashboardQueryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[QUERY]");
   DashboardQuery response = dashboardQueryServiceClient.getDashboardQuery(name);
 }
 

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

GetDashboardQuery

Get a dashboard query.

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

  • getDashboardQuery(GetDashboardQueryRequest request)

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

  • getDashboardQuery(DashboardQueryName name)

  • getDashboardQuery(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.

  • getDashboardQueryCallable()

ExecuteDashboardQuery

Execute a query and return the data.

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

  • executeDashboardQuery(ExecuteDashboardQueryRequest request)

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

  • executeDashboardQuery(InstanceName parent, DashboardQuery query)

  • executeDashboardQuery(String parent, DashboardQuery query)

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

  • executeDashboardQueryCallable()

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 DashboardQueryServiceSettings 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
 DashboardQueryServiceSettings dashboardQueryServiceSettings =
     DashboardQueryServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 DashboardQueryServiceClient dashboardQueryServiceClient =
     DashboardQueryServiceClient.create(dashboardQueryServiceSettings);
 

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
 DashboardQueryServiceSettings dashboardQueryServiceSettings =
     DashboardQueryServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 DashboardQueryServiceClient dashboardQueryServiceClient =
     DashboardQueryServiceClient.create(dashboardQueryServiceSettings);
 

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
 DashboardQueryServiceSettings dashboardQueryServiceSettings =
     DashboardQueryServiceSettings.newHttpJsonBuilder().build();
 DashboardQueryServiceClient dashboardQueryServiceClient =
     DashboardQueryServiceClient.create(dashboardQueryServiceSettings);
 

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

Inheritance

java.lang.Object > DashboardQueryServiceClient

Static Methods

create()

public static final DashboardQueryServiceClient create()

Constructs an instance of DashboardQueryServiceClient with default settings.

Returns
Type Description
DashboardQueryServiceClient
Exceptions
Type Description
IOException

create(DashboardQueryServiceSettings settings)

public static final DashboardQueryServiceClient create(DashboardQueryServiceSettings settings)

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

create(DashboardQueryServiceStub stub)

public static final DashboardQueryServiceClient create(DashboardQueryServiceStub stub)

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

Parameter
Name Description
stub DashboardQueryServiceStub
Returns
Type Description
DashboardQueryServiceClient

Constructors

DashboardQueryServiceClient(DashboardQueryServiceSettings settings)

protected DashboardQueryServiceClient(DashboardQueryServiceSettings settings)

Constructs an instance of DashboardQueryServiceClient, 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 DashboardQueryServiceSettings

DashboardQueryServiceClient(DashboardQueryServiceStub stub)

protected DashboardQueryServiceClient(DashboardQueryServiceStub stub)
Parameter
Name Description
stub DashboardQueryServiceStub

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

executeDashboardQuery(ExecuteDashboardQueryRequest request)

public final ExecuteDashboardQueryResponse executeDashboardQuery(ExecuteDashboardQueryRequest request)

Execute a query and return the data.

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 (DashboardQueryServiceClient dashboardQueryServiceClient =
     DashboardQueryServiceClient.create()) {
   ExecuteDashboardQueryRequest request =
       ExecuteDashboardQueryRequest.newBuilder()
           .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
           .setQuery(DashboardQuery.newBuilder().build())
           .addAllFilters(new ArrayList<DashboardFilter>())
           .setClearCache(true)
           .setUsePreviousTimeRange(true)
           .build();
   ExecuteDashboardQueryResponse response =
       dashboardQueryServiceClient.executeDashboardQuery(request);
 }
 
Parameter
Name Description
request ExecuteDashboardQueryRequest

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

Returns
Type Description
ExecuteDashboardQueryResponse

executeDashboardQuery(InstanceName parent, DashboardQuery query)

public final ExecuteDashboardQueryResponse executeDashboardQuery(InstanceName parent, DashboardQuery query)

Execute a query and return the data.

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 (DashboardQueryServiceClient dashboardQueryServiceClient =
     DashboardQueryServiceClient.create()) {
   InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
   DashboardQuery query = DashboardQuery.newBuilder().build();
   ExecuteDashboardQueryResponse response =
       dashboardQueryServiceClient.executeDashboardQuery(parent, query);
 }
 
Parameters
Name Description
parent InstanceName

Required. The parent, under which to run this dashboardQuery. Format: projects/{project}/locations/{location}/instances/{instance}

query DashboardQuery

Required. The query to execute and get results back for. QueryID or 'query', 'input.time_window' fields will be used. Use 'native_dashboard' and 'dashboard_chart' fields if it is an in-dashboard query.

Returns
Type Description
ExecuteDashboardQueryResponse

executeDashboardQuery(String parent, DashboardQuery query)

public final ExecuteDashboardQueryResponse executeDashboardQuery(String parent, DashboardQuery query)

Execute a query and return the data.

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 (DashboardQueryServiceClient dashboardQueryServiceClient =
     DashboardQueryServiceClient.create()) {
   String parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString();
   DashboardQuery query = DashboardQuery.newBuilder().build();
   ExecuteDashboardQueryResponse response =
       dashboardQueryServiceClient.executeDashboardQuery(parent, query);
 }
 
Parameters
Name Description
parent String

Required. The parent, under which to run this dashboardQuery. Format: projects/{project}/locations/{location}/instances/{instance}

query DashboardQuery

Required. The query to execute and get results back for. QueryID or 'query', 'input.time_window' fields will be used. Use 'native_dashboard' and 'dashboard_chart' fields if it is an in-dashboard query.

Returns
Type Description
ExecuteDashboardQueryResponse

executeDashboardQueryCallable()

public final UnaryCallable<ExecuteDashboardQueryRequest,ExecuteDashboardQueryResponse> executeDashboardQueryCallable()

Execute a query and return the data.

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 (DashboardQueryServiceClient dashboardQueryServiceClient =
     DashboardQueryServiceClient.create()) {
   ExecuteDashboardQueryRequest request =
       ExecuteDashboardQueryRequest.newBuilder()
           .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
           .setQuery(DashboardQuery.newBuilder().build())
           .addAllFilters(new ArrayList<DashboardFilter>())
           .setClearCache(true)
           .setUsePreviousTimeRange(true)
           .build();
   ApiFuture<ExecuteDashboardQueryResponse> future =
       dashboardQueryServiceClient.executeDashboardQueryCallable().futureCall(request);
   // Do something.
   ExecuteDashboardQueryResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<ExecuteDashboardQueryRequest,ExecuteDashboardQueryResponse>

getDashboardQuery(DashboardQueryName name)

public final DashboardQuery getDashboardQuery(DashboardQueryName name)

Get a dashboard query.

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 (DashboardQueryServiceClient dashboardQueryServiceClient =
     DashboardQueryServiceClient.create()) {
   DashboardQueryName name =
       DashboardQueryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[QUERY]");
   DashboardQuery response = dashboardQueryServiceClient.getDashboardQuery(name);
 }
 
Parameter
Name Description
name DashboardQueryName

Required. The name of the dashboardQuery to retrieve. Format: projects/{project}/locations/{location}/instances/{instance}/dashboardQueries/{query}

Returns
Type Description
DashboardQuery

getDashboardQuery(GetDashboardQueryRequest request)

public final DashboardQuery getDashboardQuery(GetDashboardQueryRequest request)

Get a dashboard query.

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 (DashboardQueryServiceClient dashboardQueryServiceClient =
     DashboardQueryServiceClient.create()) {
   GetDashboardQueryRequest request =
       GetDashboardQueryRequest.newBuilder()
           .setName(
               DashboardQueryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[QUERY]")
                   .toString())
           .build();
   DashboardQuery response = dashboardQueryServiceClient.getDashboardQuery(request);
 }
 
Parameter
Name Description
request GetDashboardQueryRequest

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

Returns
Type Description
DashboardQuery

getDashboardQuery(String name)

public final DashboardQuery getDashboardQuery(String name)

Get a dashboard query.

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 (DashboardQueryServiceClient dashboardQueryServiceClient =
     DashboardQueryServiceClient.create()) {
   String name =
       DashboardQueryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[QUERY]").toString();
   DashboardQuery response = dashboardQueryServiceClient.getDashboardQuery(name);
 }
 
Parameter
Name Description
name String

Required. The name of the dashboardQuery to retrieve. Format: projects/{project}/locations/{location}/instances/{instance}/dashboardQueries/{query}

Returns
Type Description
DashboardQuery

getDashboardQueryCallable()

public final UnaryCallable<GetDashboardQueryRequest,DashboardQuery> getDashboardQueryCallable()

Get a dashboard query.

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 (DashboardQueryServiceClient dashboardQueryServiceClient =
     DashboardQueryServiceClient.create()) {
   GetDashboardQueryRequest request =
       GetDashboardQueryRequest.newBuilder()
           .setName(
               DashboardQueryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[QUERY]")
                   .toString())
           .build();
   ApiFuture<DashboardQuery> future =
       dashboardQueryServiceClient.getDashboardQueryCallable().futureCall(request);
   // Do something.
   DashboardQuery response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetDashboardQueryRequest,DashboardQuery>

getSettings()

public final DashboardQueryServiceSettings getSettings()
Returns
Type Description
DashboardQueryServiceSettings

getStub()

public DashboardQueryServiceStub getStub()
Returns
Type Description
DashboardQueryServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()