Skip to content

Commit c5bc296

Browse files
Google APIscopybara-github
authored andcommitted
feat: If you're a domain administrator or a delegated administrator, you can now include the useAdminAccess parameter when you call the Chat API with your administrator privileges with the following methods to manage Chat spaces and memberships in your Workspace organization:
- SearchSpaces - DeleteSpace - UpdateSpace - GetSpace - ListMemberships - DeleteMembership - CreateMembership - UpdateMembership - GetMembership Additionally, `last_active_time` and `membership_count` parameters are added to the `Space` resource. docs: A comment for field `filter` in message `.google.chat.v1.ListMembershipsRequest` is updated to support `!=` operator PiperOrigin-RevId: 673895888
1 parent eafe1c8 commit c5bc296

5 files changed

Lines changed: 288 additions & 2 deletions

File tree

google/chat/v1/chat_grpc_service_config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
{ "service": "google.chat.v1.ChatService", "method": "GetSpace" },
1313
{ "service": "google.chat.v1.ChatService", "method": "ListSpaces" },
1414
{ "service": "google.chat.v1.ChatService", "method": "DeleteSpace" },
15+
{ "service": "google.chat.v1.ChatService", "method": "SearchSpaces" },
1516
{ "service": "google.chat.v1.ChatService", "method": "CreateMembership" },
1617
{ "service": "google.chat.v1.ChatService", "method": "GetMembership" },
1718
{ "service": "google.chat.v1.ChatService", "method": "ListMemberships" },

google/chat/v1/chat_service.proto

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,18 @@ service ChatService {
269269
option (google.api.method_signature) = "";
270270
}
271271

272+
// Returns a list of spaces in a Google Workspace organization based on an
273+
// administrator's search. Requires [user
274+
// authentication with administrator
275+
// privileges](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user#admin-privileges).
276+
// In the request, set `use_admin_access` to `true`.
277+
rpc SearchSpaces(SearchSpacesRequest) returns (SearchSpacesResponse) {
278+
option (google.api.http) = {
279+
get: "/v1/spaces:search"
280+
};
281+
option (google.api.method_signature) = "";
282+
}
283+
272284
// Returns details about a space. For an example, see
273285
// [Get details about a
274286
// space](https://developers.google.com/workspace/chat/get-spaces).

google/chat/v1/chat_v1.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ authentication:
162162
https://www.googleapis.com/auth/chat.bot,
163163
https://www.googleapis.com/auth/chat.spaces,
164164
https://www.googleapis.com/auth/chat.spaces.readonly
165+
- selector: google.chat.v1.ChatService.SearchSpaces
166+
oauth:
167+
canonical_scopes: |-
168+
https://www.googleapis.com/auth/chat.admin.spaces,
169+
https://www.googleapis.com/auth/chat.admin.spaces.readonly
165170
- selector: google.chat.v1.ChatService.SetUpSpace
166171
oauth:
167172
canonical_scopes: |-

google/chat/v1/membership.proto

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,21 @@ message CreateMembershipRequest {
156156
// membership relation for itself, it must use the `chat.memberships.app`
157157
// scope, set `user.type` to `BOT`, and set `user.name` to `users/app`.
158158
Membership membership = 2 [(google.api.field_behavior) = REQUIRED];
159+
160+
// When `true`, the method runs using the user's Google Workspace
161+
// administrator privileges.
162+
//
163+
// The calling user must be a Google Workspace administrator with the
164+
// [manage chat and spaces conversations
165+
// privilege](https://support.google.com/a/answer/13369245).
166+
//
167+
// Requires the `chat.admin.memberships` [OAuth 2.0
168+
// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
169+
//
170+
// Creating app memberships or creating memberships for users outside the
171+
// administrator's Google Workspace organization isn't supported using admin
172+
// access.
173+
bool use_admin_access = 5;
159174
}
160175

161176
// Request message for updating a membership.
@@ -172,6 +187,17 @@ message UpdateMembershipRequest {
172187
// - `role`
173188
google.protobuf.FieldMask update_mask = 2
174189
[(google.api.field_behavior) = REQUIRED];
190+
191+
// When `true`, the method runs using the user's Google Workspace
192+
// administrator privileges.
193+
//
194+
// The calling user must be a Google Workspace administrator with the
195+
// [manage chat and spaces conversations
196+
// privilege](https://support.google.com/a/answer/13369245).
197+
//
198+
// Requires the `chat.admin.memberships` [OAuth 2.0
199+
// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
200+
bool use_admin_access = 3;
175201
}
176202

