@google-apps/chat 0.31.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -172,6 +172,7 @@ class ChatServiceClient {
172
172
  customEmojiPathTemplate: new this._gaxModule.PathTemplate('customEmojis/{custom_emoji}'),
173
173
  membershipPathTemplate: new this._gaxModule.PathTemplate('spaces/{space}/members/{member}'),
174
174
  messagePathTemplate: new this._gaxModule.PathTemplate('spaces/{space}/messages/{message}'),
175
+ messagePinPathTemplate: new this._gaxModule.PathTemplate('spaces/{space}/messagePins/{message_pin}'),
175
176
  quotedMessageMetadataPathTemplate: new this._gaxModule.PathTemplate('spaces/{space}/messages/{message}/quotedMessageMetadata/{quoted_message_metadata}'),
176
177
  reactionPathTemplate: new this._gaxModule.PathTemplate('spaces/{space}/messages/{message}/reactions/{reaction}'),
177
178
  sectionPathTemplate: new this._gaxModule.PathTemplate('users/{user}/sections/{section}'),
@@ -194,6 +195,7 @@ class ChatServiceClient {
194
195
  searchSpaces: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'spaces'),
195
196
  findGroupChats: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'spaces'),
196
197
  listReactions: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'reactions'),
198
+ listMessagePins: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'messagePins'),
197
199
  listCustomEmojis: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'customEmojis'),
198
200
  listSpaceEvents: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'spaceEvents'),
199
201
  listSections: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'sections'),
@@ -259,6 +261,9 @@ class ChatServiceClient {
259
261
  'createReaction',
260
262
  'listReactions',
261
263
  'deleteReaction',
264
+ 'listMessagePins',
265
+ 'createMessagePin',
266
+ 'deleteMessagePin',
262
267
  'createCustomEmoji',
263
268
  'getCustomEmoji',
264
269
  'listCustomEmojis',
@@ -378,6 +383,8 @@ class ChatServiceClient {
378
383
  'https://www.googleapis.com/auth/chat.messages.readonly',
379
384
  'https://www.googleapis.com/auth/chat.spaces',
380
385
  'https://www.googleapis.com/auth/chat.spaces.create',
386
+ 'https://www.googleapis.com/auth/chat.spaces.pins',
387
+ 'https://www.googleapis.com/auth/chat.spaces.pins.readonly',
381
388
  'https://www.googleapis.com/auth/chat.spaces.readonly',
382
389
  'https://www.googleapis.com/auth/chat.users.availability',
383
390
  'https://www.googleapis.com/auth/chat.users.availability.readonly',
@@ -1204,6 +1211,92 @@ class ChatServiceClient {
1204
1211
  throw error;
1205
1212
  });
1206
1213
  }
