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 
18 namespace Google\Service\AndroidEnterprise\Resource;
19 
20 use Google\Service\AndroidEnterprise\AuthenticationToken;
21 use Google\Service\AndroidEnterprise\ProductSet;
22 use Google\Service\AndroidEnterprise\User;
23 use Google\Service\AndroidEnterprise\UsersListResponse;
24 
25 /**
26  * The "users" collection of methods.
27  * Typical usage is:
28  *  <code>
29  *   $androidenterpriseService = new Google\Service\AndroidEnterprise(...);
30  *   $users = $androidenterpriseService->users;
31  *  </code>
32  */
33 class Users extends \Google\Service\Resource
34 {
35   /**
36    * Deleted an EMM-managed user. (users.delete)
37    *
38    * @param string $enterpriseId The ID of the enterprise.
39    * @param string $userId The ID of the user.
40    * @param array $optParams Optional parameters.
41    */
42   public function delete($enterpriseId, $userId, $optParams = [])
43   {
44     $params = ['enterpriseId' => $enterpriseId, 'userId' => $userId];
45     $params = array_merge($params, $optParams);
46     return $this->call('delete', [$params]);
47   }
48   /**
49    * Generates an authentication token which the device policy client can use to
50    * provision the given EMM-managed user account on a device. The generated token
51    * is single-use and expires after a few minutes. You can provision a maximum of
52    * 10 devices per user. This call only works with EMM-managed accounts.
53    * (users.generateAuthenticationToken)
54    *
55    * @param string $enterpriseId The ID of the enterprise.
56    * @param string $userId The ID of the user.
57    * @param array $optParams Optional parameters.
58    * @return AuthenticationToken
59    */
60   public function generateAuthenticationToken($enterpriseId, $userId, $optParams = [])
61   {
62     $params = ['enterpriseId' => $enterpriseId, 'userId' => $userId];
63     $params = array_merge($params, $optParams);
64     return $this->call('generateAuthenticationToken', [$params], AuthenticationToken::class);
65   }
66   /**
67    * Retrieves a user's details. (users.get)
68    *
69    * @param string $enterpriseId The ID of the enterprise.
70    * @param string $userId The ID of the user.
71    * @param array $optParams Optional parameters.
72    * @return User
73    */
74   public function get($enterpriseId, $userId, $optParams = [])
75   {
76     $params = ['enterpriseId' => $enterpriseId, 'userId' => $userId];
77     $params = array_merge($params, $optParams);
78     return $this->call('get', [$params], User::class);
79   }
80   /**
81    * Retrieves the set of products a user is entitled to access.
82    * (users.getAvailableProductSet)
83    *
84    * @param string $enterpriseId The ID of the enterprise.
85    * @param string $userId The ID of the user.
86    * @param array $optParams Optional parameters.
87    * @return ProductSet
88    */
89   public function getAvailableProductSet($enterpriseId, $userId, $optParams = [])
90   {
91     $params = ['enterpriseId' => $enterpriseId, 'userId' => $userId];
92     $params = array_merge($params, $optParams);
93     return $this->call('getAvailableProductSet', [$params], ProductSet::class);
94   }
95   /**
96    * Creates a new EMM-managed user. The Users resource passed in the body of the
97    * request should include an accountIdentifier and an accountType. If a
98    * corresponding user already exists with the same account identifier, the user
99    * will be updated with the resource. In this case only the displayName field
100    * can be changed. (users.insert)
101    *
102    * @param string $enterpriseId The ID of the enterprise.
103    * @param User $postBody
104    * @param array $optParams Optional parameters.
105    * @return User
106    */
107   public function insert($enterpriseId, User $postBody, $optParams = [])
108   {
109     $params = ['enterpriseId' => $enterpriseId, 'postBody' => $postBody];
110     $params = array_merge($params, $optParams);
111     return $this->call('insert', [$params], User::class);
112   }
113   /**
114    * Looks up a user by primary email address. This is only supported for Google-
115    * managed users. Lookup of the id is not needed for EMM-managed users because
116    * the id is already returned in the result of the Users.insert call.
117    * (users.listUsers)
118    *
119    * @param string $enterpriseId The ID of the enterprise.
120    * @param string $email Required. The exact primary email address of the user to
121    * look up.
122    * @param array $optParams Optional parameters.
123    * @return UsersListResponse
124    */
125   public function listUsers($enterpriseId, $email, $optParams = [])
126   {
127     $params = ['enterpriseId' => $enterpriseId, 'email' => $email];
128     $params = array_merge($params, $optParams);
129     return $this->call('list', [$params], UsersListResponse::class);
130   }
131   /**
132    * Revokes access to all devices currently provisioned to the user. The user
133    * will no longer be able to use the managed Play store on any of their managed
134    * devices. This call only works with EMM-managed accounts.
135    * (users.revokeDeviceAccess)
136    *
137    * @param string $enterpriseId The ID of the enterprise.
138    * @param string $userId The ID of the user.
139    * @param array $optParams Optional parameters.
140    */
141   public function revokeDeviceAccess($enterpriseId, $userId, $optParams = [])
142   {
143     $params = ['enterpriseId' => $enterpriseId, 'userId' => $userId];
144     $params = array_merge($params, $optParams);
145     return $this->call('revokeDeviceAccess', [$params]);
146   }
147   /**
148    * Modifies the set of products that a user is entitled to access (referred to
149    * as *whitelisted* products). Only products that are approved or products that
150    * were previously approved (products with revoked approval) can be whitelisted.
151    * (users.setAvailableProductSet)
152    *
153    * @param string $enterpriseId The ID of the enterprise.
154    * @param string $userId The ID of the user.
155    * @param ProductSet $postBody
156    * @param array $optParams Optional parameters.
157    * @return ProductSet
158    */
159   public function setAvailableProductSet($enterpriseId, $userId, ProductSet $postBody, $optParams = [])
160   {
161     $params = ['enterpriseId' => $enterpriseId, 'userId' => $userId, 'postBody' => $postBody];
162     $params = array_merge($params, $optParams);
163     return $this->call('setAvailableProductSet', [$params], ProductSet::class);
164   }
165   /**
166    * Updates the details of an EMM-managed user. Can be used with EMM-managed
167    * users only (not Google managed users). Pass the new details in the Users
168    * resource in the request body. Only the displayName field can be changed.
169    * Other fields must either be unset or have the currently active value.
170    * (users.update)
171    *
172    * @param string $enterpriseId The ID of the enterprise.
173    * @param string $userId The ID of the user.
174    * @param User $postBody
175    * @param array $optParams Optional parameters.
176    * @return User
177    */
178   public function update($enterpriseId, $userId, User $postBody, $optParams = [])
179   {
180     $params = ['enterpriseId' => $enterpriseId, 'userId' => $userId, 'postBody' => $postBody];
181     $params = array_merge($params, $optParams);
182     return $this->call('update', [$params], User::class);
183   }
184 }
185 
186 // Adding a class alias for backwards compatibility with the previous class name.
187 class_alias(Users::class, 'Google_Service_AndroidEnterprise_Resource_Users');
188