From 7cca6bfbf113327ea7de5de408fadf39bcc02d93 Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Thu, 3 Dec 2020 05:19:21 -0800 Subject: [PATCH] feat(chat): update the API #### chat:v1 The following keys were added: - resources.dms.methods.messages.description - resources.dms.methods.messages.flatPath - resources.dms.methods.messages.httpMethod - resources.dms.methods.messages.id - resources.dms.methods.messages.parameterOrder - resources.dms.methods.messages.parameters.parent.description - resources.dms.methods.messages.parameters.parent.location - resources.dms.methods.messages.parameters.parent.pattern - resources.dms.methods.messages.parameters.parent.required - resources.dms.methods.messages.parameters.parent.type - resources.dms.methods.messages.parameters.threadKey.description - resources.dms.methods.messages.parameters.threadKey.location - resources.dms.methods.messages.parameters.threadKey.type - resources.dms.methods.messages.path - resources.dms.methods.messages.request.$ref - resources.dms.methods.messages.response.$ref - resources.dms.resources.conversations.methods.messages.description - resources.dms.resources.conversations.methods.messages.flatPath - resources.dms.resources.conversations.methods.messages.httpMethod - resources.dms.resources.conversations.methods.messages.id - resources.dms.resources.conversations.methods.messages.parameterOrder - resources.dms.resources.conversations.methods.messages.parameters.parent.description - resources.dms.resources.conversations.methods.messages.parameters.parent.location - resources.dms.resources.conversations.methods.messages.parameters.parent.pattern - resources.dms.resources.conversations.methods.messages.parameters.parent.required - resources.dms.resources.conversations.methods.messages.parameters.parent.type - resources.dms.resources.conversations.methods.messages.parameters.threadKey.description - resources.dms.resources.conversations.methods.messages.parameters.threadKey.location - resources.dms.resources.conversations.methods.messages.parameters.threadKey.type - resources.dms.resources.conversations.methods.messages.path - resources.dms.resources.conversations.methods.messages.request.$ref - resources.dms.resources.conversations.methods.messages.response.$ref - resources.rooms.methods.messages.description - resources.rooms.methods.messages.flatPath - resources.rooms.methods.messages.httpMethod - resources.rooms.methods.messages.id - resources.rooms.methods.messages.parameterOrder - resources.rooms.methods.messages.parameters.parent.description - resources.rooms.methods.messages.parameters.parent.location - resources.rooms.methods.messages.parameters.parent.pattern - resources.rooms.methods.messages.parameters.parent.required - resources.rooms.methods.messages.parameters.parent.type - resources.rooms.methods.messages.parameters.threadKey.description - resources.rooms.methods.messages.parameters.threadKey.location - resources.rooms.methods.messages.parameters.threadKey.type - resources.rooms.methods.messages.path - resources.rooms.methods.messages.request.$ref - resources.rooms.methods.messages.response.$ref - resources.rooms.resources.conversations.methods.messages.description - resources.rooms.resources.conversations.methods.messages.flatPath - resources.rooms.resources.conversations.methods.messages.httpMethod - resources.rooms.resources.conversations.methods.messages.id - resources.rooms.resources.conversations.methods.messages.parameterOrder - resources.rooms.resources.conversations.methods.messages.parameters.parent.description - resources.rooms.resources.conversations.methods.messages.parameters.parent.location - resources.rooms.resources.conversations.methods.messages.parameters.parent.pattern - resources.rooms.resources.conversations.methods.messages.parameters.parent.required - resources.rooms.resources.conversations.methods.messages.parameters.parent.type - resources.rooms.resources.conversations.methods.messages.parameters.threadKey.description - resources.rooms.resources.conversations.methods.messages.parameters.threadKey.location - resources.rooms.resources.conversations.methods.messages.parameters.threadKey.type - resources.rooms.resources.conversations.methods.messages.path - resources.rooms.resources.conversations.methods.messages.request.$ref - resources.rooms.resources.conversations.methods.messages.response.$ref --- discovery/chat-v1.json | 142 ++++++- src/apis/chat/v1.ts | 834 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 938 insertions(+), 38 deletions(-) diff --git a/discovery/chat-v1.json b/discovery/chat-v1.json index f9631d4b1a..743bf2aa3d 100644 --- a/discovery/chat-v1.json +++ b/discovery/chat-v1.json @@ -96,6 +96,76 @@ }, "protocol": "rest", "resources": { + "dms": { + "methods": { + "messages": { + "description": "Legacy path for creating message. Calling these will result in a BadRequest response.", + "flatPath": "v1/dms/{dmsId}/messages", + "httpMethod": "POST", + "id": "chat.dms.messages", + "parameterOrder": [ + "parent" + ], + "parameters": { + "parent": { + "description": "Required. Space resource name, in the form \"spaces/*\". Example: spaces/AAAAMpdlehY", + "location": "path", + "pattern": "^dms/[^/]+$", + "required": true, + "type": "string" + }, + "threadKey": { + "description": "Opaque thread identifier string that can be specified to group messages into a single thread. If this is the first message with a given thread identifier, a new thread is created. Subsequent messages with the same thread identifier will be posted into the same thread. This relieves bots and webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post further updates to it. Has no effect if thread field, corresponding to an existing thread, is set in message.", + "location": "query", + "type": "string" + } + }, + "path": "v1/{+parent}/messages", + "request": { + "$ref": "Message" + }, + "response": { + "$ref": "Message" + } + } + }, + "resources": { + "conversations": { + "methods": { + "messages": { + "description": "Legacy path for creating message. Calling these will result in a BadRequest response.", + "flatPath": "v1/dms/{dmsId}/conversations/{conversationsId}/messages", + "httpMethod": "POST", + "id": "chat.dms.conversations.messages", + "parameterOrder": [ + "parent" + ], + "parameters": { + "parent": { + "description": "Required. Space resource name, in the form \"spaces/*\". Example: spaces/AAAAMpdlehY", + "location": "path", + "pattern": "^dms/[^/]+/conversations/[^/]+$", + "required": true, + "type": "string" + }, + "threadKey": { + "description": "Opaque thread identifier string that can be specified to group messages into a single thread. If this is the first message with a given thread identifier, a new thread is created. Subsequent messages with the same thread identifier will be posted into the same thread. This relieves bots and webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post further updates to it. Has no effect if thread field, corresponding to an existing thread, is set in message.", + "location": "query", + "type": "string" + } + }, + "path": "v1/{+parent}/messages", + "request": { + "$ref": "Message" + }, + "response": { + "$ref": "Message" + } + } + } + } + } + }, "media": { "methods": { "download": { @@ -123,6 +193,76 @@ } } }, + "rooms": { + "methods": { + "messages": { + "description": "Legacy path for creating message. Calling these will result in a BadRequest response.", + "flatPath": "v1/rooms/{roomsId}/messages", + "httpMethod": "POST", + "id": "chat.rooms.messages", + "parameterOrder": [ + "parent" + ], + "parameters": { + "parent": { + "description": "Required. Space resource name, in the form \"spaces/*\". Example: spaces/AAAAMpdlehY", + "location": "path", + "pattern": "^rooms/[^/]+$", + "required": true, + "type": "string" + }, + "threadKey": { + "description": "Opaque thread identifier string that can be specified to group messages into a single thread. If this is the first message with a given thread identifier, a new thread is created. Subsequent messages with the same thread identifier will be posted into the same thread. This relieves bots and webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post further updates to it. Has no effect if thread field, corresponding to an existing thread, is set in message.", + "location": "query", + "type": "string" + } + }, + "path": "v1/{+parent}/messages", + "request": { + "$ref": "Message" + }, + "response": { + "$ref": "Message" + } + } + }, + "resources": { + "conversations": { + "methods": { + "messages": { + "description": "Legacy path for creating message. Calling these will result in a BadRequest response.", + "flatPath": "v1/rooms/{roomsId}/conversations/{conversationsId}/messages", + "httpMethod": "POST", + "id": "chat.rooms.conversations.messages", + "parameterOrder": [ + "parent" + ], + "parameters": { + "parent": { + "description": "Required. Space resource name, in the form \"spaces/*\". Example: spaces/AAAAMpdlehY", + "location": "path", + "pattern": "^rooms/[^/]+/conversations/[^/]+$", + "required": true, + "type": "string" + }, + "threadKey": { + "description": "Opaque thread identifier string that can be specified to group messages into a single thread. If this is the first message with a given thread identifier, a new thread is created. Subsequent messages with the same thread identifier will be posted into the same thread. This relieves bots and webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post further updates to it. Has no effect if thread field, corresponding to an existing thread, is set in message.", + "location": "query", + "type": "string" + } + }, + "path": "v1/{+parent}/messages", + "request": { + "$ref": "Message" + }, + "response": { + "$ref": "Message" + } + } + } + } + } + }, "spaces": { "methods": { "get": { @@ -372,7 +512,7 @@ } } }, - "revision": "20201028", + "revision": "20201127", "rootUrl": "https://chat.googleapis.com/", "schemas": { "ActionParameter": { diff --git a/src/apis/chat/v1.ts b/src/apis/chat/v1.ts index bf37806c97..f13b081ad8 100644 --- a/src/apis/chat/v1.ts +++ b/src/apis/chat/v1.ts @@ -111,7 +111,9 @@ export namespace chat_v1 { */ export class Chat { context: APIRequestContext; + dms: Resource$Dms; media: Resource$Media; + rooms: Resource$Rooms; spaces: Resource$Spaces; constructor(options: GlobalOptions, google?: GoogleConfigurable) { @@ -120,7 +122,9 @@ export namespace chat_v1 { google, }; + this.dms = new Resource$Dms(this.context); this.media = new Resource$Media(this.context); + this.rooms = new Resource$Rooms(this.context); this.spaces = new Resource$Spaces(this.context); } } @@ -719,6 +723,384 @@ export namespace chat_v1 { textParagraph?: Schema$TextParagraph; } + export class Resource$Dms { + context: APIRequestContext; + conversations: Resource$Dms$Conversations; + constructor(context: APIRequestContext) { + this.context = context; + this.conversations = new Resource$Dms$Conversations(this.context); + } + + /** + * Legacy path for creating message. Calling these will result in a BadRequest response. + * @example + * ```js + * // 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.dms.messages({ + * // Required. Space resource name, in the form "spaces/x". Example: spaces/AAAAMpdlehY + * parent: 'dms/my-dm', + * // Opaque thread identifier string that can be specified to group messages into a single thread. If this is the first message with a given thread identifier, a new thread is created. Subsequent messages with the same thread identifier will be posted into the same thread. This relieves bots and webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post further updates to it. Has no effect if thread field, corresponding to an existing thread, is set in message. + * threadKey: 'placeholder-value', + * + * // Request body metadata + * requestBody: { + * // request body parameters + * // { + * // "actionResponse": {}, + * // "annotations": [], + * // "argumentText": "my_argumentText", + * // "attachment": [], + * // "cards": [], + * // "createTime": "my_createTime", + * // "fallbackText": "my_fallbackText", + * // "name": "my_name", + * // "previewText": "my_previewText", + * // "sender": {}, + * // "slashCommand": {}, + * // "space": {}, + * // "text": "my_text", + * // "thread": {} + * // } + * }, + * }); + * console.log(res.data); + * + * // Example response + * // { + * // "actionResponse": {}, + * // "annotations": [], + * // "argumentText": "my_argumentText", + * // "attachment": [], + * // "cards": [], + * // "createTime": "my_createTime", + * // "fallbackText": "my_fallbackText", + * // "name": "my_name", + * // "previewText": "my_previewText", + * // "sender": {}, + * // "slashCommand": {}, + * // "space": {}, + * // "text": "my_text", + * // "thread": {} + * // } + * } + * + * main().catch(e => { + * console.error(e); + * throw e; + * }); + * + * ``` + * + * @param params - Parameters for request + * @param options - Optionally override request options, such as `url`, `method`, and `encoding`. + * @param callback - Optional callback that handles the response. + * @returns A promise if used with async/await, or void if used with a callback. + */ + messages( + params: Params$Resource$Dms$Messages, + options: StreamMethodOptions + ): GaxiosPromise; + messages( + params?: Params$Resource$Dms$Messages, + options?: MethodOptions + ): GaxiosPromise; + messages( + params: Params$Resource$Dms$Messages, + options: StreamMethodOptions | BodyResponseCallback, + callback: BodyResponseCallback + ): void; + messages( + params: Params$Resource$Dms$Messages, + options: MethodOptions | BodyResponseCallback, + callback: BodyResponseCallback + ): void; + messages( + params: Params$Resource$Dms$Messages, + callback: BodyResponseCallback + ): void; + messages(callback: BodyResponseCallback): void; + messages( + paramsOrCallback?: + | Params$Resource$Dms$Messages + | BodyResponseCallback + | BodyResponseCallback, + optionsOrCallback?: + | MethodOptions + | StreamMethodOptions + | BodyResponseCallback + | BodyResponseCallback, + callback?: + | BodyResponseCallback + | BodyResponseCallback + ): void | GaxiosPromise | GaxiosPromise { + let params = (paramsOrCallback || {}) as Params$Resource$Dms$Messages; + let options = (optionsOrCallback || {}) as MethodOptions; + + if (typeof paramsOrCallback === 'function') { + callback = paramsOrCallback; + params = {} as Params$Resource$Dms$Messages; + options = {}; + } + + if (typeof optionsOrCallback === 'function') { + callback = optionsOrCallback; + options = {}; + } + + const rootUrl = options.rootUrl || 'https://chat.googleapis.com/'; + const parameters = { + options: Object.assign( + { + url: (rootUrl + '/v1/{+parent}/messages').replace( + /([^:]\/)\/+/g, + '$1' + ), + method: 'POST', + }, + options + ), + params, + requiredParams: ['parent'], + pathParams: ['parent'], + context: this.context, + }; + if (callback) { + createAPIRequest( + parameters, + callback as BodyResponseCallback + ); + } else { + return createAPIRequest(parameters); + } + } + } + + export interface Params$Resource$Dms$Messages extends StandardParameters { + /** + * Required. Space resource name, in the form "spaces/x". Example: spaces/AAAAMpdlehY + */ + parent?: string; + /** + * Opaque thread identifier string that can be specified to group messages into a single thread. If this is the first message with a given thread identifier, a new thread is created. Subsequent messages with the same thread identifier will be posted into the same thread. This relieves bots and webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post further updates to it. Has no effect if thread field, corresponding to an existing thread, is set in message. + */ + threadKey?: string; + + /** + * Request body metadata + */ + requestBody?: Schema$Message; + } + + export class Resource$Dms$Conversations { + context: APIRequestContext; + constructor(context: APIRequestContext) { + this.context = context; + } + + /** + * Legacy path for creating message. Calling these will result in a BadRequest response. + * @example + * ```js + * // 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.dms.conversations.messages({ + * // Required. Space resource name, in the form "spaces/x". Example: spaces/AAAAMpdlehY + * parent: 'dms/my-dm/conversations/my-conversation', + * // Opaque thread identifier string that can be specified to group messages into a single thread. If this is the first message with a given thread identifier, a new thread is created. Subsequent messages with the same thread identifier will be posted into the same thread. This relieves bots and webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post further updates to it. Has no effect if thread field, corresponding to an existing thread, is set in message. + * threadKey: 'placeholder-value', + * + * // Request body metadata + * requestBody: { + * // request body parameters + * // { + * // "actionResponse": {}, + * // "annotations": [], + * // "argumentText": "my_argumentText", + * // "attachment": [], + * // "cards": [], + * // "createTime": "my_createTime", + * // "fallbackText": "my_fallbackText", + * // "name": "my_name", + * // "previewText": "my_previewText", + * // "sender": {}, + * // "slashCommand": {}, + * // "space": {}, + * // "text": "my_text", + * // "thread": {} + * // } + * }, + * }); + * console.log(res.data); + * + * // Example response + * // { + * // "actionResponse": {}, + * // "annotations": [], + * // "argumentText": "my_argumentText", + * // "attachment": [], + * // "cards": [], + * // "createTime": "my_createTime", + * // "fallbackText": "my_fallbackText", + * // "name": "my_name", + * // "previewText": "my_previewText", + * // "sender": {}, + * // "slashCommand": {}, + * // "space": {}, + * // "text": "my_text", + * // "thread": {} + * // } + * } + * + * main().catch(e => { + * console.error(e); + * throw e; + * }); + * + * ``` + * + * @param params - Parameters for request + * @param options - Optionally override request options, such as `url`, `method`, and `encoding`. + * @param callback - Optional callback that handles the response. + * @returns A promise if used with async/await, or void if used with a callback. + */ + messages( + params: Params$Resource$Dms$Conversations$Messages, + options: StreamMethodOptions + ): GaxiosPromise; + messages( + params?: Params$Resource$Dms$Conversations$Messages, + options?: MethodOptions + ): GaxiosPromise; + messages( + params: Params$Resource$Dms$Conversations$Messages, + options: StreamMethodOptions | BodyResponseCallback, + callback: BodyResponseCallback + ): void; + messages( + params: Params$Resource$Dms$Conversations$Messages, + options: MethodOptions | BodyResponseCallback, + callback: BodyResponseCallback + ): void; + messages( + params: Params$Resource$Dms$Conversations$Messages, + callback: BodyResponseCallback + ): void; + messages(callback: BodyResponseCallback): void; + messages( + paramsOrCallback?: + | Params$Resource$Dms$Conversations$Messages + | BodyResponseCallback + | BodyResponseCallback, + optionsOrCallback?: + | MethodOptions + | StreamMethodOptions + | BodyResponseCallback + | BodyResponseCallback, + callback?: + | BodyResponseCallback + | BodyResponseCallback + ): void | GaxiosPromise | GaxiosPromise { + let params = (paramsOrCallback || + {}) as Params$Resource$Dms$Conversations$Messages; + let options = (optionsOrCallback || {}) as MethodOptions; + + if (typeof paramsOrCallback === 'function') { + callback = paramsOrCallback; + params = {} as Params$Resource$Dms$Conversations$Messages; + options = {}; + } + + if (typeof optionsOrCallback === 'function') { + callback = optionsOrCallback; + options = {}; + } + + const rootUrl = options.rootUrl || 'https://chat.googleapis.com/'; + const parameters = { + options: Object.assign( + { + url: (rootUrl + '/v1/{+parent}/messages').replace( + /([^:]\/)\/+/g, + '$1' + ), + method: 'POST', + }, + options + ), + params, + requiredParams: ['parent'], + pathParams: ['parent'], + context: this.context, + }; + if (callback) { + createAPIRequest( + parameters, + callback as BodyResponseCallback + ); + } else { + return createAPIRequest(parameters); + } + } + } + + export interface Params$Resource$Dms$Conversations$Messages + extends StandardParameters { + /** + * Required. Space resource name, in the form "spaces/x". Example: spaces/AAAAMpdlehY + */ + parent?: string; + /** + * Opaque thread identifier string that can be specified to group messages into a single thread. If this is the first message with a given thread identifier, a new thread is created. Subsequent messages with the same thread identifier will be posted into the same thread. This relieves bots and webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post further updates to it. Has no effect if thread field, corresponding to an existing thread, is set in message. + */ + threadKey?: string; + + /** + * Request body metadata + */ + requestBody?: Schema$Message; + } + export class Resource$Media { context: APIRequestContext; constructor(context: APIRequestContext) { @@ -726,7 +1108,338 @@ export namespace chat_v1 { } /** - * Downloads media. Download is supported on the URI `/v1/media/{+name\}?alt=media`. + * Downloads media. Download is supported on the URI `/v1/media/{+name\}?alt=media`. + * @example + * ```js + * // 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.media.download({ + * // Name of the media that is being downloaded. See ReadRequest.resource_name. + * resourceName: '.*', + * }); + * console.log(res.data); + * + * // Example response + * // { + * // "resourceName": "my_resourceName" + * // } + * } + * + * main().catch(e => { + * console.error(e); + * throw e; + * }); + * + * ``` + * + * @param params - Parameters for request + * @param options - Optionally override request options, such as `url`, `method`, and `encoding`. + * @param callback - Optional callback that handles the response. + * @returns A promise if used with async/await, or void if used with a callback. + */ + download( + params: Params$Resource$Media$Download, + options: StreamMethodOptions + ): GaxiosPromise; + download( + params?: Params$Resource$Media$Download, + options?: MethodOptions + ): GaxiosPromise; + download( + params: Params$Resource$Media$Download, + options: StreamMethodOptions | BodyResponseCallback, + callback: BodyResponseCallback + ): void; + download( + params: Params$Resource$Media$Download, + options: MethodOptions | BodyResponseCallback, + callback: BodyResponseCallback + ): void; + download( + params: Params$Resource$Media$Download, + callback: BodyResponseCallback + ): void; + download(callback: BodyResponseCallback): void; + download( + paramsOrCallback?: + | Params$Resource$Media$Download + | BodyResponseCallback + | BodyResponseCallback, + optionsOrCallback?: + | MethodOptions + | StreamMethodOptions + | BodyResponseCallback + | BodyResponseCallback, + callback?: + | BodyResponseCallback + | BodyResponseCallback + ): void | GaxiosPromise | GaxiosPromise { + let params = (paramsOrCallback || {}) as Params$Resource$Media$Download; + let options = (optionsOrCallback || {}) as MethodOptions; + + if (typeof paramsOrCallback === 'function') { + callback = paramsOrCallback; + params = {} as Params$Resource$Media$Download; + options = {}; + } + + if (typeof optionsOrCallback === 'function') { + callback = optionsOrCallback; + options = {}; + } + + const rootUrl = options.rootUrl || 'https://chat.googleapis.com/'; + const parameters = { + options: Object.assign( + { + url: (rootUrl + '/v1/media/{+resourceName}').replace( + /([^:]\/)\/+/g, + '$1' + ), + method: 'GET', + }, + options + ), + params, + requiredParams: ['resourceName'], + pathParams: ['resourceName'], + context: this.context, + }; + if (callback) { + createAPIRequest( + parameters, + callback as BodyResponseCallback + ); + } else { + return createAPIRequest(parameters); + } + } + } + + export interface Params$Resource$Media$Download extends StandardParameters { + /** + * Name of the media that is being downloaded. See ReadRequest.resource_name. + */ + resourceName?: string; + } + + export class Resource$Rooms { + context: APIRequestContext; + conversations: Resource$Rooms$Conversations; + constructor(context: APIRequestContext) { + this.context = context; + this.conversations = new Resource$Rooms$Conversations(this.context); + } + + /** + * Legacy path for creating message. Calling these will result in a BadRequest response. + * @example + * ```js + * // 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.rooms.messages({ + * // Required. Space resource name, in the form "spaces/x". Example: spaces/AAAAMpdlehY + * parent: 'rooms/my-room', + * // Opaque thread identifier string that can be specified to group messages into a single thread. If this is the first message with a given thread identifier, a new thread is created. Subsequent messages with the same thread identifier will be posted into the same thread. This relieves bots and webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post further updates to it. Has no effect if thread field, corresponding to an existing thread, is set in message. + * threadKey: 'placeholder-value', + * + * // Request body metadata + * requestBody: { + * // request body parameters + * // { + * // "actionResponse": {}, + * // "annotations": [], + * // "argumentText": "my_argumentText", + * // "attachment": [], + * // "cards": [], + * // "createTime": "my_createTime", + * // "fallbackText": "my_fallbackText", + * // "name": "my_name", + * // "previewText": "my_previewText", + * // "sender": {}, + * // "slashCommand": {}, + * // "space": {}, + * // "text": "my_text", + * // "thread": {} + * // } + * }, + * }); + * console.log(res.data); + * + * // Example response + * // { + * // "actionResponse": {}, + * // "annotations": [], + * // "argumentText": "my_argumentText", + * // "attachment": [], + * // "cards": [], + * // "createTime": "my_createTime", + * // "fallbackText": "my_fallbackText", + * // "name": "my_name", + * // "previewText": "my_previewText", + * // "sender": {}, + * // "slashCommand": {}, + * // "space": {}, + * // "text": "my_text", + * // "thread": {} + * // } + * } + * + * main().catch(e => { + * console.error(e); + * throw e; + * }); + * + * ``` + * + * @param params - Parameters for request + * @param options - Optionally override request options, such as `url`, `method`, and `encoding`. + * @param callback - Optional callback that handles the response. + * @returns A promise if used with async/await, or void if used with a callback. + */ + messages( + params: Params$Resource$Rooms$Messages, + options: StreamMethodOptions + ): GaxiosPromise; + messages( + params?: Params$Resource$Rooms$Messages, + options?: MethodOptions + ): GaxiosPromise; + messages( + params: Params$Resource$Rooms$Messages, + options: StreamMethodOptions | BodyResponseCallback, + callback: BodyResponseCallback + ): void; + messages( + params: Params$Resource$Rooms$Messages, + options: MethodOptions | BodyResponseCallback, + callback: BodyResponseCallback + ): void; + messages( + params: Params$Resource$Rooms$Messages, + callback: BodyResponseCallback + ): void; + messages(callback: BodyResponseCallback): void; + messages( + paramsOrCallback?: + | Params$Resource$Rooms$Messages + | BodyResponseCallback + | BodyResponseCallback, + optionsOrCallback?: + | MethodOptions + | StreamMethodOptions + | BodyResponseCallback + | BodyResponseCallback, + callback?: + | BodyResponseCallback + | BodyResponseCallback + ): void | GaxiosPromise | GaxiosPromise { + let params = (paramsOrCallback || {}) as Params$Resource$Rooms$Messages; + let options = (optionsOrCallback || {}) as MethodOptions; + + if (typeof paramsOrCallback === 'function') { + callback = paramsOrCallback; + params = {} as Params$Resource$Rooms$Messages; + options = {}; + } + + if (typeof optionsOrCallback === 'function') { + callback = optionsOrCallback; + options = {}; + } + + const rootUrl = options.rootUrl || 'https://chat.googleapis.com/'; + const parameters = { + options: Object.assign( + { + url: (rootUrl + '/v1/{+parent}/messages').replace( + /([^:]\/)\/+/g, + '$1' + ), + method: 'POST', + }, + options + ), + params, + requiredParams: ['parent'], + pathParams: ['parent'], + context: this.context, + }; + if (callback) { + createAPIRequest( + parameters, + callback as BodyResponseCallback + ); + } else { + return createAPIRequest(parameters); + } + } + } + + export interface Params$Resource$Rooms$Messages extends StandardParameters { + /** + * Required. Space resource name, in the form "spaces/x". Example: spaces/AAAAMpdlehY + */ + parent?: string; + /** + * Opaque thread identifier string that can be specified to group messages into a single thread. If this is the first message with a given thread identifier, a new thread is created. Subsequent messages with the same thread identifier will be posted into the same thread. This relieves bots and webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post further updates to it. Has no effect if thread field, corresponding to an existing thread, is set in message. + */ + threadKey?: string; + + /** + * Request body metadata + */ + requestBody?: Schema$Message; + } + + export class Resource$Rooms$Conversations { + context: APIRequestContext; + constructor(context: APIRequestContext) { + this.context = context; + } + + /** + * Legacy path for creating message. Calling these will result in a BadRequest response. * @example * ```js * // Before running the sample: @@ -751,15 +1464,51 @@ export namespace chat_v1 { * google.options({auth: authClient}); * * // Do the magic - * const res = await chat.media.download({ - * // Name of the media that is being downloaded. See ReadRequest.resource_name. - * resourceName: '.*', + * const res = await chat.rooms.conversations.messages({ + * // Required. Space resource name, in the form "spaces/x". Example: spaces/AAAAMpdlehY + * parent: 'rooms/my-room/conversations/my-conversation', + * // Opaque thread identifier string that can be specified to group messages into a single thread. If this is the first message with a given thread identifier, a new thread is created. Subsequent messages with the same thread identifier will be posted into the same thread. This relieves bots and webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post further updates to it. Has no effect if thread field, corresponding to an existing thread, is set in message. + * threadKey: 'placeholder-value', + * + * // Request body metadata + * requestBody: { + * // request body parameters + * // { + * // "actionResponse": {}, + * // "annotations": [], + * // "argumentText": "my_argumentText", + * // "attachment": [], + * // "cards": [], + * // "createTime": "my_createTime", + * // "fallbackText": "my_fallbackText", + * // "name": "my_name", + * // "previewText": "my_previewText", + * // "sender": {}, + * // "slashCommand": {}, + * // "space": {}, + * // "text": "my_text", + * // "thread": {} + * // } + * }, * }); * console.log(res.data); * * // Example response * // { - * // "resourceName": "my_resourceName" + * // "actionResponse": {}, + * // "annotations": [], + * // "argumentText": "my_argumentText", + * // "attachment": [], + * // "cards": [], + * // "createTime": "my_createTime", + * // "fallbackText": "my_fallbackText", + * // "name": "my_name", + * // "previewText": "my_previewText", + * // "sender": {}, + * // "slashCommand": {}, + * // "space": {}, + * // "text": "my_text", + * // "thread": {} * // } * } * @@ -775,49 +1524,50 @@ export namespace chat_v1 { * @param callback - Optional callback that handles the response. * @returns A promise if used with async/await, or void if used with a callback. */ - download( - params: Params$Resource$Media$Download, + messages( + params: Params$Resource$Rooms$Conversations$Messages, options: StreamMethodOptions ): GaxiosPromise; - download( - params?: Params$Resource$Media$Download, + messages( + params?: Params$Resource$Rooms$Conversations$Messages, options?: MethodOptions - ): GaxiosPromise; - download( - params: Params$Resource$Media$Download, + ): GaxiosPromise; + messages( + params: Params$Resource$Rooms$Conversations$Messages, options: StreamMethodOptions | BodyResponseCallback, callback: BodyResponseCallback ): void; - download( - params: Params$Resource$Media$Download, - options: MethodOptions | BodyResponseCallback, - callback: BodyResponseCallback + messages( + params: Params$Resource$Rooms$Conversations$Messages, + options: MethodOptions | BodyResponseCallback, + callback: BodyResponseCallback ): void; - download( - params: Params$Resource$Media$Download, - callback: BodyResponseCallback + messages( + params: Params$Resource$Rooms$Conversations$Messages, + callback: BodyResponseCallback ): void; - download(callback: BodyResponseCallback): void; - download( + messages(callback: BodyResponseCallback): void; + messages( paramsOrCallback?: - | Params$Resource$Media$Download - | BodyResponseCallback + | Params$Resource$Rooms$Conversations$Messages + | BodyResponseCallback | BodyResponseCallback, optionsOrCallback?: | MethodOptions | StreamMethodOptions - | BodyResponseCallback + | BodyResponseCallback | BodyResponseCallback, callback?: - | BodyResponseCallback + | BodyResponseCallback | BodyResponseCallback - ): void | GaxiosPromise | GaxiosPromise { - let params = (paramsOrCallback || {}) as Params$Resource$Media$Download; + ): void | GaxiosPromise | GaxiosPromise { + let params = (paramsOrCallback || + {}) as Params$Resource$Rooms$Conversations$Messages; let options = (optionsOrCallback || {}) as MethodOptions; if (typeof paramsOrCallback === 'function') { callback = paramsOrCallback; - params = {} as Params$Resource$Media$Download; + params = {} as Params$Resource$Rooms$Conversations$Messages; options = {}; } @@ -830,35 +1580,45 @@ export namespace chat_v1 { const parameters = { options: Object.assign( { - url: (rootUrl + '/v1/media/{+resourceName}').replace( + url: (rootUrl + '/v1/{+parent}/messages').replace( /([^:]\/)\/+/g, '$1' ), - method: 'GET', + method: 'POST', }, options ), params, - requiredParams: ['resourceName'], - pathParams: ['resourceName'], + requiredParams: ['parent'], + pathParams: ['parent'], context: this.context, }; if (callback) { - createAPIRequest( + createAPIRequest( parameters, callback as BodyResponseCallback ); } else { - return createAPIRequest(parameters); + return createAPIRequest(parameters); } } } - export interface Params$Resource$Media$Download extends StandardParameters { + export interface Params$Resource$Rooms$Conversations$Messages + extends StandardParameters { /** - * Name of the media that is being downloaded. See ReadRequest.resource_name. + * Required. Space resource name, in the form "spaces/x". Example: spaces/AAAAMpdlehY */ - resourceName?: string; + parent?: string; + /** + * Opaque thread identifier string that can be specified to group messages into a single thread. If this is the first message with a given thread identifier, a new thread is created. Subsequent messages with the same thread identifier will be posted into the same thread. This relieves bots and webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post further updates to it. Has no effect if thread field, corresponding to an existing thread, is set in message. + */ + threadKey?: string; + + /** + * Request body metadata + */ + requestBody?: Schema$Message; } export class Resource$Spaces {