Class WidgetConfigServiceClient (0.99.0)

GitHub RepositoryProduct Reference

Service Description: Service for managing WidgetConfig configuration.

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 (WidgetConfigServiceClient widgetConfigServiceClient = WidgetConfigServiceClient.create()) {
   WidgetConfigName name =
       WidgetConfigName.ofProjectLocationDataStoreWidgetConfigName(
           "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[WIDGET_CONFIG]");
   WidgetConfig response = widgetConfigServiceClient.getWidgetConfig(name);
 }
 

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

GetWidgetConfig

Gets a WidgetConfig.

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

  • getWidgetConfig(GetWidgetConfigRequest request)

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

  • getWidgetConfig(WidgetConfigName name)

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

  • getWidgetConfigCallable()

UpdateWidgetConfig

Update a WidgetConfig.

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

  • updateWidgetConfig(UpdateWidgetConfigRequest request)

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

  • updateWidgetConfig(WidgetConfig widgetConfig, FieldMask updateMask)

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

  • updateWidgetConfigCallable()

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 WidgetConfigServiceSettings 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
 WidgetConfigServiceSettings widgetConfigServiceSettings =
     WidgetConfigServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 WidgetConfigServiceClient widgetConfigServiceClient =
     WidgetConfigServiceClient.create(widgetConfigServiceSettings);
 

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
 WidgetConfigServiceSettings widgetConfigServiceSettings =
     WidgetConfigServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 WidgetConfigServiceClient widgetConfigServiceClient =
     WidgetConfigServiceClient.create(widgetConfigServiceSettings);
 

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
 WidgetConfigServiceSettings widgetConfigServiceSettings =
     WidgetConfigServiceSettings.newHttpJsonBuilder().build();
 WidgetConfigServiceClient widgetConfigServiceClient =
     WidgetConfigServiceClient.create(widgetConfigServiceSettings);
 

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

Inheritance

java.lang.Object > WidgetConfigServiceClient

Static Methods

create()

public static final WidgetConfigServiceClient create()

Constructs an instance of WidgetConfigServiceClient with default settings.

Returns
Type Description
WidgetConfigServiceClient
Exceptions
Type Description
IOException

create(WidgetConfigServiceSettings settings)

public static final WidgetConfigServiceClient create(WidgetConfigServiceSettings settings)

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

create(WidgetConfigServiceStub stub)

public static final WidgetConfigServiceClient create(WidgetConfigServiceStub stub)

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

Parameter
Name Description
stub WidgetConfigServiceStub
Returns
Type Description
WidgetConfigServiceClient

Constructors

WidgetConfigServiceClient(WidgetConfigServiceSettings settings)

protected WidgetConfigServiceClient(WidgetConfigServiceSettings settings)

Constructs an instance of WidgetConfigServiceClient, 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 WidgetConfigServiceSettings

WidgetConfigServiceClient(WidgetConfigServiceStub stub)

protected WidgetConfigServiceClient(WidgetConfigServiceStub stub)
Parameter
Name Description
stub WidgetConfigServiceStub

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

getSettings()

public final @Nullable WidgetConfigServiceSettings getSettings()
Returns
Type Description
@org.jspecify.annotations.Nullable com.google.cloud.discoveryengine.v1.WidgetConfigServiceSettings

getStub()

public WidgetConfigServiceStub getStub()
Returns
Type Description
WidgetConfigServiceStub

getWidgetConfig(@Nullable WidgetConfigName name)

public final WidgetConfig getWidgetConfig(@Nullable WidgetConfigName name)

Gets a WidgetConfig.

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 (WidgetConfigServiceClient widgetConfigServiceClient = WidgetConfigServiceClient.create()) {
   WidgetConfigName name =
       WidgetConfigName.ofProjectLocationDataStoreWidgetConfigName(
           "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[WIDGET_CONFIG]");
   WidgetConfig response = widgetConfigServiceClient.getWidgetConfig(name);
 }
 
Parameter
Name Description
name @org.jspecify.annotations.Nullable com.google.cloud.discoveryengine.v1.WidgetConfigName

Required. Full WidgetConfig resource name. Format: projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/widgetConfigs/{widget_config_id}

Returns
Type Description
WidgetConfig

getWidgetConfig(GetWidgetConfigRequest request)

public final WidgetConfig getWidgetConfig(GetWidgetConfigRequest request)

