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"; 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 = "AttachmentProto"; 26option java_package = "com.google.chat.v1"; 27option php_namespace = "Google\\Apps\\Chat\\V1"; 28option ruby_package = "Google::Apps::Chat::V1"; 29 30// An attachment in Google Chat. 31message Attachment { 32 option (google.api.resource) = { 33 type: "chat.googleapis.com/Attachment" 34 pattern: "spaces/{space}/messages/{message}/attachments/{attachment}" 35 }; 36 37 // The source of the attachment. 38 enum Source { 39 // Reserved. 40 SOURCE_UNSPECIFIED = 0; 41 42 // The file is a Google Drive file. 43 DRIVE_FILE = 1; 44 45 // The file is uploaded to Chat. 46 UPLOADED_CONTENT = 2; 47 } 48 49 // Resource name of the attachment, in the form 50 // `spaces/*/messages/*/attachments/*`. 51 string name = 1; 52 53 // Output only. The original file name for the content, not the full path. 54 string content_name = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; 55 56 // Output only. The content type (MIME type) of the file. 57 string content_type = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; 58 59 // The data reference to the attachment. 60 oneof data_ref { 61 // A reference to the attachment data. This field is used with the media API 62 // to download the attachment data. 63 AttachmentDataRef attachment_data_ref = 4; 64 65 // Output only. A reference to the Google Drive attachment. This field is 66 // used with the Google Drive API. 67 DriveDataRef drive_data_ref = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; 68 } 69 70 // Output only. The thumbnail URL which should be used to preview the 71 // attachment to a human user. Chat apps shouldn't use this URL to download 72 // attachment content. 73 string thumbnail_uri = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; 74 75 // Output only. The download URL which should be used to allow a human user to 76 // download the attachment. Chat apps shouldn't use this URL to download 77 // attachment content. 78 string download_uri = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; 79 80 // Output only. The source of the attachment. 81 Source source = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; 82} 83 84// A reference to the data of a drive attachment. 85message DriveDataRef { 86 // The ID for the drive file. Use with the Drive API. 87 string drive_file_id = 2; 88} 89 90// A reference to the attachment data. 91message AttachmentDataRef { 92 // The resource name of the attachment data. This field is used with the media 93 // API to download the attachment data. 94 string resource_name = 1; 95 96 // Opaque token containing a reference to an uploaded attachment. Treated by 97 // clients as an opaque string and used to create or update Chat messages with 98 // attachments. 99 string attachment_upload_token = 2; 100} 101 102// Request to get an attachment. 103message GetAttachmentRequest { 104 // Required. Resource name of the attachment, in the form 105 // `spaces/*/messages/*/attachments/*`. 106 string name = 1 [ 107 (google.api.field_behavior) = REQUIRED, 108 (google.api.resource_reference) = { type: "chat.googleapis.com/Attachment" } 109 ]; 110} 111 112// Request to upload an attachment. 113message UploadAttachmentRequest { 114 // Required. Resource name of the Chat space in which the attachment is 115 // uploaded. Format "spaces/{space}". 116 string parent = 1 [ 117 (google.api.field_behavior) = REQUIRED, 118 (google.api.resource_reference) = { 119 child_type: "chat.googleapis.com/Message" 120 } 121 ]; 122 123 // Required. The filename of the attachment, including the file extension. 124 string filename = 4 [(google.api.field_behavior) = REQUIRED]; 125} 126 127// Response of uploading an attachment. 128message UploadAttachmentResponse { 129 // Reference to the uploaded attachment. 130 AttachmentDataRef attachment_data_ref = 1; 131} 132