177203
// Request message for listing memberships.
@@ -215,8 +241,8 @@ message ListMembershipsRequest {
215241
//
216242
// To filter by role, set `role` to `ROLE_MEMBER` or `ROLE_MANAGER`.
217243
//
218-
// To filter by type, set `member.type` to `HUMAN` or `BOT`. Developer
219-
// Preview: You can also filter for `member.type` using the `!=` operator.
244+
// To filter by type, set `member.type` to `HUMAN` or `BOT`. You can also
245+
// filter for `member.type` using the `!=` operator.
220246
//
221247
// To filter by both role and type, use the `AND` operator. To filter by
222248
// either role or type, use the `OR` operator.
@@ -263,6 +289,20 @@ message ListMembershipsRequest {
263289
// Currently requires [user
264290
// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
265291
bool show_invited = 7 [(google.api.field_behavior) = OPTIONAL];
292+
293+
// When `true`, the method runs using the user's Google Workspace
294+
// administrator privileges.
295+
//
296+
// The calling user must be a Google Workspace administrator with the
297+
// [manage chat and spaces conversations
298+
// privilege](https://support.google.com/a/answer/13369245).
299+
//
300+
// Requires either the `chat.admin.memberships.readonly` or
301+
// `chat.admin.memberships` [OAuth 2.0
302+
// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
303+
//
304+
// Listing app memberships in a space isn't supported when using admin access.
305+
bool use_admin_access = 8;
266306
}
267307

268308
// Response to list memberships of the space.
@@ -295,6 +335,20 @@ message GetMembershipRequest {
295335
(google.api.field_behavior) = REQUIRED,
296336
(google.api.resource_reference) = { type: "chat.googleapis.com/Membership" }
297337
];
338+
339+
// When `true`, the method runs using the user's Google Workspace
340+
// administrator privileges.
341+
//
342+
// The calling user must be a Google Workspace administrator with the
343+
// [manage chat and spaces conversations
344+
// privilege](https://support.google.com/a/answer/13369245).
345+
//
346+
// Requires the `chat.admin.memberships` or `chat.admin.memberships.readonly`
347+
// [OAuth 2.0
348+
// scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
349+
//
350+
// Getting app memberships in a space isn't supported when using admin access.
351+
bool use_admin_access = 3;
298352
}
299353

300354
// Request to delete a membership in a space.
@@ -317,4 +371,17 @@ message DeleteMembershipRequest {
317371
(google.api.field_behavior) = REQUIRED,
318372
(google.api.resource_reference) = { type: "chat.googleapis.com/Membership" }
319373
];
374+
375+
// When `true`, the method runs using the user's Google Workspace
376+
// administrator privileges.
377+
//
378+
// The calling user must be a Google Workspace administrator with the
379+
// [manage chat and spaces conversations
380+
// privilege](https://support.google.com/a/answer/13369245).
381+
//
382+
// Requires the `chat.admin.memberships` [OAuth 2.0
383+
// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
384+
//
385+
// Deleting app memberships in a space isn't supported using admin access.
386+
bool use_admin_access = 2;
320387
}

google/chat/v1/space.proto

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ message Space {
103103
string guidelines = 2;
104104
}
105105

