@google-apps/chat 0.25.0 → 0.26.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.
@@ -168,6 +168,7 @@ class ChatServiceClient {
168
168
  // Create useful helper objects for these.
169
169
  this.pathTemplates = {
170
170
  attachmentPathTemplate: new this._gaxModule.PathTemplate('spaces/{space}/messages/{message}/attachments/{attachment}'),
171
+ availabilityPathTemplate: new this._gaxModule.PathTemplate('users/{user}/availability'),
171
172
  customEmojiPathTemplate: new this._gaxModule.PathTemplate('customEmojis/{custom_emoji}'),
172
173
  membershipPathTemplate: new this._gaxModule.PathTemplate('spaces/{space}/members/{member}'),
173
174
  messagePathTemplate: new this._gaxModule.PathTemplate('spaces/{space}/messages/{message}'),
@@ -263,6 +264,11 @@ class ChatServiceClient {
263
264
  'getSpaceReadState',
264
265
  'updateSpaceReadState',
265
266
  'getThreadReadState',
267
+ 'getAvailability',
268
+ 'markAsActive',
269
+ 'markAsAway',
270
+ 'markAsDoNotDisturb',
271
+ 'updateAvailability',
266
272
  'getSpaceEvent',
267
273
  'listSpaceEvents',
268
274
  'getSpaceNotificationSetting',
@@ -368,6 +374,8 @@ class ChatServiceClient {
368
374
  'https://www.googleapis.com/auth/chat.spaces',
369
375
  'https://www.googleapis.com/auth/chat.spaces.create',
370
376
  'https://www.googleapis.com/auth/chat.spaces.readonly',
377
+ 'https://www.googleapis.com/auth/chat.users.availability',
378
+ 'https://www.googleapis.com/auth/chat.users.availability.readonly',
371
379
  'https://www.googleapis.com/auth/chat.users.readstate',
372
380
  'https://www.googleapis.com/auth/chat.users.readstate.readonly',
373
381
  'https://www.googleapis.com/auth/chat.users.sections',
@@ -1445,6 +1453,221 @@ class ChatServiceClient {
1445
1453
  throw error;
1446
1454
  });
1447
1455
  }
1456
+ getAvailability(request, optionsOrCallback, callback) {
1457
+ request = request || {};
1458
+ let options;
1459
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
1460
+ callback = optionsOrCallback;
1461
+ options = {};
1462
+ }
1463
+ else {
1464
+ options = optionsOrCallback;
1465
+ }
1466
+ options = options || {};
1467
+ options.otherArgs = options.otherArgs || {};
1468
+ options.otherArgs.headers = options.otherArgs.headers || {};
1469
+ options.otherArgs.headers['x-goog-request-params'] =
1470
+ this._gaxModule.routingHeader.fromParams({
1471
+ name: request.name ?? '',
1472
+ });
1473
+ this.initialize().catch((err) => {
1474
+ throw err;
1475
+ });
1476
+ this._log.info('getAvailability request %j', request);
1477
+ const wrappedCallback = callback
1478
+ ? (error, response, options, rawResponse) => {
1479
+ this._log.info('getAvailability response %j', response);
1480
+ callback(error, response, options, rawResponse); // We verified callback above.
1481
+ }
1482
+ : undefined;
1483
+ return this.innerApiCalls
1484
+ .getAvailability(request, options, wrappedCallback)
1485
+ ?.then(([response, options, rawResponse]) => {
1486
+ this._log.info('getAvailability response %j', response);
1487
+ return [response, options, rawResponse];
1488
+ })
1489
+ .catch((error) => {
1490
+ if (error &&
1491
+ 'statusDetails' in error &&
1492
+ error.statusDetails instanceof Array) {
1493
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
1494
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
1495
+ }
1496
+ throw error;
1497
+ });
1498
+ }
1499
+ markAsActive(request, optionsOrCallback, callback) {
1500
+ request = request || {};
1501
+ let options;
1502
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
1503
+ callback = optionsOrCallback;
1504
+ options = {};
1505
+ }
1506
+ else {
1507
+ options = optionsOrCallback;
1508
+ }
1509
+ options = options || {};
1510
+ options.otherArgs = options.otherArgs || {};
1511
+ options.otherArgs.headers = options.otherArgs.headers || {};
1512
+ options.otherArgs.headers['x-goog-request-params'] =
1513
+ this._gaxModule.routingHeader.fromParams({
1514
+ name: request.name ?? '',
1515
+ });
1516
+ this.initialize().catch((err) => {
1517
+ throw err;
1518
+ });
1519
+ this._log.info('markAsActive request %j', request);
1520
+ const wrappedCallback = callback
1521
+ ? (error, response, options, rawResponse) => {
1522
+ this._log.info('markAsActive response %j', response);
1523
+ callback(error, response, options, rawResponse); // We verified callback above.
1524
+ }
1525
+ : undefined;
1526
+ return this.innerApiCalls
1527
+ .markAsActive(request, options, wrappedCallback)
1528
+ ?.then(([response, options, rawResponse]) => {
1529
+ this._log.info('markAsActive response %j', response);
1530
+ return [response, options, rawResponse];
1531
+ })
1532
+ .catch((error) => {
1533
+ if (error &&
1534
+ 'statusDetails' in error &&
1535
+ error.statusDetails instanceof Array) {
1536
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
1537
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
1538
+ }
1539
+ throw error;
1540
+ });
1541
+ }
1542
+ markAsAway(request, optionsOrCallback, callback) {
1543
+ request = request || {};
1544
+ let options;
1545
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
1546
+ callback = optionsOrCallback;
1547
+ options = {};
1548
+ }
1549
+ else {
1550
+ options = optionsOrCallback;
1551
+ }
1552
+ options = options || {};
1553
+ options.otherArgs = options.otherArgs || {};
1554
+ options.otherArgs.headers = options.otherArgs.headers || {};
1555
+ options.otherArgs.headers['x-goog-request-params'] =
1556
+ this._gaxModule.routingHeader.fromParams({
1557
+ name: request.name ?? '',
1558
+ });
1559
+ this.initialize().catch((err) => {
1560
+ throw err;
1561
+ });
1562
+ this._log.info('markAsAway request %j', request);
1563
+ const wrappedCallback = callback
1564
+ ? (error, response, options, rawResponse) => {
1565
+ this._log.info('markAsAway response %j', response);
1566
+ callback(error, response, options, rawResponse); // We verified callback above.
1567
+ }
1568
+ : undefined;
1569
+ return this.innerApiCalls
1570
+ .markAsAway(request, options, wrappedCallback)
1571
+ ?.then(([response, options, rawResponse]) => {
1572
+ this._log.info('markAsAway response %j', response);
1573
+ return [response, options, rawResponse];
1574
+ })
1575
+ .catch((error) => {
1576
+ if (error &&
1577
+ 'statusDetails' in error &&
1578
+ error.statusDetails instanceof Array) {
1579
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
1580
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
1581
+ }
1582
+ throw error;
1583
+ });
1584
+ }
1585
+ markAsDoNotDisturb(request, optionsOrCallback, callback) {
1586
+ request = request || {};
1587
+ let options;
1588
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
1589
+ callback = optionsOrCallback;
1590
+ options = {};
1591
+ }
1592
+ else {
1593
+ options = optionsOrCallback;
1594
+ }
1595
+ options = options || {};
1596
+ options.otherArgs = options.otherArgs || {};
1597
+ options.otherArgs.headers = options.otherArgs.headers || {};
1598
+ options.otherArgs.headers['x-goog-request-params'] =
1599
+ this._gaxModule.routingHeader.fromParams({
1600
+ name: request.name ?? '',
1601
+ });
1602
+ this.initialize().catch((err) => {
1603
+ throw err;
1604
+ });
1605
+ this._log.info('markAsDoNotDisturb request %j', request);
1606
+ const wrappedCallback = callback
1607
+ ? (error, response, options, rawResponse) => {
1608
+ this._log.info('markAsDoNotDisturb response %j', response);
1609
+ callback(error, response, options, rawResponse); // We verified callback above.
1610
+ }
1611
+ : undefined;
1612
+ return this.innerApiCalls
1613
+ .markAsDoNotDisturb(request, options, wrappedCallback)
1614
+ ?.then(([response, options, rawResponse]) => {
1615
+ this._log.info('markAsDoNotDisturb response %j', response);
1616
+ return [response, options, rawResponse];
1617
+ })
1618
+ .catch((error) => {
1619
+ if (error &&
1620
+ 'statusDetails' in error &&
1621
+ error.statusDetails instanceof Array) {
1622
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
1623
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
1624
+ }
1625
+ throw error;
1626
+ });
1627
+ }
1628
+ updateAvailability(request, optionsOrCallback, callback) {
1629
+ request = request || {};
1630
+ let options;
1631
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
1632
+ callback = optionsOrCallback;
1633
+ options = {};
1634
+ }
1635
+ else {
1636
+ options = optionsOrCallback;
1637
+ }
1638
+ options = options || {};
1639
+ options.otherArgs = options.otherArgs || {};
1640
+ options.otherArgs.headers = options.otherArgs.headers || {};
1641
+ options.otherArgs.headers['x-goog-request-params'] =
1642
+ this._gaxModule.routingHeader.fromParams({
1643
+ 'availability.name': request.availability.name ?? '',
1644
+ });
1645
+ this.initialize().catch((err) => {
1646
+ throw err;
1647
+ });
1648
+ this._log.info('updateAvailability request %j', request);
1649
+ const wrappedCallback = callback
1650
+ ? (error, response, options, rawResponse) => {
1651
+ this._log.info('updateAvailability response %j', response);
1652
+ callback(error, response, options, rawResponse); // We verified callback above.
1653
+ }
1654
+ : undefined;
1655
+ return this.innerApiCalls
1656
+ .updateAvailability(request, options, wrappedCallback)
1657
+ ?.then(([response, options, rawResponse]) => {
1658
+ this._log.info('updateAvailability response %j', response);
1659
+ return [response, options, rawResponse];
1660
+ })
1661
+ .catch((error) => {
1662
+ if (error &&
1663
+ 'statusDetails' in error &&
1664
+ error.statusDetails instanceof Array) {
1665
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
1666
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
1667
+ }
1668
+ throw error;
1669
+ });
1670
+ }
1448
1671
  getSpaceEvent(request, optionsOrCallback, callback) {
1449
1672
  request = request || {};
1450
1673
  let options;
@@ -3970,6 +4193,28 @@ class ChatServiceClient {
3970
4193
  return this.pathTemplates.attachmentPathTemplate.match(attachmentName)
3971
4194
  .attachment;
3972
4195
  }
4196
+ /**
4197
+ * Return a fully-qualified availability resource name string.
4198
+ *
4199
+ * @param {string} user
4200
+ * @returns {string} Resource name string.
4201
+ */
4202
+ availabilityPath(user) {
4203
+ return this.pathTemplates.availabilityPathTemplate.render({
4204
+ user: user,
4205
+ });
4206
+ }
4207
+ /**
4208
+ * Parse the user from Availability resource.
4209
+ *
4210
+ * @param {string} availabilityName
4211
+ * A fully-qualified path representing Availability resource.
4212
+ * @returns {string} A string representing the user.
4213
+ */
4214
+ matchUserFromAvailabilityName(availabilityName) {
4215
+ return this.pathTemplates.availabilityPathTemplate.match(availabilityName)
4216
+ .user;
4217
+ }
3973
4218
  /**
3974
4219
  * Return a fully-qualified customEmoji resource name string.
3975
4220
  *