setDefaultBranch method

Future<GoogleProtobufEmpty> setDefaultBranch(
  1. GoogleCloudRetailV2SetDefaultBranchRequest request,
  2. String catalog, {
  3. String? $fields,
})

Set a specified branch id as default branch.

API methods such as SearchService.Search, ProductService.GetProduct, ProductService.ListProducts will treat requests using "default_branch" to the actual branch id set as default. For example, if projects / * /locations / * /catalogs / * /branches/1 is set as default, setting SearchRequest.branch to projects / * /locations / * /catalogs / * /branches/default_branch is equivalent to setting SearchRequest.branch to projects / * /locations / * /catalogs / * /branches/1. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using projects / * /locations / * /catalogs / * /branches/default_branch as SearchRequest.branch to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.

request - The metadata request object.

Request parameters:

catalog - Full resource name of the catalog, such as projects / * /locations/global/catalogs/default_catalog. Value must have pattern ^projects/\[^/\]+/locations/\[^/\]+/catalogs/\[^/\]+$.

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

Completes with a GoogleProtobufEmpty.

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<GoogleProtobufEmpty> setDefaultBranch(
  GoogleCloudRetailV2SetDefaultBranchRequest request,
  core.String catalog, {
  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('$catalog') + ':setDefaultBranch';

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