1214
+ createMessagePin(request, optionsOrCallback, callback) {
1215
+ request = request || {};
1216
+ let options;
1217
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
1218
+ callback = optionsOrCallback;
1219
+ options = {};
1220
+ }
1221
+ else {
1222
+ options = optionsOrCallback;
1223
+ }
1224
+ options = options || {};
1225
+ options.otherArgs = options.otherArgs || {};
1226
+ options.otherArgs.headers = options.otherArgs.headers || {};
1227
+ options.otherArgs.headers['x-goog-request-params'] =
1228
+ this._gaxModule.routingHeader.fromParams({
1229
+ parent: request.parent ?? '',
1230
+ });
1231
+ this.initialize().catch(err => {
1232
+ throw err;
1233
+ });
1234
+ this._log.info('createMessagePin request %j', request);
1235
+ const wrappedCallback = callback
1236
+ ? (error, response, options, rawResponse) => {
1237
+ this._log.info('createMessagePin response %j', response);
1238
+ callback(error, response, options, rawResponse); // We verified callback above.
1239
+ }
1240
+ : undefined;
1241
+ return this.innerApiCalls
1242
+ .createMessagePin(request, options, wrappedCallback)
1243
+ ?.then(([response, options, rawResponse]) => {
1244
+ this._log.info('createMessagePin response %j', response);
1245
+ return [response, options, rawResponse];
1246
+ })
1247
+ .catch((error) => {
1248
+ if (error &&
1249
+ 'statusDetails' in error &&
1250
+ error.statusDetails instanceof Array) {
1251
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
1252
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
1253
+ }
1254
+ throw error;
1255
+ });
1256
+ }
1257
+ deleteMessagePin(request, optionsOrCallback, callback) {
1258
+ request = request || {};
1259
+ let options;
1260
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
1261
+ callback = optionsOrCallback;
1262
+ options = {};
1263
+ }
1264
+ else {
1265
+ options = optionsOrCallback;
1266
+ }
1267
+ options = options || {};
1268
+ options.otherArgs = options.otherArgs || {};
1269
+ options.otherArgs.headers = options.otherArgs.headers || {};
1270
+ options.otherArgs.headers['x-goog-request-params'] =
1271
+ this._gaxModule.routingHeader.fromParams({
1272
+ name: request.name ?? '',
1273
+ });
1274
+ this.initialize().catch(err => {
1275
+ throw err;
1276
+ });
1277
+ this._log.info('deleteMessagePin request %j', request);
1278
+ const wrappedCallback = callback
1279
+ ? (error, response, options, rawResponse) => {
1280
+ this._log.info('deleteMessagePin response %j', response);
1281
+ callback(error, response, options, rawResponse); // We verified callback above.
1282
+ }
1283
+ : undefined;
1284
+ return this.innerApiCalls
1285
+ .deleteMessagePin(request, options, wrappedCallback)
1286
+ ?.then(([response, options, rawResponse]) => {
1287
+ this._log.info('deleteMessagePin response %j', response);
1288
+ return [response, options, rawResponse];
1289
+ })
1290
+ .catch((error) => {
1291
+ if (error &&
1292
+ 'statusDetails' in error &&
1293
+ error.statusDetails instanceof Array) {
1294
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
1295
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
1296
+ }
1297
+ throw error;
1298
+ });
1299
+ }
1207
1300
  createCustomEmoji(request, optionsOrCallback, callback) {
1208
1301
  request = request || {};
1209
1302
  let options;
@@ -3940,6 +4033,139 @@ class ChatServiceClient {
3940
4033
  this._log.info('listReactions iterate %j', request);
3941
4034
  return this.descriptors.page.listReactions.asyncIterate(this.innerApiCalls['listReactions'], request, callSettings);
3942
4035
  }
4036
+ listMessagePins(request, optionsOrCallback, callback) {
4037
+ request = request || {};
4038
+ let options;
4039
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
4040
+ callback = optionsOrCallback;
4041
+ options = {};
4042
+ }
4043
+ else {
4044
+ options = optionsOrCallback;
4045
+ }
4046
+ options = options || {};
4047
+ options.otherArgs = options.otherArgs || {};
4048
+ options.otherArgs.headers = options.otherArgs.headers || {};
4049
+ options.otherArgs.headers['x-goog-request-params'] =
4050
+ this._gaxModule.routingHeader.fromParams({
4051
+ parent: request.parent ?? '',
4052
+ });
4053
+ this.initialize().catch(err => {
4054
+ throw err;
4055
+ });
4056
+ const wrappedCallback = callback
4057
+ ? (error, values, nextPageRequest, rawResponse) => {
4058
+ this._log.info('listMessagePins values %j', values);
4059
+ callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
4060
+ }
4061
+ : undefined;
4062
+ this._log.info('listMessagePins request %j', request);
4063
+ return this.innerApiCalls
4064
+ .listMessagePins(request, options, wrappedCallback)
4065
+ ?.then(([response, input, output]) => {
4066
+ this._log.info('listMessagePins values %j', response);
4067
+ return [response, input, output];
4068
+ });
4069
+ }
4070
+ /**
4071
+ * Equivalent to `listMessagePins`, but returns a NodeJS Stream object.
4072
+ * @param {Object} request
4073
+ * The request object that will be sent.
4074
+ * @param {string} request.parent
4075
+ * Required. The parent space which owns the collection of pinned items
4076
+ * Format: `spaces/{space}`
4077
+ * @param {number} [request.pageSize]
4078
+ * Optional. The maximum number of message pins returned. The service might
4079
+ * return fewer messages than this value. The maximum value is 100. If you use
4080
+ * a value more than 100, it's automatically changed to 100. If unspecified,
4081
+ * at most 100 message pins will be returned. Negative values return an
4082
+ * `INVALID_ARGUMENT` error.
4083
+ * @param {string} [request.pageToken]
4084
+ * Optional. A page token received from a previous list message pins call.
4085
+ * Provide this parameter to retrieve the subsequent page.
4086
+ *
4087
+ * When paginating, all other parameters provided should match the call that
4088
+ * provided the page token. Passing different values to the other parameters
4089
+ * might lead to unexpected results.
4090
+ * @param {object} [options]
4091
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
4092
+ * @returns {Stream}
4093
+ * An object stream which emits an object representing {@link protos.google.chat.v1.MessagePin|MessagePin} on 'data' event.
4094
+ * The client library will perform auto-pagination by default: it will call the API as many
4095
+ * times as needed. Note that it can affect your quota.
4096
+ * We recommend using `listMessagePinsAsync()`
4097
+ * method described below for async iteration which you can stop as needed.
4098
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
4099
+ * for more details and examples.
4100
+ */
4101
+ listMessagePinsStream(request, options) {
4102
+ request = request || {};
4103
+ options = options || {};
4104
+ options.otherArgs = options.otherArgs || {};
4105
+ options.otherArgs.headers = options.otherArgs.headers || {};
4106
+ options.otherArgs.headers['x-goog-request-params'] =
4107
+ this._gaxModule.routingHeader.fromParams({
4108
+ parent: request.parent ?? '',
4109
+ });
4110
+ const defaultCallSettings = this._defaults['listMessagePins'];
4111
+ const callSettings = defaultCallSettings.merge(options);
4112
+ this.initialize().catch(err => {
4113
+ throw err;
4114
+ });
4115
+ this._log.info('listMessagePins stream %j', request);
4116
+ return this.descriptors.page.listMessagePins.createStream(this.innerApiCalls.listMessagePins, request, callSettings);
4117
+ }
4118
+ /**
4119
+ * Equivalent to `listMessagePins`, but returns an iterable object.
4120
+ *
4121
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
4122
+ * @param {Object} request
4123
+ * The request object that will be sent.
4124
+ * @param {string} request.parent
4125
+ * Required. The parent space which owns the collection of pinned items
4126
+ * Format: `spaces/{space}`
4127
+ * @param {number} [request.pageSize]
4128
+ * Optional. The maximum number of message pins returned. The service might
4129
+ * return fewer messages than this value. The maximum value is 100. If you use
4130
+ * a value more than 100, it's automatically changed to 100. If unspecified,
4131
+ * at most 100 message pins will be returned. Negative values return an
4132
+ * `INVALID_ARGUMENT` error.
4133
+ * @param {string} [request.pageToken]
4134
+ * Optional. A page token received from a previous list message pins call.
4135
+ * Provide this parameter to retrieve the subsequent page.
4136
+ *
4137
+ * When paginating, all other parameters provided should match the call that
4138
+ * provided the page token. Passing different values to the other parameters
4139
+ * might lead to unexpected results.
4140
+ * @param {object} [options]
4141
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
4142
+ * @returns {Object}
4143
+ * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
4144
+ * When you iterate the returned iterable, each element will be an object representing
4145
+ * {@link protos.google.chat.v1.MessagePin|MessagePin}. The API will be called under the hood as needed, once per the page,
4146
+ * so you can stop the iteration when you don't need more results.
4147
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
4148
+ * for more details and examples.
4149
+ * @example <caption>include:samples/generated/v1/chat_service.list_message_pins.js</caption>
4150
+ * region_tag:chat_v1_generated_ChatService_ListMessagePins_async
4151
+ */
4152
+ listMessagePinsAsync(request, options) {
4153
+ request = request || {};
4154
+ options = options || {};
4155
+ options.otherArgs = options.otherArgs || {};
4156
+ options.otherArgs.headers = options.otherArgs.headers || {};
4157
+ options.otherArgs.headers['x-goog-request-params'] =
4158
+ this._gaxModule.routingHeader.fromParams({
4159
+ parent: request.parent ?? '',
4160
+ });
4161
+ const defaultCallSettings = this._defaults['listMessagePins'];
4162
+ const callSettings = defaultCallSettings.merge(options);
4163
+ this.initialize().catch(err => {
4164
+ throw err;
4165
+ });
4166
+ this._log.info('listMessagePins iterate %j', request);
4167
+ return this.descriptors.page.listMessagePins.asyncIterate(this.innerApiCalls['listMessagePins'], request, callSettings);
4168
+ }
3943
4169
  listCustomEmojis(request, optionsOrCallback, callback) {
3944
4170
  request = request || {};
3945
4171
  let options;
@@ -4819,6 +5045,41 @@ class ChatServiceClient {
4819
5045
  matchMessageFromMessageName(messageName) {
4820
5046
  return this.pathTemplates.messagePathTemplate.match(messageName).message;
4821
5047
  }
5048
+ /**
5049
+ * Return a fully-qualified messagePin resource name string.
5050
+ *
5051
+ * @param {string} space
5052
+ * @param {string} message_pin
5053
+ * @returns {string} Resource name string.
5054
+ */
5055
+ messagePinPath(space, messagePin) {
5056
+ return this.pathTemplates.messagePinPathTemplate.render({
5057
+ space: space,
5058
+ message_pin: messagePin,
5059
+ });
5060
+ }
5061
+ /**
5062
+ * Parse the space from MessagePin resource.
5063
+ *
5064
+ * @param {string} messagePinName
5065
+ * A fully-qualified path representing MessagePin resource.
5066
+ * @returns {string} A string representing the space.
5067
+ */
5068
+ matchSpaceFromMessagePinName(messagePinName) {
5069
+ return this.pathTemplates.messagePinPathTemplate.match(messagePinName)
5070
+ .space;
5071
+ }
5072
+ /**
5073
+ * Parse the message_pin from MessagePin resource.
5074
+ *
5075
+ * @param {string} messagePinName
5076
+ * A fully-qualified path representing MessagePin resource.
5077
+ * @returns {string} A string representing the message_pin.
5078
+ */
5079
+ matchMessagePinFromMessagePinName(messagePinName) {
5080
+ return this.pathTemplates.messagePinPathTemplate.match(messagePinName)
5081
+ .message_pin;
5082
+ }
4822
5083
  /**
4823
5084
  * Return a fully-qualified quotedMessageMetadata resource name string.
4824
5085
  *