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\Licensing\Resource;
19
20use Google\Service\Licensing\LicenseAssignment;
21use Google\Service\Licensing\LicenseAssignmentInsert;
22use Google\Service\Licensing\LicenseAssignmentList;
23use Google\Service\Licensing\LicensingEmpty;
24
25/**
26 * The "licenseAssignments" collection of methods.
27 * Typical usage is:
28 *  <code>
29 *   $licensingService = new Google\Service\Licensing(...);
30 *   $licenseAssignments = $licensingService->licenseAssignments;
31 *  </code>
32 */
33class LicenseAssignments extends \Google\Service\Resource
34{
35  /**
36   * Revoke a license. (licenseAssignments.delete)
37   *
38   * @param string $productId A product's unique identifier. For more information
39   * about products in this version of the API, see Products and SKUs.
40   * @param string $skuId A product SKU's unique identifier. For more information
41   * about available SKUs in this version of the API, see Products and SKUs.
42   * @param string $userId The user's current primary email address. If the user's
43   * email address changes, use the new email address in your API requests. Since
44   * a `userId` is subject to change, do not use a `userId` value as a key for
45   * persistent data. This key could break if the current user's email address
46   * changes. If the `userId` is suspended, the license status changes.
47   * @param array $optParams Optional parameters.
48   * @return LicensingEmpty
49   */
50  public function delete($productId, $skuId, $userId, $optParams = [])
51  {
52    $params = ['productId' => $productId, 'skuId' => $skuId, 'userId' => $userId];
53    $params = array_merge($params, $optParams);
54    return $this->call('delete', [$params], LicensingEmpty::class);
55  }
56  /**
57   * Get a specific user's license by product SKU. (licenseAssignments.get)
58   *
59   * @param string $productId A product's unique identifier. For more information
60   * about products in this version of the API, see Products and SKUs.
61   * @param string $skuId A product SKU's unique identifier. For more information
62   * about available SKUs in this version of the API, see Products and SKUs.
63   * @param string $userId The user's current primary email address. If the user's
64   * email address changes, use the new email address in your API requests. Since
65   * a `userId` is subject to change, do not use a `userId` value as a key for
66   * persistent data. This key could break if the current user's email address
67   * changes. If the `userId` is suspended, the license status changes.
68   * @param array $optParams Optional parameters.
69   * @return LicenseAssignment
70   */
71  public function get($productId, $skuId, $userId, $optParams = [])
72  {
73    $params = ['productId' => $productId, 'skuId' => $skuId, 'userId' => $userId];
74    $params = array_merge($params, $optParams);
75    return $this->call('get', [$params], LicenseAssignment::class);
76  }
77  /**
78   * Assign a license. (licenseAssignments.insert)
79   *
80   * @param string $productId A product's unique identifier. For more information
81   * about products in this version of the API, see Products and SKUs.
82   * @param string $skuId A product SKU's unique identifier. For more information
83   * about available SKUs in this version of the API, see Products and SKUs.
84   * @param LicenseAssignmentInsert $postBody
85   * @param array $optParams Optional parameters.
86   * @return LicenseAssignment
87   */
88  public function insert($productId, $skuId, LicenseAssignmentInsert $postBody, $optParams = [])
89  {
90    $params = ['productId' => $productId, 'skuId' => $skuId, 'postBody' => $postBody];
91    $params = array_merge($params, $optParams);
92    return $this->call('insert', [$params], LicenseAssignment::class);
93  }
94  /**
95   * List all users assigned licenses for a specific product SKU.
96   * (licenseAssignments.listForProduct)
97   *
98   * @param string $productId A product's unique identifier. For more information
99   * about products in this version of the API, see Products and SKUs.
100   * @param string $customerId Customer's `customerId`. A previous version of this
101   * API accepted the primary domain name as a value for this field. If the
102   * customer is suspended, the server returns an error.
103   * @param array $optParams Optional parameters.
104   *
105   * @opt_param string maxResults The `maxResults` query string determines how
106   * many entries are returned on each page of a large response. This is an
107   * optional parameter. The value must be a positive number.
108   * @opt_param string pageToken Token to fetch the next page of data. The
109   * `maxResults` query string is related to the `pageToken` since `maxResults`
110   * determines how many entries are returned on each page. This is an optional
111   * query string. If not specified, the server returns the first page.
112   * @return LicenseAssignmentList
113   */
114  public function listForProduct($productId, $customerId, $optParams = [])
115  {
116    $params = ['productId' => $productId, 'customerId' => $customerId];
117    $params = array_merge($params, $optParams);
118    return $this->call('listForProduct', [$params], LicenseAssignmentList::class);
119  }
120  /**
121   * List all users assigned licenses for a specific product SKU.
122   * (licenseAssignments.listForProductAndSku)
123   *
124   * @param string $productId A product's unique identifier. For more information
125   * about products in this version of the API, see Products and SKUs.
126   * @param string $skuId A product SKU's unique identifier. For more information
127   * about available SKUs in this version of the API, see Products and SKUs.
128   * @param string $customerId Customer's `customerId`. A previous version of this
129   * API accepted the primary domain name as a value for this field. If the
130   * customer is suspended, the server returns an error.
131   * @param array $optParams Optional parameters.
132   *
133   * @opt_param string maxResults The `maxResults` query string determines how
134   * many entries are returned on each page of a large response. This is an
135   * optional parameter. The value must be a positive number.
136   * @opt_param string pageToken Token to fetch the next page of data. The
137   * `maxResults` query string is related to the `pageToken` since `maxResults`
138   * determines how many entries are returned on each page. This is an optional
139   * query string. If not specified, the server returns the first page.
140   * @return LicenseAssignmentList
141   */
142  public function listForProductAndSku($productId, $skuId, $customerId, $optParams = [])
143  {
144    $params = ['productId' => $productId, 'skuId' => $skuId, 'customerId' => $customerId];
145    $params = array_merge($params, $optParams);
146    return $this->call('listForProductAndSku', [$params], LicenseAssignmentList::class);
147  }
148  /**
149   * Reassign a user's product SKU with a different SKU in the same product. This
150   * method supports patch semantics. (licenseAssignments.patch)
151   *
152   * @param string $productId A product's unique identifier. For more information
153   * about products in this version of the API, see Products and SKUs.
154   * @param string $skuId A product SKU's unique identifier. For more information
155   * about available SKUs in this version of the API, see Products and SKUs.
156   * @param string $userId The user's current primary email address. If the user's
157   * email address changes, use the new email address in your API requests. Since
158   * a `userId` is subject to change, do not use a `userId` value as a key for
159   * persistent data. This key could break if the current user's email address
160   * changes. If the `userId` is suspended, the license status changes.
161   * @param LicenseAssignment $postBody
162   * @param array $optParams Optional parameters.
163   * @return LicenseAssignment
164   */
165  public function patch($productId, $skuId, $userId, LicenseAssignment $postBody, $optParams = [])
166  {
167    $params = ['productId' => $productId, 'skuId' => $skuId, 'userId' => $userId, 'postBody' => $postBody];
168    $params = array_merge($params, $optParams);
169    return $this->call('patch', [$params], LicenseAssignment::class);
170  }
171  /**
172   * Reassign a user's product SKU with a different SKU in the same product.
173   * (licenseAssignments.update)
174   *
175   * @param string $productId A product's unique identifier. For more information
176   * about products in this version of the API, see Products and SKUs.
177   * @param string $skuId A product SKU's unique identifier. For more information
178   * about available SKUs in this version of the API, see Products and SKUs.
179   * @param string $userId The user's current primary email address. If the user's
180   * email address changes, use the new email address in your API requests. Since
181   * a `userId` is subject to change, do not use a `userId` value as a key for
182   * persistent data. This key could break if the current user's email address
183   * changes. If the `userId` is suspended, the license status changes.
184   * @param LicenseAssignment $postBody
185   * @param array $optParams Optional parameters.
186   * @return LicenseAssignment
187   */
188  public function update($productId, $skuId, $userId, LicenseAssignment $postBody, $optParams = [])
189  {
190    $params = ['productId' => $productId, 'skuId' => $skuId, 'userId' => $userId, 'postBody' => $postBody];
191    $params = array_merge($params, $optParams);
192    return $this->call('update', [$params], LicenseAssignment::class);
193  }
194}
195
196// Adding a class alias for backwards compatibility with the previous class name.
197class_alias(LicenseAssignments::class, 'Google_Service_Licensing_Resource_LicenseAssignments');
198