106+
// Represents the count of memberships of a space, grouped into categories.
107+
message MembershipCount {
108+
// Count of human users that have directly joined the space, not counting
109+
// users joined by having membership in a joined group.
110+
int32 joined_direct_human_user_count = 4;
111+
112+
// Count of all groups that have directly joined the space.
113+
int32 joined_group_count = 5;
114+
}
115+
106116
// Represents the [access
107117
// setting](https://support.google.com/chat/answer/11971020) of the space.
108118
message AccessSettings {
@@ -218,6 +228,10 @@ message Space {
218228
(google.api.field_behavior) = OPTIONAL
219229
];
220230

231+
// Output only. Timestamp of the last message in the space.
232+
google.protobuf.Timestamp last_active_time = 18
233+
[(google.api.field_behavior) = OUTPUT_ONLY];
234+
221235
// Output only. For direct message (DM) spaces with a Chat app, whether the
222236
// space was created by a Google Workspace administrator. Administrators can
223237
// install and set up a direct message with a Chat app on behalf of users in
@@ -226,6 +240,12 @@ message Space {
226240
// To support admin install, your Chat app must feature direct messaging.
227241
bool admin_installed = 19 [(google.api.field_behavior) = OUTPUT_ONLY];
228242

243+
// Output only. The count of joined memberships grouped by member type.
244+
// Populated when the `space_type` is `SPACE`, `DIRECT_MESSAGE` or
245+
// `GROUP_CHAT`.
246+
MembershipCount membership_count = 20
247+
[(google.api.field_behavior) = OUTPUT_ONLY];
248+
229249
// Optional. Specifies the [access
230250
// setting](https://support.google.com/chat/answer/11971020) of the space.
231251
// Only populated when the `space_type` is `SPACE`.
@@ -318,6 +338,17 @@ message GetSpaceRequest {
318338
(google.api.field_behavior) = REQUIRED,
319339
(google.api.resource_reference) = { type: "chat.googleapis.com/Space" }
320340
];
341+
342+
// When `true`, the method runs using the user's Google Workspace
343+
// administrator privileges.
344+
//
345+
// The calling user must be a Google Workspace administrator with the
346+
// [manage chat and spaces conversations
347+
// privilege](https://support.google.com/a/answer/13369245).
348+
//
349+
// Requires the `chat.admin.spaces` or `chat.admin.spaces.readonly` [OAuth 2.0
350+
// scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
351+
bool use_admin_access = 2;
321352
}
322353

323354
// A request to get direct message space based on the user resource.
@@ -397,6 +428,165 @@ message UpdateSpaceRequest {
397428
// (Warning: mutually exclusive with all other non-permission settings field
398429
// paths). `permission_settings` is not supported with admin access.
399430
google.protobuf.FieldMask update_mask = 2;
431+
432+
// When `true`, the method runs using the user's Google Workspace
433+
// administrator privileges.
434+
//
435+
// The calling user must be a Google Workspace administrator with the
436+
// [manage chat and spaces conversations
437+
// privilege](https://support.google.com/a/answer/13369245).
438+
//
439+
// Requires the `chat.admin.spaces` [OAuth 2.0
440+
// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
441+
//
442+
// Some `FieldMask` values are not supported using admin access. For details,
443+
// see the description of `update_mask`.
444+
bool use_admin_access = 3;
445+
}
446+
447+
// Request to search for a list of spaces based on a query.
448+
message SearchSpacesRequest {
449+
// When `true`, the method runs using the user's Google Workspace
450+
// administrator privileges.
451+
//
452+
// The calling user must be a Google Workspace administrator with the
453+
// [manage chat and spaces conversations
454+
// privilege](https://support.google.com/a/answer/13369245).
455+
//
456+
// Requires either the `chat.admin.spaces.readonly` or `chat.admin.spaces`
457+
// [OAuth 2.0
458+
// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
459+
//
460+
// This method currently only supports admin access, thus only `true` is
461+
// accepted for this field.
462+
bool use_admin_access = 1;
463+
464+
// The maximum number of spaces to return. The service may return fewer than
465+
// this value.
466+
//
467+
// If unspecified, at most 100 spaces are returned.
468+
//
469+
// The maximum value is 1000. If you use a value more than 1000, it's
470+
// automatically changed to 1000.
471+
int32 page_size = 2;
472+
473+
// A token, received from the previous search spaces call. Provide this
474+
// parameter to retrieve the subsequent page.
475+
//
476+
// When paginating, all other parameters provided should match the call that
477+
// provided the page token. Passing different values to the other parameters
478+
// might lead to unexpected results.
479+
string page_token = 3;
480+
481+
// Required. A search query.
482+
//
483+
// You can search by using the following parameters:
484+
//
485+
// - `create_time`
486+
// - `customer`
487+
// - `display_name`
488+
// - `external_user_allowed`
489+
// - `last_active_time`
490+
// - `space_history_state`
491+
// - `space_type`
492+
//
493+
// `create_time` and `last_active_time` accept a timestamp in
494+
// [RFC-3339](https://www.rfc-editor.org/rfc/rfc3339) format and the supported
495+
// comparison operators are: `=`, `<`, `>`, `<=`, `>=`.
496+
//
497+
// `customer` is required and is used to indicate which customer
498+
// to fetch spaces from. `customers/my_customer` is the only supported value.
499+
//
500+
// `display_name` only accepts the `HAS` (`:`) operator. The text to
501+
// match is first tokenized into tokens and each token is prefix-matched
502+
// case-insensitively and independently as a substring anywhere in the space's
503+
// `display_name`. For example, `Fun Eve` matches `Fun event` or `The
504+
// evening was fun`, but not `notFun event` or `even`.
505+
//
506+
// `external_user_allowed` accepts either `true` or `false`.
507+
//
508+
// `space_history_state` only accepts values from the [`historyState`]
509+
// (https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces#Space.HistoryState)
510+
// field of a `space` resource.
511+
//
512+
// `space_type` is required and the only valid value is `SPACE`.
513+
//
514+
// Across different fields, only `AND` operators are supported. A valid
515+
// example is `space_type = "SPACE" AND display_name:"Hello"` and an invalid
516+
// example is `space_type = "SPACE" OR display_name:"Hello"`.
517+
//
518+
// Among the same field,
519+
// `space_type` doesn't support `AND` or `OR` operators.
520+
// `display_name`, 'space_history_state', and 'external_user_allowed' only
521+
// support `OR` operators.
522+
// `last_active_time` and `create_time` support both `AND` and `OR` operators.
523+
// `AND` can only be used to represent an interval, such as `last_active_time
524+
// < "2022-01-01T00:00:00+00:00" AND last_active_time >
525+
// "2023-01-01T00:00:00+00:00"`.
526+
//
527+
// The following example queries are valid:
528+
//
529+
// ```
530+
// customer = "customers/my_customer" AND space_type = "SPACE"
531+
//
532+
// customer = "customers/my_customer" AND space_type = "SPACE" AND
533+
// display_name:"Hello World"
534+
//
535+
// customer = "customers/my_customer" AND space_type = "SPACE" AND
536+
// (last_active_time < "2020-01-01T00:00:00+00:00" OR last_active_time >
537+
// "2022-01-01T00:00:00+00:00")
538+
//
539+
// customer = "customers/my_customer" AND space_type = "SPACE" AND
540+
// (display_name:"Hello World" OR display_name:"Fun event") AND
541+
// (last_active_time > "2020-01-01T00:00:00+00:00" AND last_active_time <
542+
// "2022-01-01T00:00:00+00:00")
543+
//
544+
// customer = "customers/my_customer" AND space_type = "SPACE" AND
545+
// (create_time > "2019-01-01T00:00:00+00:00" AND create_time <
546+
// "2020-01-01T00:00:00+00:00") AND (external_user_allowed = "true") AND
547+
// (space_history_state = "HISTORY_ON" OR space_history_state = "HISTORY_OFF")
548+
// ```
549+
string query = 4 [(google.api.field_behavior) = REQUIRED];
550+
551+
// Optional. How the list of spaces is ordered.
552+
//
553+
// Supported attributes to order by are:
554+
//
555+
// - `membership_count.joined_direct_human_user_count` — Denotes the count of
556+
// human users that have directly joined a space.
557+
// - `last_active_time` — Denotes the time when last eligible item is added to
558+
// any topic of this space.
559+
// - `create_time` — Denotes the time of the space creation.
560+
//
561+
// Valid ordering operation values are:
562+
//
563+
// - `ASC` for ascending. Default value.
564+
//
565+
// - `DESC` for descending.
566+
//
567+
// The supported syntax are:
568+
//
569+
// - `membership_count.joined_direct_human_user_count DESC`
570+
// - `membership_count.joined_direct_human_user_count ASC`
571+
// - `last_active_time DESC`
572+
// - `last_active_time ASC`
573+
// - `create_time DESC`
574+
// - `create_time ASC`
575+
string order_by = 5 [(google.api.field_behavior) = OPTIONAL];
576+
}
577+
578+
// Response with a list of spaces corresponding to the search spaces request.
579+
message SearchSpacesResponse {
580+
// A page of the requested spaces.
581+
repeated Space spaces = 1;
582+
583+
// A token that can be used to retrieve the next page. If this field is empty,
584+
// there are no subsequent pages.
585+
string next_page_token = 2;
586+
587+
// The total number of spaces that match the query, across all pages. If the
588+
// result is over 10,000 spaces, this value is an estimate.
589+
int32 total_size = 3;
400590
}
401591

402592
// Request for deleting a space.
@@ -408,6 +598,17 @@ message DeleteSpaceRequest {
408598
(google.api.field_behavior) = REQUIRED,
409599
(google.api.resource_reference) = { type: "chat.googleapis.com/Space" }
410600
];
601+
602+
// When `true`, the method runs using the user's Google Workspace
603+
// administrator privileges.
604+
//
605+
// The calling user must be a Google Workspace administrator with the
606+
// [manage chat and spaces conversations
607+
// privilege](https://support.google.com/a/answer/13369245).
608+
//
609+
// Requires the `chat.admin.delete` [OAuth 2.0
610+
// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
611+
bool use_admin_access = 2;
411612
}
412613

413614
// Request message for completing the import process for a space.

0 commit comments

Comments
 (0)