[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\HangoutsChat\Resource;
|
---|
| 19 |
|
---|
| 20 | use Google\Service\HangoutsChat\ListMembershipsResponse;
|
---|
| 21 | use Google\Service\HangoutsChat\Membership;
|
---|
| 22 |
|
---|
| 23 | /**
|
---|
| 24 | * The "members" collection of methods.
|
---|
| 25 | * Typical usage is:
|
---|
| 26 | * <code>
|
---|
| 27 | * $chatService = new Google\Service\HangoutsChat(...);
|
---|
| 28 | * $members = $chatService->spaces_members;
|
---|
| 29 | * </code>
|
---|
| 30 | */
|
---|
| 31 | class SpacesMembers extends \Google\Service\Resource
|
---|
| 32 | {
|
---|
| 33 | /**
|
---|
| 34 | * Creates a membership for the calling Chat app, a user, or a Google Group.
|
---|
| 35 | * Creating memberships for other Chat apps isn't supported. When creating a
|
---|
| 36 | * membership, if the specified member has their auto-accept policy turned off,
|
---|
| 37 | * then they're invited, and must accept the space invitation before joining.
|
---|
| 38 | * Otherwise, creating a membership adds the member directly to the specified
|
---|
| 39 | * space. Supports the following types of
|
---|
| 40 | * [authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 41 | * authorize): - [App
|
---|
| 42 | * authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 43 | * authorize-chat-app) with [administrator
|
---|
| 44 | * approval](https://support.google.com/a?p=chat-app-auth) in [Developer
|
---|
| 45 | * Preview](https://developers.google.com/workspace/preview) - [User
|
---|
| 46 | * authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 47 | * authorize-chat-user) You can authenticate and authorize this method with
|
---|
| 48 | * administrator privileges by setting the `use_admin_access` field in the
|
---|
| 49 | * request. For example usage, see: - [Invite or add a user to a
|
---|
| 50 | * space](https://developers.google.com/workspace/chat/create-members#create-
|
---|
| 51 | * user-membership). - [Invite or add a Google Group to a
|
---|
| 52 | * space](https://developers.google.com/workspace/chat/create-members#create-
|
---|
| 53 | * group-membership). - [Add the Chat app to a
|
---|
| 54 | * space](https://developers.google.com/workspace/chat/create-members#create-
|
---|
| 55 | * membership-calling-api). (members.create)
|
---|
| 56 | *
|
---|
| 57 | * @param string $parent Required. The resource name of the space for which to
|
---|
| 58 | * create the membership. Format: spaces/{space}
|
---|
| 59 | * @param Membership $postBody
|
---|
| 60 | * @param array $optParams Optional parameters.
|
---|
| 61 | *
|
---|
| 62 | * @opt_param bool useAdminAccess Optional. When `true`, the method runs using
|
---|
| 63 | * the user's Google Workspace administrator privileges. The calling user must
|
---|
| 64 | * be a Google Workspace administrator with the [manage chat and spaces
|
---|
| 65 | * conversations privilege](https://support.google.com/a/answer/13369245).
|
---|
| 66 | * Requires the `chat.admin.memberships` [OAuth 2.0
|
---|
| 67 | * scope](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 68 | * authorize#chat-api-scopes). Creating app memberships or creating memberships
|
---|
| 69 | * for users outside the administrator's Google Workspace organization isn't
|
---|
| 70 | * supported using admin access.
|
---|
| 71 | * @return Membership
|
---|
| 72 | * @throws \Google\Service\Exception
|
---|
| 73 | */
|
---|
| 74 | public function create($parent, Membership $postBody, $optParams = [])
|
---|
| 75 | {
|
---|
| 76 | $params = ['parent' => $parent, 'postBody' => $postBody];
|
---|
| 77 | $params = array_merge($params, $optParams);
|
---|
| 78 | return $this->call('create', [$params], Membership::class);
|
---|
| 79 | }
|
---|
| 80 | /**
|
---|
| 81 | * Deletes a membership. For an example, see [Remove a user or a Google Chat app
|
---|
| 82 | * from a space](https://developers.google.com/workspace/chat/delete-members).
|
---|
| 83 | * Supports the following types of
|
---|
| 84 | * [authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 85 | * authorize): - [App
|
---|
| 86 | * authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 87 | * authorize-chat-app) with [administrator
|
---|
| 88 | * approval](https://support.google.com/a?p=chat-app-auth) in [Developer
|
---|
| 89 | * Preview](https://developers.google.com/workspace/preview) - [User
|
---|
| 90 | * authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 91 | * authorize-chat-user) You can authenticate and authorize this method with
|
---|
| 92 | * administrator privileges by setting the `use_admin_access` field in the
|
---|
| 93 | * request. (members.delete)
|
---|
| 94 | *
|
---|
| 95 | * @param string $name Required. Resource name of the membership to delete. Chat
|
---|
| 96 | * apps can delete human users' or their own memberships. Chat apps can't delete
|
---|
| 97 | * other apps' memberships. When deleting a human membership, requires the
|
---|
| 98 | * `chat.memberships` scope and `spaces/{space}/members/{member}` format. You
|
---|
| 99 | * can use the email as an alias for `{member}`. For example,
|
---|
| 100 | * `spaces/{space}/members/example@gmail.com` where `example@gmail.com` is the
|
---|
| 101 | * email of the Google Chat user. When deleting an app membership, requires the
|
---|
| 102 | * `chat.memberships.app` scope and `spaces/{space}/members/app` format. Format:
|
---|
| 103 | * `spaces/{space}/members/{member}` or `spaces/{space}/members/app`.
|
---|
| 104 | * @param array $optParams Optional parameters.
|
---|
| 105 | *
|
---|
| 106 | * @opt_param bool useAdminAccess Optional. When `true`, the method runs using
|
---|
| 107 | * the user's Google Workspace administrator privileges. The calling user must
|
---|
| 108 | * be a Google Workspace administrator with the [manage chat and spaces
|
---|
| 109 | * conversations privilege](https://support.google.com/a/answer/13369245).
|
---|
| 110 | * Requires the `chat.admin.memberships` [OAuth 2.0
|
---|
| 111 | * scope](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 112 | * authorize#chat-api-scopes). Deleting app memberships in a space isn't
|
---|
| 113 | * supported using admin access.
|
---|
| 114 | * @return Membership
|
---|
| 115 | * @throws \Google\Service\Exception
|
---|
| 116 | */
|
---|
| 117 | public function delete($name, $optParams = [])
|
---|
| 118 | {
|
---|
| 119 | $params = ['name' => $name];
|
---|
| 120 | $params = array_merge($params, $optParams);
|
---|
| 121 | return $this->call('delete', [$params], Membership::class);
|
---|
| 122 | }
|
---|
| 123 | /**
|
---|
| 124 | * Returns details about a membership. For an example, see [Get details about a
|
---|
| 125 | * user's or Google Chat app's
|
---|
| 126 | * membership](https://developers.google.com/workspace/chat/get-members).
|
---|
| 127 | * Supports the following types of
|
---|
| 128 | * [authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 129 | * authorize): - [App
|
---|
| 130 | * authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 131 | * authorize-chat-app) - [User
|
---|
| 132 | * authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 133 | * authorize-chat-user) You can authenticate and authorize this method with
|
---|
| 134 | * administrator privileges by setting the `use_admin_access` field in the
|
---|
| 135 | * request. (members.get)
|
---|
| 136 | *
|
---|
| 137 | * @param string $name Required. Resource name of the membership to retrieve. To
|
---|
| 138 | * get the app's own membership [by using user
|
---|
| 139 | * authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 140 | * authorize-chat-user), you can optionally use `spaces/{space}/members/app`.
|
---|
| 141 | * Format: `spaces/{space}/members/{member}` or `spaces/{space}/members/app` You
|
---|
| 142 | * can use the user's email as an alias for `{member}`. For example,
|
---|
| 143 | * `spaces/{space}/members/example@gmail.com` where `example@gmail.com` is the
|
---|
| 144 | * email of the Google Chat user.
|
---|
| 145 | * @param array $optParams Optional parameters.
|
---|
| 146 | *
|
---|
| 147 | * @opt_param bool useAdminAccess Optional. When `true`, the method runs using
|
---|
| 148 | * the user's Google Workspace administrator privileges. The calling user must
|
---|
| 149 | * be a Google Workspace administrator with the [manage chat and spaces
|
---|
| 150 | * conversations privilege](https://support.google.com/a/answer/13369245).
|
---|
| 151 | * Requires the `chat.admin.memberships` or `chat.admin.memberships.readonly`
|
---|
| 152 | * [OAuth 2.0 scopes](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 153 | * authorize#chat-api-scopes). Getting app memberships in a space isn't
|
---|
| 154 | * supported when using admin access.
|
---|
| 155 | * @return Membership
|
---|
| 156 | * @throws \Google\Service\Exception
|
---|
| 157 | */
|
---|
| 158 | public function get($name, $optParams = [])
|
---|
| 159 | {
|
---|
| 160 | $params = ['name' => $name];
|
---|
| 161 | $params = array_merge($params, $optParams);
|
---|
| 162 | return $this->call('get', [$params], Membership::class);
|
---|
| 163 | }
|
---|
| 164 | /**
|
---|
| 165 | * Lists memberships in a space. For an example, see [List users and Google Chat
|
---|
| 166 | * apps in a space](https://developers.google.com/workspace/chat/list-members).
|
---|
| 167 | * Listing memberships with [app
|
---|
| 168 | * authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 169 | * authorize-chat-app) lists memberships in spaces that the Chat app has access
|
---|
| 170 | * to, but excludes Chat app memberships, including its own. Listing memberships
|
---|
| 171 | * with [User
|
---|
| 172 | * authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 173 | * authorize-chat-user) lists memberships in spaces that the authenticated user
|
---|
| 174 | * has access to. Supports the following types of
|
---|
| 175 | * [authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 176 | * authorize): - [App
|
---|
| 177 | * authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 178 | * authorize-chat-app) - [User
|
---|
| 179 | * authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 180 | * authorize-chat-user) You can authenticate and authorize this method with
|
---|
| 181 | * administrator privileges by setting the `use_admin_access` field in the
|
---|
| 182 | * request. (members.listSpacesMembers)
|
---|
| 183 | *
|
---|
| 184 | * @param string $parent Required. The resource name of the space for which to
|
---|
| 185 | * fetch a membership list. Format: spaces/{space}
|
---|
| 186 | * @param array $optParams Optional parameters.
|
---|
| 187 | *
|
---|
| 188 | * @opt_param string filter Optional. A query filter. You can filter memberships
|
---|
| 189 | * by a member's role ([`role`](https://developers.google.com/workspace/chat/api
|
---|
| 190 | * /reference/rest/v1/spaces.members#membershiprole)) and type ([`member.type`](
|
---|
| 191 | * https://developers.google.com/workspace/chat/api/reference/rest/v1/User#type)
|
---|
| 192 | * ). To filter by role, set `role` to `ROLE_MEMBER` or `ROLE_MANAGER`. To
|
---|
| 193 | * filter by type, set `member.type` to `HUMAN` or `BOT`. You can also filter
|
---|
| 194 | * for `member.type` using the `!=` operator. To filter by both role and type,
|
---|
| 195 | * use the `AND` operator. To filter by either role or type, use the `OR`
|
---|
| 196 | * operator. Either `member.type = "HUMAN"` or `member.type != "BOT"` is
|
---|
| 197 | * required when `use_admin_access` is set to true. Other member type filters
|
---|
| 198 | * will be rejected. For example, the following queries are valid: ``` role =
|
---|
| 199 | * "ROLE_MANAGER" OR role = "ROLE_MEMBER" member.type = "HUMAN" AND role =
|
---|
| 200 | * "ROLE_MANAGER" member.type != "BOT" ``` The following queries are invalid:
|
---|
| 201 | * ``` member.type = "HUMAN" AND member.type = "BOT" role = "ROLE_MANAGER" AND
|
---|
| 202 | * role = "ROLE_MEMBER" ``` Invalid queries are rejected by the server with an
|
---|
| 203 | * `INVALID_ARGUMENT` error.
|
---|
| 204 | * @opt_param int pageSize Optional. The maximum number of memberships to
|
---|
| 205 | * return. The service might return fewer than this value. If unspecified, at
|
---|
| 206 | * most 100 memberships are returned. The maximum value is 1000. If you use a
|
---|
| 207 | * value more than 1000, it's automatically changed to 1000. Negative values
|
---|
| 208 | * return an `INVALID_ARGUMENT` error.
|
---|
| 209 | * @opt_param string pageToken Optional. A page token, received from a previous
|
---|
| 210 | * call to list memberships. Provide this parameter to retrieve the subsequent
|
---|
| 211 | * page. When paginating, all other parameters provided should match the call
|
---|
| 212 | * that provided the page token. Passing different values to the other
|
---|
| 213 | * parameters might lead to unexpected results.
|
---|
| 214 | * @opt_param bool showGroups Optional. When `true`, also returns memberships
|
---|
| 215 | * associated with a Google Group, in addition to other types of memberships. If
|
---|
| 216 | * a filter is set, Google Group memberships that don't match the filter
|
---|
| 217 | * criteria aren't returned.
|
---|
| 218 | * @opt_param bool showInvited Optional. When `true`, also returns memberships
|
---|
| 219 | * associated with invited members, in addition to other types of memberships.
|
---|
| 220 | * If a filter is set, invited memberships that don't match the filter criteria
|
---|
| 221 | * aren't returned. Currently requires [user
|
---|
| 222 | * authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 223 | * authorize-chat-user).
|
---|
| 224 | * @opt_param bool useAdminAccess Optional. When `true`, the method runs using
|
---|
| 225 | * the user's Google Workspace administrator privileges. The calling user must
|
---|
| 226 | * be a Google Workspace administrator with the [manage chat and spaces
|
---|
| 227 | * conversations privilege](https://support.google.com/a/answer/13369245).
|
---|
| 228 | * Requires either the `chat.admin.memberships.readonly` or
|
---|
| 229 | * `chat.admin.memberships` [OAuth 2.0
|
---|
| 230 | * scope](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 231 | * authorize#chat-api-scopes). Listing app memberships in a space isn't
|
---|
| 232 | * supported when using admin access.
|
---|
| 233 | * @return ListMembershipsResponse
|
---|
| 234 | * @throws \Google\Service\Exception
|
---|
| 235 | */
|
---|
| 236 | public function listSpacesMembers($parent, $optParams = [])
|
---|
| 237 | {
|
---|
| 238 | $params = ['parent' => $parent];
|
---|
| 239 | $params = array_merge($params, $optParams);
|
---|
| 240 | return $this->call('list', [$params], ListMembershipsResponse::class);
|
---|
| 241 | }
|
---|
| 242 | /**
|
---|
| 243 | * Updates a membership. For an example, see [Update a user's membership in a
|
---|
| 244 | * space](https://developers.google.com/workspace/chat/update-members). Supports
|
---|
| 245 | * the following types of
|
---|
| 246 | * [authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 247 | * authorize): - [App
|
---|
| 248 | * authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 249 | * authorize-chat-app) with [administrator
|
---|
| 250 | * approval](https://support.google.com/a?p=chat-app-auth) in [Developer
|
---|
| 251 | * Preview](https://developers.google.com/workspace/preview) - [User
|
---|
| 252 | * authentication](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 253 | * authorize-chat-user) You can authenticate and authorize this method with
|
---|
| 254 | * administrator privileges by setting the `use_admin_access` field in the
|
---|
| 255 | * request. (members.patch)
|
---|
| 256 | *
|
---|
| 257 | * @param string $name Identifier. Resource name of the membership, assigned by
|
---|
| 258 | * the server. Format: `spaces/{space}/members/{member}`
|
---|
| 259 | * @param Membership $postBody
|
---|
| 260 | * @param array $optParams Optional parameters.
|
---|
| 261 | *
|
---|
| 262 | * @opt_param string updateMask Required. The field paths to update. Separate
|
---|
| 263 | * multiple values with commas or use `*` to update all field paths. Currently
|
---|
| 264 | * supported field paths: - `role`
|
---|
| 265 | * @opt_param bool useAdminAccess Optional. When `true`, the method runs using
|
---|
| 266 | * the user's Google Workspace administrator privileges. The calling user must
|
---|
| 267 | * be a Google Workspace administrator with the [manage chat and spaces
|
---|
| 268 | * conversations privilege](https://support.google.com/a/answer/13369245).
|
---|
| 269 | * Requires the `chat.admin.memberships` [OAuth 2.0
|
---|
| 270 | * scope](https://developers.google.com/workspace/chat/authenticate-
|
---|
| 271 | * authorize#chat-api-scopes).
|
---|
| 272 | * @return Membership
|
---|
| 273 | * @throws \Google\Service\Exception
|
---|
| 274 | */
|
---|
| 275 | public function patch($name, Membership $postBody, $optParams = [])
|
---|
| 276 | {
|
---|
| 277 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
| 278 | $params = array_merge($params, $optParams);
|
---|
| 279 | return $this->call('patch', [$params], Membership::class);
|
---|
| 280 | }
|
---|
| 281 | }
|
---|
| 282 |
|
---|
| 283 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
| 284 | class_alias(SpacesMembers::class, 'Google_Service_HangoutsChat_Resource_SpacesMembers');
|
---|