Gets a WidgetConfig.

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 (WidgetConfigServiceClient widgetConfigServiceClient = WidgetConfigServiceClient.create()) {
   GetWidgetConfigRequest request =
       GetWidgetConfigRequest.newBuilder()
           .setName(
               WidgetConfigName.ofProjectLocationDataStoreWidgetConfigName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[WIDGET_CONFIG]")
                   .toString())
           .setAcceptCache(true)
           .setGetWidgetConfigRequestOption(
               GetWidgetConfigRequest.GetWidgetConfigRequestOption.newBuilder().build())
           .setLanguageCode("languageCode-2092349083")
           .setModelInfoView(ModelInfoView.forNumber(0))
           .build();
   WidgetConfig response = widgetConfigServiceClient.getWidgetConfig(request);
 }
 
Parameter
Name Description
request GetWidgetConfigRequest

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

Returns
Type Description
WidgetConfig

getWidgetConfig(String name)

public final WidgetConfig getWidgetConfig(String name)

Gets a WidgetConfig.

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 (WidgetConfigServiceClient widgetConfigServiceClient = WidgetConfigServiceClient.create()) {
   String name =
       WidgetConfigName.ofProjectLocationDataStoreWidgetConfigName(
               "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[WIDGET_CONFIG]")
           .toString();
   WidgetConfig response = widgetConfigServiceClient.getWidgetConfig(name);
 }
 
Parameter
Name Description
name String

Required. Full WidgetConfig resource name. Format: projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/widgetConfigs/{widget_config_id}

Returns
Type Description
WidgetConfig

getWidgetConfigCallable()

public final UnaryCallable<GetWidgetConfigRequest,WidgetConfig> getWidgetConfigCallable()

Gets a WidgetConfig.

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 (WidgetConfigServiceClient widgetConfigServiceClient = WidgetConfigServiceClient.create()) {
   GetWidgetConfigRequest request =
       GetWidgetConfigRequest.newBuilder()
           .setName(
               WidgetConfigName.ofProjectLocationDataStoreWidgetConfigName(
                       "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[WIDGET_CONFIG]")
                   .toString())
           .setAcceptCache(true)
           .setGetWidgetConfigRequestOption(
               GetWidgetConfigRequest.GetWidgetConfigRequestOption.newBuilder().build())
           .setLanguageCode("languageCode-2092349083")
           .setModelInfoView(ModelInfoView.forNumber(0))
           .build();
   ApiFuture<WidgetConfig> future =
       widgetConfigServiceClient.getWidgetConfigCallable().futureCall(request);
   // Do something.
   WidgetConfig response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetWidgetConfigRequest,WidgetConfig>

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

updateWidgetConfig(UpdateWidgetConfigRequest request)

public final WidgetConfig updateWidgetConfig(UpdateWidgetConfigRequest request)

Update a WidgetConfig.

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 (WidgetConfigServiceClient widgetConfigServiceClient = WidgetConfigServiceClient.create()) {
   UpdateWidgetConfigRequest request =
       UpdateWidgetConfigRequest.newBuilder()
           .setWidgetConfig(WidgetConfig.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   WidgetConfig response = widgetConfigServiceClient.updateWidgetConfig(request);
 }
 
Parameter
Name Description
request UpdateWidgetConfigRequest

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

Returns
Type Description
WidgetConfig

updateWidgetConfig(WidgetConfig widgetConfig, FieldMask updateMask)

public final WidgetConfig updateWidgetConfig(WidgetConfig widgetConfig, FieldMask updateMask)

Update a WidgetConfig.

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 (WidgetConfigServiceClient widgetConfigServiceClient = WidgetConfigServiceClient.create()) {
   WidgetConfig widgetConfig = WidgetConfig.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   WidgetConfig response =
       widgetConfigServiceClient.updateWidgetConfig(widgetConfig, updateMask);
 }
 
Parameters
Name Description
widgetConfig WidgetConfig

Required. The WidgetConfig to update.

If the caller does not have permission to update the WidgetConfig, then a PERMISSION_DENIED error is returned.

If the WidgetConfig to update does not exist, a NOT_FOUND error is returned.

updateMask FieldMask

Indicates which fields in the provided WidgetConfig to update. The following are the only supported fields:

  • WidgetConfig.enable_autocomplete

If not set, all supported fields are updated.

Returns
Type Description
WidgetConfig

updateWidgetConfigCallable()

public final UnaryCallable<UpdateWidgetConfigRequest,WidgetConfig> updateWidgetConfigCallable()

Update a WidgetConfig.

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 (WidgetConfigServiceClient widgetConfigServiceClient = WidgetConfigServiceClient.create()) {
   UpdateWidgetConfigRequest request =
       UpdateWidgetConfigRequest.newBuilder()
           .setWidgetConfig(WidgetConfig.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<WidgetConfig> future =
       widgetConfigServiceClient.updateWidgetConfigCallable().futureCall(request);
   // Do something.
   WidgetConfig response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UpdateWidgetConfigRequest,WidgetConfig>