xref: /aosp_15_r20/external/googleapis/google/chat/v1/annotation.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/chat/v1/attachment.proto";
20import "google/chat/v1/user.proto";
21
22option csharp_namespace = "Google.Apps.Chat.V1";
23option go_package = "cloud.google.com/go/chat/apiv1/chatpb;chatpb";
24option java_multiple_files = true;
25option java_outer_classname = "AnnotationProto";
26option java_package = "com.google.chat.v1";
27option php_namespace = "Google\\Apps\\Chat\\V1";
28option ruby_package = "Google::Apps::Chat::V1";
29
30// Output only. Annotations associated with the plain-text body of the message.
31// To add basic formatting to a text message, see
32// [Format text
33// messages](https://developers.google.com/workspace/chat/format-messages).
34//
35// Example plain-text message body:
36// ```
37// Hello @FooBot how are you!"
38// ```
39//
40// The corresponding annotations metadata:
41// ```
42// "annotations":[{
43//   "type":"USER_MENTION",
44//   "startIndex":6,
45//   "length":7,
46//   "userMention": {
47//     "user": {
48//       "name":"users/{user}",
49//       "displayName":"FooBot",
50//       "avatarUrl":"https://goo.gl/aeDtrS",
51//       "type":"BOT"
52//     },
53//     "type":"MENTION"
54//    }
55// }]
56// ```
57message Annotation {
58  // The type of this annotation.
59  AnnotationType type = 1;
60
61  // Start index (0-based, inclusive) in the plain-text message body this
62  // annotation corresponds to.
63  optional int32 start_index = 2;
64
65  // Length of the substring in the plain-text message body this annotation
66  // corresponds to.
67  int32 length = 3;
68
69  // Additional metadata about the annotation.
70  oneof metadata {
71    // The metadata of user mention.
72    UserMentionMetadata user_mention = 4;
73
74    // The metadata for a slash command.
75    SlashCommandMetadata slash_command = 5;
76
77    // The metadata for a rich link.
78    RichLinkMetadata rich_link_metadata = 6;
79  }
80}
81
82// Annotation metadata for user mentions (@).
83message UserMentionMetadata {
84  enum Type {
85    // Default value for the enum. Don't use.
86    TYPE_UNSPECIFIED = 0;
87
88    // Add user to space.
89    ADD = 1;
90
91    // Mention user in space.
92    MENTION = 2;
93  }
94
95  // The user mentioned.
96  User user = 1;
97
98  // The type of user mention.
99  Type type = 2;
100}
101
102// Annotation metadata for slash commands (/).
103message SlashCommandMetadata {
104  enum Type {
105    // Default value for the enum. Don't use.
106    TYPE_UNSPECIFIED = 0;
107
108    // Add Chat app to space.
109    ADD = 1;
110
111    // Invoke slash command in space.
112    INVOKE = 2;
113  }
114
115  // The Chat app whose command was invoked.
116  User bot = 1;
117
118  // The type of slash command.
119  Type type = 2;
120
121  // The name of the invoked slash command.
122  string command_name = 3;
123
124  // The command ID of the invoked slash command.
125  int64 command_id = 4;
126
127  // Indicates whether the slash command is for a dialog.
128  bool triggers_dialog = 5;
129}
130
131// A rich link to a resource.
132message RichLinkMetadata {
133  // The rich link type. More types might be added in the future.
134  enum RichLinkType {
135    // Default value for the enum. Don't use.
136    RICH_LINK_TYPE_UNSPECIFIED = 0;
137
138    // A Google Drive rich link type.
139    DRIVE_FILE = 1;
140  }
141
142  // The URI of this link.
143  string uri = 1;
144
145  // The rich link type.
146  RichLinkType rich_link_type = 2;
147
148  // Data for the linked resource.
149  oneof data {
150    // Data for a drive link.
151    DriveLinkData drive_link_data = 3;
152  }
153}
154
155// Data for Google Drive links.
156message DriveLinkData {
157  // A
158  // [DriveDataRef](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages.attachments#drivedataref)
159  // which references a Google Drive file.
160  DriveDataRef drive_data_ref = 1;
161
162  // The mime type of the linked Google Drive resource.
163  string mime_type = 2;
164}
165
166// Type of the annotation.
167enum AnnotationType {
168  // Default value for the enum. Don't use.
169  ANNOTATION_TYPE_UNSPECIFIED = 0;
170
171  // A user is mentioned.
172  USER_MENTION = 1;
173
174  // A slash command is invoked.
175  SLASH_COMMAND = 2;
176
177  // A rich link annotation.
178  RICH_LINK = 3;
179}
180