@azure/web-pubsub 1.1.2-alpha.20230418.1 → 1.1.3-alpha.20230727.2

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -39,6 +39,31 @@ var jwt__default = /*#__PURE__*/_interopDefaultLegacy(jwt);
39
39
  * Code generated by Microsoft (R) AutoRest Code Generator.
40
40
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
41
41
  */
42
+ const AddToGroupsRequest = {
43
+ type: {
44
+ name: "Composite",
45
+ className: "AddToGroupsRequest",
46
+ modelProperties: {
47
+ groups: {
48
+ serializedName: "groups",
49
+ type: {
50
+ name: "Sequence",
51
+ element: {
52
+ type: {
53
+ name: "String"
54
+ }
55
+ }
56
+ }
57
+ },
58
+ filter: {
59
+ serializedName: "filter",
60
+ type: {
61
+ name: "String"
62
+ }
63
+ }
64
+ }
65
+ }
66
+ };
42
67
  const ErrorDetail = {
43
68
  type: {
44
69
  name: "Composite",
@@ -119,6 +144,45 @@ const ClientTokenResponse = {
119
144
  }
120
145
  }
121
146
  };
147
+ const RemoveFromGroupsRequest = {
148
+ type: {
149
+ name: "Composite",
150
+ className: "RemoveFromGroupsRequest",
151
+ modelProperties: {
152
+ groups: {
153
+ serializedName: "groups",
154
+ type: {
155
+ name: "Sequence",
156
+ element: {
157
+ type: {
158
+ name: "String"
159
+ }
160
+ }
161
+ }
162
+ },
163
+ filter: {
164
+ serializedName: "filter",
165
+ type: {
166
+ name: "String"
167
+ }
168
+ }
169
+ }
170
+ }
171
+ };
172
+ const WebPubSubAddConnectionsToGroupsExceptionHeaders = {
173
+ type: {
174
+ name: "Composite",
175
+ className: "WebPubSubAddConnectionsToGroupsExceptionHeaders",
176
+ modelProperties: {
177
+ errorCode: {
178
+ serializedName: "x-ms-error-code",
179
+ type: {
180
+ name: "String"
181
+ }
182
+ }
183
+ }
184
+ }
185
+ };
122
186
  const WebPubSubCloseAllConnectionsExceptionHeaders = {
123
187
  type: {
124
188
  name: "Composite",
@@ -147,6 +211,20 @@ const WebPubSubGenerateClientTokenExceptionHeaders = {
147
211
  }
148
212
  }
149
213
  };
