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\Directory\Resource;
19
20use Google\Service\Directory\Channel;
21use Google\Service\Directory\User;
22use Google\Service\Directory\UserMakeAdmin;
23use Google\Service\Directory\UserUndelete;
24use Google\Service\Directory\Users as UsersModel;
25
26/**
27 * The "users" collection of methods.
28 * Typical usage is:
29 *  <code>
30 *   $adminService = new Google\Service\Directory(...);
31 *   $users = $adminService->users;
32 *  </code>
33 */
34class Users extends \Google\Service\Resource
35{
36  /**
37   * Deletes a user. (users.delete)
38   *
39   * @param string $userKey Identifies the user in the API request. The value can
40   * be the user's primary email address, alias email address, or unique user ID.
41   * @param array $optParams Optional parameters.
42   */
43  public function delete($userKey, $optParams = [])
44  {
45    $params = ['userKey' => $userKey];
46    $params = array_merge($params, $optParams);
47    return $this->call('delete', [$params]);
48  }
49  /**
50   * Retrieves a user. (users.get)
51   *
52   * @param string $userKey Identifies the user in the API request. The value can
53   * be the user's primary email address, alias email address, or unique user ID.
54   * @param array $optParams Optional parameters.
55   *
56   * @opt_param string customFieldMask A comma-separated list of schema names. All
57   * fields from these schemas are fetched. This should only be set when
58   * `projection=custom`.
59   * @opt_param string projection What subset of fields to fetch for this user.
60   * @opt_param string viewType Whether to fetch the administrator-only or domain-
61   * wide public view of the user. For more information, see [Retrieve a user as a
62   * non-administrator](/admin-sdk/directory/v1/guides/manage-
63   * users#retrieve_users_non_admin).
64   * @return User
65   */
66  public function get($userKey, $optParams = [])
67  {
68    $params = ['userKey' => $userKey];
69    $params = array_merge($params, $optParams);
70    return $this->call('get', [$params], User::class);
71  }
72  /**
73   * Creates a user. (users.insert)
74   *
75   * @param User $postBody
76   * @param array $optParams Optional parameters.
77   * @return User
78   */
79  public function insert(User $postBody, $optParams = [])
80  {
81    $params = ['postBody' => $postBody];
82    $params = array_merge($params, $optParams);
83    return $this->call('insert', [$params], User::class);
84  }
85  /**
86   * Retrieves a paginated list of either deleted users or all users in a domain.
87   * (users.listUsers)
88   *
89   * @param array $optParams Optional parameters.
90   *
91   * @opt_param string customFieldMask A comma-separated list of schema names. All
92   * fields from these schemas are fetched. This should only be set when
93   * `projection=custom`.
94   * @opt_param string customer The unique ID for the customer's Google Workspace
95   * account. In case of a multi-domain account, to fetch all groups for a
96   * customer, fill this field instead of domain. You can also use the
97   * `my_customer` alias to represent your account's `customerId`. The
98   * `customerId` is also returned as part of the [Users resource](/admin-
99   * sdk/directory/v1/reference/users). Either the `customer` or the `domain`
100   * parameter must be provided.
101   * @opt_param string domain The domain name. Use this field to get groups from
102   * only one domain. To return all domains for a customer account, use the
103   * `customer` query parameter instead. Either the `customer` or the `domain`
104   * parameter must be provided.
105   * @opt_param string event Event on which subscription is intended (if
106   * subscribing)
107   * @opt_param int maxResults Maximum number of results to return.
108   * @opt_param string orderBy Property to use for sorting results.
109   * @opt_param string pageToken Token to specify next page in the list
110   * @opt_param string projection What subset of fields to fetch for this user.
111   * @opt_param string query Query string for searching user fields. For more
112   * information on constructing user queries, see [Search for Users](/admin-
113   * sdk/directory/v1/guides/search-users).
114   * @opt_param string showDeleted If set to `true`, retrieves the list of deleted
115   * users. (Default: `false`)
116   * @opt_param string sortOrder Whether to return results in ascending or
117   * descending order, ignoring case.
118   * @opt_param string viewType Whether to fetch the administrator-only or domain-
119   * wide public view of the user. For more information, see [Retrieve a user as a
120   * non-administrator](/admin-sdk/directory/v1/guides/manage-
121   * users#retrieve_users_non_admin).
122   * @return UsersModel
123   */
124  public function listUsers($optParams = [])
125  {
126    $params = [];
127    $params = array_merge($params, $optParams);
128    return $this->call('list', [$params], UsersModel::class);
129  }
130  /**
131   * Makes a user a super administrator. (users.makeAdmin)
132   *
133   * @param string $userKey Identifies the user in the API request. The value can
134   * be the user's primary email address, alias email address, or unique user ID.
135   * @param UserMakeAdmin $postBody
136   * @param array $optParams Optional parameters.
137   */
138  public function makeAdmin($userKey, UserMakeAdmin $postBody, $optParams = [])
139  {
140    $params = ['userKey' => $userKey, 'postBody' => $postBody];
141    $params = array_merge($params, $optParams);
142    return $this->call('makeAdmin', [$params]);
143  }
144  /**
145   * Updates a user using patch semantics. The update method should be used
146   * instead, since it also supports patch semantics and has better performance.
147   * This method is unable to clear fields that contain repeated objects
148   * (`addresses`, `phones`, etc). Use the update method instead. (users.patch)
149   *
150   * @param string $userKey Identifies the user in the API request. The value can
151   * be the user's primary email address, alias email address, or unique user ID.
152   * @param User $postBody
153   * @param array $optParams Optional parameters.
154   * @return User
155   */
156  public function patch($userKey, User $postBody, $optParams = [])
157  {
158    $params = ['userKey' => $userKey, 'postBody' => $postBody];
159    $params = array_merge($params, $optParams);
160    return $this->call('patch', [$params], User::class);
161  }
162  /**
163   * Signs a user out of all web and device sessions and reset their sign-in
164   * cookies. User will have to sign in by authenticating again. (users.signOut)
165   *
166   * @param string $userKey Identifies the target user in the API request. The
167   * value can be the user's primary email address, alias email address, or unique
168   * user ID.
169   * @param array $optParams Optional parameters.
170   */
171  public function signOut($userKey, $optParams = [])
172  {
173    $params = ['userKey' => $userKey];
174    $params = array_merge($params, $optParams);
175    return $this->call('signOut', [$params]);
176  }
177  /**
178   * Undeletes a deleted user. (users.undelete)
179   *
180   * @param string $userKey The immutable id of the user
181   * @param UserUndelete $postBody
182   * @param array $optParams Optional parameters.
183   */
184  public function undelete($userKey, UserUndelete $postBody, $optParams = [])
185  {
186    $params = ['userKey' => $userKey, 'postBody' => $postBody];
187    $params = array_merge($params, $optParams);
188    return $this->call('undelete', [$params]);
189  }
190  /**
191   * Updates a user. This method supports patch semantics, meaning you only need
192   * to include the fields you wish to update. Fields that are not present in the
193   * request will be preserved, and fields set to `null` will be cleared.
194   * (users.update)
195   *
196   * @param string $userKey Identifies the user in the API request. The value can
197   * be the user's primary email address, alias email address, or unique user ID.
198   * @param User $postBody
199   * @param array $optParams Optional parameters.
200   * @return User
201   */
202  public function update($userKey, User $postBody, $optParams = [])
203  {
204    $params = ['userKey' => $userKey, 'postBody' => $postBody];
205    $params = array_merge($params, $optParams);
206    return $this->call('update', [$params], User::class);
207  }
208  /**
209   * Watches for changes in users list. (users.watch)
210   *
211   * @param Channel $postBody
212   * @param array $optParams Optional parameters.
213   *
214   * @opt_param string customFieldMask Comma-separated list of schema names. All
215   * fields from these schemas are fetched. This should only be set when
216   * projection=custom.
217   * @opt_param string customer Immutable ID of the Google Workspace account. In
218   * case of multi-domain, to fetch all users for a customer, fill this field
219   * instead of domain.
220   * @opt_param string domain Name of the domain. Fill this field to get users
221   * from only this domain. To return all users in a multi-domain fill customer
222   * field instead."
223   * @opt_param string event Events to watch for.
224   * @opt_param int maxResults Maximum number of results to return.
225   * @opt_param string orderBy Column to use for sorting results
226   * @opt_param string pageToken Token to specify next page in the list
227   * @opt_param string projection What subset of fields to fetch for this user.
228   * @opt_param string query Query string search. Should be of the form "".
229   * Complete documentation is at https: //developers.google.com/admin-
230   * sdk/directory/v1/guides/search-users
231   * @opt_param string showDeleted If set to true, retrieves the list of deleted
232   * users. (Default: false)
233   * @opt_param string sortOrder Whether to return results in ascending or
234   * descending order.
235   * @opt_param string viewType Whether to fetch the administrator-only or domain-
236   * wide public view of the user. For more information, see [Retrieve a user as a
237   * non-administrator](/admin-sdk/directory/v1/guides/manage-
238   * users#retrieve_users_non_admin).
239   * @return Channel
240   */
241  public function watch(Channel $postBody, $optParams = [])
242  {
243    $params = ['postBody' => $postBody];
244    $params = array_merge($params, $optParams);
245    return $this->call('watch', [$params], Channel::class);
246  }
247}
248
249// Adding a class alias for backwards compatibility with the previous class name.
250class_alias(Users::class, 'Google_Service_Directory_Resource_Users');
251