xref: /aosp_15_r20/external/googleapis/google/chat/v1/chat_service.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/annotations.proto";
20import "google/api/client.proto";
21import "google/chat/v1/attachment.proto";
22import "google/chat/v1/membership.proto";
23import "google/chat/v1/message.proto";
24import "google/chat/v1/reaction.proto";
25import "google/chat/v1/space.proto";
26import "google/chat/v1/space_read_state.proto";
27import "google/chat/v1/space_setup.proto";
28import "google/chat/v1/thread_read_state.proto";
29import "google/protobuf/empty.proto";
30
31option csharp_namespace = "Google.Apps.Chat.V1";
32option go_package = "cloud.google.com/go/chat/apiv1/chatpb;chatpb";
33option java_multiple_files = true;
34option java_outer_classname = "ChatServiceProto";
35option java_package = "com.google.chat.v1";
36option php_namespace = "Google\\Apps\\Chat\\V1";
37option ruby_package = "Google::Apps::Chat::V1";
38
39// Enables developers to build Chat apps and
40// integrations on Google Chat Platform.
41service ChatService {
42  option (google.api.default_host) = "chat.googleapis.com";
43  option (google.api.oauth_scopes) =
44      "https://www.googleapis.com/auth/chat.bot,"
45      "https://www.googleapis.com/auth/chat.delete,"
46      "https://www.googleapis.com/auth/chat.import,"
47      "https://www.googleapis.com/auth/chat.memberships,"
48      "https://www.googleapis.com/auth/chat.memberships.app,"
49      "https://www.googleapis.com/auth/chat.memberships.readonly,"
50      "https://www.googleapis.com/auth/chat.messages,"
51      "https://www.googleapis.com/auth/chat.messages.create,"
52      "https://www.googleapis.com/auth/chat.messages.reactions,"
53      "https://www.googleapis.com/auth/chat.messages.reactions.create,"
54      "https://www.googleapis.com/auth/chat.messages.reactions.readonly,"
55      "https://www.googleapis.com/auth/chat.messages.readonly,"
56      "https://www.googleapis.com/auth/chat.spaces,"
57      "https://www.googleapis.com/auth/chat.spaces.create,"
58      "https://www.googleapis.com/auth/chat.spaces.readonly,"
59      "https://www.googleapis.com/auth/chat.users.readstate,"
60      "https://www.googleapis.com/auth/chat.users.readstate.readonly";
61
62  // Creates a message in a Google Chat space. For an example, see [Send a
63  // message](https://developers.google.com/workspace/chat/create-messages).
64  //
65  // Calling this method requires
66  // [authentication](https://developers.google.com/workspace/chat/authenticate-authorize)
67  // and supports the following authentication types:
68  //
69  // - For text messages, user authentication or app authentication are
70  // supported.
71  // - For card messages, only app authentication is supported. (Only Chat apps
72  // can create card messages.)
73  rpc CreateMessage(CreateMessageRequest) returns (Message) {
74    option (google.api.http) = {
75      post: "/v1/{parent=spaces/*}/messages"
76      body: "message"
77    };
78    option (google.api.method_signature) = "parent,message,message_id";
79  }
80
81  // Lists messages in a space that the caller is a member of, including
82  // messages from blocked members and spaces. For an example, see
83  // [List messages](/chat/api/guides/v1/messages/list).
84  // Requires [user
85  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
86  rpc ListMessages(ListMessagesRequest) returns (ListMessagesResponse) {
87    option (google.api.http) = {
88      get: "/v1/{parent=spaces/*}/messages"
89    };
90    option (google.api.method_signature) = "parent";
91  }
92
93  // Lists memberships in a space. For an example, see [List users and Google
94  // Chat apps in a
95  // space](https://developers.google.com/workspace/chat/list-members). Listing
96  // memberships with [app
97  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
98  // lists memberships in spaces that the Chat app has
99  // access to, but excludes Chat app memberships,
100  // including its own. Listing memberships with
101  // [User
102  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
103  // lists memberships in spaces that the authenticated user has access to.
104  //
105  // Requires
106  // [authentication](https://developers.google.com/workspace/chat/authenticate-authorize).
107  // Supports
108  // [app
109  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
110  // and [user
111  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
112  rpc ListMemberships(ListMembershipsRequest)
113      returns (ListMembershipsResponse) {
114    option (google.api.http) = {
115      get: "/v1/{parent=spaces/*}/members"
116    };
117    option (google.api.method_signature) = "parent";
118  }
119
120  // Returns details about a membership. For an example, see
121  // [Get details about a user's or Google Chat app's
122  // membership](https://developers.google.com/workspace/chat/get-members).
123  //
124  // Requires
125  // [authentication](https://developers.google.com/workspace/chat/authenticate-authorize).
126  // Supports
127  // [app
128  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
129  // and [user
130  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
131  rpc GetMembership(GetMembershipRequest) returns (Membership) {
132    option (google.api.http) = {
133      get: "/v1/{name=spaces/*/members/*}"
134    };
135    option (google.api.method_signature) = "name";
136  }
137
138  // Returns details about a message.
139  // For an example, see [Get details about a
140  // message](https://developers.google.com/workspace/chat/get-messages).
141  //
142  // Requires
143  // [authentication](https://developers.google.com/workspace/chat/authenticate-authorize).
144  // Supports
145  // [app
146  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
147  // and [user
148  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
149  //
150  // Note: Might return a message from a blocked member or space.
151  rpc GetMessage(GetMessageRequest) returns (Message) {
152    option (google.api.http) = {
153      get: "/v1/{name=spaces/*/messages/*}"
154    };
155    option (google.api.method_signature) = "name";
156  }
157
158  // Updates a message. There's a difference between the `patch` and `update`
159  // methods. The `patch`
160  // method uses a `patch` request while the `update` method uses a `put`
161  // request. We recommend using the `patch` method. For an example, see
162  // [Update a
163  // message](https://developers.google.com/workspace/chat/update-messages).
164  //
165  // Requires
166  // [authentication](https://developers.google.com/workspace/chat/authenticate-authorize).
167  // Supports
168  // [app
169  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
170  // and [user
171  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
172  // When using app authentication, requests can only update messages
173  // created by the calling Chat app.
174  rpc UpdateMessage(UpdateMessageRequest) returns (Message) {
175    option (google.api.http) = {
176      put: "/v1/{message.name=spaces/*/messages/*}"
177      body: "message"
178      additional_bindings {
179        patch: "/v1/{message.name=spaces/*/messages/*}"
180        body: "message"
181      }
182    };
183    option (google.api.method_signature) = "message,update_mask";
184  }
185
186  // Deletes a message.
187  // For an example, see [Delete a
188  // message](https://developers.google.com/workspace/chat/delete-messages).
189  //
190  // Requires
191  // [authentication](https://developers.google.com/workspace/chat/authenticate-authorize).
192  // Supports
193  // [app
194  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
195  // and [user
196  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
197  // When using app authentication, requests can only delete messages
198  // created by the calling Chat app.
199  rpc DeleteMessage(DeleteMessageRequest) returns (google.protobuf.Empty) {
200    option (google.api.http) = {
201      delete: "/v1/{name=spaces/*/messages/*}"
202    };
203    option (google.api.method_signature) = "name";
204  }
205
206  // Gets the metadata of a message attachment. The attachment data is fetched
207  // using the [media
208  // API](https://developers.google.com/workspace/chat/api/reference/rest/v1/media/download).
209  // For an example, see
210  // [Get metadata about a message
211  // attachment](https://developers.google.com/workspace/chat/get-media-attachments).
212  // Requires [app
213  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app).
214  rpc GetAttachment(GetAttachmentRequest) returns (Attachment) {
215    option (google.api.http) = {
216      get: "/v1/{name=spaces/*/messages/*/attachments/*}"
217    };
218    option (google.api.method_signature) = "name";
219  }
220
221  // Uploads an attachment. For an example, see
222  // [Upload media as a file
223  // attachment](https://developers.google.com/workspace/chat/upload-media-attachments).
224  // Requires user
225  // [authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
226  //
227  // You can upload attachments up to 200 MB. Certain file types aren't
228  // supported. For details, see [File types blocked by Google
229  // Chat](https://support.google.com/chat/answer/7651457?&co=GENIE.Platform%3DDesktop#File%20types%20blocked%20in%20Google%20Chat).
230  rpc UploadAttachment(UploadAttachmentRequest)
231      returns (UploadAttachmentResponse) {
232    option (google.api.http) = {
233      post: "/v1/{parent=spaces/*}/attachments:upload"
234      body: "*"
235    };
236  }
237
238  // Lists spaces the caller is a member of. Group chats and DMs aren't listed
239  // until the first message is sent. For an example, see
240  // [List
241  // spaces](https://developers.google.com/workspace/chat/list-spaces).
242  //
243  // Requires
244  // [authentication](https://developers.google.com/workspace/chat/authenticate-authorize).
245  // Supports
246  // [app
247  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
248  // and [user
249  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
250  //
251  // Lists spaces visible to the caller or authenticated user. Group chats
252  // and DMs aren't listed until the first message is sent.
253  rpc ListSpaces(ListSpacesRequest) returns (ListSpacesResponse) {
254    option (google.api.http) = {
255      get: "/v1/spaces"
256    };
257    option (google.api.method_signature) = "";
258  }
259
260  // Returns details about a space. For an example, see
261  // [Get details about a
262  // space](https://developers.google.com/workspace/chat/get-spaces).
263  //
264  // Requires
265  // [authentication](https://developers.google.com/workspace/chat/authenticate-authorize).
266  // Supports
267  // [app
268  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
269  // and [user
270  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
271  rpc GetSpace(GetSpaceRequest) returns (Space) {
272    option (google.api.http) = {
273      get: "/v1/{name=spaces/*}"
274    };
275    option (google.api.method_signature) = "name";
276  }
277
278  // Creates a named space. Spaces grouped by topics aren't supported. For an
279  // example, see [Create a
280  // space](https://developers.google.com/workspace/chat/create-spaces).
281  //
282  //  If you receive the error message `ALREADY_EXISTS` when creating
283  //  a space, try a different `displayName`. An existing space within
284  //  the Google Workspace organization might already use this display name.
285  //
286  // Requires [user
287  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
288  rpc CreateSpace(CreateSpaceRequest) returns (Space) {
289    option (google.api.http) = {
290      post: "/v1/spaces"
291      body: "space"
292    };
293    option (google.api.method_signature) = "space";
294  }
295
296  // Creates a space and adds specified users to it. The calling user is
297  // automatically added to the space, and shouldn't be specified as a
298  // membership in the request. For an example, see
299  // [Set up a space with initial
300  // members](https://developers.google.com/workspace/chat/set-up-spaces).
301  //
302  // To specify the human members to add, add memberships with the appropriate
303  // `member.name` in the `SetUpSpaceRequest`. To add a human user, use
304  // `users/{user}`, where `{user}` can be the email address for the user. For
305  // users in the same Workspace organization `{user}` can also be the `id` for
306  // the person from the People API, or the `id` for the user in the Directory
307  // API. For example, if the People API Person profile ID for
308  // `[email protected]` is `123456789`, you can add the user to the space by
309  // setting the `membership.member.name` to `users/user@example.com` or
310  // `users/123456789`.
311  //
312  // For a space or group chat, if the caller blocks or is blocked by some
313  // members, then those members aren't added to the created space.
314  //
315  // To create a direct message (DM) between the calling user and another human
316  // user, specify exactly one membership to represent the human user. If
317  // one user blocks the other, the request fails and the DM isn't created.
318  //
319  // To create a DM between the calling user and the calling app, set
320  // `Space.singleUserBotDm` to `true` and don't specify any memberships. You
321  // can only use this method to set up a DM with the calling app. To add the
322  // calling app as a member of a space or an existing DM between two human
323  // users, see
324  // [Invite or add a user or app to a
325  // space](https://developers.google.com/workspace/chat/create-members).
326  //
327  // If a DM already exists between two users, even when one user blocks the
328  // other at the time a request is made, then the existing DM is returned.
329  //
330  // Spaces with threaded replies aren't supported. If you receive the error
331  // message `ALREADY_EXISTS` when setting up a space, try a different
332  // `displayName`. An existing space within the Google Workspace organization
333  // might already use this display name.
334  //
335  // Requires [user
336  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
337  rpc SetUpSpace(SetUpSpaceRequest) returns (Space) {
338    option (google.api.http) = {
339      post: "/v1/spaces:setup"
340      body: "*"
341    };
342  }
343
344  // Updates a space. For an example, see
345  // [Update a
346  // space](https://developers.google.com/workspace/chat/update-spaces).
347  //
348  // If you're updating the `displayName` field and receive the error message
349  // `ALREADY_EXISTS`, try a different display name.. An existing space within
350  // the Google Workspace organization might already use this display name.
351  //
352  // Requires [user
353  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
354  rpc UpdateSpace(UpdateSpaceRequest) returns (Space) {
355    option (google.api.http) = {
356      patch: "/v1/{space.name=spaces/*}"
357      body: "space"
358    };
359    option (google.api.method_signature) = "space,update_mask";
360  }
361
362  // Deletes a named space. Always performs a cascading delete, which means
363  // that the space's child resources—like messages posted in the space and
364  // memberships in the space—are also deleted. For an example, see
365  // [Delete a
366  // space](https://developers.google.com/workspace/chat/delete-spaces).
367  // Requires [user
368  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
369  // from a user who has permission to delete the space.
370  rpc DeleteSpace(DeleteSpaceRequest) returns (google.protobuf.Empty) {
371    option (google.api.http) = {
372      delete: "/v1/{name=spaces/*}"
373    };
374    option (google.api.method_signature) = "name";
375  }
376
377  // Completes the
378  // [import process](https://developers.google.com/workspace/chat/import-data)
379  // for the specified space and makes it visible to users.
380  // Requires app authentication and domain-wide delegation. For more
381  // information, see [Authorize Google Chat apps to import
382  // data](https://developers.google.com/workspace/chat/authorize-import).
383  rpc CompleteImportSpace(CompleteImportSpaceRequest)
384      returns (CompleteImportSpaceResponse) {
385    option (google.api.http) = {
386      post: "/v1/{name=spaces/*}:completeImport"
387      body: "*"
388    };
389  }
390
391  // Returns the existing direct message with the specified user. If no direct
392  // message space is found, returns a `404 NOT_FOUND` error. For an example,
393  // see
394  // [Find a direct message](/chat/api/guides/v1/spaces/find-direct-message).
395  //
396  // With [user
397  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user),
398  // returns the direct message space between the specified user and the
399  // authenticated user.
400  //
401  // With [app
402  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app),
403  // returns the direct message space between the specified user and the calling
404  // Chat app.
405  //
406  // Requires [user
407  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
408  // or [app
409  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app).
410  rpc FindDirectMessage(FindDirectMessageRequest) returns (Space) {
411    option (google.api.http) = {
412      get: "/v1/spaces:findDirectMessage"
413    };
414  }
415
416  // Creates a human membership or app membership for the calling app. Creating
417  // memberships for other apps isn't supported. For an example, see
418  // [Invite or add a user or a Google Chat app to a
419  // space](https://developers.google.com/workspace/chat/create-members).
420  // When creating a membership, if the specified member has their auto-accept
421  // policy turned off, then they're invited, and must accept the space
422  // invitation before joining. Otherwise, creating a membership adds the member
423  // directly to the specified space. Requires [user
424  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
425  //
426  // To specify the member to add, set the `membership.member.name` in the
427  // `CreateMembershipRequest`:
428  //
429  // - To add the calling app to a space or a direct message between two human
430  //   users, use `users/app`. Unable to add other
431  //   apps to the space.
432  //
433  // - To add a human user, use `users/{user}`, where `{user}` can be the email
434  // address for the user. For users in the same Workspace organization `{user}`
435  // can also be the `id` for the person from the People API, or the `id` for
436  // the user in the Directory API. For example, if the People API Person
437  // profile ID for `[email protected]` is `123456789`, you can add the user to
438  // the space by setting the `membership.member.name` to
439  // `users/user@example.com` or `users/123456789`.
440  rpc CreateMembership(CreateMembershipRequest) returns (Membership) {
441    option (google.api.http) = {
442      post: "/v1/{parent=spaces/*}/members"
443      body: "membership"
444    };
445    option (google.api.method_signature) = "parent,membership";
446  }
447
448  // Updates a membership. Requires [user
449  // authentication](https://developers.google.com/chat/api/guides/auth/users).
450  rpc UpdateMembership(UpdateMembershipRequest) returns (Membership) {
451    option (google.api.http) = {
452      patch: "/v1/{membership.name=spaces/*/members/*}"
453      body: "membership"
454    };
455    option (google.api.method_signature) = "membership,update_mask";
456  }
457
458  // Deletes a membership. For an example, see
459  // [Remove a user or a Google Chat app from a
460  // space](https://developers.google.com/workspace/chat/delete-members).
461  //
462  // Requires [user
463  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
464  rpc DeleteMembership(DeleteMembershipRequest) returns (Membership) {
465    option (google.api.http) = {
466      delete: "/v1/{name=spaces/*/members/*}"
467    };
468    option (google.api.method_signature) = "name";
469  }
470
471  // Creates a reaction and adds it to a message. Only unicode emojis are
472  // supported. For an example, see
473  // [Add a reaction to a
474  // message](https://developers.google.com/workspace/chat/create-reactions).
475  // Requires [user
476  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
477  rpc CreateReaction(CreateReactionRequest) returns (Reaction) {
478    option (google.api.http) = {
479      post: "/v1/{parent=spaces/*/messages/*}/reactions"
480      body: "reaction"
481    };
482    option (google.api.method_signature) = "parent,reaction";
483  }
484
485  // Lists reactions to a message. For an example, see
486  // [List reactions for a
487  // message](https://developers.google.com/workspace/chat/list-reactions).
488  // Requires [user
489  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
490  rpc ListReactions(ListReactionsRequest) returns (ListReactionsResponse) {
491    option (google.api.http) = {
492      get: "/v1/{parent=spaces/*/messages/*}/reactions"
493    };
494    option (google.api.method_signature) = "parent";
495  }
496
497  // Deletes a reaction to a message. Only unicode emojis are supported.
498  // For an example, see
499  // [Delete a
500  // reaction](https://developers.google.com/workspace/chat/delete-reactions).
501  // Requires [user
502  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
503  rpc DeleteReaction(DeleteReactionRequest) returns (google.protobuf.Empty) {
504    option (google.api.http) = {
505      delete: "/v1/{name=spaces/*/messages/*/reactions/*}"
506    };
507    option (google.api.method_signature) = "name";
508  }
509
510  // Returns details about a user's read state within a space, used to identify
511  // read and unread messages.
512  //
513  // Requires [user
514  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
515  rpc GetSpaceReadState(GetSpaceReadStateRequest) returns (SpaceReadState) {
516    option (google.api.http) = {
517      get: "/v1/{name=users/*/spaces/*/spaceReadState}"
518    };
519    option (google.api.method_signature) = "name";
520  }
521
522  // Updates a user's read state within a space, used to identify read and
523  // unread messages.
524  //
525  // Requires [user
526  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
527  rpc UpdateSpaceReadState(UpdateSpaceReadStateRequest)
528      returns (SpaceReadState) {
529    option (google.api.http) = {
530      patch: "/v1/{space_read_state.name=users/*/spaces/*/spaceReadState}"
531      body: "space_read_state"
532    };
533    option (google.api.method_signature) = "space_read_state,update_mask";
534  }
535
536  // Returns details about a user's read state within a thread, used to identify
537  // read and unread messages.
538  //
539  // Requires [user
540  // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
541  rpc GetThreadReadState(GetThreadReadStateRequest) returns (ThreadReadState) {
542    option (google.api.http) = {
543      get: "/v1/{name=users/*/spaces/*/threads/*/threadReadState}"
544    };
545    option (google.api.method_signature) = "name";
546  }
547}
548