predict method

Makes a recommendation prediction.

request - The metadata request object.

Request parameters:

placement - Required. Full resource name of the format: {placement=projects / * /locations/global/catalogs/default_catalog/servingConfigs / * } or {placement=projects / * /locations/global/catalogs/default_catalog/placements / * }. We recommend using the servingConfigs resource. placements is a legacy resource. The ID of the Recommendations AI serving config or placement. Before you can request predictions from your model, you must create at least one serving config or placement for it. For more information, see Manage serving configs. The full list of available serving configs can be seen at https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs Value must have pattern ^projects/\[^/\]+/locations/\[^/\]+/catalogs/\[^/\]+/servingConfigs/\[^/\]+$.

$fields - Selector specifying which fields to include in a partial response.

Completes with a GoogleCloudRetailV2PredictResponse.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<GoogleCloudRetailV2PredictResponse> predict(
  GoogleCloudRetailV2PredictRequest request,
  core.String placement, {
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v2/' + core.Uri.encodeFull('$placement') + ':predict';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return GoogleCloudRetailV2PredictResponse.fromJson(
      response_ as core.Map<core.String, core.dynamic>);
}