Retail v2 API - Class PredictionServiceClient (2.5.0)

public abstract class PredictionServiceClient

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

PredictionService client wrapper, for convenient use.

Inheritance

object > PredictionServiceClient

Namespace

GoogleCloudGoogle.Cloud.RetailV2

Assembly

Google.Cloud.Retail.V2.dll

Remarks

Service for making recommendation prediction.

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

The default endpoint for the PredictionService 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 PredictionService scopes.

Property Value
TypeDescription
IReadOnlyListstring
Remarks

The default PredictionService scopes are:

GrpcClient

public virtual PredictionService.PredictionServiceClient GrpcClient { get; }

The underlying gRPC PredictionService client

Property Value
TypeDescription
PredictionServicePredictionServiceClient

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

Create()

public static PredictionServiceClient Create()

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

Returns
TypeDescription
PredictionServiceClient

The created PredictionServiceClient.

CreateAsync(CancellationToken)

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

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

Parameter
NameDescription
cancellationTokenCancellationToken

The CancellationToken to use while creating the client.

Returns
TypeDescription
TaskPredictionServiceClient

The task representing the created PredictionServiceClient.

Predict(PredictRequest, CallSettings)

public virtual PredictResponse Predict(PredictRequest request, CallSettings callSettings = null)

Makes a recommendation prediction.

Parameters
NameDescription
requestPredictRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PredictResponse

The RPC response.

Example
// Create client
PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create();
// Initialize request argument(s)
PredictRequest request = new PredictRequest
{
    Placement = "",
    UserEvent = new UserEvent(),
    PageSize = 0,
    Filter = "",
    ValidateOnly = false,
    Params = { { "", new Value() }, },
    Labels = { { "", "" }, },
};
// Make the request
PredictResponse response = predictionServiceClient.Predict(request);

PredictAsync(PredictRequest, CallSettings)

public virtual Task<PredictResponse> PredictAsync(PredictRequest request, CallSettings callSettings = null)

Makes a recommendation prediction.

Parameters
NameDescription
requestPredictRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskPredictResponse

A Task containing the RPC response.

Example
// Create client
PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync();
// Initialize request argument(s)
PredictRequest request = new PredictRequest
{
    Placement = "",
    UserEvent = new UserEvent(),
    PageSize = 0,
    Filter = "",
    ValidateOnly = false,
    Params = { { "", new Value() }, },
    Labels = { { "", "" }, },
};
// Make the request
PredictResponse response = await predictionServiceClient.PredictAsync(request);

PredictAsync(PredictRequest, CancellationToken)

public virtual Task<PredictResponse> PredictAsync(PredictRequest request, CancellationToken cancellationToken)

Makes a recommendation prediction.

Parameters
NameDescription
requestPredictRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskPredictResponse

A Task containing the RPC response.

Example
// Create client
PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync();
// Initialize request argument(s)
PredictRequest request = new PredictRequest
{
    Placement = "",
    UserEvent = new UserEvent(),
    PageSize = 0,
    Filter = "",
    ValidateOnly = false,
    Params = { { "", new Value() }, },
    Labels = { { "", "" }, },
};
// Make the request
PredictResponse response = await predictionServiceClient.PredictAsync(request);

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.