[e3d4e0a] | 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\Directory\Resource;
|
---|
| 19 |
|
---|
| 20 | use Google\Service\Directory\Channel;
|
---|
| 21 | use Google\Service\Directory\User;
|
---|
| 22 | use Google\Service\Directory\UserMakeAdmin;
|
---|
| 23 | use Google\Service\Directory\UserUndelete;
|
---|
| 24 | use 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 | */
|
---|
| 34 | class 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 | * @throws \Google\Service\Exception
|
---|
| 43 | */
|
---|
| 44 | public function delete($userKey, $optParams = [])
|
---|
| 45 | {
|
---|
| 46 | $params = ['userKey' => $userKey];
|
---|
| 47 | $params = array_merge($params, $optParams);
|
---|
| 48 | return $this->call('delete', [$params]);
|
---|
| 49 | }
|
---|
| 50 | /**
|
---|
| 51 | * Retrieves a user. (users.get)
|
---|
| 52 | *
|
---|
| 53 | * @param string $userKey Identifies the user in the API request. The value can
|
---|
| 54 | * be the user's primary email address, alias email address, or unique user ID.
|
---|
| 55 | * @param array $optParams Optional parameters.
|
---|
| 56 | *
|
---|
| 57 | * @opt_param string customFieldMask A comma-separated list of schema names. All
|
---|
| 58 | * fields from these schemas are fetched. This should only be set when
|
---|
| 59 | * `projection=custom`.
|
---|
| 60 | * @opt_param string projection What subset of fields to fetch for this user.
|
---|
| 61 | * @opt_param string viewType Whether to fetch the administrator-only or domain-
|
---|
| 62 | * wide public view of the user. For more information, see [Retrieve a user as a
|
---|
| 63 | * non-administrator](/admin-sdk/directory/v1/guides/manage-
|
---|
| 64 | * users#retrieve_users_non_admin).
|
---|
| 65 | * @return User
|
---|
| 66 | * @throws \Google\Service\Exception
|
---|
| 67 | */
|
---|
| 68 | public function get($userKey, $optParams = [])
|
---|
| 69 | {
|
---|
| 70 | $params = ['userKey' => $userKey];
|
---|
| 71 | $params = array_merge($params, $optParams);
|
---|
| 72 | return $this->call('get', [$params], User::class);
|
---|
| 73 | }
|
---|
| 74 | /**
|
---|
| 75 | * Creates a user. Mutate calls immediately following user creation might
|
---|
| 76 | * sometimes fail as the user isn't fully created due to propagation delay in
|
---|
| 77 | * our backends. Check the error details for the "User creation is not complete"
|
---|
| 78 | * message to see if this is the case. Retrying the calls after some time can
|
---|
| 79 | * help in this case. If `resolveConflictAccount` is set to `true`, a `202`
|
---|
| 80 | * response code means that a conflicting unmanaged account exists and was
|
---|
| 81 | * invited to join the organization. A `409` response code means that a
|
---|
| 82 | * conflicting account exists so the user wasn't created based on the [handling
|
---|
| 83 | * unmanaged user accounts](https://support.google.com/a/answer/11112794) option
|
---|
| 84 | * selected. (users.insert)
|
---|
| 85 | *
|
---|
| 86 | * @param User $postBody
|
---|
| 87 | * @param array $optParams Optional parameters.
|
---|
| 88 | *
|
---|
| 89 | * @opt_param bool resolveConflictAccount Optional. If set to `true`, the option
|
---|
| 90 | * selected for [handling unmanaged user
|
---|
| 91 | * accounts](https://support.google.com/a/answer/11112794) will apply. Default:
|
---|
| 92 | * `false`
|
---|
| 93 | * @return User
|
---|
| 94 | * @throws \Google\Service\Exception
|
---|
| 95 | */
|
---|
| 96 | public function insert(User $postBody, $optParams = [])
|
---|
| 97 | {
|
---|
| 98 | $params = ['postBody' => $postBody];
|
---|
| 99 | $params = array_merge($params, $optParams);
|
---|
| 100 | return $this->call('insert', [$params], User::class);
|
---|
| 101 | }
|
---|
| 102 | /**
|
---|
| 103 | * Retrieves a paginated list of either deleted users or all users in a domain.
|
---|
| 104 | * (users.listUsers)
|
---|
| 105 | *
|
---|
| 106 | * @param array $optParams Optional parameters.
|
---|
| 107 | *
|
---|
| 108 | * @opt_param string customFieldMask A comma-separated list of schema names. All
|
---|
| 109 | * fields from these schemas are fetched. This should only be set when
|
---|
| 110 | * `projection=custom`.
|
---|
| 111 | * @opt_param string customer The unique ID for the customer's Google Workspace
|
---|
| 112 | * account. In case of a multi-domain account, to fetch all users for a
|
---|
| 113 | * customer, use this field instead of `domain`. You can also use the
|
---|
| 114 | * `my_customer` alias to represent your account's `customerId`. The
|
---|
| 115 | * `customerId` is also returned as part of the [Users](/admin-
|
---|
| 116 | * sdk/directory/v1/reference/users) resource. You must provide either the
|
---|
| 117 | * `customer` or the `domain` parameter.
|
---|
| 118 | * @opt_param string domain The domain name. Use this field to get users from
|
---|
| 119 | * only one domain. To return all domains for a customer account, use the
|
---|
| 120 | * `customer` query parameter instead. Either the `customer` or the `domain`
|
---|
| 121 | * parameter must be provided.
|
---|
| 122 | * @opt_param string event Event on which subscription is intended (if
|
---|
| 123 | * subscribing)
|
---|
| 124 | * @opt_param int maxResults Maximum number of results to return.
|
---|
| 125 | * @opt_param string orderBy Property to use for sorting results.
|
---|
| 126 | * @opt_param string pageToken Token to specify next page in the list
|
---|
| 127 | * @opt_param string projection What subset of fields to fetch for this user.
|
---|
| 128 | * @opt_param string query Query string for searching user fields. For more
|
---|
| 129 | * information on constructing user queries, see [Search for Users](/admin-
|
---|
| 130 | * sdk/directory/v1/guides/search-users).
|
---|
| 131 | * @opt_param string showDeleted If set to `true`, retrieves the list of deleted
|
---|
| 132 | * users. (Default: `false`)
|
---|
| 133 | * @opt_param string sortOrder Whether to return results in ascending or
|
---|
| 134 | * descending order, ignoring case.
|
---|
| 135 | * @opt_param string viewType Whether to fetch the administrator-only or domain-
|
---|
| 136 | * wide public view of the user. For more information, see [Retrieve a user as a
|
---|
| 137 | * non-administrator](/admin-sdk/directory/v1/guides/manage-
|
---|
| 138 | * users#retrieve_users_non_admin).
|
---|
| 139 | * @return UsersModel
|
---|
| 140 | * @throws \Google\Service\Exception
|
---|
| 141 | */
|
---|
| 142 | public function listUsers($optParams = [])
|
---|
| 143 | {
|
---|
| 144 | $params = [];
|
---|
| 145 | $params = array_merge($params, $optParams);
|
---|
| 146 | return $this->call('list', [$params], UsersModel::class);
|
---|
| 147 | }
|
---|
| 148 | /**
|
---|
| 149 | * Makes a user a super administrator. (users.makeAdmin)
|
---|
| 150 | *
|
---|
| 151 | * @param string $userKey Identifies the user in the API request. The value can
|
---|
| 152 | * be the user's primary email address, alias email address, or unique user ID.
|
---|
| 153 | * @param UserMakeAdmin $postBody
|
---|
| 154 | * @param array $optParams Optional parameters.
|
---|
| 155 | * @throws \Google\Service\Exception
|
---|
| 156 | */
|
---|
| 157 | public function makeAdmin($userKey, UserMakeAdmin $postBody, $optParams = [])
|
---|
| 158 | {
|
---|
| 159 | $params = ['userKey' => $userKey, 'postBody' => $postBody];
|
---|
| 160 | $params = array_merge($params, $optParams);
|
---|
| 161 | return $this->call('makeAdmin', [$params]);
|
---|
| 162 | }
|
---|
| 163 | /**
|
---|
| 164 | * Updates a user using patch semantics. The update method should be used
|
---|
| 165 | * instead, because it also supports patch semantics and has better performance.
|
---|
| 166 | * If you're mapping an external identity to a Google identity, use the
|
---|
| 167 | * [`update`](https://developers.google.com/admin-
|
---|
| 168 | * sdk/directory/v1/reference/users/update) method instead of the `patch`
|
---|
| 169 | * method. This method is unable to clear fields that contain repeated objects
|
---|
| 170 | * (`addresses`, `phones`, etc). Use the update method instead. (users.patch)
|
---|
| 171 | *
|
---|
| 172 | * @param string $userKey Identifies the user in the API request. The value can
|
---|
| 173 | * be the user's primary email address, alias email address, or unique user ID.
|
---|
| 174 | * @param User $postBody
|
---|
| 175 | * @param array $optParams Optional parameters.
|
---|
| 176 | * @return User
|
---|
| 177 | * @throws \Google\Service\Exception
|
---|
| 178 | */
|
---|
| 179 | public function patch($userKey, User $postBody, $optParams = [])
|
---|
| 180 | {
|
---|
| 181 | $params = ['userKey' => $userKey, 'postBody' => $postBody];
|
---|
| 182 | $params = array_merge($params, $optParams);
|
---|
| 183 | return $this->call('patch', [$params], User::class);
|
---|
| 184 | }
|
---|
| 185 | /**
|
---|
| 186 | * Signs a user out of all web and device sessions and reset their sign-in
|
---|
| 187 | * cookies. User will have to sign in by authenticating again. (users.signOut)
|
---|
| 188 | *
|
---|
| 189 | * @param string $userKey Identifies the target user in the API request. The
|
---|
| 190 | * value can be the user's primary email address, alias email address, or unique
|
---|
| 191 | * user ID.
|
---|
| 192 | * @param array $optParams Optional parameters.
|
---|
| 193 | * @throws \Google\Service\Exception
|
---|
| 194 | */
|
---|
| 195 | public function signOut($userKey, $optParams = [])
|
---|
| 196 | {
|
---|
| 197 | $params = ['userKey' => $userKey];
|
---|
| 198 | $params = array_merge($params, $optParams);
|
---|
| 199 | return $this->call('signOut', [$params]);
|
---|
| 200 | }
|
---|
| 201 | /**
|
---|
| 202 | * Undeletes a deleted user. (users.undelete)
|
---|
| 203 | *
|
---|
| 204 | * @param string $userKey The immutable id of the user
|
---|
| 205 | * @param UserUndelete $postBody
|
---|
| 206 | * @param array $optParams Optional parameters.
|
---|
| 207 | * @throws \Google\Service\Exception
|
---|
| 208 | */
|
---|
| 209 | public function undelete($userKey, UserUndelete $postBody, $optParams = [])
|
---|
| 210 | {
|
---|
| 211 | $params = ['userKey' => $userKey, 'postBody' => $postBody];
|
---|
| 212 | $params = array_merge($params, $optParams);
|
---|
| 213 | return $this->call('undelete', [$params]);
|
---|
| 214 | }
|
---|
| 215 | /**
|
---|
| 216 | * Updates a user. This method supports patch semantics, meaning that you only
|
---|
| 217 | * need to include the fields you wish to update. Fields that are not present in
|
---|
| 218 | * the request will be preserved, and fields set to `null` will be cleared. For
|
---|
| 219 | * repeating fields that contain arrays, individual items in the array can't be
|
---|
| 220 | * patched piecemeal; they must be supplied in the request body with the desired
|
---|
| 221 | * values for all items. See the [user accounts
|
---|
| 222 | * guide](https://developers.google.com/admin-sdk/directory/v1/guides/manage-
|
---|
| 223 | * users#update_user) for more information. (users.update)
|
---|
| 224 | *
|
---|
| 225 | * @param string $userKey Identifies the user in the API request. The value can
|
---|
| 226 | * be the user's primary email address, alias email address, or unique user ID.
|
---|
| 227 | * @param User $postBody
|
---|
| 228 | * @param array $optParams Optional parameters.
|
---|
| 229 | * @return User
|
---|
| 230 | * @throws \Google\Service\Exception
|
---|
| 231 | */
|
---|
| 232 | public function update($userKey, User $postBody, $optParams = [])
|
---|
| 233 | {
|
---|
| 234 | $params = ['userKey' => $userKey, 'postBody' => $postBody];
|
---|
| 235 | $params = array_merge($params, $optParams);
|
---|
| 236 | return $this->call('update', [$params], User::class);
|
---|
| 237 | }
|
---|
| 238 | /**
|
---|
| 239 | * Watches for changes in users list. (users.watch)
|
---|
| 240 | *
|
---|
| 241 | * @param Channel $postBody
|
---|
| 242 | * @param array $optParams Optional parameters.
|
---|
| 243 | *
|
---|
| 244 | * @opt_param string customFieldMask Comma-separated list of schema names. All
|
---|
| 245 | * fields from these schemas are fetched. This should only be set when
|
---|
| 246 | * projection=custom.
|
---|
| 247 | * @opt_param string customer Immutable ID of the Google Workspace account. In
|
---|
| 248 | * case of multi-domain, to fetch all users for a customer, fill this field
|
---|
| 249 | * instead of domain.
|
---|
| 250 | * @opt_param string domain Name of the domain. Fill this field to get users
|
---|
| 251 | * from only this domain. To return all users in a multi-domain fill customer
|
---|
| 252 | * field instead."
|
---|
| 253 | * @opt_param string event Events to watch for.
|
---|
| 254 | * @opt_param int maxResults Maximum number of results to return.
|
---|
| 255 | * @opt_param string orderBy Column to use for sorting results
|
---|
| 256 | * @opt_param string pageToken Token to specify next page in the list
|
---|
| 257 | * @opt_param string projection What subset of fields to fetch for this user.
|
---|
| 258 | * @opt_param string query Query string search. Should be of the form "".
|
---|
| 259 | * Complete documentation is at https: //developers.google.com/admin-
|
---|
| 260 | * sdk/directory/v1/guides/search-users
|
---|
| 261 | * @opt_param string showDeleted If set to true, retrieves the list of deleted
|
---|
| 262 | * users. (Default: false)
|
---|
| 263 | * @opt_param string sortOrder Whether to return results in ascending or
|
---|
| 264 | * descending order.
|
---|
| 265 | * @opt_param string viewType Whether to fetch the administrator-only or domain-
|
---|
| 266 | * wide public view of the user. For more information, see [Retrieve a user as a
|
---|
| 267 | * non-administrator](/admin-sdk/directory/v1/guides/manage-
|
---|
| 268 | * users#retrieve_users_non_admin).
|
---|
| 269 | * @return Channel
|
---|
| 270 | * @throws \Google\Service\Exception
|
---|
| 271 | */
|
---|
| 272 | public function watch(Channel $postBody, $optParams = [])
|
---|
| 273 | {
|
---|
| 274 | $params = ['postBody' => $postBody];
|
---|
| 275 | $params = array_merge($params, $optParams);
|
---|
| 276 | return $this->call('watch', [$params], Channel::class);
|
---|
| 277 | }
|
---|
| 278 | }
|
---|
| 279 |
|
---|
| 280 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
| 281 | class_alias(Users::class, 'Google_Service_Directory_Resource_Users');
|
---|