From 961233803ceae68358794cbeef1475352944582d Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Wed, 15 Jul 2020 04:29:31 -0700 Subject: [PATCH] feat(chat): update the API #### chat:v1 The following keys were added: - resources.spaces.resources.messages.resources.attachments.methods.get.description - resources.spaces.resources.messages.resources.attachments.methods.get.flatPath - resources.spaces.resources.messages.resources.attachments.methods.get.httpMethod - resources.spaces.resources.messages.resources.attachments.methods.get.id - resources.spaces.resources.messages.resources.attachments.methods.get.parameterOrder - resources.spaces.resources.messages.resources.attachments.methods.get.parameters.name.description - resources.spaces.resources.messages.resources.attachments.methods.get.parameters.name.location - resources.spaces.resources.messages.resources.attachments.methods.get.parameters.name.pattern - resources.spaces.resources.messages.resources.attachments.methods.get.parameters.name.required - resources.spaces.resources.messages.resources.attachments.methods.get.parameters.name.type - resources.spaces.resources.messages.resources.attachments.methods.get.path - resources.spaces.resources.messages.resources.attachments.methods.get.response.$ref - schemas.Attachment.description - schemas.Attachment.id - schemas.Attachment.properties.attachmentDataRef.$ref - schemas.Attachment.properties.attachmentDataRef.description - schemas.Attachment.properties.contentName.description - schemas.Attachment.properties.contentName.type - schemas.Attachment.properties.contentType.description - schemas.Attachment.properties.contentType.type - schemas.Attachment.properties.downloadUri.description - schemas.Attachment.properties.downloadUri.type - schemas.Attachment.properties.driveDataRef.$ref - schemas.Attachment.properties.driveDataRef.description - schemas.Attachment.properties.name.description - schemas.Attachment.properties.name.type - schemas.Attachment.properties.source.description - schemas.Attachment.properties.source.enum - schemas.Attachment.properties.source.enumDescriptions - schemas.Attachment.properties.source.type - schemas.Attachment.properties.thumbnailUri.description - schemas.Attachment.properties.thumbnailUri.type - schemas.Attachment.type - schemas.AttachmentDataRef.description - schemas.AttachmentDataRef.id - schemas.AttachmentDataRef.properties.resourceName.description - schemas.AttachmentDataRef.properties.resourceName.type - schemas.AttachmentDataRef.type - schemas.DriveDataRef.description - schemas.DriveDataRef.id - schemas.DriveDataRef.properties.driveFileId.description - schemas.DriveDataRef.properties.driveFileId.type - schemas.DriveDataRef.type - schemas.Message.properties.attachment.description - schemas.Message.properties.attachment.items.$ref - schemas.Message.properties.attachment.type --- discovery/chat-v1.json | 108 +++++++++++++++++++- src/apis/chat/v1.ts | 217 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 324 insertions(+), 1 deletion(-) diff --git a/discovery/chat-v1.json b/discovery/chat-v1.json index ffe0af9b28..9723f622af 100644 --- a/discovery/chat-v1.json +++ b/discovery/chat-v1.json @@ -312,12 +312,40 @@ "$ref": "Message" } } + }, + "resources": { + "attachments": { + "methods": { + "get": { + "description": "Gets the metadata of a message attachment. The attachment data is fetched\nusing the media API.", + "flatPath": "v1/spaces/{spacesId}/messages/{messagesId}/attachments/{attachmentsId}", + "httpMethod": "GET", + "id": "chat.spaces.messages.attachments.get", + "parameterOrder": [ + "name" + ], + "parameters": { + "name": { + "description": "Resource name of the attachment, in the form\n\"spaces/*/messages/*/attachments/*\".", + "location": "path", + "pattern": "^spaces/[^/]+/messages/[^/]+/attachments/[^/]+$", + "required": true, + "type": "string" + } + }, + "path": "v1/{+name}", + "response": { + "$ref": "Attachment" + } + } + } + } } } } } }, - "revision": "20200701", + "revision": "20200708", "rootUrl": "https://chat.googleapis.com/", "schemas": { "ActionParameter": { @@ -395,6 +423,66 @@ }, "type": "object" }, + "Attachment": { + "description": "An attachment in Hangouts Chat.", + "id": "Attachment", + "properties": { + "attachmentDataRef": { + "$ref": "AttachmentDataRef", + "description": "A reference to the attachment data. This is used with the media API to\ndownload the attachment data." + }, + "contentName": { + "description": "The original file name for the content, not the full path.", + "type": "string" + }, + "contentType": { + "description": "The content type (MIME type) of the file.", + "type": "string" + }, + "downloadUri": { + "description": "Output only. The download URL which should be used to allow a human user to\ndownload the attachment. Bots should not use this URL to download\nattachment content.", + "type": "string" + }, + "driveDataRef": { + "$ref": "DriveDataRef", + "description": "A reference to the drive attachment. This is used with the Drive API." + }, + "name": { + "description": "Resource name of the attachment, in the form\n\"spaces/*/messages/*/attachments/*\".", + "type": "string" + }, + "source": { + "description": "The source of the attachment.", + "enum": [ + "SOURCE_UNSPECIFIED", + "DRIVE_FILE", + "UPLOADED_CONTENT" + ], + "enumDescriptions": [ + "", + "", + "" + ], + "type": "string" + }, + "thumbnailUri": { + "description": "Output only. The thumbnail URL which should be used to preview the\nattachment to a human user. Bots should not use this URL to download\nattachment content.", + "type": "string" + } + }, + "type": "object" + }, + "AttachmentDataRef": { + "description": "A reference to the data of an attachment.", + "id": "AttachmentDataRef", + "properties": { + "resourceName": { + "description": "The resource name of the attachment data. This is used with the media API\nto download the attachment data.", + "type": "string" + } + }, + "type": "object" + }, "Button": { "description": "A button. Can be a text button or an image button.", "id": "Button", @@ -544,6 +632,17 @@ }, "type": "object" }, + "DriveDataRef": { + "description": "A reference to the data of a drive attachment.", + "id": "DriveDataRef", + "properties": { + "driveFileId": { + "description": "The id for the drive file, for use with the Drive API.", + "type": "string" + } + }, + "type": "object" + }, "Empty": { "description": "A generic empty message that you can re-use to avoid defining duplicated\nempty messages in your APIs. A typical example is to use it as the request\nor the response type of an API method. For instance:\n\n service Foo {\n rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);\n }\n\nThe JSON representation for `Empty` is empty JSON object `{}`.", "id": "Empty", @@ -871,6 +970,13 @@ "description": "Plain-text body of the message with all bot mentions stripped out.", "type": "string" }, + "attachment": { + "description": "User uploaded attachment.", + "items": { + "$ref": "Attachment" + }, + "type": "array" + }, "cards": { "description": "Rich, formatted and interactive cards that can be used to display UI\nelements such as: formatted texts, buttons, clickable images. Cards are\nnormally displayed below the plain-text body of the message.", "items": { diff --git a/src/apis/chat/v1.ts b/src/apis/chat/v1.ts index 3389333b1d..822eb38133 100644 --- a/src/apis/chat/v1.ts +++ b/src/apis/chat/v1.ts @@ -174,6 +174,52 @@ export namespace chat_v1 { */ userMention?: Schema$UserMentionMetadata; } + /** + * An attachment in Hangouts Chat. + */ + export interface Schema$Attachment { + /** + * A reference to the attachment data. This is used with the media API to download the attachment data. + */ + attachmentDataRef?: Schema$AttachmentDataRef; + /** + * The original file name for the content, not the full path. + */ + contentName?: string | null; + /** + * The content type (MIME type) of the file. + */ + contentType?: string | null; + /** + * Output only. The download URL which should be used to allow a human user to download the attachment. Bots should not use this URL to download attachment content. + */ + downloadUri?: string | null; + /** + * A reference to the drive attachment. This is used with the Drive API. + */ + driveDataRef?: Schema$DriveDataRef; + /** + * Resource name of the attachment, in the form "spaces/x/messages/x/attachments/*". + */ + name?: string | null; + /** + * The source of the attachment. + */ + source?: string | null; + /** + * Output only. The thumbnail URL which should be used to preview the attachment to a human user. Bots should not use this URL to download attachment content. + */ + thumbnailUri?: string | null; + } + /** + * A reference to the data of an attachment. + */ + export interface Schema$AttachmentDataRef { + /** + * The resource name of the attachment data. This is used with the media API to download the attachment data. + */ + resourceName?: string | null; + } /** * A button. Can be a text button or an image button. */ @@ -280,6 +326,15 @@ export namespace chat_v1 { */ user?: Schema$User; } + /** + * A reference to the data of a drive attachment. + */ + export interface Schema$DriveDataRef { + /** + * The id for the drive file, for use with the Drive API. + */ + driveFileId?: string | null; + } /** * A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } The JSON representation for `Empty` is empty JSON object `{}`. */ @@ -429,6 +484,10 @@ export namespace chat_v1 { * Plain-text body of the message with all bot mentions stripped out. */ argumentText?: string | null; + /** + * User uploaded attachment. + */ + attachment?: Schema$Attachment[]; /** * Rich, formatted and interactive cards that can be used to display UI elements such as: formatted texts, buttons, clickable images. Cards are normally displayed below the plain-text body of the message. */ @@ -1221,8 +1280,10 @@ export namespace chat_v1 { export class Resource$Spaces$Messages { context: APIRequestContext; + attachments: Resource$Spaces$Messages$Attachments; constructor(context: APIRequestContext) { this.context = context; + this.attachments = new Resource$Spaces$Messages$Attachments(this.context); } /** @@ -1273,6 +1334,7 @@ export namespace chat_v1 { * // "actionResponse": {}, * // "annotations": [], * // "argumentText": "my_argumentText", + * // "attachment": [], * // "cards": [], * // "createTime": "my_createTime", * // "fallbackText": "my_fallbackText", @@ -1292,6 +1354,7 @@ export namespace chat_v1 { * // "actionResponse": {}, * // "annotations": [], * // "argumentText": "my_argumentText", + * // "attachment": [], * // "cards": [], * // "createTime": "my_createTime", * // "fallbackText": "my_fallbackText", @@ -1568,6 +1631,7 @@ export namespace chat_v1 { * // "actionResponse": {}, * // "annotations": [], * // "argumentText": "my_argumentText", + * // "attachment": [], * // "cards": [], * // "createTime": "my_createTime", * // "fallbackText": "my_fallbackText", @@ -1716,6 +1780,7 @@ export namespace chat_v1 { * // "actionResponse": {}, * // "annotations": [], * // "argumentText": "my_argumentText", + * // "attachment": [], * // "cards": [], * // "createTime": "my_createTime", * // "fallbackText": "my_fallbackText", @@ -1735,6 +1800,7 @@ export namespace chat_v1 { * // "actionResponse": {}, * // "annotations": [], * // "argumentText": "my_argumentText", + * // "attachment": [], * // "cards": [], * // "createTime": "my_createTime", * // "fallbackText": "my_fallbackText", @@ -1886,4 +1952,155 @@ export namespace chat_v1 { */ requestBody?: Schema$Message; } + + export class Resource$Spaces$Messages$Attachments { + context: APIRequestContext; + constructor(context: APIRequestContext) { + this.context = context; + } + + /** + * chat.spaces.messages.attachments.get + * @desc Gets the metadata of a message attachment. The attachment data is fetched using the media API. + * @example + * // Before running the sample: + * // - Enable the API at: + * // https://console.developers.google.com/apis/api/chat.googleapis.com + * // - Login into gcloud by running: + * // `$ gcloud auth application-default login` + * // - Install the npm module by running: + * // `$ npm install googleapis` + * + * const {google} = require('googleapis'); + * const chat = google.chat('v1'); + * + * async function main() { + * const auth = new google.auth.GoogleAuth({ + * // Scopes can be specified either as an array or as a single, space-delimited string. + * scopes: [], + * }); + * + * // Acquire an auth client, and bind it to all future calls + * const authClient = await auth.getClient(); + * google.options({auth: authClient}); + * + * // Do the magic + * const res = await chat.spaces.messages.attachments.get({ + * // Resource name of the attachment, in the form + * // "spaces/x/messages/x/attachments/x". + * name: 'spaces/my-space/messages/my-message/attachments/my-attachment', + * }); + * console.log(res.data); + * + * // Example response + * // { + * // "attachmentDataRef": {}, + * // "contentName": "my_contentName", + * // "contentType": "my_contentType", + * // "downloadUri": "my_downloadUri", + * // "driveDataRef": {}, + * // "name": "my_name", + * // "source": "my_source", + * // "thumbnailUri": "my_thumbnailUri" + * // } + * } + * + * main().catch(e => { + * console.error(e); + * throw e; + * }); + * + * @alias chat.spaces.messages.attachments.get + * @memberOf! () + * + * @param {object} params Parameters for request + * @param {string} params.name Resource name of the attachment, in the form "spaces/x/messages/x/attachments/x". + * @param {object} [options] Optionally override request options, such as `url`, `method`, and `encoding`. + * @param {callback} callback The callback that handles the response. + * @return {object} Request object + */ + get( + params: Params$Resource$Spaces$Messages$Attachments$Get, + options: StreamMethodOptions + ): GaxiosPromise; + get( + params?: Params$Resource$Spaces$Messages$Attachments$Get, + options?: MethodOptions + ): GaxiosPromise; + get( + params: Params$Resource$Spaces$Messages$Attachments$Get, + options: StreamMethodOptions | BodyResponseCallback, + callback: BodyResponseCallback + ): void; + get( + params: Params$Resource$Spaces$Messages$Attachments$Get, + options: MethodOptions | BodyResponseCallback, + callback: BodyResponseCallback + ): void; + get( + params: Params$Resource$Spaces$Messages$Attachments$Get, + callback: BodyResponseCallback + ): void; + get(callback: BodyResponseCallback): void; + get( + paramsOrCallback?: + | Params$Resource$Spaces$Messages$Attachments$Get + | BodyResponseCallback + | BodyResponseCallback, + optionsOrCallback?: + | MethodOptions + | StreamMethodOptions + | BodyResponseCallback + | BodyResponseCallback, + callback?: + | BodyResponseCallback + | BodyResponseCallback + ): void | GaxiosPromise | GaxiosPromise { + let params = (paramsOrCallback || + {}) as Params$Resource$Spaces$Messages$Attachments$Get; + let options = (optionsOrCallback || {}) as MethodOptions; + + if (typeof paramsOrCallback === 'function') { + callback = paramsOrCallback; + params = {} as Params$Resource$Spaces$Messages$Attachments$Get; + options = {}; + } + + if (typeof optionsOrCallback === 'function') { + callback = optionsOrCallback; + options = {}; + } + + const rootUrl = options.rootUrl || 'https://chat.googleapis.com/'; + const parameters = { + options: Object.assign( + { + url: (rootUrl + '/v1/{+name}').replace(/([^:]\/)\/+/g, '$1'), + method: 'GET', + }, + options + ), + params, + requiredParams: ['name'], + pathParams: ['name'], + context: this.context, + }; + if (callback) { + createAPIRequest( + parameters, + callback as BodyResponseCallback<{} | void> + ); + } else { + return createAPIRequest(parameters); + } + } + } + + export interface Params$Resource$Spaces$Messages$Attachments$Get + extends StandardParameters { + /** + * Resource name of the attachment, in the form "spaces/x/messages/x/attachments/x". + */ + name?: string; + } }