1<?php
2/*
3 * Copyright 2014 Google Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy of
7 * the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17
18namespace Google\Service\CloudRetail\Resource;
19
20use Google\Service\CloudRetail\GoogleCloudRetailV2Catalog;
21use Google\Service\CloudRetail\GoogleCloudRetailV2CompleteQueryResponse;
22use Google\Service\CloudRetail\GoogleCloudRetailV2GetDefaultBranchResponse;
23use Google\Service\CloudRetail\GoogleCloudRetailV2ListCatalogsResponse;
24use Google\Service\CloudRetail\GoogleCloudRetailV2SetDefaultBranchRequest;
25use Google\Service\CloudRetail\GoogleProtobufEmpty;
26
27/**
28 * The "catalogs" collection of methods.
29 * Typical usage is:
30 *  <code>
31 *   $retailService = new Google\Service\CloudRetail(...);
32 *   $catalogs = $retailService->catalogs;
33 *  </code>
34 */
35class ProjectsLocationsCatalogs extends \Google\Service\Resource
36{
37  /**
38   * Completes the specified prefix with keyword suggestions. This feature is only
39   * available for users who have Retail Search enabled. Please enable Retail
40   * Search on Cloud Console before using this feature. (catalogs.completeQuery)
41   *
42   * @param string $catalog Required. Catalog for which the completion is
43   * performed. Full resource name of catalog, such as
44   * `projects/locations/global/catalogs/default_catalog`.
45   * @param array $optParams Optional parameters.
46   *
47   * @opt_param string dataset Determines which dataset to use for fetching
48   * completion. "user-data" will use the imported dataset through
49   * CompletionService.ImportCompletionData. "cloud-retail" will use the dataset
50   * generated by cloud retail based on user events. If leave empty, it will use
51   * the "user-data". Current supported values: * user-data * cloud-retail This
52   * option requires additional allowlisting. Before using cloud-retail, contact
53   * Cloud Retail support team first.
54   * @opt_param string deviceType The device type context for completion
55   * suggestions. It is useful to apply different suggestions on different device
56   * types, e.g. `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across
57   * all device types. Supported formats: * `UNKNOWN_DEVICE_TYPE` * `DESKTOP` *
58   * `MOBILE` * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`.
59   * @opt_param string languageCodes The language filters applied to the output
60   * suggestions. If set, it should contain the language of the query. If not set,
61   * suggestions are returned without considering language restrictions. This is
62   * the BCP-47 language code, such as "en-US" or "sr-Latn". For more information,
63   * see [Tags for Identifying Languages](https://tools.ietf.org/html/bcp47). The
64   * maximum number of language codes is 3.
65   * @opt_param int maxSuggestions Completion max suggestions. If left unset or
66   * set to 0, then will fallback to the configured value
67   * CompletionConfig.max_suggestions. The maximum allowed max suggestions is 20.
68   * If it is set higher, it will be capped by 20.
69   * @opt_param string query Required. The query used to generate suggestions. The
70   * maximum number of allowed characters is 255.
71   * @opt_param string visitorId Required field. A unique identifier for tracking
72   * visitors. For example, this could be implemented with an HTTP cookie, which
73   * should be able to uniquely identify a visitor on a single device. This unique
74   * identifier should not change if the visitor logs in or out of the website.
75   * The field must be a UTF-8 encoded string with a length limit of 128
76   * characters. Otherwise, an INVALID_ARGUMENT error is returned.
77   * @return GoogleCloudRetailV2CompleteQueryResponse
78   */
79  public function completeQuery($catalog, $optParams = [])
80  {
81    $params = ['catalog' => $catalog];
82    $params = array_merge($params, $optParams);
83    return $this->call('completeQuery', [$params], GoogleCloudRetailV2CompleteQueryResponse::class);
84  }
85  /**
86   * Get which branch is currently default branch set by
87   * CatalogService.SetDefaultBranch method under a specified parent catalog.
88   * (catalogs.getDefaultBranch)
89   *
90   * @param string $catalog The parent catalog resource name, such as
91   * `projects/locations/global/catalogs/default_catalog`.
92   * @param array $optParams Optional parameters.
93   * @return GoogleCloudRetailV2GetDefaultBranchResponse
94   */
95  public function getDefaultBranch($catalog, $optParams = [])
96  {
97    $params = ['catalog' => $catalog];
98    $params = array_merge($params, $optParams);
99    return $this->call('getDefaultBranch', [$params], GoogleCloudRetailV2GetDefaultBranchResponse::class);
100  }
101  /**
102   * Lists all the Catalogs associated with the project.
103   * (catalogs.listProjectsLocationsCatalogs)
104   *
105   * @param string $parent Required. The account resource name with an associated
106   * location. If the caller does not have permission to list Catalogs under this
107   * location, regardless of whether or not this location exists, a
108   * PERMISSION_DENIED error is returned.
109   * @param array $optParams Optional parameters.
110   *
111   * @opt_param int pageSize Maximum number of Catalogs to return. If unspecified,
112   * defaults to 50. The maximum allowed value is 1000. Values above 1000 will be
113   * coerced to 1000. If this field is negative, an INVALID_ARGUMENT is returned.
114   * @opt_param string pageToken A page token
115   * ListCatalogsResponse.next_page_token, received from a previous
116   * CatalogService.ListCatalogs call. Provide this to retrieve the subsequent
117   * page. When paginating, all other parameters provided to
118   * CatalogService.ListCatalogs must match the call that provided the page token.
119   * Otherwise, an INVALID_ARGUMENT error is returned.
120   * @return GoogleCloudRetailV2ListCatalogsResponse
121   */
122  public function listProjectsLocationsCatalogs($parent, $optParams = [])
123  {
124    $params = ['parent' => $parent];
125    $params = array_merge($params, $optParams);
126    return $this->call('list', [$params], GoogleCloudRetailV2ListCatalogsResponse::class);
127  }
128  /**
129   * Updates the Catalogs. (catalogs.patch)
130   *
131   * @param string $name Required. Immutable. The fully qualified resource name of
132   * the catalog.
133   * @param GoogleCloudRetailV2Catalog $postBody
134   * @param array $optParams Optional parameters.
135   *
136   * @opt_param string updateMask Indicates which fields in the provided Catalog
137   * to update. If an unsupported or unknown field is provided, an
138   * INVALID_ARGUMENT error is returned.
139   * @return GoogleCloudRetailV2Catalog
140   */
141  public function patch($name, GoogleCloudRetailV2Catalog $postBody, $optParams = [])
142  {
143    $params = ['name' => $name, 'postBody' => $postBody];
144    $params = array_merge($params, $optParams);
145    return $this->call('patch', [$params], GoogleCloudRetailV2Catalog::class);
146  }
147  /**
148   * Set a specified branch id as default branch. API methods such as
149   * SearchService.Search, ProductService.GetProduct, ProductService.ListProducts
150   * will treat requests using "default_branch" to the actual branch id set as
151   * default. For example, if `projects/locations/catalogs/branches/1` is set as
152   * default, setting SearchRequest.branch to
153   * `projects/locations/catalogs/branches/default_branch` is equivalent to
154   * setting SearchRequest.branch to `projects/locations/catalogs/branches/1`.
155   * Using multiple branches can be useful when developers would like to have a
156   * staging branch to test and verify for future usage. When it becomes ready,
157   * developers switch on the staging branch using this API while keeping using
158   * `projects/locations/catalogs/branches/default_branch` as SearchRequest.branch
159   * to route the traffic to this staging branch. CAUTION: If you have live
160   * predict/search traffic, switching the default branch could potentially cause
161   * outages if the ID space of the new branch is very different from the old one.
162   * More specifically: * PredictionService will only return product IDs from
163   * branch {newBranch}. * SearchService will only return product IDs from branch
164   * {newBranch} (if branch is not explicitly set). * UserEventService will only
165   * join events with products from branch {newBranch}.
166   * (catalogs.setDefaultBranch)
167   *
168   * @param string $catalog Full resource name of the catalog, such as
169   * `projects/locations/global/catalogs/default_catalog`.
170   * @param GoogleCloudRetailV2SetDefaultBranchRequest $postBody
171   * @param array $optParams Optional parameters.
172   * @return GoogleProtobufEmpty
173   */
174  public function setDefaultBranch($catalog, GoogleCloudRetailV2SetDefaultBranchRequest $postBody, $optParams = [])
175  {
176    $params = ['catalog' => $catalog, 'postBody' => $postBody];
177    $params = array_merge($params, $optParams);
178    return $this->call('setDefaultBranch', [$params], GoogleProtobufEmpty::class);
179  }
180}
181
182// Adding a class alias for backwards compatibility with the previous class name.
183class_alias(ProjectsLocationsCatalogs::class, 'Google_Service_CloudRetail_Resource_ProjectsLocationsCatalogs');
184