xref: /aosp_15_r20/external/googleapis/google/chat/v1/membership.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2023 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.chat.v1;
18
19import "google/api/field_behavior.proto";
20import "google/api/resource.proto";
21import "google/chat/v1/group.proto";
22import "google/chat/v1/user.proto";
23import "google/protobuf/field_mask.proto";
24import "google/protobuf/timestamp.proto";
25
26option csharp_namespace = "Google.Apps.Chat.V1";
27option go_package = "cloud.google.com/go/chat/apiv1/chatpb;chatpb";
28option java_multiple_files = true;
29option java_outer_classname = "MembershipProto";
30option java_package = "com.google.chat.v1";
31option php_namespace = "Google\\Apps\\Chat\\V1";
32option ruby_package = "Google::Apps::Chat::V1";
33
34// Represents a membership relation in Google Chat, such as whether a user or
35// Chat app is invited to, part of, or absent from a space.
36message Membership {
37  option (google.api.resource) = {
38    type: "chat.googleapis.com/Membership"
39    pattern: "spaces/{space}/members/{member}"
40  };
41
42  // Specifies the member's relationship with a space. Other membership states
43  // might be supported in the future.
44  enum MembershipState {
45    // Default value. Don't use.
46    MEMBERSHIP_STATE_UNSPECIFIED = 0;
47
48    // The user is added to the space, and can participate in the space.
49    JOINED = 1;
50
51    // The user is invited to join the space, but hasn't joined it.
52    INVITED = 2;
53
54    // The user doesn't belong to the space and doesn't have a pending
55    // invitation to join the space.
56    NOT_A_MEMBER = 3;
57  }
58
59  // Represents a user's permitted actions in a Chat space. More enum values
60  // might be added in the future.
61  enum MembershipRole {
62    // Default value. For [users][google.chat.v1.Membership.member]: they
63    // aren't a member of the space, but can be invited. For
64    // [Google Groups][google.chat.v1.Membership.group_member]: they're always
65    //  assigned this role (other enum values might be used in the future).
66    MEMBERSHIP_ROLE_UNSPECIFIED = 0;
67
68    // A member of the space. The user has basic permissions, like sending
69    // messages to the space. In 1:1 and unnamed group conversations, everyone
70    // has this role.
71    ROLE_MEMBER = 1;
72
73    // A space manager. The user has all basic permissions plus administrative
74    // permissions that let them manage the space, like adding or removing
75    // members. Only supported in
76    // [SpaceType.SPACE][google.chat.v1.Space.SpaceType].
77    ROLE_MANAGER = 2;
78  }
79
80  // Resource name of the membership, assigned by the server.
81  //
82  // Format: `spaces/{space}/members/{member}`
83  string name = 1 [
84    (google.api.resource_reference) = { type: "chat.googleapis.com/Membership" }
85  ];
86
87  // Output only. State of the membership.
88  MembershipState state = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
89
90  // Optional. User's role within a Chat space, which determines their permitted
91  // actions in the space.
92  //
93  // This field can only be used as input in `UpdateMembership`.
94  MembershipRole role = 7 [(google.api.field_behavior) = OPTIONAL];
95
96  // Member associated with this membership. Other member types might be
97  // supported in the future.
98  oneof memberType {
99    // The Google Chat user or app the membership corresponds to.
100    // If your Chat app [authenticates as a
101    // user](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user),
102    // the output populates the
103    // [user](https://developers.google.com/workspace/chat/api/reference/rest/v1/User)
104    // `name` and `type`.
105    User member = 3;
106
107    // The Google Group the membership corresponds to.
108    // Only supports read operations. Other operations, like creating or
109    // updating a membership, aren't currently supported.
110    Group group_member = 5;
111  }
112
113  // Optional. Immutable. The creation time of the membership, such as when a
114  // member joined or was invited to join a space. This field is output only,
115  // except when used to import historical memberships in import mode spaces.
116  google.protobuf.Timestamp create_time = 4 [
117    (google.api.field_behavior) = IMMUTABLE,
118    (google.api.field_behavior) = OPTIONAL
119  ];
120
121  // Optional. Immutable. The deletion time of the membership, such as when a
122  // member left or was removed from a space. This field is output only, except
123  // when used to import historical memberships in import mode spaces.
124  google.protobuf.Timestamp delete_time = 8 [
125    (google.api.field_behavior) = IMMUTABLE,
126    (google.api.field_behavior) = OPTIONAL
127  ];
128}
129
130// Request message for creating a membership.
131message CreateMembershipRequest {
132  // Required. The resource name of the space for which to create the
133  // membership.
134  //
135  // Format: spaces/{space}
136  string parent = 1 [
137    (google.api.field_behavior) = REQUIRED,
138    (google.api.resource_reference) = {
139      child_type: "chat.googleapis.com/Membership"
140    }
141  ];
142
143  // Required. The membership relation to create.
144  // The `memberType` field must contain a user with the `user.name` and
145  // `user.type` fields populated. The server will assign a resource name
146  // and overwrite anything specified.
147  // When a Chat app creates a membership relation for a human user, it must use
148  // the `chat.memberships` scope, set `user.type` to `HUMAN`, and set
149  // `user.name` with format `users/{user}`, where `{user}` can be the email
150  // address for the user. For users in the same Workspace organization `{user}`
151  // can also be the `id` of the
152  // [person](https://developers.google.com/people/api/rest/v1/people) from the
153  // People API, or the `id` for the user in the Directory API. For example, if
154  // the People API Person profile ID for `[email protected]` is `123456789`, you
155  // can add the user to the space by setting the `membership.member.name` to
156  // `users/user@example.com` or `users/123456789`. When a Chat app creates a
157  // membership relation for itself, it must use the `chat.memberships.app`
158  // scope, set `user.type` to `BOT`, and set `user.name` to `users/app`.
159  Membership membership = 2 [(google.api.field_behavior) = REQUIRED];
160}
161
162// Request message for updating a membership.
163message UpdateMembershipRequest {
164  // Required. The membership to update. Only fields specified by `update_mask`
165  // are updated.
166  Membership membership = 1 [(google.api.field_behavior) = REQUIRED];
167
168  // Required. The field paths to update. Separate multiple values with commas
169  // or use `*` to update all field paths.
170  //
171  // Currently supported field paths:
172  //
173  // - `role`
174  google.protobuf.FieldMask update_mask = 2
175      [(google.api.field_behavior) = REQUIRED];
176}
177
178// Request message for listing memberships.
179message ListMembershipsRequest {
180  // Required. The resource name of the space for which to fetch a membership
181  // list.
182  //
183  // Format: spaces/{space}
184  string parent = 1 [
185    (google.api.field_behavior) = REQUIRED,
186    (google.api.resource_reference) = {
187      child_type: "chat.googleapis.com/Membership"
188    }
189  ];
190
191  // Optional. The maximum number of memberships to return. The service might
192  // return fewer than this value.
193  //
194  // If unspecified, at most 100 memberships are returned.
195  //
196  // The maximum value is 1000. If you use a value more than 1000, it's
197  // automatically changed to 1000.
198  //
199  // Negative values return an `INVALID_ARGUMENT` error.
200  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
201
202  // Optional. A page token, received from a previous call to list memberships.
203  // Provide this parameter to retrieve the subsequent page.
204  //
205  // When paginating, all other parameters provided should match the call that
206  // provided the page token. Passing different values to the other parameters
207  // might lead to unexpected results.
208  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
209
210  // Optional. A query filter.
211  //
212  // You can filter memberships by a member's role
213  // ([`role`](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.members#membershiprole))
214  // and type
215  // ([`member.type`](https://developers.google.com/workspace/chat/api/reference/rest/v1/User#type)).
216  //
217  // To filter by role, set `role` to `ROLE_MEMBER` or `ROLE_MANAGER`.
218  //
219  // To filter by type, set `member.type` to `HUMAN` or `BOT`.
220  //
221  // To filter by both role and type, use the `AND` operator. To filter by
222  // either role or type, use the `OR` operator.
223  //
224  // For example, the following queries are valid:
225  //
226  // ```
227  // role = "ROLE_MANAGER" OR role = "ROLE_MEMBER"
228  // member.type = "HUMAN" AND role = "ROLE_MANAGER"
229  // ```
230  //
231  // The following queries are invalid:
232  //
233  // ```
234  // member.type = "HUMAN" AND member.type = "BOT"
235  // role = "ROLE_MANAGER" AND role = "ROLE_MEMBER"
236  // ```
237  //
238  //
239  // Invalid queries are rejected by the server with an `INVALID_ARGUMENT`
240  // error.
241  string filter = 5 [(google.api.field_behavior) = OPTIONAL];
242
243  // Optional. When `true`, also returns memberships associated with a
244  // [Google Group][google.chat.v1.Membership.group_member], in
245  // addition to other types of memberships. If a
246  // [filter][google.chat.v1.ListMembershipsRequest.filter] is set,
247  // [Google Group][google.chat.v1.Membership.group_member]
248  // memberships that don't match the filter criteria aren't returned.
249  bool show_groups = 6 [(google.api.field_behavior) = OPTIONAL];
250
251  // Optional. When `true`, also returns memberships associated with
252  // [invited][google.chat.v1.Membership.MembershipState.INVITED] members, in
253  // addition to other types of memberships. If a
254  // filter is set,
255  // [invited][google.chat.v1.Membership.MembershipState.INVITED] memberships
256  // that don't match the filter criteria aren't returned.
257  //
258  // Currently requires [user
259  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
260  bool show_invited = 7 [(google.api.field_behavior) = OPTIONAL];
261}
262
263// Response to list memberships of the space.
264message ListMembershipsResponse {
265  // Unordered list. List of memberships in the requested (or first) page.
266  repeated Membership memberships = 1
267      [(google.api.field_behavior) = UNORDERED_LIST];
268
269  // A token that you can send as `pageToken` to retrieve the next page of
270  // results. If empty, there are no subsequent pages.
271  string next_page_token = 2;
272}
273
274// Request to get a membership of a space.
275message GetMembershipRequest {
276  // Required. Resource name of the membership to retrieve.
277  //
278  // To get the app's own membership, you can optionally use
279  // `spaces/{space}/members/app`.
280  //
281  // Format: `spaces/{space}/members/{member}` or `spaces/{space}/members/app`
282  //
283  // When [authenticated as a
284  // user](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user),
285  // you can use the user's email as an alias for `{member}`. For example,
286  // `spaces/{space}/members/example@gmail.com` where `[email protected]` is the
287  // email of the Google Chat user.
288  string name = 1 [
289    (google.api.field_behavior) = REQUIRED,
290    (google.api.resource_reference) = { type: "chat.googleapis.com/Membership" }
291  ];
292}
293
294// Request to delete a membership in a space.
295message DeleteMembershipRequest {
296  // Required. Resource name of the membership to delete. Chat apps can delete
297  // human users' or their own memberships. Chat apps can't delete other apps'
298  // memberships.
299  //
300  // When deleting a human membership, requires the `chat.memberships` scope and
301  // `spaces/{space}/members/{member}` format. You can use the email as an
302  // alias for `{member}`. For example,
303  // `spaces/{space}/members/example@gmail.com` where `[email protected]` is the
304  // email of the Google Chat user.
305  //
306  // When deleting an app membership, requires the `chat.memberships.app` scope
307  // and `spaces/{space}/members/app` format.
308  //
309  // Format: `spaces/{space}/members/{member}` or `spaces/{space}/members/app`.
310  string name = 1 [
311    (google.api.field_behavior) = REQUIRED,
312    (google.api.resource_reference) = { type: "chat.googleapis.com/Membership" }
313  ];
314}
315