214
+ const WebPubSubRemoveConnectionsFromGroupsExceptionHeaders = {
215
+ type: {
216
+ name: "Composite",
217
+ className: "WebPubSubRemoveConnectionsFromGroupsExceptionHeaders",
218
+ modelProperties: {
219
+ errorCode: {
220
+ serializedName: "x-ms-error-code",
221
+ type: {
222
+ name: "String"
223
+ }
224
+ }
225
+ }
226
+ }
227
+ };
150
228
  const WebPubSubSendToAllExceptionHeaders = {
151
229
  type: {
152
230
  name: "Composite",
@@ -416,11 +494,15 @@ const WebPubSubAddUserToGroupExceptionHeaders = {
416
494
 
417
495
  var Mappers = /*#__PURE__*/Object.freeze({
418
496
  __proto__: null,
497
+ AddToGroupsRequest: AddToGroupsRequest,
419
498
  ErrorDetail: ErrorDetail,
420
499
  InnerError: InnerError,
421
500
  ClientTokenResponse: ClientTokenResponse,
501
+ RemoveFromGroupsRequest: RemoveFromGroupsRequest,
502
+ WebPubSubAddConnectionsToGroupsExceptionHeaders: WebPubSubAddConnectionsToGroupsExceptionHeaders,
422
503
  WebPubSubCloseAllConnectionsExceptionHeaders: WebPubSubCloseAllConnectionsExceptionHeaders,
423
504
  WebPubSubGenerateClientTokenExceptionHeaders: WebPubSubGenerateClientTokenExceptionHeaders,
505
+ WebPubSubRemoveConnectionsFromGroupsExceptionHeaders: WebPubSubRemoveConnectionsFromGroupsExceptionHeaders,
424
506
  WebPubSubSendToAllExceptionHeaders: WebPubSubSendToAllExceptionHeaders,
425
507
  WebPubSubCloseConnectionExceptionHeaders: WebPubSubCloseConnectionExceptionHeaders,
426
508
  WebPubSubConnectionExistsExceptionHeaders: WebPubSubConnectionExistsExceptionHeaders,
@@ -452,7 +534,7 @@ var Mappers = /*#__PURE__*/Object.freeze({
452
534
  const endpoint = {
453
535
  parameterPath: "endpoint",
454
536
  mapper: {
455
- serializedName: "Endpoint",
537
+ serializedName: "endpoint",
456
538
  required: true,
457
539
  type: {
458
540
  name: "String"
@@ -463,7 +545,7 @@ const endpoint = {
463
545
  const apiVersion = {
464
546
  parameterPath: "apiVersion",
465
547
  mapper: {
466
- defaultValue: "2022-11-01",
548
+ defaultValue: "2023-07-01",
467
549
  isConstant: true,
468
550
  serializedName: "api-version",
469
551
  type: {
@@ -471,6 +553,21 @@ const apiVersion = {
471
553
  }
472
554
  }
473
555
  };
556
+ const contentType = {
557
+ parameterPath: ["options", "contentType"],
558
+ mapper: {
559
+ defaultValue: "application/json",
560
+ isConstant: true,
561
+ serializedName: "Content-Type",
562
+ type: {
563
+ name: "String"
564
+ }
565
+ }
566
+ };
567
+ const groupsToAdd = {
568
+ parameterPath: "groupsToAdd",
569
+ mapper: AddToGroupsRequest
570
+ };
474
571
  const accept = {
475
572
  parameterPath: "accept",
476
573
  mapper: {
@@ -582,7 +679,11 @@ const groups = {
582
679
  },
583
680
  collectionFormat: "Multi"
584
681
  };
585
- const contentType = {
682
+ const groupsToRemove = {
683
+ parameterPath: "groupsToRemove",
684
+ mapper: RemoveFromGroupsRequest
685
+ };
686
+ const contentType1 = {
586
687
  parameterPath: "contentType",
587
688
  mapper: {
588
689
  serializedName: "Content-Type",
@@ -614,7 +715,7 @@ const accept2 = {
614
715
  }
615
716
  }
616
717
  };
617
- const contentType1 = {
718
+ const contentType2 = {
618
719
  parameterPath: "contentType",
619
720
  mapper: {
620
721
  defaultValue: "text/plain",
@@ -670,6 +771,19 @@ const filter = {
670
771
  }
671
772
  }
672
773
  };
774
+ const messageTtlSeconds = {
775
+ parameterPath: ["options", "messageTtlSeconds"],
776
+ mapper: {
777
+ constraints: {
778
+ InclusiveMaximum: 300,
779
+ InclusiveMinimum: 0
780
+ },
781
+ serializedName: "messageTtlSeconds",
782
+ type: {
783
+ name: "Number"
784
+ }
785
+ }
786
+ };
673
787
  const connectionId = {
674
788
  parameterPath: "connectionId",
675
789
  mapper: {
@@ -782,6 +896,16 @@ class WebPubSubImpl {
782
896
  constructor(client) {
783
897
  this.client = client;
784
898
  }
899
+ /**
900
+ * Add filtered connections to multiple groups.
901
+ * @param hub Target hub name, which should start with alphabetic characters and only contain
902
+ * alpha-numeric characters or underscore.
903
+ * @param groupsToAdd Target groups and connection filter.
904
+ * @param options The options parameters.
905
+ */
906
+ addConnectionsToGroups(hub, groupsToAdd, options) {
907
+ return this.client.sendOperationRequest({ hub, groupsToAdd, options }, addConnectionsToGroupsOperationSpec);
908
+ }
785
909
  /**
786
910
  * Close the connections in the hub.
787
911
  * @param hub Target hub name, which should start with alphabetic characters and only contain
@@ -800,6 +924,16 @@ class WebPubSubImpl {
800
924
  generateClientToken(hub, options) {
801
925
  return this.client.sendOperationRequest({ hub, options }, generateClientTokenOperationSpec);
802
926
  }
927
+ /**
928
+ * Remove filtered connections from multiple groups.
929
+ * @param hub Target hub name, which should start with alphabetic characters and only contain
930
+ * alpha-numeric characters or underscore.
931
+ * @param groupsToRemove Target groups and connection filter.
932
+ * @param options The options parameters.
933
+ */
934
+ removeConnectionsFromGroups(hub, groupsToRemove, options) {
935
+ return this.client.sendOperationRequest({ hub, groupsToRemove, options }, removeConnectionsFromGroupsOperationSpec);
936
+ }
803
937
  /**
804
938
  * Broadcast content inside request body to all the connected client connections.
805
939
  * @param args Includes all the parameters for this operation.
@@ -1106,6 +1240,23 @@ class WebPubSubImpl {
1106
1240
  }
1107
1241
  // Operation Specifications
1108
1242
  const serializer = coreClient__namespace.createSerializer(Mappers, /* isXml */ false);
1243
+ const addConnectionsToGroupsOperationSpec = {
1244
+ path: "/api/hubs/{hub}/:addToGroups",
1245
+ httpMethod: "POST",
1246
+ responses: {
1247
+ 200: {},
1248
+ default: {
1249
+ bodyMapper: ErrorDetail,
1250
+ headersMapper: WebPubSubAddConnectionsToGroupsExceptionHeaders
1251
+ }
1252
+ },
1253
+ requestBody: groupsToAdd,
1254
+ queryParameters: [apiVersion],
1255
+ urlParameters: [endpoint, hub],
1256
+ headerParameters: [contentType, accept],
1257
+ mediaType: "json",
1258
+ serializer
1259
+ };
1109
1260
  const closeAllConnectionsOperationSpec = {
1110
1261
  path: "/api/hubs/{hub}/:closeConnections",
1111
1262
  httpMethod: "POST",
@@ -1148,6 +1299,23 @@ const generateClientTokenOperationSpec = {
1148
1299
  headerParameters: [accept1],
1149
1300
  serializer
1150
1301
  };
1302
+ const removeConnectionsFromGroupsOperationSpec = {
1303
+ path: "/api/hubs/{hub}/:removeFromGroups",
1304
+ httpMethod: "POST",
1305
+ responses: {
1306
+ 200: {},
1307
+ default: {
1308
+ bodyMapper: ErrorDetail,
1309
+ headersMapper: WebPubSubRemoveConnectionsFromGroupsExceptionHeaders
1310
+ }
1311
+ },
1312
+ requestBody: groupsToRemove,
1313
+ queryParameters: [apiVersion],
1314
+ urlParameters: [endpoint, hub],
1315
+ headerParameters: [contentType, accept],
1316
+ mediaType: "json",
1317
+ serializer
1318
+ };
1151
1319
  const sendToAll$binaryOperationSpec = {
1152
1320
  path: "/api/hubs/{hub}/:send",
1153
1321
  httpMethod: "POST",
@@ -1162,10 +1330,11 @@ const sendToAll$binaryOperationSpec = {
1162
1330
  queryParameters: [
1163
1331
  apiVersion,
1164
1332
  excludedConnections,
1165
- filter
1333
+ filter,
1334
+ messageTtlSeconds
1166
1335
  ],
1167
1336
  urlParameters: [endpoint, hub],
1168
- headerParameters: [contentType, accept2],
1337
+ headerParameters: [contentType1, accept2],
1169
1338
  mediaType: "binary",
1170
1339
  serializer
1171
1340
  };
@@ -1183,10 +1352,11 @@ const sendToAll$textOperationSpec = {
1183
1352
  queryParameters: [
1184
1353
  apiVersion,
1185
1354
  excludedConnections,
1186
- filter
1355
+ filter,
1356
+ messageTtlSeconds
1187
1357
  ],
1188
1358
  urlParameters: [endpoint, hub],
1189
- headerParameters: [contentType1, accept3],
1359
+ headerParameters: [contentType2, accept3],
1190
1360
  mediaType: "text",
1191
1361
  serializer
1192
1362
  };
@@ -1230,9 +1400,9 @@ const sendToConnection$binaryOperationSpec = {
1230
1400
  }
1231
1401
  },
1232
1402
  requestBody: message,
1233
- queryParameters: [apiVersion],
1403
+ queryParameters: [apiVersion, messageTtlSeconds],
1234
1404
  urlParameters: [endpoint, hub, connectionId],
1235
- headerParameters: [contentType, accept2],
1405
+ headerParameters: [contentType1, accept2],
1236
1406
  mediaType: "binary",
1237
1407
  serializer
1238
1408
  };
@@ -1247,9 +1417,9 @@ const sendToConnection$textOperationSpec = {
1247
1417
  }
1248
1418
  },
1249
1419
  requestBody: message1,
1250
- queryParameters: [apiVersion],
1420
+ queryParameters: [apiVersion, messageTtlSeconds],
1251
1421
  urlParameters: [endpoint, hub, connectionId],
1252
- headerParameters: [contentType1, accept3],
1422
+ headerParameters: [contentType2, accept3],
1253
1423
  mediaType: "text",
1254
1424
  serializer
1255
1425
  };
@@ -1315,10 +1485,11 @@ const sendToGroup$binaryOperationSpec = {
1315
1485
  queryParameters: [
1316
1486
  apiVersion,
1317
1487
  excludedConnections,
1318
- filter
1488
+ filter,
1489
+ messageTtlSeconds
1319
1490
  ],
1320
1491
  urlParameters: [endpoint, hub, group],
1321
- headerParameters: [contentType, accept2],
1492
+ headerParameters: [contentType1, accept2],
1322
1493
  mediaType: "binary",
1323
1494
  serializer
1324
1495
  };
@@ -1336,10 +1507,11 @@ const sendToGroup$textOperationSpec = {
1336
1507
  queryParameters: [
1337
1508
  apiVersion,
1338
1509
  excludedConnections,
1339
- filter
1510
+ filter,
1511
+ messageTtlSeconds
1340
1512
  ],
1341
1513
  urlParameters: [endpoint, hub, group],
1342
- headerParameters: [contentType1, accept3],
1514
+ headerParameters: [contentType2, accept3],
1343
1515
  mediaType: "text",
1344
1516
  serializer
1345
1517
  };
@@ -1486,9 +1658,13 @@ const sendToUser$binaryOperationSpec = {
1486
1658
  }
1487
1659
  },
1488
1660
  requestBody: message,
1489
- queryParameters: [apiVersion, filter],
1661
+ queryParameters: [
1662
+ apiVersion,
1663
+ filter,
1664
+ messageTtlSeconds
1665
+ ],
1490
1666
  urlParameters: [endpoint, hub, userId1],
1491
- headerParameters: [contentType, accept2],
1667
+ headerParameters: [contentType1, accept2],
1492
1668
  mediaType: "binary",
1493
1669
  serializer
1494
1670
  };
@@ -1503,9 +1679,13 @@ const sendToUser$textOperationSpec = {
1503
1679
  }
1504
1680
  },
1505
1681
  requestBody: message1,
1506
- queryParameters: [apiVersion, filter],
1682
+ queryParameters: [
1683
+ apiVersion,
1684
+ filter,
1685
+ messageTtlSeconds
1686
+ ],
1507
1687
  urlParameters: [endpoint, hub, userId1],
1508
- headerParameters: [contentType1, accept3],
1688
+ headerParameters: [contentType2, accept3],
1509
1689
  mediaType: "text",
1510
1690
  serializer
1511
1691
  };
@@ -1591,18 +1771,18 @@ class GeneratedClient extends coreClient__namespace.ServiceClient {
1591
1771
  const defaults = {
1592
1772
  requestContentType: "application/json; charset=utf-8"
1593
1773
  };
1594
- const packageDetails = `azsdk-js-web-pubsub/1.1.0`;
1774
+ const packageDetails = `azsdk-js-web-pubsub/1.1.3`;
1595
1775
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
1596
1776
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
1597
1777
  : `${packageDetails}`;
1598
1778
  const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
1599
1779
  userAgentPrefix
1600
- }, baseUri: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "{Endpoint}" });
1780
+ }, endpoint: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "{endpoint}" });
1601
1781
  super(optionsWithDefaults);
1602
1782
  // Parameter assignments
1603
1783
  this.endpoint = endpoint;
1604
1784
  // Assigning values to Constant parameters
1605
- this.apiVersion = options.apiVersion || "2022-11-01";
1785
+ this.apiVersion = options.apiVersion || "2023-07-01";
1606
1786
  this.healthApi = new HealthApiImpl(this);
1607
1787
  this.webPubSub = new WebPubSubImpl(this);
1608
1788
  this.addCustomApiVersionPolicy(options.apiVersion);
@@ -1894,7 +2074,7 @@ class WebPubSubServiceClient {
1894
2074
  /**
1895
2075
  * The Web PubSub API version being used by this client
1896
2076
  */
1897
- this.apiVersion = "2022-11-01";
2077
+ this.apiVersion = "2023-07-01";
1898
2078
  // unpack constructor arguments
1899
2079
  if (typeof credsOrHubName === "object") {
1900
2080
  this.endpoint = endpointOrConnectionString;
@@ -2039,6 +2219,34 @@ class WebPubSubServiceClient {
2039
2219
  return this.client.webPubSub.removeConnectionFromAllGroups(this.hubName, connectionId, updatedOptions);
2040
2220
  });
2041
2221
  }
2222
+ /**
2223
+ * Add filtered connections to multiple groups
2224
+ * @param groups - A list of groups which target connections will be added into
2225
+ * @param filter - An OData filter which target connections satisfy
2226
+ * @param options - Additional options
2227
+ */
2228
+ async addConnectionsToGroups(groups, filter, options = {}) {
2229
+ return tracingClient.withSpan("WebPubSubServiceClient.addConnectionsToGroups", options, (updatedOptions) => {
2230
+ return this.client.webPubSub.addConnectionsToGroups(this.hubName, {
2231
+ groups: groups,
2232
+ filter: filter,
2233
+ }, updatedOptions);
2234
+ });
2235
+ }
2236
+ /**
2237
+ * Remove filtered connections from multiple groups
2238
+ * @param groups - A list of groups which target connections will be removed from
2239
+ * @param filter - An OData filter which target connections satisfy
2240
+ * @param options - Additional options
2241
+ */
2242
+ async removeConnectionsFromGroups(groups, filter, options = {}) {
2243
+ return tracingClient.withSpan("WebPubSubServiceClient.removeConnectionsFromGroups", options, (updatedOptions) => {
2244
+ return this.client.webPubSub.removeConnectionsFromGroups(this.hubName, {
2245
+ groups: groups,
2246
+ filter: filter,
2247
+ }, updatedOptions);
2248
+ });
2249
+ }
2042
2250
  /**
2043
2251
  * Check if a particular group exists (i.e. has active connections).
2044
2252
  *