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\Vision\Resource;
19
20use Google\Service\Vision\ListProductsResponse;
21use Google\Service\Vision\Operation;
22use Google\Service\Vision\Product;
23use Google\Service\Vision\PurgeProductsRequest;
24use Google\Service\Vision\VisionEmpty;
25
26/**
27 * The "products" collection of methods.
28 * Typical usage is:
29 *  <code>
30 *   $visionService = new Google\Service\Vision(...);
31 *   $products = $visionService->products;
32 *  </code>
33 */
34class ProjectsLocationsProducts extends \Google\Service\Resource
35{
36  /**
37   * Creates and returns a new product resource. Possible errors: * Returns
38   * INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. *
39   * Returns INVALID_ARGUMENT if description is longer than 4096 characters. *
40   * Returns INVALID_ARGUMENT if product_category is missing or invalid.
41   * (products.create)
42   *
43   * @param string $parent Required. The project in which the Product should be
44   * created. Format is `projects/PROJECT_ID/locations/LOC_ID`.
45   * @param Product $postBody
46   * @param array $optParams Optional parameters.
47   *
48   * @opt_param string productId A user-supplied resource id for this Product. If
49   * set, the server will attempt to use this value as the resource id. If it is
50   * already in use, an error is returned with code ALREADY_EXISTS. Must be at
51   * most 128 characters long. It cannot contain the character `/`.
52   * @return Product
53   */
54  public function create($parent, Product $postBody, $optParams = [])
55  {
56    $params = ['parent' => $parent, 'postBody' => $postBody];
57    $params = array_merge($params, $optParams);
58    return $this->call('create', [$params], Product::class);
59  }
60  /**
61   * Permanently deletes a product and its reference images. Metadata of the
62   * product and all its images will be deleted right away, but search queries
63   * against ProductSets containing the product may still work until all related
64   * caches are refreshed. (products.delete)
65   *
66   * @param string $name Required. Resource name of product to delete. Format is:
67   * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
68   * @param array $optParams Optional parameters.
69   * @return VisionEmpty
70   */
71  public function delete($name, $optParams = [])
72  {
73    $params = ['name' => $name];
74    $params = array_merge($params, $optParams);
75    return $this->call('delete', [$params], VisionEmpty::class);
76  }
77  /**
78   * Gets information associated with a Product. Possible errors: * Returns
79   * NOT_FOUND if the Product does not exist. (products.get)
80   *
81   * @param string $name Required. Resource name of the Product to get. Format is:
82   * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
83   * @param array $optParams Optional parameters.
84   * @return Product
85   */
86  public function get($name, $optParams = [])
87  {
88    $params = ['name' => $name];
89    $params = array_merge($params, $optParams);
90    return $this->call('get', [$params], Product::class);
91  }
92  /**
93   * Lists products in an unspecified order. Possible errors: * Returns
94   * INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
95   * (products.listProjectsLocationsProducts)
96   *
97   * @param string $parent Required. The project OR ProductSet from which Products
98   * should be listed. Format: `projects/PROJECT_ID/locations/LOC_ID`
99   * @param array $optParams Optional parameters.
100   *
101   * @opt_param int pageSize The maximum number of items to return. Default 10,
102   * maximum 100.
103   * @opt_param string pageToken The next_page_token returned from a previous List
104   * request, if any.
105   * @return ListProductsResponse
106   */
107  public function listProjectsLocationsProducts($parent, $optParams = [])
108  {
109    $params = ['parent' => $parent];
110    $params = array_merge($params, $optParams);
111    return $this->call('list', [$params], ListProductsResponse::class);
112  }
113  /**
114   * Makes changes to a Product resource. Only the `display_name`, `description`,
115   * and `labels` fields can be updated right now. If labels are updated, the
116   * change will not be reflected in queries until the next index time. Possible
117   * errors: * Returns NOT_FOUND if the Product does not exist. * Returns
118   * INVALID_ARGUMENT if display_name is present in update_mask but is missing
119   * from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT
120   * if description is present in update_mask but is longer than 4096 characters.
121   * * Returns INVALID_ARGUMENT if product_category is present in update_mask.
122   * (products.patch)
123   *
124   * @param string $name The resource name of the product. Format is:
125   * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. This field is
126   * ignored when creating a product.
127   * @param Product $postBody
128   * @param array $optParams Optional parameters.
129   *
130   * @opt_param string updateMask The FieldMask that specifies which fields to
131   * update. If update_mask isn't specified, all mutable fields are to be updated.
132   * Valid mask paths include `product_labels`, `display_name`, and `description`.
133   * @return Product
134   */
135  public function patch($name, Product $postBody, $optParams = [])
136  {
137    $params = ['name' => $name, 'postBody' => $postBody];
138    $params = array_merge($params, $optParams);
139    return $this->call('patch', [$params], Product::class);
140  }
141  /**
142   * Asynchronous API to delete all Products in a ProductSet or all Products that
143   * are in no ProductSet. If a Product is a member of the specified ProductSet in
144   * addition to other ProductSets, the Product will still be deleted. It is
145   * recommended to not delete the specified ProductSet until after this operation
146   * has completed. It is also recommended to not add any of the Products involved
147   * in the batch delete to a new ProductSet while this operation is running
148   * because those Products may still end up deleted. It's not possible to undo
149   * the PurgeProducts operation. Therefore, it is recommended to keep the csv
150   * files used in ImportProductSets (if that was how you originally built the
151   * Product Set) before starting PurgeProducts, in case you need to re-import the
152   * data after deletion. If the plan is to purge all of the Products from a
153   * ProductSet and then re-use the empty ProductSet to re-import new Products
154   * into the empty ProductSet, you must wait until the PurgeProducts operation
155   * has finished for that ProductSet. The google.longrunning.Operation API can be
156   * used to keep track of the progress and results of the request.
157   * `Operation.metadata` contains `BatchOperationMetadata`. (progress)
158   * (products.purge)
159   *
160   * @param string $parent Required. The project and location in which the
161   * Products should be deleted. Format is `projects/PROJECT_ID/locations/LOC_ID`.
162   * @param PurgeProductsRequest $postBody
163   * @param array $optParams Optional parameters.
164   * @return Operation
165   */
166  public function purge($parent, PurgeProductsRequest $postBody, $optParams = [])
167  {
168    $params = ['parent' => $parent, 'postBody' => $postBody];
169    $params = array_merge($params, $optParams);
170    return $this->call('purge', [$params], Operation::class);
171  }
172}
173
174// Adding a class alias for backwards compatibility with the previous class name.
175class_alias(ProjectsLocationsProducts::class, 'Google_Service_Vision_Resource_ProjectsLocationsProducts');
176