Class PredictionServiceClient
PredictionService client wrapper, for convenient use.
Inherited Members
Namespace: Google.Cloud.Retail.V2
Assembly: Google.Cloud.Retail.V2.dll
Syntax
public abstract class PredictionServiceClient
Remarks
Service for making recommendation prediction.
Properties
DefaultEndpoint
The default endpoint for the PredictionService service, which is a host of "retail.googleapis.com" and a port of 443.
Declaration
public static string DefaultEndpoint { get; }
Property Value
Type | Description |
---|---|
System.String |
DefaultScopes
The default PredictionService scopes.
Declaration
public static IReadOnlyList<string> DefaultScopes { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<System.String> |
Remarks
The default PredictionService scopes are:
GrpcClient
The underlying gRPC PredictionService client
Declaration
public virtual PredictionService.PredictionServiceClient GrpcClient { get; }
Property Value
Type | Description |
---|---|
PredictionService.PredictionServiceClient |
Methods
Create()
Synchronously creates a PredictionServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use PredictionServiceClientBuilder.
Declaration
public static PredictionServiceClient Create()
Returns
Type | Description |
---|---|
PredictionServiceClient | The created PredictionServiceClient. |
CreateAsync(CancellationToken)
Asynchronously creates a PredictionServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use PredictionServiceClientBuilder.
Declaration
public static Task<PredictionServiceClient> CreateAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken | The System.Threading.CancellationToken to use while creating the client. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<PredictionServiceClient> | The task representing the created PredictionServiceClient. |
Predict(PredictRequest, CallSettings)
Makes a recommendation prediction.
Declaration
public virtual PredictResponse Predict(PredictRequest request, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
PredictRequest | request | The request object containing all of the parameters for the API call. |
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
PredictResponse | The RPC response. |
Sample code
// Create client
PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create();
// Initialize request argument(s)
PredictRequest request = new PredictRequest
{
Placement = "",
UserEvent = new UserEvent(),
PageSize = 0,
PageToken = "",
Filter = "",
ValidateOnly = false,
Params = { { "", new Value() }, },
Labels = { { "", "" }, },
};
// Make the request
PredictResponse response = predictionServiceClient.Predict(request);
PredictAsync(PredictRequest, CallSettings)
Makes a recommendation prediction.
Declaration
public virtual Task<PredictResponse> PredictAsync(PredictRequest request, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
PredictRequest | request | The request object containing all of the parameters for the API call. |
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<PredictResponse> | A Task containing the RPC response. |
Sample code
// Create client
PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync();
// Initialize request argument(s)
PredictRequest request = new PredictRequest
{
Placement = "",
UserEvent = new UserEvent(),
PageSize = 0,
PageToken = "",
Filter = "",
ValidateOnly = false,
Params = { { "", new Value() }, },
Labels = { { "", "" }, },
};
// Make the request
PredictResponse response = await predictionServiceClient.PredictAsync(request);
PredictAsync(PredictRequest, CancellationToken)
Makes a recommendation prediction.
Declaration
public virtual Task<PredictResponse> PredictAsync(PredictRequest request, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
PredictRequest | request | The request object containing all of the parameters for the API call. |
System.Threading.CancellationToken | cancellationToken | A System.Threading.CancellationToken to use for this RPC. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<PredictResponse> | A Task containing the RPC response. |
Sample code
// Create client
PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync();
// Initialize request argument(s)
PredictRequest request = new PredictRequest
{
Placement = "",
UserEvent = new UserEvent(),
PageSize = 0,
PageToken = "",
Filter = "",
ValidateOnly = false,
Params = { { "", new Value() }, },
Labels = { { "", "" }, },
};
// Make the request
PredictResponse response = await predictionServiceClient.PredictAsync(request);
ShutdownDefaultChannelsAsync()
Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.
Declaration
public static Task ShutdownDefaultChannelsAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.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.