Retail v2 API - Class CompletionServiceClient (2.8.0)

public abstract class CompletionServiceClient

Reference documentation and code samples for the Retail v2 API class CompletionServiceClient.

CompletionService client wrapper, for convenient use.

Inheritance

object > CompletionServiceClient

Namespace

Google.Cloud.Retail.V2

Assembly

Google.Cloud.Retail.V2.dll

Remarks

Autocomplete service for retail.

This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

The default endpoint for the CompletionService service, which is a host of "retail.googleapis.com" and a port of 443.

Property Value
TypeDescription
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default CompletionService scopes.

Property Value
TypeDescription
IReadOnlyListstring
Remarks

The default CompletionService scopes are:

GrpcClient

public virtual CompletionService.CompletionServiceClient GrpcClient { get; }

The underlying gRPC CompletionService client

Property Value
TypeDescription
CompletionServiceCompletionServiceClient

ImportCompletionDataOperationsClient

public virtual OperationsClient ImportCompletionDataOperationsClient { get; }

The long-running operations client for ImportCompletionData.

Property Value
TypeDescription
OperationsClient

LocationsClient

public virtual LocationsClient LocationsClient { get; }

The LocationsClient associated with this client.

Property Value
TypeDescription
LocationsClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
TypeDescription
ServiceMetadata

Methods

CompleteQuery(CompleteQueryRequest, CallSettings)

public virtual CompleteQueryResponse CompleteQuery(CompleteQueryRequest request, CallSettings callSettings = null)

Completes the specified prefix with keyword suggestions.

This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.

Parameters
NameDescription
requestCompleteQueryRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
CompleteQueryResponse

The RPC response.

Example
// Create client
CompletionServiceClient completionServiceClient = CompletionServiceClient.Create();
// Initialize request argument(s)
CompleteQueryRequest request = new CompleteQueryRequest
{
    CatalogAsCatalogName = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]"),
    Query = "",
    LanguageCodes = { "", },
    DeviceType = "",
    MaxSuggestions = 0,
    Dataset = "",
    VisitorId = "",
    Entity = "",
};
// Make the request
CompleteQueryResponse response = completionServiceClient.CompleteQuery(request);

CompleteQueryAsync(CompleteQueryRequest, CallSettings)

public virtual Task<CompleteQueryResponse> CompleteQueryAsync(CompleteQueryRequest request, CallSettings callSettings = null)

Completes the specified prefix with keyword suggestions.

This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.

Parameters
NameDescription
requestCompleteQueryRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskCompleteQueryResponse

A Task containing the RPC response.

Example
// Create client
CompletionServiceClient completionServiceClient = await CompletionServiceClient.CreateAsync();
// Initialize request argument(s)
CompleteQueryRequest request = new CompleteQueryRequest
{
    CatalogAsCatalogName = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]"),
    Query = "",
    LanguageCodes = { "", },
    DeviceType = "",
    MaxSuggestions = 0,
    Dataset = "",
    VisitorId = "",
    Entity = "",
};
// Make the request
CompleteQueryResponse response = await completionServiceClient.CompleteQueryAsync(request);

CompleteQueryAsync(CompleteQueryRequest, CancellationToken)

public virtual Task<CompleteQueryResponse> CompleteQueryAsync(CompleteQueryRequest request, CancellationToken cancellationToken)

Completes the specified prefix with keyword suggestions.

This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.

Parameters
NameDescription
requestCompleteQueryRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskCompleteQueryResponse

A Task containing the RPC response.

Example
// Create client
CompletionServiceClient completionServiceClient = await CompletionServiceClient.CreateAsync();
// Initialize request argument(s)
CompleteQueryRequest request = new CompleteQueryRequest
{
    CatalogAsCatalogName = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]"),
    Query = "",
    LanguageCodes = { "", },
    DeviceType = "",
    MaxSuggestions = 0,
    Dataset = "",
    VisitorId = "",
    Entity = "",
};
// Make the request
CompleteQueryResponse response = await completionServiceClient.CompleteQueryAsync(request);

Create()

public static CompletionServiceClient Create()

Synchronously creates a CompletionServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use CompletionServiceClientBuilder.

Returns
TypeDescription
CompletionServiceClient

The created CompletionServiceClient.

CreateAsync(CancellationToken)

public static Task<CompletionServiceClient> CreateAsync(CancellationToken cancellationToken = default)

Asynchronously creates a CompletionServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use CompletionServiceClientBuilder.

Parameter
NameDescription
cancellationTokenCancellationToken

The CancellationToken to use while creating the client.

Returns
TypeDescription
TaskCompletionServiceClient

The task representing the created CompletionServiceClient.

ImportCompletionData(ImportCompletionDataRequest, CallSettings)

public virtual Operation<ImportCompletionDataResponse, ImportMetadata> ImportCompletionData(ImportCompletionDataRequest request, CallSettings callSettings = null)

Bulk import of processed completion dataset.

Request processing is asynchronous. Partial updating is not supported.

The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours.

This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.

Parameters
NameDescription
requestImportCompletionDataRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationImportCompletionDataResponseImportMetadata

The RPC response.

Example
// Create client
CompletionServiceClient completionServiceClient = CompletionServiceClient.Create();
// Initialize request argument(s)
ImportCompletionDataRequest request = new ImportCompletionDataRequest
{
    ParentAsCatalogName = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]"),
    InputConfig = new CompletionDataInputConfig(),
    NotificationPubsubTopic = "",
};
// Make the request
Operation<ImportCompletionDataResponse, ImportMetadata> response = completionServiceClient.ImportCompletionData(request);

// Poll until the returned long-running operation is complete
Operation<ImportCompletionDataResponse, ImportMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
ImportCompletionDataResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<ImportCompletionDataResponse, ImportMetadata> retrievedResponse = completionServiceClient.PollOnceImportCompletionData(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    ImportCompletionDataResponse retrievedResult = retrievedResponse.Result;
}

ImportCompletionDataAsync(ImportCompletionDataRequest, CallSettings)

public virtual Task<Operation<ImportCompletionDataResponse, ImportMetadata>> ImportCompletionDataAsync(ImportCompletionDataRequest request, CallSettings callSettings = null)

Bulk import of processed completion dataset.

Request processing is asynchronous. Partial updating is not supported.

The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours.

This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.

Parameters
NameDescription
requestImportCompletionDataRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationImportCompletionDataResponseImportMetadata

A Task containing the RPC response.

Example
// Create client
CompletionServiceClient completionServiceClient = await CompletionServiceClient.CreateAsync();
// Initialize request argument(s)
ImportCompletionDataRequest request = new ImportCompletionDataRequest
{
    ParentAsCatalogName = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]"),
    InputConfig = new CompletionDataInputConfig(),
    NotificationPubsubTopic = "",
};
// Make the request
Operation<ImportCompletionDataResponse, ImportMetadata> response = await completionServiceClient.ImportCompletionDataAsync(request);

// Poll until the returned long-running operation is complete
Operation<ImportCompletionDataResponse, ImportMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
ImportCompletionDataResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<ImportCompletionDataResponse, ImportMetadata> retrievedResponse = await completionServiceClient.PollOnceImportCompletionDataAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    ImportCompletionDataResponse retrievedResult = retrievedResponse.Result;
}

ImportCompletionDataAsync(ImportCompletionDataRequest, CancellationToken)

public virtual Task<Operation<ImportCompletionDataResponse, ImportMetadata>> ImportCompletionDataAsync(ImportCompletionDataRequest request, CancellationToken cancellationToken)

Bulk import of processed completion dataset.

Request processing is asynchronous. Partial updating is not supported.

The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours.

This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.

Parameters
NameDescription
requestImportCompletionDataRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskOperationImportCompletionDataResponseImportMetadata

A Task containing the RPC response.

Example
// Create client
CompletionServiceClient completionServiceClient = await CompletionServiceClient.CreateAsync();
// Initialize request argument(s)
ImportCompletionDataRequest request = new ImportCompletionDataRequest
{
    ParentAsCatalogName = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]"),
    InputConfig = new CompletionDataInputConfig(),
    NotificationPubsubTopic = "",
};
// Make the request
Operation<ImportCompletionDataResponse, ImportMetadata> response = await completionServiceClient.ImportCompletionDataAsync(request);

// Poll until the returned long-running operation is complete
Operation<ImportCompletionDataResponse, ImportMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
ImportCompletionDataResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<ImportCompletionDataResponse, ImportMetadata> retrievedResponse = await completionServiceClient.PollOnceImportCompletionDataAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    ImportCompletionDataResponse retrievedResult = retrievedResponse.Result;
}

PollOnceImportCompletionData(string, CallSettings)

public virtual Operation<ImportCompletionDataResponse, ImportMetadata> PollOnceImportCompletionData(string operationName, CallSettings callSettings = null)

Poll an operation once, using an operationName from a previous invocation of ImportCompletionData .

Parameters
NameDescription
operationNamestring

The name of a previously invoked operation. Must not be null or empty.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationImportCompletionDataResponseImportMetadata

The result of polling the operation.

PollOnceImportCompletionDataAsync(string, CallSettings)

public virtual Task<Operation<ImportCompletionDataResponse, ImportMetadata>> PollOnceImportCompletionDataAsync(string operationName, CallSettings callSettings = null)

Asynchronously poll an operation once, using an operationName from a previous invocation of ImportCompletionData.

Parameters
NameDescription
operationNamestring

The name of a previously invoked operation. Must not be null or empty.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationImportCompletionDataResponseImportMetadata

A task representing the result of polling the operation.

ShutdownDefaultChannelsAsync()

public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.

Returns
TypeDescription
Task

A task representing the asynchronous shutdown operation.

Remarks

After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.