@azure/web-pubsub 1.0.0-beta.2 → 1.0.1-alpha.20211215.2
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +40 -0
- package/README.md +118 -31
- package/dist/index.js +1315 -567
- package/dist/index.js.map +1 -1
- package/dist-esm/samples-dev/broadcasting.js +16 -16
- package/dist-esm/samples-dev/broadcasting.js.map +1 -1
- package/dist-esm/samples-dev/directMessage.js +9 -9
- package/dist-esm/samples-dev/directMessage.js.map +1 -1
- package/dist-esm/samples-dev/managingGroups.js +11 -12
- package/dist-esm/samples-dev/managingGroups.js.map +1 -1
- package/dist-esm/src/generated/generatedClient.js +23 -0
- package/dist-esm/src/generated/generatedClient.js.map +1 -0
- package/dist-esm/src/generated/generatedClientContext.js +41 -0
- package/dist-esm/src/generated/generatedClientContext.js.map +1 -0
- package/dist-esm/src/generated/index.js +10 -2
- package/dist-esm/src/generated/index.js.map +1 -1
- package/dist-esm/src/generated/models/index.js +13 -1
- package/dist-esm/src/generated/models/index.js.map +1 -1
- package/dist-esm/src/generated/models/mappers.js +368 -0
- package/dist-esm/src/generated/models/mappers.js.map +1 -0
- package/dist-esm/src/generated/models/parameters.js +124 -43
- package/dist-esm/src/generated/models/parameters.js.map +1 -1
- package/dist-esm/src/generated/operations/healthApi.js +16 -11
- package/dist-esm/src/generated/operations/healthApi.js.map +1 -1
- package/dist-esm/src/generated/operations/index.js +7 -0
- package/dist-esm/src/generated/operations/index.js.map +1 -1
- package/dist-esm/src/generated/operations/webPubSub.js +341 -175
- package/dist-esm/src/generated/operations/webPubSub.js.map +1 -1
- package/dist-esm/src/generated/operationsInterfaces/healthApi.js +9 -0
- package/dist-esm/src/generated/operationsInterfaces/healthApi.js.map +1 -0
- package/dist-esm/src/generated/operationsInterfaces/index.js +10 -0
- package/dist-esm/src/generated/operationsInterfaces/index.js.map +1 -0
- package/dist-esm/src/generated/operationsInterfaces/webPubSub.js +9 -0
- package/dist-esm/src/generated/operationsInterfaces/webPubSub.js.map +1 -0
- package/dist-esm/src/groupClient.js +74 -92
- package/dist-esm/src/groupClient.js.map +1 -1
- package/dist-esm/src/hubClient.js +280 -196
- package/dist-esm/src/hubClient.js.map +1 -1
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/logger.js +1 -1
- package/dist-esm/src/logger.js.map +1 -1
- package/dist-esm/src/parseConnectionString.js +3 -1
- package/dist-esm/src/parseConnectionString.js.map +1 -1
- package/dist-esm/src/reverseProxyPolicy.js +21 -0
- package/dist-esm/src/reverseProxyPolicy.js.map +1 -0
- package/dist-esm/src/utils.js +8 -6
- package/dist-esm/src/utils.js.map +1 -1
- package/dist-esm/src/webPubSubCredentialPolicy.js +18 -18
- package/dist-esm/src/webPubSubCredentialPolicy.js.map +1 -1
- package/dist-esm/test/conn.spec.js +7 -8
- package/dist-esm/test/conn.spec.js.map +1 -1
- package/dist-esm/test/groups.spec.js +39 -38
- package/dist-esm/test/groups.spec.js.map +1 -1
- package/dist-esm/test/hubs.spec.js +95 -49
- package/dist-esm/test/hubs.spec.js.map +1 -1
- package/dist-esm/test/integration.spec.js +128 -0
- package/dist-esm/test/integration.spec.js.map +1 -0
- package/dist-esm/test/testEnv.js +5 -1
- package/dist-esm/test/testEnv.js.map +1 -1
- package/package.json +37 -36
- package/types/web-pubsub.d.ts +186 -138
- package/dist-esm/src/generated/azureWebPubSubServiceRestAPI.js +0 -15
- package/dist-esm/src/generated/azureWebPubSubServiceRestAPI.js.map +0 -1
- package/dist-esm/src/generated/azureWebPubSubServiceRestAPIContext.js +0 -34
- package/dist-esm/src/generated/azureWebPubSubServiceRestAPIContext.js.map +0 -1
- package/dist-esm/src/normalizeOptions.js +0 -8
- package/dist-esm/src/normalizeOptions.js.map +0 -1
package/dist/index.js
CHANGED
@@ -5,17 +5,419 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
6
6
|
|
7
7
|
var coreAuth = require('@azure/core-auth');
|
8
|
-
var
|
9
|
-
var
|
8
|
+
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
9
|
+
var coreClient = require('@azure/core-client');
|
10
10
|
var coreTracing = require('@azure/core-tracing');
|
11
11
|
var jwt = _interopDefault(require('jsonwebtoken'));
|
12
12
|
var logger$1 = require('@azure/logger');
|
13
13
|
var url = require('url');
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
/*
|
16
|
+
* Copyright (c) Microsoft Corporation.
|
17
|
+
* Licensed under the MIT License.
|
18
|
+
*
|
19
|
+
* Code generated by Microsoft (R) AutoRest Code Generator.
|
20
|
+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
21
|
+
*/
|
22
|
+
const ClientTokenResponse = {
|
23
|
+
type: {
|
24
|
+
name: "Composite",
|
25
|
+
className: "ClientTokenResponse",
|
26
|
+
modelProperties: {
|
27
|
+
token: {
|
28
|
+
serializedName: "token",
|
29
|
+
type: {
|
30
|
+
name: "String"
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
};
|
36
|
+
const ErrorDetail = {
|
37
|
+
type: {
|
38
|
+
name: "Composite",
|
39
|
+
className: "ErrorDetail",
|
40
|
+
modelProperties: {
|
41
|
+
code: {
|
42
|
+
serializedName: "code",
|
43
|
+
type: {
|
44
|
+
name: "String"
|
45
|
+
}
|
46
|
+
},
|
47
|
+
message: {
|
48
|
+
serializedName: "message",
|
49
|
+
type: {
|
50
|
+
name: "String"
|
51
|
+
}
|
52
|
+
},
|
53
|
+
target: {
|
54
|
+
serializedName: "target",
|
55
|
+
type: {
|
56
|
+
name: "String"
|
57
|
+
}
|
58
|
+
},
|
59
|
+
details: {
|
60
|
+
serializedName: "details",
|
61
|
+
type: {
|
62
|
+
name: "Sequence",
|
63
|
+
element: {
|
64
|
+
type: {
|
65
|
+
name: "Composite",
|
66
|
+
className: "ErrorDetail"
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
},
|
71
|
+
inner: {
|
72
|
+
serializedName: "inner",
|
73
|
+
type: {
|
74
|
+
name: "Composite",
|
75
|
+
className: "InnerError"
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
};
|
81
|
+
const InnerError = {
|
82
|
+
type: {
|
83
|
+
name: "Composite",
|
84
|
+
className: "InnerError",
|
85
|
+
modelProperties: {
|
86
|
+
code: {
|
87
|
+
serializedName: "code",
|
88
|
+
type: {
|
89
|
+
name: "String"
|
90
|
+
}
|
91
|
+
},
|
92
|
+
inner: {
|
93
|
+
serializedName: "inner",
|
94
|
+
type: {
|
95
|
+
name: "Composite",
|
96
|
+
className: "InnerError"
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
101
|
+
};
|
102
|
+
const WebPubSubGenerateClientTokenExceptionHeaders = {
|
103
|
+
type: {
|
104
|
+
name: "Composite",
|
105
|
+
className: "WebPubSubGenerateClientTokenExceptionHeaders",
|
106
|
+
modelProperties: {
|
107
|
+
errorCode: {
|
108
|
+
serializedName: "x-ms-error-code",
|
109
|
+
type: {
|
110
|
+
name: "String"
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}
|
114
|
+
}
|
115
|
+
};
|
116
|
+
const WebPubSubCloseAllConnectionsExceptionHeaders = {
|
117
|
+
type: {
|
118
|
+
name: "Composite",
|
119
|
+
className: "WebPubSubCloseAllConnectionsExceptionHeaders",
|
120
|
+
modelProperties: {
|
121
|
+
errorCode: {
|
122
|
+
serializedName: "x-ms-error-code",
|
123
|
+
type: {
|
124
|
+
name: "String"
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}
|
129
|
+
};
|
130
|
+
const WebPubSubSendToAllExceptionHeaders = {
|
131
|
+
type: {
|
132
|
+
name: "Composite",
|
133
|
+
className: "WebPubSubSendToAllExceptionHeaders",
|
134
|
+
modelProperties: {
|
135
|
+
errorCode: {
|
136
|
+
serializedName: "x-ms-error-code",
|
137
|
+
type: {
|
138
|
+
name: "String"
|
139
|
+
}
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
};
|
144
|
+
const WebPubSubConnectionExistsExceptionHeaders = {
|
145
|
+
type: {
|
146
|
+
name: "Composite",
|
147
|
+
className: "WebPubSubConnectionExistsExceptionHeaders",
|
148
|
+
modelProperties: {
|
149
|
+
errorCode: {
|
150
|
+
serializedName: "x-ms-error-code",
|
151
|
+
type: {
|
152
|
+
name: "String"
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
156
|
+
}
|
157
|
+
};
|
158
|
+
const WebPubSubCloseConnectionExceptionHeaders = {
|
159
|
+
type: {
|
160
|
+
name: "Composite",
|
161
|
+
className: "WebPubSubCloseConnectionExceptionHeaders",
|
162
|
+
modelProperties: {
|
163
|
+
errorCode: {
|
164
|
+
serializedName: "x-ms-error-code",
|
165
|
+
type: {
|
166
|
+
name: "String"
|
167
|
+
}
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
};
|
172
|
+
const WebPubSubSendToConnectionExceptionHeaders = {
|
173
|
+
type: {
|
174
|
+
name: "Composite",
|
175
|
+
className: "WebPubSubSendToConnectionExceptionHeaders",
|
176
|
+
modelProperties: {
|
177
|
+
errorCode: {
|
178
|
+
serializedName: "x-ms-error-code",
|
179
|
+
type: {
|
180
|
+
name: "String"
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}
|
184
|
+
}
|
185
|
+
};
|
186
|
+
const WebPubSubGroupExistsExceptionHeaders = {
|
187
|
+
type: {
|
188
|
+
name: "Composite",
|
189
|
+
className: "WebPubSubGroupExistsExceptionHeaders",
|
190
|
+
modelProperties: {
|
191
|
+
errorCode: {
|
192
|
+
serializedName: "x-ms-error-code",
|
193
|
+
type: {
|
194
|
+
name: "String"
|
195
|
+
}
|
196
|
+
}
|
197
|
+
}
|
198
|
+
}
|
199
|
+
};
|
200
|
+
const WebPubSubCloseGroupConnectionsExceptionHeaders = {
|
201
|
+
type: {
|
202
|
+
name: "Composite",
|
203
|
+
className: "WebPubSubCloseGroupConnectionsExceptionHeaders",
|
204
|
+
modelProperties: {
|
205
|
+
errorCode: {
|
206
|
+
serializedName: "x-ms-error-code",
|
207
|
+
type: {
|
208
|
+
name: "String"
|
209
|
+
}
|
210
|
+
}
|
211
|
+
}
|
212
|
+
}
|
213
|
+
};
|
214
|
+
const WebPubSubSendToGroupExceptionHeaders = {
|
215
|
+
type: {
|
216
|
+
name: "Composite",
|
217
|
+
className: "WebPubSubSendToGroupExceptionHeaders",
|
218
|
+
modelProperties: {
|
219
|
+
errorCode: {
|
220
|
+
serializedName: "x-ms-error-code",
|
221
|
+
type: {
|
222
|
+
name: "String"
|
223
|
+
}
|
224
|
+
}
|
225
|
+
}
|
226
|
+
}
|
227
|
+
};
|
228
|
+
const WebPubSubAddConnectionToGroupExceptionHeaders = {
|
229
|
+
type: {
|
230
|
+
name: "Composite",
|
231
|
+
className: "WebPubSubAddConnectionToGroupExceptionHeaders",
|
232
|
+
modelProperties: {
|
233
|
+
errorCode: {
|
234
|
+
serializedName: "x-ms-error-code",
|
235
|
+
type: {
|
236
|
+
name: "String"
|
237
|
+
}
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|
241
|
+
};
|
242
|
+
const WebPubSubRemoveConnectionFromGroupExceptionHeaders = {
|
243
|
+
type: {
|
244
|
+
name: "Composite",
|
245
|
+
className: "WebPubSubRemoveConnectionFromGroupExceptionHeaders",
|
246
|
+
modelProperties: {
|
247
|
+
errorCode: {
|
248
|
+
serializedName: "x-ms-error-code",
|
249
|
+
type: {
|
250
|
+
name: "String"
|
251
|
+
}
|
252
|
+
}
|
253
|
+
}
|
254
|
+
}
|
255
|
+
};
|
256
|
+
const WebPubSubUserExistsExceptionHeaders = {
|
257
|
+
type: {
|
258
|
+
name: "Composite",
|
259
|
+
className: "WebPubSubUserExistsExceptionHeaders",
|
260
|
+
modelProperties: {
|
261
|
+
errorCode: {
|
262
|
+
serializedName: "x-ms-error-code",
|
263
|
+
type: {
|
264
|
+
name: "String"
|
265
|
+
}
|
266
|
+
}
|
267
|
+
}
|
268
|
+
}
|
269
|
+
};
|
270
|
+
const WebPubSubCloseUserConnectionsExceptionHeaders = {
|
271
|
+
type: {
|
272
|
+
name: "Composite",
|
273
|
+
className: "WebPubSubCloseUserConnectionsExceptionHeaders",
|
274
|
+
modelProperties: {
|
275
|
+
errorCode: {
|
276
|
+
serializedName: "x-ms-error-code",
|
277
|
+
type: {
|
278
|
+
name: "String"
|
279
|
+
}
|
280
|
+
}
|
281
|
+
}
|
282
|
+
}
|
283
|
+
};
|
284
|
+
const WebPubSubSendToUserExceptionHeaders = {
|
285
|
+
type: {
|
286
|
+
name: "Composite",
|
287
|
+
className: "WebPubSubSendToUserExceptionHeaders",
|
288
|
+
modelProperties: {
|
289
|
+
errorCode: {
|
290
|
+
serializedName: "x-ms-error-code",
|
291
|
+
type: {
|
292
|
+
name: "String"
|
293
|
+
}
|
294
|
+
}
|
295
|
+
}
|
296
|
+
}
|
297
|
+
};
|
298
|
+
const WebPubSubAddUserToGroupExceptionHeaders = {
|
299
|
+
type: {
|
300
|
+
name: "Composite",
|
301
|
+
className: "WebPubSubAddUserToGroupExceptionHeaders",
|
302
|
+
modelProperties: {
|
303
|
+
errorCode: {
|
304
|
+
serializedName: "x-ms-error-code",
|
305
|
+
type: {
|
306
|
+
name: "String"
|
307
|
+
}
|
308
|
+
}
|
309
|
+
}
|
310
|
+
}
|
311
|
+
};
|
312
|
+
const WebPubSubRemoveUserFromGroupExceptionHeaders = {
|
313
|
+
type: {
|
314
|
+
name: "Composite",
|
315
|
+
className: "WebPubSubRemoveUserFromGroupExceptionHeaders",
|
316
|
+
modelProperties: {
|
317
|
+
errorCode: {
|
318
|
+
serializedName: "x-ms-error-code",
|
319
|
+
type: {
|
320
|
+
name: "String"
|
321
|
+
}
|
322
|
+
}
|
323
|
+
}
|
324
|
+
}
|
325
|
+
};
|
326
|
+
const WebPubSubRemoveUserFromAllGroupsExceptionHeaders = {
|
327
|
+
type: {
|
328
|
+
name: "Composite",
|
329
|
+
className: "WebPubSubRemoveUserFromAllGroupsExceptionHeaders",
|
330
|
+
modelProperties: {
|
331
|
+
errorCode: {
|
332
|
+
serializedName: "x-ms-error-code",
|
333
|
+
type: {
|
334
|
+
name: "String"
|
335
|
+
}
|
336
|
+
}
|
337
|
+
}
|
338
|
+
}
|
339
|
+
};
|
340
|
+
const WebPubSubGrantPermissionExceptionHeaders = {
|
341
|
+
type: {
|
342
|
+
name: "Composite",
|
343
|
+
className: "WebPubSubGrantPermissionExceptionHeaders",
|
344
|
+
modelProperties: {
|
345
|
+
errorCode: {
|
346
|
+
serializedName: "x-ms-error-code",
|
347
|
+
type: {
|
348
|
+
name: "String"
|
349
|
+
}
|
350
|
+
}
|
351
|
+
}
|
352
|
+
}
|
353
|
+
};
|
354
|
+
const WebPubSubRevokePermissionExceptionHeaders = {
|
355
|
+
type: {
|
356
|
+
name: "Composite",
|
357
|
+
className: "WebPubSubRevokePermissionExceptionHeaders",
|
358
|
+
modelProperties: {
|
359
|
+
errorCode: {
|
360
|
+
serializedName: "x-ms-error-code",
|
361
|
+
type: {
|
362
|
+
name: "String"
|
363
|
+
}
|
364
|
+
}
|
365
|
+
}
|
366
|
+
}
|
367
|
+
};
|
368
|
+
const WebPubSubCheckPermissionExceptionHeaders = {
|
369
|
+
type: {
|
370
|
+
name: "Composite",
|
371
|
+
className: "WebPubSubCheckPermissionExceptionHeaders",
|
372
|
+
modelProperties: {
|
373
|
+
errorCode: {
|
374
|
+
serializedName: "x-ms-error-code",
|
375
|
+
type: {
|
376
|
+
name: "String"
|
377
|
+
}
|
378
|
+
}
|
379
|
+
}
|
380
|
+
}
|
381
|
+
};
|
382
|
+
|
383
|
+
var Mappers = /*#__PURE__*/Object.freeze({
|
384
|
+
__proto__: null,
|
385
|
+
ClientTokenResponse: ClientTokenResponse,
|
386
|
+
ErrorDetail: ErrorDetail,
|
387
|
+
InnerError: InnerError,
|
388
|
+
WebPubSubGenerateClientTokenExceptionHeaders: WebPubSubGenerateClientTokenExceptionHeaders,
|
389
|
+
WebPubSubCloseAllConnectionsExceptionHeaders: WebPubSubCloseAllConnectionsExceptionHeaders,
|
390
|
+
WebPubSubSendToAllExceptionHeaders: WebPubSubSendToAllExceptionHeaders,
|
391
|
+
WebPubSubConnectionExistsExceptionHeaders: WebPubSubConnectionExistsExceptionHeaders,
|
392
|
+
WebPubSubCloseConnectionExceptionHeaders: WebPubSubCloseConnectionExceptionHeaders,
|
393
|
+
WebPubSubSendToConnectionExceptionHeaders: WebPubSubSendToConnectionExceptionHeaders,
|
394
|
+
WebPubSubGroupExistsExceptionHeaders: WebPubSubGroupExistsExceptionHeaders,
|
395
|
+
WebPubSubCloseGroupConnectionsExceptionHeaders: WebPubSubCloseGroupConnectionsExceptionHeaders,
|
396
|
+
WebPubSubSendToGroupExceptionHeaders: WebPubSubSendToGroupExceptionHeaders,
|
397
|
+
WebPubSubAddConnectionToGroupExceptionHeaders: WebPubSubAddConnectionToGroupExceptionHeaders,
|
398
|
+
WebPubSubRemoveConnectionFromGroupExceptionHeaders: WebPubSubRemoveConnectionFromGroupExceptionHeaders,
|
399
|
+
WebPubSubUserExistsExceptionHeaders: WebPubSubUserExistsExceptionHeaders,
|
400
|
+
WebPubSubCloseUserConnectionsExceptionHeaders: WebPubSubCloseUserConnectionsExceptionHeaders,
|
401
|
+
WebPubSubSendToUserExceptionHeaders: WebPubSubSendToUserExceptionHeaders,
|
402
|
+
WebPubSubAddUserToGroupExceptionHeaders: WebPubSubAddUserToGroupExceptionHeaders,
|
403
|
+
WebPubSubRemoveUserFromGroupExceptionHeaders: WebPubSubRemoveUserFromGroupExceptionHeaders,
|
404
|
+
WebPubSubRemoveUserFromAllGroupsExceptionHeaders: WebPubSubRemoveUserFromAllGroupsExceptionHeaders,
|
405
|
+
WebPubSubGrantPermissionExceptionHeaders: WebPubSubGrantPermissionExceptionHeaders,
|
406
|
+
WebPubSubRevokePermissionExceptionHeaders: WebPubSubRevokePermissionExceptionHeaders,
|
407
|
+
WebPubSubCheckPermissionExceptionHeaders: WebPubSubCheckPermissionExceptionHeaders
|
408
|
+
});
|
409
|
+
|
410
|
+
/*
|
411
|
+
* Copyright (c) Microsoft Corporation.
|
412
|
+
* Licensed under the MIT License.
|
413
|
+
*
|
414
|
+
* Code generated by Microsoft (R) AutoRest Code Generator.
|
415
|
+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
416
|
+
*/
|
417
|
+
const endpoint = {
|
418
|
+
parameterPath: "endpoint",
|
17
419
|
mapper: {
|
18
|
-
serializedName: "
|
420
|
+
serializedName: "Endpoint",
|
19
421
|
required: true,
|
20
422
|
type: {
|
21
423
|
name: "String"
|
@@ -26,7 +428,7 @@ const $host = {
|
|
26
428
|
const apiVersion = {
|
27
429
|
parameterPath: "apiVersion",
|
28
430
|
mapper: {
|
29
|
-
defaultValue: "
|
431
|
+
defaultValue: "2021-10-01",
|
30
432
|
isConstant: true,
|
31
433
|
serializedName: "api-version",
|
32
434
|
type: {
|
@@ -34,6 +436,88 @@ const apiVersion = {
|
|
34
436
|
}
|
35
437
|
}
|
36
438
|
};
|
439
|
+
const accept = {
|
440
|
+
parameterPath: "accept",
|
441
|
+
mapper: {
|
442
|
+
defaultValue: "application/json, text/json",
|
443
|
+
isConstant: true,
|
444
|
+
serializedName: "Accept",
|
445
|
+
type: {
|
446
|
+
name: "String"
|
447
|
+
}
|
448
|
+
}
|
449
|
+
};
|
450
|
+
const hub = {
|
451
|
+
parameterPath: "hub",
|
452
|
+
mapper: {
|
453
|
+
constraints: {
|
454
|
+
Pattern: new RegExp("^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$")
|
455
|
+
},
|
456
|
+
serializedName: "hub",
|
457
|
+
required: true,
|
458
|
+
type: {
|
459
|
+
name: "String"
|
460
|
+
}
|
461
|
+
}
|
462
|
+
};
|
463
|
+
const userId = {
|
464
|
+
parameterPath: ["options", "userId"],
|
465
|
+
mapper: {
|
466
|
+
serializedName: "userId",
|
467
|
+
type: {
|
468
|
+
name: "String"
|
469
|
+
}
|
470
|
+
}
|
471
|
+
};
|
472
|
+
const roles = {
|
473
|
+
parameterPath: ["options", "roles"],
|
474
|
+
mapper: {
|
475
|
+
serializedName: "role",
|
476
|
+
type: {
|
477
|
+
name: "Sequence",
|
478
|
+
element: {
|
479
|
+
type: {
|
480
|
+
name: "String"
|
481
|
+
}
|
482
|
+
}
|
483
|
+
}
|
484
|
+
},
|
485
|
+
collectionFormat: "Multi"
|
486
|
+
};
|
487
|
+
const expirationTimeInMinutes = {
|
488
|
+
parameterPath: ["options", "expirationTimeInMinutes"],
|
489
|
+
mapper: {
|
490
|
+
defaultValue: 60,
|
491
|
+
serializedName: "minutesToExpire",
|
492
|
+
type: {
|
493
|
+
name: "Number"
|
494
|
+
}
|
495
|
+
}
|
496
|
+
};
|
497
|
+
const excluded = {
|
498
|
+
parameterPath: ["options", "excluded"],
|
499
|
+
mapper: {
|
500
|
+
serializedName: "excluded",
|
501
|
+
type: {
|
502
|
+
name: "Sequence",
|
503
|
+
element: {
|
504
|
+
type: {
|
505
|
+
name: "String"
|
506
|
+
}
|
507
|
+
}
|
508
|
+
}
|
509
|
+
},
|
510
|
+
collectionFormat: "Multi"
|
511
|
+
};
|
512
|
+
const reason = {
|
513
|
+
parameterPath: ["options", "reason"],
|
514
|
+
mapper: {
|
515
|
+
serializedName: "reason",
|
516
|
+
type: {
|
517
|
+
name: "String"
|
518
|
+
}
|
519
|
+
}
|
520
|
+
};
|
37
521
|
const contentType = {
|
38
522
|
parameterPath: "contentType",
|
39
523
|
mapper: {
|
@@ -55,6 +539,17 @@ const message = {
|
|
55
539
|
}
|
56
540
|
}
|
57
541
|
};
|
542
|
+
const accept1 = {
|
543
|
+
parameterPath: "accept",
|
544
|
+
mapper: {
|
545
|
+
defaultValue: "application/json, text/json",
|
546
|
+
isConstant: true,
|
547
|
+
serializedName: "Accept",
|
548
|
+
type: {
|
549
|
+
name: "String"
|
550
|
+
}
|
551
|
+
}
|
552
|
+
};
|
58
553
|
const contentType1 = {
|
59
554
|
parameterPath: "contentType",
|
60
555
|
mapper: {
|
@@ -76,18 +571,19 @@ const message1 = {
|
|
76
571
|
}
|
77
572
|
}
|
78
573
|
};
|
79
|
-
const
|
80
|
-
parameterPath: "
|
574
|
+
const accept2 = {
|
575
|
+
parameterPath: "accept",
|
81
576
|
mapper: {
|
82
|
-
|
83
|
-
|
577
|
+
defaultValue: "application/json, text/json",
|
578
|
+
isConstant: true,
|
579
|
+
serializedName: "Accept",
|
84
580
|
type: {
|
85
581
|
name: "String"
|
86
582
|
}
|
87
583
|
}
|
88
584
|
};
|
89
|
-
const
|
90
|
-
parameterPath: ["options", "
|
585
|
+
const excludedConnections = {
|
586
|
+
parameterPath: ["options", "excludedConnections"],
|
91
587
|
mapper: {
|
92
588
|
serializedName: "excluded",
|
93
589
|
type: {
|
@@ -99,11 +595,14 @@ const excluded = {
|
|
99
595
|
}
|
100
596
|
}
|
101
597
|
},
|
102
|
-
collectionFormat:
|
598
|
+
collectionFormat: "Multi"
|
103
599
|
};
|
104
600
|
const connectionId = {
|
105
601
|
parameterPath: "connectionId",
|
106
602
|
mapper: {
|
603
|
+
constraints: {
|
604
|
+
MinLength: 1
|
605
|
+
},
|
107
606
|
serializedName: "connectionId",
|
108
607
|
required: true,
|
109
608
|
type: {
|
@@ -111,18 +610,13 @@ const connectionId = {
|
|
111
610
|
}
|
112
611
|
}
|
113
612
|
};
|
114
|
-
const reason = {
|
115
|
-
parameterPath: ["options", "reason"],
|
116
|
-
mapper: {
|
117
|
-
serializedName: "reason",
|
118
|
-
type: {
|
119
|
-
name: "String"
|
120
|
-
}
|
121
|
-
}
|
122
|
-
};
|
123
613
|
const group = {
|
124
614
|
parameterPath: "group",
|
125
615
|
mapper: {
|
616
|
+
constraints: {
|
617
|
+
MaxLength: 1024,
|
618
|
+
MinLength: 1
|
619
|
+
},
|
126
620
|
serializedName: "group",
|
127
621
|
required: true,
|
128
622
|
type: {
|
@@ -130,9 +624,12 @@ const group = {
|
|
130
624
|
}
|
131
625
|
}
|
132
626
|
};
|
133
|
-
const
|
627
|
+
const userId1 = {
|
134
628
|
parameterPath: "userId",
|
135
629
|
mapper: {
|
630
|
+
constraints: {
|
631
|
+
MinLength: 1
|
632
|
+
},
|
136
633
|
serializedName: "userId",
|
137
634
|
required: true,
|
138
635
|
type: {
|
@@ -159,29 +656,16 @@ const targetName = {
|
|
159
656
|
}
|
160
657
|
}
|
161
658
|
};
|
162
|
-
const permission1 = {
|
163
|
-
parameterPath: "permission",
|
164
|
-
mapper: {
|
165
|
-
serializedName: "permission",
|
166
|
-
required: true,
|
167
|
-
type: {
|
168
|
-
name: "String"
|
169
|
-
}
|
170
|
-
}
|
171
|
-
};
|
172
|
-
const permission2 = {
|
173
|
-
parameterPath: "permission",
|
174
|
-
mapper: {
|
175
|
-
serializedName: "permission",
|
176
|
-
required: true,
|
177
|
-
type: {
|
178
|
-
name: "String"
|
179
|
-
}
|
180
|
-
}
|
181
|
-
};
|
182
659
|
|
183
|
-
|
184
|
-
|
660
|
+
/*
|
661
|
+
* Copyright (c) Microsoft Corporation.
|
662
|
+
* Licensed under the MIT License.
|
663
|
+
*
|
664
|
+
* Code generated by Microsoft (R) AutoRest Code Generator.
|
665
|
+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
666
|
+
*/
|
667
|
+
/** Class containing HealthApi operations. */
|
668
|
+
class HealthApiImpl {
|
185
669
|
/**
|
186
670
|
* Initialize a new instance of the class HealthApi class.
|
187
671
|
* @param client Reference to the service client
|
@@ -193,26 +677,30 @@ class HealthApi {
|
|
193
677
|
* Get service health status.
|
194
678
|
* @param options The options parameters.
|
195
679
|
*/
|
196
|
-
|
197
|
-
|
198
|
-
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
199
|
-
};
|
200
|
-
return this.client.sendOperationRequest(operationArguments, getHealthStatusOperationSpec);
|
680
|
+
getServiceStatus(options) {
|
681
|
+
return this.client.sendOperationRequest({ options }, getServiceStatusOperationSpec);
|
201
682
|
}
|
202
683
|
}
|
203
684
|
// Operation Specifications
|
204
|
-
const serializer =
|
205
|
-
const
|
685
|
+
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
|
686
|
+
const getServiceStatusOperationSpec = {
|
206
687
|
path: "/api/health",
|
207
688
|
httpMethod: "HEAD",
|
208
689
|
responses: { 200: {}, default: {} },
|
209
690
|
queryParameters: [apiVersion],
|
210
|
-
urlParameters: [
|
691
|
+
urlParameters: [endpoint],
|
211
692
|
serializer
|
212
693
|
};
|
213
694
|
|
214
|
-
|
215
|
-
|
695
|
+
/*
|
696
|
+
* Copyright (c) Microsoft Corporation.
|
697
|
+
* Licensed under the MIT License.
|
698
|
+
*
|
699
|
+
* Code generated by Microsoft (R) AutoRest Code Generator.
|
700
|
+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
701
|
+
*/
|
702
|
+
/** Class containing WebPubSub operations. */
|
703
|
+
class WebPubSubImpl {
|
216
704
|
/**
|
217
705
|
* Initialize a new instance of the class WebPubSub class.
|
218
706
|
* @param client Reference to the service client
|
@@ -220,6 +708,24 @@ class WebPubSub {
|
|
220
708
|
constructor(client) {
|
221
709
|
this.client = client;
|
222
710
|
}
|
711
|
+
/**
|
712
|
+
* Generate token for the client to connect Azure Web PubSub service.
|
713
|
+
* @param hub Target hub name, which should start with alphabetic characters and only contain
|
714
|
+
* alpha-numeric characters or underscore.
|
715
|
+
* @param options The options parameters.
|
716
|
+
*/
|
717
|
+
generateClientToken(hub, options) {
|
718
|
+
return this.client.sendOperationRequest({ hub, options }, generateClientTokenOperationSpec);
|
719
|
+
}
|
720
|
+
/**
|
721
|
+
* Close the connections in the hub.
|
722
|
+
* @param hub Target hub name, which should start with alphabetic characters and only contain
|
723
|
+
* alpha-numeric characters or underscore.
|
724
|
+
* @param options The options parameters.
|
725
|
+
*/
|
726
|
+
closeAllConnections(hub, options) {
|
727
|
+
return this.client.sendOperationRequest({ hub, options }, closeAllConnectionsOperationSpec);
|
728
|
+
}
|
223
729
|
/**
|
224
730
|
* Broadcast content inside request body to all the connected client connections.
|
225
731
|
* @param args Includes all the parameters for this operation.
|
@@ -252,7 +758,7 @@ class WebPubSub {
|
|
252
758
|
else {
|
253
759
|
throw new TypeError(`"contentType" must be a valid value but instead was "${args[1]}".`);
|
254
760
|
}
|
255
|
-
operationArguments.options =
|
761
|
+
operationArguments.options = options || {};
|
256
762
|
return this.client.sendOperationRequest(operationArguments, operationSpec);
|
257
763
|
}
|
258
764
|
/**
|
@@ -263,12 +769,7 @@ class WebPubSub {
|
|
263
769
|
* @param options The options parameters.
|
264
770
|
*/
|
265
771
|
connectionExists(hub, connectionId, options) {
|
266
|
-
|
267
|
-
hub,
|
268
|
-
connectionId,
|
269
|
-
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
270
|
-
};
|
271
|
-
return this.client.sendOperationRequest(operationArguments, connectionExistsOperationSpec);
|
772
|
+
return this.client.sendOperationRequest({ hub, connectionId, options }, connectionExistsOperationSpec);
|
272
773
|
}
|
273
774
|
/**
|
274
775
|
* Close the client connection.
|
@@ -277,13 +778,8 @@ class WebPubSub {
|
|
277
778
|
* @param connectionId Target connection Id.
|
278
779
|
* @param options The options parameters.
|
279
780
|
*/
|
280
|
-
|
281
|
-
|
282
|
-
hub,
|
283
|
-
connectionId,
|
284
|
-
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
285
|
-
};
|
286
|
-
return this.client.sendOperationRequest(operationArguments, closeClientConnectionOperationSpec);
|
781
|
+
closeConnection(hub, connectionId, options) {
|
782
|
+
return this.client.sendOperationRequest({ hub, connectionId, options }, closeConnectionOperationSpec);
|
287
783
|
}
|
288
784
|
/**
|
289
785
|
* Send content inside request body to the specific connection.
|
@@ -319,7 +815,7 @@ class WebPubSub {
|
|
319
815
|
else {
|
320
816
|
throw new TypeError(`"contentType" must be a valid value but instead was "${args[2]}".`);
|
321
817
|
}
|
322
|
-
operationArguments.options =
|
818
|
+
operationArguments.options = options || {};
|
323
819
|
return this.client.sendOperationRequest(operationArguments, operationSpec);
|
324
820
|
}
|
325
821
|
/**
|
@@ -330,12 +826,17 @@ class WebPubSub {
|
|
330
826
|
* @param options The options parameters.
|
331
827
|
*/
|
332
828
|
groupExists(hub, group, options) {
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
829
|
+
return this.client.sendOperationRequest({ hub, group, options }, groupExistsOperationSpec);
|
830
|
+
}
|
831
|
+
/**
|
832
|
+
* Close connections in the specific group.
|
833
|
+
* @param hub Target hub name, which should start with alphabetic characters and only contain
|
834
|
+
* alpha-numeric characters or underscore.
|
835
|
+
* @param group Target group name, which length should be greater than 0 and less than 1025.
|
836
|
+
* @param options The options parameters.
|
837
|
+
*/
|
838
|
+
closeGroupConnections(hub, group, options) {
|
839
|
+
return this.client.sendOperationRequest({ hub, group, options }, closeGroupConnectionsOperationSpec);
|
339
840
|
}
|
340
841
|
/**
|
341
842
|
* Send content inside request body to a group of connections.
|
@@ -371,7 +872,7 @@ class WebPubSub {
|
|
371
872
|
else {
|
372
873
|
throw new TypeError(`"contentType" must be a valid value but instead was "${args[2]}".`);
|
373
874
|
}
|
374
|
-
operationArguments.options =
|
875
|
+
operationArguments.options = options || {};
|
375
876
|
return this.client.sendOperationRequest(operationArguments, operationSpec);
|
376
877
|
}
|
377
878
|
/**
|
@@ -383,13 +884,7 @@ class WebPubSub {
|
|
383
884
|
* @param options The options parameters.
|
384
885
|
*/
|
385
886
|
addConnectionToGroup(hub, group, connectionId, options) {
|
386
|
-
|
387
|
-
hub,
|
388
|
-
group,
|
389
|
-
connectionId,
|
390
|
-
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
391
|
-
};
|
392
|
-
return this.client.sendOperationRequest(operationArguments, addConnectionToGroupOperationSpec);
|
887
|
+
return this.client.sendOperationRequest({ hub, group, connectionId, options }, addConnectionToGroupOperationSpec);
|
393
888
|
}
|
394
889
|
/**
|
395
890
|
* Remove a connection from the target group.
|
@@ -400,28 +895,27 @@ class WebPubSub {
|
|
400
895
|
* @param options The options parameters.
|
401
896
|
*/
|
402
897
|
removeConnectionFromGroup(hub, group, connectionId, options) {
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
898
|
+
return this.client.sendOperationRequest({ hub, group, connectionId, options }, removeConnectionFromGroupOperationSpec);
|
899
|
+
}
|
900
|
+
/**
|
901
|
+
* Check if there are any client connections connected for the given user.
|
902
|
+
* @param hub Target hub name, which should start with alphabetic characters and only contain
|
903
|
+
* alpha-numeric characters or underscore.
|
904
|
+
* @param userId Target user Id.
|
905
|
+
* @param options The options parameters.
|
906
|
+
*/
|
907
|
+
userExists(hub, userId, options) {
|
908
|
+
return this.client.sendOperationRequest({ hub, userId, options }, userExistsOperationSpec);
|
410
909
|
}
|
411
910
|
/**
|
412
|
-
*
|
911
|
+
* Close connections for the specific user.
|
413
912
|
* @param hub Target hub name, which should start with alphabetic characters and only contain
|
414
913
|
* alpha-numeric characters or underscore.
|
415
|
-
* @param userId
|
914
|
+
* @param userId The user Id.
|
416
915
|
* @param options The options parameters.
|
417
916
|
*/
|
418
|
-
|
419
|
-
|
420
|
-
hub,
|
421
|
-
userId,
|
422
|
-
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
423
|
-
};
|
424
|
-
return this.client.sendOperationRequest(operationArguments, userExistsOperationSpec);
|
917
|
+
closeUserConnections(hub, userId, options) {
|
918
|
+
return this.client.sendOperationRequest({ hub, userId, options }, closeUserConnectionsOperationSpec);
|
425
919
|
}
|
426
920
|
/**
|
427
921
|
* Send content inside request body to the specific user.
|
@@ -457,26 +951,9 @@ class WebPubSub {
|
|
457
951
|
else {
|
458
952
|
throw new TypeError(`"contentType" must be a valid value but instead was "${args[2]}".`);
|
459
953
|
}
|
460
|
-
operationArguments.options =
|
954
|
+
operationArguments.options = options || {};
|
461
955
|
return this.client.sendOperationRequest(operationArguments, operationSpec);
|
462
956
|
}
|
463
|
-
/**
|
464
|
-
* Check whether a user exists in the target group.
|
465
|
-
* @param hub Target hub name, which should start with alphabetic characters and only contain
|
466
|
-
* alpha-numeric characters or underscore.
|
467
|
-
* @param group Target group name, which length should be greater than 0 and less than 1025.
|
468
|
-
* @param userId Target user Id.
|
469
|
-
* @param options The options parameters.
|
470
|
-
*/
|
471
|
-
userExistsInGroup(hub, group, userId, options) {
|
472
|
-
const operationArguments = {
|
473
|
-
hub,
|
474
|
-
group,
|
475
|
-
userId,
|
476
|
-
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
477
|
-
};
|
478
|
-
return this.client.sendOperationRequest(operationArguments, userExistsInGroupOperationSpec);
|
479
|
-
}
|
480
957
|
/**
|
481
958
|
* Add a user to the target group.
|
482
959
|
* @param hub Target hub name, which should start with alphabetic characters and only contain
|
@@ -486,13 +963,7 @@ class WebPubSub {
|
|
486
963
|
* @param options The options parameters.
|
487
964
|
*/
|
488
965
|
addUserToGroup(hub, group, userId, options) {
|
489
|
-
|
490
|
-
hub,
|
491
|
-
group,
|
492
|
-
userId,
|
493
|
-
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
494
|
-
};
|
495
|
-
return this.client.sendOperationRequest(operationArguments, addUserToGroupOperationSpec);
|
966
|
+
return this.client.sendOperationRequest({ hub, group, userId, options }, addUserToGroupOperationSpec);
|
496
967
|
}
|
497
968
|
/**
|
498
969
|
* Remove a user from the target group.
|
@@ -503,13 +974,7 @@ class WebPubSub {
|
|
503
974
|
* @param options The options parameters.
|
504
975
|
*/
|
505
976
|
removeUserFromGroup(hub, group, userId, options) {
|
506
|
-
|
507
|
-
hub,
|
508
|
-
group,
|
509
|
-
userId,
|
510
|
-
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
511
|
-
};
|
512
|
-
return this.client.sendOperationRequest(operationArguments, removeUserFromGroupOperationSpec);
|
977
|
+
return this.client.sendOperationRequest({ hub, group, userId, options }, removeUserFromGroupOperationSpec);
|
513
978
|
}
|
514
979
|
/**
|
515
980
|
* Remove a user from all groups.
|
@@ -519,12 +984,7 @@ class WebPubSub {
|
|
519
984
|
* @param options The options parameters.
|
520
985
|
*/
|
521
986
|
removeUserFromAllGroups(hub, userId, options) {
|
522
|
-
|
523
|
-
hub,
|
524
|
-
userId,
|
525
|
-
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
526
|
-
};
|
527
|
-
return this.client.sendOperationRequest(operationArguments, removeUserFromAllGroupsOperationSpec);
|
987
|
+
return this.client.sendOperationRequest({ hub, userId, options }, removeUserFromAllGroupsOperationSpec);
|
528
988
|
}
|
529
989
|
/**
|
530
990
|
* Grant permission to the connection.
|
@@ -535,13 +995,7 @@ class WebPubSub {
|
|
535
995
|
* @param options The options parameters.
|
536
996
|
*/
|
537
997
|
grantPermission(hub, permission, connectionId, options) {
|
538
|
-
|
539
|
-
hub,
|
540
|
-
permission,
|
541
|
-
connectionId,
|
542
|
-
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
543
|
-
};
|
544
|
-
return this.client.sendOperationRequest(operationArguments, grantPermissionOperationSpec);
|
998
|
+
return this.client.sendOperationRequest({ hub, permission, connectionId, options }, grantPermissionOperationSpec);
|
545
999
|
}
|
546
1000
|
/**
|
547
1001
|
* Revoke permission for the connection.
|
@@ -552,13 +1006,7 @@ class WebPubSub {
|
|
552
1006
|
* @param options The options parameters.
|
553
1007
|
*/
|
554
1008
|
revokePermission(hub, permission, connectionId, options) {
|
555
|
-
|
556
|
-
hub,
|
557
|
-
permission,
|
558
|
-
connectionId,
|
559
|
-
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
560
|
-
};
|
561
|
-
return this.client.sendOperationRequest(operationArguments, revokePermissionOperationSpec);
|
1009
|
+
return this.client.sendOperationRequest({ hub, permission, connectionId, options }, revokePermissionOperationSpec);
|
562
1010
|
}
|
563
1011
|
/**
|
564
1012
|
* Check if a connection has permission to the specified action.
|
@@ -569,293 +1017,506 @@ class WebPubSub {
|
|
569
1017
|
* @param options The options parameters.
|
570
1018
|
*/
|
571
1019
|
checkPermission(hub, permission, connectionId, options) {
|
572
|
-
|
573
|
-
hub,
|
574
|
-
permission,
|
575
|
-
connectionId,
|
576
|
-
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
|
577
|
-
};
|
578
|
-
return this.client.sendOperationRequest(operationArguments, checkPermissionOperationSpec);
|
1020
|
+
return this.client.sendOperationRequest({ hub, permission, connectionId, options }, checkPermissionOperationSpec);
|
579
1021
|
}
|
580
1022
|
}
|
581
1023
|
// Operation Specifications
|
582
|
-
const serializer$1 =
|
1024
|
+
const serializer$1 = coreClient.createSerializer(Mappers, /* isXml */ false);
|
1025
|
+
const generateClientTokenOperationSpec = {
|
1026
|
+
path: "/api/hubs/{hub}/:generateToken",
|
1027
|
+
httpMethod: "POST",
|
1028
|
+
responses: {
|
1029
|
+
200: {
|
1030
|
+
bodyMapper: ClientTokenResponse
|
1031
|
+
},
|
1032
|
+
default: {
|
1033
|
+
bodyMapper: ErrorDetail,
|
1034
|
+
headersMapper: WebPubSubGenerateClientTokenExceptionHeaders
|
1035
|
+
}
|
1036
|
+
},
|
1037
|
+
queryParameters: [
|
1038
|
+
apiVersion,
|
1039
|
+
userId,
|
1040
|
+
roles,
|
1041
|
+
expirationTimeInMinutes
|
1042
|
+
],
|
1043
|
+
urlParameters: [endpoint, hub],
|
1044
|
+
headerParameters: [accept],
|
1045
|
+
serializer: serializer$1
|
1046
|
+
};
|
1047
|
+
const closeAllConnectionsOperationSpec = {
|
1048
|
+
path: "/api/hubs/{hub}/:closeConnections",
|
1049
|
+
httpMethod: "POST",
|
1050
|
+
responses: {
|
1051
|
+
204: {},
|
1052
|
+
default: {
|
1053
|
+
bodyMapper: ErrorDetail,
|
1054
|
+
headersMapper: WebPubSubCloseAllConnectionsExceptionHeaders
|
1055
|
+
}
|
1056
|
+
},
|
1057
|
+
queryParameters: [
|
1058
|
+
apiVersion,
|
1059
|
+
excluded,
|
1060
|
+
reason
|
1061
|
+
],
|
1062
|
+
urlParameters: [endpoint, hub],
|
1063
|
+
headerParameters: [accept],
|
1064
|
+
serializer: serializer$1
|
1065
|
+
};
|
583
1066
|
const sendToAll$binaryOperationSpec = {
|
584
1067
|
path: "/api/hubs/{hub}/:send",
|
585
1068
|
httpMethod: "POST",
|
586
|
-
responses: {
|
1069
|
+
responses: {
|
1070
|
+
202: {},
|
1071
|
+
default: {
|
1072
|
+
bodyMapper: ErrorDetail,
|
1073
|
+
headersMapper: WebPubSubSendToAllExceptionHeaders
|
1074
|
+
}
|
1075
|
+
},
|
587
1076
|
requestBody: message,
|
588
|
-
queryParameters: [apiVersion,
|
589
|
-
urlParameters: [
|
590
|
-
headerParameters: [contentType],
|
1077
|
+
queryParameters: [apiVersion, excludedConnections],
|
1078
|
+
urlParameters: [endpoint, hub],
|
1079
|
+
headerParameters: [contentType, accept1],
|
591
1080
|
mediaType: "binary",
|
592
1081
|
serializer: serializer$1
|
593
1082
|
};
|
594
1083
|
const sendToAll$textOperationSpec = {
|
595
1084
|
path: "/api/hubs/{hub}/:send",
|
596
1085
|
httpMethod: "POST",
|
597
|
-
responses: {
|
1086
|
+
responses: {
|
1087
|
+
202: {},
|
1088
|
+
default: {
|
1089
|
+
bodyMapper: ErrorDetail,
|
1090
|
+
headersMapper: WebPubSubSendToAllExceptionHeaders
|
1091
|
+
}
|
1092
|
+
},
|
598
1093
|
requestBody: message1,
|
599
|
-
queryParameters: [apiVersion,
|
600
|
-
urlParameters: [
|
601
|
-
headerParameters: [contentType1],
|
1094
|
+
queryParameters: [apiVersion, excludedConnections],
|
1095
|
+
urlParameters: [endpoint, hub],
|
1096
|
+
headerParameters: [contentType1, accept2],
|
602
1097
|
mediaType: "text",
|
603
1098
|
serializer: serializer$1
|
604
1099
|
};
|
605
1100
|
const connectionExistsOperationSpec = {
|
606
1101
|
path: "/api/hubs/{hub}/connections/{connectionId}",
|
607
1102
|
httpMethod: "HEAD",
|
608
|
-
responses: {
|
1103
|
+
responses: {
|
1104
|
+
200: {},
|
1105
|
+
404: {},
|
1106
|
+
default: {
|
1107
|
+
bodyMapper: ErrorDetail,
|
1108
|
+
headersMapper: WebPubSubConnectionExistsExceptionHeaders
|
1109
|
+
}
|
1110
|
+
},
|
609
1111
|
queryParameters: [apiVersion],
|
610
|
-
urlParameters: [
|
1112
|
+
urlParameters: [endpoint, hub, connectionId],
|
1113
|
+
headerParameters: [accept],
|
611
1114
|
serializer: serializer$1
|
612
1115
|
};
|
613
|
-
const
|
1116
|
+
const closeConnectionOperationSpec = {
|
614
1117
|
path: "/api/hubs/{hub}/connections/{connectionId}",
|
615
1118
|
httpMethod: "DELETE",
|
616
|
-
responses: {
|
1119
|
+
responses: {
|
1120
|
+
204: {},
|
1121
|
+
default: {
|
1122
|
+
bodyMapper: ErrorDetail,
|
1123
|
+
headersMapper: WebPubSubCloseConnectionExceptionHeaders
|
1124
|
+
}
|
1125
|
+
},
|
617
1126
|
queryParameters: [apiVersion, reason],
|
618
|
-
urlParameters: [
|
1127
|
+
urlParameters: [endpoint, hub, connectionId],
|
1128
|
+
headerParameters: [accept],
|
619
1129
|
serializer: serializer$1
|
620
1130
|
};
|
621
1131
|
const sendToConnection$binaryOperationSpec = {
|
622
1132
|
path: "/api/hubs/{hub}/connections/{connectionId}/:send",
|
623
1133
|
httpMethod: "POST",
|
624
|
-
responses: {
|
1134
|
+
responses: {
|
1135
|
+
202: {},
|
1136
|
+
default: {
|
1137
|
+
bodyMapper: ErrorDetail,
|
1138
|
+
headersMapper: WebPubSubSendToConnectionExceptionHeaders
|
1139
|
+
}
|
1140
|
+
},
|
625
1141
|
requestBody: message,
|
626
1142
|
queryParameters: [apiVersion],
|
627
|
-
urlParameters: [
|
628
|
-
headerParameters: [contentType],
|
1143
|
+
urlParameters: [endpoint, hub, connectionId],
|
1144
|
+
headerParameters: [contentType, accept1],
|
629
1145
|
mediaType: "binary",
|
630
1146
|
serializer: serializer$1
|
631
1147
|
};
|
632
1148
|
const sendToConnection$textOperationSpec = {
|
633
1149
|
path: "/api/hubs/{hub}/connections/{connectionId}/:send",
|
634
1150
|
httpMethod: "POST",
|
635
|
-
responses: {
|
1151
|
+
responses: {
|
1152
|
+
202: {},
|
1153
|
+
default: {
|
1154
|
+
bodyMapper: ErrorDetail,
|
1155
|
+
headersMapper: WebPubSubSendToConnectionExceptionHeaders
|
1156
|
+
}
|
1157
|
+
},
|
636
1158
|
requestBody: message1,
|
637
1159
|
queryParameters: [apiVersion],
|
638
|
-
urlParameters: [
|
639
|
-
headerParameters: [contentType1],
|
1160
|
+
urlParameters: [endpoint, hub, connectionId],
|
1161
|
+
headerParameters: [contentType1, accept2],
|
640
1162
|
mediaType: "text",
|
641
1163
|
serializer: serializer$1
|
642
1164
|
};
|
643
1165
|
const groupExistsOperationSpec = {
|
644
1166
|
path: "/api/hubs/{hub}/groups/{group}",
|
645
1167
|
httpMethod: "HEAD",
|
646
|
-
responses: {
|
1168
|
+
responses: {
|
1169
|
+
200: {},
|
1170
|
+
404: {},
|
1171
|
+
default: {
|
1172
|
+
bodyMapper: ErrorDetail,
|
1173
|
+
headersMapper: WebPubSubGroupExistsExceptionHeaders
|
1174
|
+
}
|
1175
|
+
},
|
647
1176
|
queryParameters: [apiVersion],
|
648
|
-
urlParameters: [
|
1177
|
+
urlParameters: [endpoint, hub, group],
|
1178
|
+
headerParameters: [accept],
|
1179
|
+
serializer: serializer$1
|
1180
|
+
};
|
1181
|
+
const closeGroupConnectionsOperationSpec = {
|
1182
|
+
path: "/api/hubs/{hub}/groups/{group}/:closeConnections",
|
1183
|
+
httpMethod: "POST",
|
1184
|
+
responses: {
|
1185
|
+
204: {},
|
1186
|
+
default: {
|
1187
|
+
bodyMapper: ErrorDetail,
|
1188
|
+
headersMapper: WebPubSubCloseGroupConnectionsExceptionHeaders
|
1189
|
+
}
|
1190
|
+
},
|
1191
|
+
queryParameters: [
|
1192
|
+
apiVersion,
|
1193
|
+
excluded,
|
1194
|
+
reason
|
1195
|
+
],
|
1196
|
+
urlParameters: [endpoint, hub, group],
|
1197
|
+
headerParameters: [accept],
|
649
1198
|
serializer: serializer$1
|
650
1199
|
};
|
651
1200
|
const sendToGroup$binaryOperationSpec = {
|
652
1201
|
path: "/api/hubs/{hub}/groups/{group}/:send",
|
653
1202
|
httpMethod: "POST",
|
654
|
-
responses: {
|
1203
|
+
responses: {
|
1204
|
+
202: {},
|
1205
|
+
default: {
|
1206
|
+
bodyMapper: ErrorDetail,
|
1207
|
+
headersMapper: WebPubSubSendToGroupExceptionHeaders
|
1208
|
+
}
|
1209
|
+
},
|
655
1210
|
requestBody: message,
|
656
|
-
queryParameters: [apiVersion,
|
657
|
-
urlParameters: [
|
658
|
-
headerParameters: [contentType],
|
1211
|
+
queryParameters: [apiVersion, excludedConnections],
|
1212
|
+
urlParameters: [endpoint, hub, group],
|
1213
|
+
headerParameters: [contentType, accept1],
|
659
1214
|
mediaType: "binary",
|
660
1215
|
serializer: serializer$1
|
661
1216
|
};
|
662
1217
|
const sendToGroup$textOperationSpec = {
|
663
1218
|
path: "/api/hubs/{hub}/groups/{group}/:send",
|
664
1219
|
httpMethod: "POST",
|
665
|
-
responses: {
|
1220
|
+
responses: {
|
1221
|
+
202: {},
|
1222
|
+
default: {
|
1223
|
+
bodyMapper: ErrorDetail,
|
1224
|
+
headersMapper: WebPubSubSendToGroupExceptionHeaders
|
1225
|
+
}
|
1226
|
+
},
|
666
1227
|
requestBody: message1,
|
667
|
-
queryParameters: [apiVersion,
|
668
|
-
urlParameters: [
|
669
|
-
headerParameters: [contentType1],
|
1228
|
+
queryParameters: [apiVersion, excludedConnections],
|
1229
|
+
urlParameters: [endpoint, hub, group],
|
1230
|
+
headerParameters: [contentType1, accept2],
|
670
1231
|
mediaType: "text",
|
671
1232
|
serializer: serializer$1
|
672
1233
|
};
|
673
1234
|
const addConnectionToGroupOperationSpec = {
|
674
1235
|
path: "/api/hubs/{hub}/groups/{group}/connections/{connectionId}",
|
675
1236
|
httpMethod: "PUT",
|
676
|
-
responses: {
|
1237
|
+
responses: {
|
1238
|
+
200: {},
|
1239
|
+
404: {},
|
1240
|
+
default: {
|
1241
|
+
bodyMapper: ErrorDetail,
|
1242
|
+
headersMapper: WebPubSubAddConnectionToGroupExceptionHeaders
|
1243
|
+
}
|
1244
|
+
},
|
677
1245
|
queryParameters: [apiVersion],
|
678
1246
|
urlParameters: [
|
679
|
-
|
1247
|
+
endpoint,
|
680
1248
|
hub,
|
681
1249
|
connectionId,
|
682
1250
|
group
|
683
1251
|
],
|
1252
|
+
headerParameters: [accept],
|
684
1253
|
serializer: serializer$1
|
685
1254
|
};
|
686
1255
|
const removeConnectionFromGroupOperationSpec = {
|
687
1256
|
path: "/api/hubs/{hub}/groups/{group}/connections/{connectionId}",
|
688
1257
|
httpMethod: "DELETE",
|
689
|
-
responses: {
|
1258
|
+
responses: {
|
1259
|
+
204: {},
|
1260
|
+
default: {
|
1261
|
+
bodyMapper: ErrorDetail,
|
1262
|
+
headersMapper: WebPubSubRemoveConnectionFromGroupExceptionHeaders
|
1263
|
+
}
|
1264
|
+
},
|
690
1265
|
queryParameters: [apiVersion],
|
691
1266
|
urlParameters: [
|
692
|
-
|
1267
|
+
endpoint,
|
693
1268
|
hub,
|
694
1269
|
connectionId,
|
695
1270
|
group
|
696
1271
|
],
|
1272
|
+
headerParameters: [accept],
|
697
1273
|
serializer: serializer$1
|
698
1274
|
};
|
699
1275
|
const userExistsOperationSpec = {
|
700
1276
|
path: "/api/hubs/{hub}/users/{userId}",
|
701
1277
|
httpMethod: "HEAD",
|
702
|
-
responses: {
|
1278
|
+
responses: {
|
1279
|
+
200: {},
|
1280
|
+
404: {},
|
1281
|
+
default: {
|
1282
|
+
bodyMapper: ErrorDetail,
|
1283
|
+
headersMapper: WebPubSubUserExistsExceptionHeaders
|
1284
|
+
}
|
1285
|
+
},
|
703
1286
|
queryParameters: [apiVersion],
|
704
|
-
urlParameters: [
|
1287
|
+
urlParameters: [endpoint, hub, userId1],
|
1288
|
+
headerParameters: [accept],
|
1289
|
+
serializer: serializer$1
|
1290
|
+
};
|
1291
|
+
const closeUserConnectionsOperationSpec = {
|
1292
|
+
path: "/api/hubs/{hub}/users/{userId}/:closeConnections",
|
1293
|
+
httpMethod: "POST",
|
1294
|
+
responses: {
|
1295
|
+
204: {},
|
1296
|
+
default: {
|
1297
|
+
bodyMapper: ErrorDetail,
|
1298
|
+
headersMapper: WebPubSubCloseUserConnectionsExceptionHeaders
|
1299
|
+
}
|
1300
|
+
},
|
1301
|
+
queryParameters: [
|
1302
|
+
apiVersion,
|
1303
|
+
excluded,
|
1304
|
+
reason
|
1305
|
+
],
|
1306
|
+
urlParameters: [endpoint, hub, userId1],
|
1307
|
+
headerParameters: [accept],
|
705
1308
|
serializer: serializer$1
|
706
1309
|
};
|
707
1310
|
const sendToUser$binaryOperationSpec = {
|
708
1311
|
path: "/api/hubs/{hub}/users/{userId}/:send",
|
709
1312
|
httpMethod: "POST",
|
710
|
-
responses: {
|
1313
|
+
responses: {
|
1314
|
+
202: {},
|
1315
|
+
default: {
|
1316
|
+
bodyMapper: ErrorDetail,
|
1317
|
+
headersMapper: WebPubSubSendToUserExceptionHeaders
|
1318
|
+
}
|
1319
|
+
},
|
711
1320
|
requestBody: message,
|
712
1321
|
queryParameters: [apiVersion],
|
713
|
-
urlParameters: [
|
714
|
-
headerParameters: [contentType],
|
1322
|
+
urlParameters: [endpoint, hub, userId1],
|
1323
|
+
headerParameters: [contentType, accept1],
|
715
1324
|
mediaType: "binary",
|
716
1325
|
serializer: serializer$1
|
717
1326
|
};
|
718
1327
|
const sendToUser$textOperationSpec = {
|
719
1328
|
path: "/api/hubs/{hub}/users/{userId}/:send",
|
720
1329
|
httpMethod: "POST",
|
721
|
-
responses: {
|
1330
|
+
responses: {
|
1331
|
+
202: {},
|
1332
|
+
default: {
|
1333
|
+
bodyMapper: ErrorDetail,
|
1334
|
+
headersMapper: WebPubSubSendToUserExceptionHeaders
|
1335
|
+
}
|
1336
|
+
},
|
722
1337
|
requestBody: message1,
|
723
1338
|
queryParameters: [apiVersion],
|
724
|
-
urlParameters: [
|
725
|
-
headerParameters: [contentType1],
|
1339
|
+
urlParameters: [endpoint, hub, userId1],
|
1340
|
+
headerParameters: [contentType1, accept2],
|
726
1341
|
mediaType: "text",
|
727
1342
|
serializer: serializer$1
|
728
1343
|
};
|
729
|
-
const userExistsInGroupOperationSpec = {
|
730
|
-
path: "/api/hubs/{hub}/users/{userId}/groups/{group}",
|
731
|
-
httpMethod: "HEAD",
|
732
|
-
responses: { 200: {}, 404: {}, default: {} },
|
733
|
-
queryParameters: [apiVersion],
|
734
|
-
urlParameters: [
|
735
|
-
$host,
|
736
|
-
hub,
|
737
|
-
group,
|
738
|
-
userId
|
739
|
-
],
|
740
|
-
serializer: serializer$1
|
741
|
-
};
|
742
1344
|
const addUserToGroupOperationSpec = {
|
743
1345
|
path: "/api/hubs/{hub}/users/{userId}/groups/{group}",
|
744
1346
|
httpMethod: "PUT",
|
745
|
-
responses: {
|
1347
|
+
responses: {
|
1348
|
+
200: {},
|
1349
|
+
404: {},
|
1350
|
+
default: {
|
1351
|
+
bodyMapper: ErrorDetail,
|
1352
|
+
headersMapper: WebPubSubAddUserToGroupExceptionHeaders
|
1353
|
+
}
|
1354
|
+
},
|
746
1355
|
queryParameters: [apiVersion],
|
747
1356
|
urlParameters: [
|
748
|
-
|
1357
|
+
endpoint,
|
749
1358
|
hub,
|
750
1359
|
group,
|
751
|
-
|
1360
|
+
userId1
|
752
1361
|
],
|
1362
|
+
headerParameters: [accept],
|
753
1363
|
serializer: serializer$1
|
754
1364
|
};
|
755
1365
|
const removeUserFromGroupOperationSpec = {
|
756
1366
|
path: "/api/hubs/{hub}/users/{userId}/groups/{group}",
|
757
1367
|
httpMethod: "DELETE",
|
758
|
-
responses: {
|
1368
|
+
responses: {
|
1369
|
+
204: {},
|
1370
|
+
default: {
|
1371
|
+
bodyMapper: ErrorDetail,
|
1372
|
+
headersMapper: WebPubSubRemoveUserFromGroupExceptionHeaders
|
1373
|
+
}
|
1374
|
+
},
|
759
1375
|
queryParameters: [apiVersion],
|
760
1376
|
urlParameters: [
|
761
|
-
|
1377
|
+
endpoint,
|
762
1378
|
hub,
|
763
1379
|
group,
|
764
|
-
|
1380
|
+
userId1
|
765
1381
|
],
|
1382
|
+
headerParameters: [accept],
|
766
1383
|
serializer: serializer$1
|
767
1384
|
};
|
768
1385
|
const removeUserFromAllGroupsOperationSpec = {
|
769
1386
|
path: "/api/hubs/{hub}/users/{userId}/groups",
|
770
1387
|
httpMethod: "DELETE",
|
771
|
-
responses: {
|
1388
|
+
responses: {
|
1389
|
+
204: {},
|
1390
|
+
default: {
|
1391
|
+
bodyMapper: ErrorDetail,
|
1392
|
+
headersMapper: WebPubSubRemoveUserFromAllGroupsExceptionHeaders
|
1393
|
+
}
|
1394
|
+
},
|
772
1395
|
queryParameters: [apiVersion],
|
773
|
-
urlParameters: [
|
1396
|
+
urlParameters: [endpoint, hub, userId1],
|
1397
|
+
headerParameters: [accept],
|
774
1398
|
serializer: serializer$1
|
775
1399
|
};
|
776
1400
|
const grantPermissionOperationSpec = {
|
777
1401
|
path: "/api/hubs/{hub}/permissions/{permission}/connections/{connectionId}",
|
778
1402
|
httpMethod: "PUT",
|
779
|
-
responses: {
|
1403
|
+
responses: {
|
1404
|
+
200: {},
|
1405
|
+
default: {
|
1406
|
+
bodyMapper: ErrorDetail,
|
1407
|
+
headersMapper: WebPubSubGrantPermissionExceptionHeaders
|
1408
|
+
}
|
1409
|
+
},
|
780
1410
|
queryParameters: [apiVersion, targetName],
|
781
1411
|
urlParameters: [
|
782
|
-
|
1412
|
+
endpoint,
|
783
1413
|
hub,
|
784
1414
|
connectionId,
|
785
1415
|
permission
|
786
1416
|
],
|
1417
|
+
headerParameters: [accept],
|
787
1418
|
serializer: serializer$1
|
788
1419
|
};
|
789
1420
|
const revokePermissionOperationSpec = {
|
790
1421
|
path: "/api/hubs/{hub}/permissions/{permission}/connections/{connectionId}",
|
791
1422
|
httpMethod: "DELETE",
|
792
|
-
responses: {
|
1423
|
+
responses: {
|
1424
|
+
204: {},
|
1425
|
+
default: {
|
1426
|
+
bodyMapper: ErrorDetail,
|
1427
|
+
headersMapper: WebPubSubRevokePermissionExceptionHeaders
|
1428
|
+
}
|
1429
|
+
},
|
793
1430
|
queryParameters: [apiVersion, targetName],
|
794
1431
|
urlParameters: [
|
795
|
-
|
1432
|
+
endpoint,
|
796
1433
|
hub,
|
797
1434
|
connectionId,
|
798
|
-
|
1435
|
+
permission
|
799
1436
|
],
|
1437
|
+
headerParameters: [accept],
|
800
1438
|
serializer: serializer$1
|
801
1439
|
};
|
802
1440
|
const checkPermissionOperationSpec = {
|
803
1441
|
path: "/api/hubs/{hub}/permissions/{permission}/connections/{connectionId}",
|
804
1442
|
httpMethod: "HEAD",
|
805
|
-
responses: {
|
1443
|
+
responses: {
|
1444
|
+
200: {},
|
1445
|
+
404: {},
|
1446
|
+
default: {
|
1447
|
+
bodyMapper: ErrorDetail,
|
1448
|
+
headersMapper: WebPubSubCheckPermissionExceptionHeaders
|
1449
|
+
}
|
1450
|
+
},
|
806
1451
|
queryParameters: [apiVersion, targetName],
|
807
1452
|
urlParameters: [
|
808
|
-
|
1453
|
+
endpoint,
|
809
1454
|
hub,
|
810
1455
|
connectionId,
|
811
|
-
|
1456
|
+
permission
|
812
1457
|
],
|
1458
|
+
headerParameters: [accept],
|
813
1459
|
serializer: serializer$1
|
814
1460
|
};
|
815
1461
|
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
*
|
1462
|
+
/*
|
1463
|
+
* Copyright (c) Microsoft Corporation.
|
1464
|
+
* Licensed under the MIT License.
|
1465
|
+
*
|
1466
|
+
* Code generated by Microsoft (R) AutoRest Code Generator.
|
1467
|
+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
820
1468
|
*/
|
821
|
-
|
1469
|
+
/** @internal */
|
1470
|
+
class GeneratedClientContext extends coreClient.ServiceClient {
|
822
1471
|
/**
|
823
|
-
* Initializes a new instance of the
|
824
|
-
* @param
|
1472
|
+
* Initializes a new instance of the GeneratedClientContext class.
|
1473
|
+
* @param endpoint HTTP or HTTPS endpoint for the Web PubSub service instance.
|
825
1474
|
* @param options The parameter options
|
826
1475
|
*/
|
827
|
-
constructor(
|
828
|
-
if (
|
829
|
-
throw new Error("'
|
1476
|
+
constructor(endpoint, options) {
|
1477
|
+
if (endpoint === undefined) {
|
1478
|
+
throw new Error("'endpoint' cannot be null");
|
830
1479
|
}
|
831
1480
|
// Initializing default values for options
|
832
1481
|
if (!options) {
|
833
1482
|
options = {};
|
834
1483
|
}
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
1484
|
+
const defaults = {
|
1485
|
+
requestContentType: "application/json; charset=utf-8"
|
1486
|
+
};
|
1487
|
+
const packageDetails = `azsdk-js-web-pubsub/1.0.1`;
|
1488
|
+
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
1489
|
+
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
1490
|
+
: `${packageDetails}`;
|
1491
|
+
const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
|
1492
|
+
userAgentPrefix
|
1493
|
+
}, baseUri: options.endpoint || "{Endpoint}" });
|
1494
|
+
super(optionsWithDefaults);
|
842
1495
|
// Parameter assignments
|
843
|
-
this
|
1496
|
+
this.endpoint = endpoint;
|
844
1497
|
// Assigning values to Constant parameters
|
845
|
-
this.apiVersion = options.apiVersion || "
|
1498
|
+
this.apiVersion = options.apiVersion || "2021-10-01";
|
846
1499
|
}
|
847
1500
|
}
|
848
1501
|
|
849
|
-
|
1502
|
+
/*
|
1503
|
+
* Copyright (c) Microsoft Corporation.
|
1504
|
+
* Licensed under the MIT License.
|
1505
|
+
*
|
1506
|
+
* Code generated by Microsoft (R) AutoRest Code Generator.
|
1507
|
+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
1508
|
+
*/
|
1509
|
+
/** @internal */
|
1510
|
+
class GeneratedClient extends GeneratedClientContext {
|
850
1511
|
/**
|
851
|
-
* Initializes a new instance of the
|
852
|
-
* @param
|
1512
|
+
* Initializes a new instance of the GeneratedClient class.
|
1513
|
+
* @param endpoint HTTP or HTTPS endpoint for the Web PubSub service instance.
|
853
1514
|
* @param options The parameter options
|
854
1515
|
*/
|
855
|
-
constructor(
|
856
|
-
super(
|
857
|
-
this.healthApi = new
|
858
|
-
this.webPubSub = new
|
1516
|
+
constructor(endpoint, options) {
|
1517
|
+
super(endpoint, options);
|
1518
|
+
this.healthApi = new HealthApiImpl(this);
|
1519
|
+
this.webPubSub = new WebPubSubImpl(this);
|
859
1520
|
}
|
860
1521
|
}
|
861
1522
|
|
@@ -867,12 +1528,8 @@ const createSpan = coreTracing.createSpanFunction({
|
|
867
1528
|
});
|
868
1529
|
|
869
1530
|
// Copyright (c) Microsoft Corporation.
|
870
|
-
|
871
|
-
|
872
|
-
return Object.assign(Object.assign({}, otherOptions), { excluded: excludedConnections });
|
873
|
-
}
|
874
|
-
|
875
|
-
function isHttpRequestBody(obj) {
|
1531
|
+
// Licensed under the MIT license.
|
1532
|
+
function isRequestBody(obj) {
|
876
1533
|
return (typeof obj === "function" ||
|
877
1534
|
(typeof obj === "object" &&
|
878
1535
|
obj != null &&
|
@@ -880,18 +1537,18 @@ function isHttpRequestBody(obj) {
|
|
880
1537
|
obj.constructor.name === "Blob" ||
|
881
1538
|
ArrayBuffer.isView(obj))));
|
882
1539
|
}
|
883
|
-
function
|
1540
|
+
function getPayloadForMessage(message, options) {
|
884
1541
|
if ((options === null || options === void 0 ? void 0 : options.contentType) === "text/plain") {
|
885
1542
|
if (typeof message !== "string") {
|
886
1543
|
throw new TypeError("Message must be a string.");
|
887
1544
|
}
|
888
|
-
return "text/plain";
|
1545
|
+
return { contentType: "text/plain", payload: message };
|
889
1546
|
}
|
890
|
-
else if (
|
891
|
-
return "application/octet-stream";
|
1547
|
+
else if (isRequestBody(message)) {
|
1548
|
+
return { contentType: "application/octet-stream", payload: message };
|
892
1549
|
}
|
893
1550
|
else {
|
894
|
-
return "application/json";
|
1551
|
+
return { contentType: "application/json", payload: JSON.stringify(message) };
|
895
1552
|
}
|
896
1553
|
}
|
897
1554
|
|
@@ -901,7 +1558,6 @@ function getContentTypeForMessage(message, options) {
|
|
901
1558
|
*/
|
902
1559
|
class WebPubSubGroupImpl {
|
903
1560
|
/**
|
904
|
-
* @private
|
905
1561
|
* @internal
|
906
1562
|
*/
|
907
1563
|
constructor(client, hubName, groupName) {
|
@@ -916,150 +1572,137 @@ class WebPubSubGroupImpl {
|
|
916
1572
|
/**
|
917
1573
|
* Add a specific connection to this group
|
918
1574
|
*
|
919
|
-
* @param connectionId The connection id to add to this group
|
920
|
-
* @param options Additional options
|
1575
|
+
* @param connectionId - The connection id to add to this group
|
1576
|
+
* @param options - Additional options
|
921
1577
|
*/
|
922
|
-
addConnection(connectionId, options = {}) {
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
}
|
930
|
-
return res;
|
1578
|
+
async addConnection(connectionId, options = {}) {
|
1579
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-group-addConnection", options);
|
1580
|
+
let response;
|
1581
|
+
function onResponse(rawResponse, flatResponse) {
|
1582
|
+
response = rawResponse;
|
1583
|
+
if (updatedOptions.onResponse) {
|
1584
|
+
updatedOptions.onResponse(rawResponse, flatResponse);
|
931
1585
|
}
|
932
|
-
|
933
|
-
|
1586
|
+
}
|
1587
|
+
try {
|
1588
|
+
await this.client.webPubSub.addConnectionToGroup(this.hubName, this.groupName, connectionId, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
1589
|
+
if (response.status === 404) {
|
1590
|
+
throw new coreRestPipeline.RestError(`Connection id '${connectionId}' doesn't exist`, {
|
1591
|
+
statusCode: response === null || response === void 0 ? void 0 : response.status,
|
1592
|
+
request: response === null || response === void 0 ? void 0 : response.request,
|
1593
|
+
response: response
|
1594
|
+
});
|
934
1595
|
}
|
935
|
-
}
|
1596
|
+
}
|
1597
|
+
finally {
|
1598
|
+
span.end();
|
1599
|
+
}
|
936
1600
|
}
|
937
1601
|
/**
|
938
1602
|
* Remove a specific connection from this group
|
939
1603
|
*
|
940
|
-
* @param connectionId The connection id to remove from this group
|
941
|
-
* @param options Additional options
|
1604
|
+
* @param connectionId - The connection id to remove from this group
|
1605
|
+
* @param options - Additional options
|
942
1606
|
*/
|
943
|
-
removeConnection(connectionId, options = {}) {
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
span.end();
|
952
|
-
}
|
953
|
-
});
|
1607
|
+
async removeConnection(connectionId, options = {}) {
|
1608
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-group-removeConnection", options);
|
1609
|
+
try {
|
1610
|
+
await this.client.webPubSub.removeConnectionFromGroup(this.hubName, this.groupName, connectionId, updatedOptions);
|
1611
|
+
}
|
1612
|
+
finally {
|
1613
|
+
span.end();
|
1614
|
+
}
|
954
1615
|
}
|
955
1616
|
/**
|
956
|
-
*
|
1617
|
+
* Close all connections to this group
|
957
1618
|
*
|
958
|
-
* @param
|
959
|
-
* @param options Additional options
|
1619
|
+
* @param options - Additional options
|
960
1620
|
*/
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
}
|
970
|
-
});
|
1621
|
+
async closeAllConnections(options = {}) {
|
1622
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-group-closeAllConnections", options);
|
1623
|
+
try {
|
1624
|
+
return await this.client.webPubSub.closeGroupConnections(this.hubName, this.groupName, updatedOptions);
|
1625
|
+
}
|
1626
|
+
finally {
|
1627
|
+
span.end();
|
1628
|
+
}
|
971
1629
|
}
|
972
1630
|
/**
|
973
|
-
*
|
1631
|
+
* Add a user to this group
|
974
1632
|
*
|
975
|
-
* @param username The user name to
|
976
|
-
* @param options Additional options
|
1633
|
+
* @param username - The user name to add
|
1634
|
+
* @param options - Additional options
|
977
1635
|
*/
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
else if (res._response.status === 404) {
|
987
|
-
return false;
|
988
|
-
}
|
989
|
-
else {
|
990
|
-
// this is sad - wish this was handled by autorest.
|
991
|
-
throw new coreHttp.RestError(res._response.bodyAsText, undefined, res._response.status, res._response.request, res._response);
|
992
|
-
}
|
993
|
-
}
|
994
|
-
finally {
|
995
|
-
span.end();
|
996
|
-
}
|
997
|
-
});
|
1636
|
+
async addUser(username, options = {}) {
|
1637
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-group-addUser", options);
|
1638
|
+
try {
|
1639
|
+
await this.client.webPubSub.addUserToGroup(this.hubName, this.groupName, username, updatedOptions);
|
1640
|
+
}
|
1641
|
+
finally {
|
1642
|
+
span.end();
|
1643
|
+
}
|
998
1644
|
}
|
999
1645
|
/**
|
1000
1646
|
* Remove a user from this group
|
1001
1647
|
*
|
1002
|
-
* @param username The user name to remove
|
1003
|
-
* @param options Additional options
|
1648
|
+
* @param username - The user name to remove
|
1649
|
+
* @param options - Additional options
|
1004
1650
|
*/
|
1005
|
-
removeUser(username, options = {}) {
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
}
|
1024
|
-
finally {
|
1025
|
-
span.end();
|
1026
|
-
}
|
1027
|
-
});
|
1651
|
+
async removeUser(username, options = {}) {
|
1652
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-group-removeUser", options);
|
1653
|
+
try {
|
1654
|
+
await this.client.webPubSub.removeUserFromGroup(this.hubName, this.groupName, username, updatedOptions);
|
1655
|
+
}
|
1656
|
+
finally {
|
1657
|
+
span.end();
|
1658
|
+
}
|
1659
|
+
}
|
1660
|
+
async sendToAll(message, options = {}) {
|
1661
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-group-sendToAll", options);
|
1662
|
+
const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
|
1663
|
+
try {
|
1664
|
+
await this.client.webPubSub.sendToGroup(this.hubName, this.groupName, contentType, payload, updatedOptions);
|
1665
|
+
}
|
1666
|
+
finally {
|
1667
|
+
span.end();
|
1668
|
+
}
|
1028
1669
|
}
|
1029
1670
|
}
|
1030
1671
|
|
1031
1672
|
// Copyright (c) Microsoft Corporation.
|
1032
|
-
|
1673
|
+
/**
|
1674
|
+
* The programmatic identifier of the webPubSubKeyCredentialPolicy.
|
1675
|
+
*/
|
1676
|
+
const webPubSubKeyCredentialPolicyName = "webPubSubKeyCredentialPolicy";
|
1677
|
+
/**
|
1678
|
+
* Create an HTTP pipeline policy to authenticate a request
|
1679
|
+
* using an `AzureKeyCredential` for Text Analytics
|
1680
|
+
* @internal
|
1681
|
+
*/
|
1682
|
+
function webPubSubKeyCredentialPolicy(credential) {
|
1033
1683
|
return {
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
};
|
1038
|
-
}
|
1039
|
-
class WebPubSubKeyCredentialPolicy extends coreHttp.BaseRequestPolicy {
|
1040
|
-
constructor(nextPolicy, options, credential) {
|
1041
|
-
super(nextPolicy, options);
|
1042
|
-
this.credential = credential;
|
1043
|
-
}
|
1044
|
-
sendRequest(request) {
|
1045
|
-
request.headers.set("Authorization", "Bearer " +
|
1046
|
-
jwt.sign({}, this.credential.key, {
|
1684
|
+
name: webPubSubKeyCredentialPolicyName,
|
1685
|
+
sendRequest(request, next) {
|
1686
|
+
const bearerToken = jwt.sign({}, credential.key, {
|
1047
1687
|
audience: request.url,
|
1048
1688
|
expiresIn: "1h",
|
1049
1689
|
algorithm: "HS256"
|
1050
|
-
})
|
1051
|
-
|
1052
|
-
|
1690
|
+
});
|
1691
|
+
request.headers.set("Authorization", `Bearer ${bearerToken}`);
|
1692
|
+
return next(request);
|
1693
|
+
}
|
1694
|
+
};
|
1053
1695
|
}
|
1054
1696
|
|
1055
1697
|
// Copyright (c) Microsoft Corporation.
|
1056
1698
|
/**
|
1057
|
-
* The
|
1699
|
+
* The `@azure/logger` configuration for this package.
|
1058
1700
|
*/
|
1059
1701
|
const logger = logger$1.createClientLogger("web-pubsub");
|
1060
1702
|
|
1703
|
+
// Copyright (c) Microsoft Corporation.
|
1061
1704
|
function parseConnectionString(conn) {
|
1062
|
-
|
1705
|
+
const parsed = {};
|
1063
1706
|
conn.split(";").forEach((i) => {
|
1064
1707
|
const assignmentPos = i.indexOf("=");
|
1065
1708
|
if (assignmentPos === -1)
|
@@ -1086,22 +1729,44 @@ function parseConnectionString(conn) {
|
|
1086
1729
|
return { credential, endpoint };
|
1087
1730
|
}
|
1088
1731
|
|
1732
|
+
// Copyright (c) Microsoft Corporation.
|
1733
|
+
// Licensed under the MIT license.
|
1734
|
+
const webPubSubReverseProxyPolicyName = "webPubSubReverseProxyPolicy";
|
1735
|
+
/**
|
1736
|
+
* Create an HTTP pipeline policy to use a reverse proxy.
|
1737
|
+
* This is generally going to be an Azure APIM endpoint.
|
1738
|
+
* @internal
|
1739
|
+
*/
|
1740
|
+
function webPubSubReverseProxyPolicy(endpoint) {
|
1741
|
+
const rpEndpointUrl = new URL(endpoint);
|
1742
|
+
return {
|
1743
|
+
name: webPubSubReverseProxyPolicyName,
|
1744
|
+
sendRequest(request, next) {
|
1745
|
+
const parsedUrl = new URL(request.url);
|
1746
|
+
parsedUrl.host = rpEndpointUrl.host;
|
1747
|
+
request.url = parsedUrl.toString();
|
1748
|
+
return next(request);
|
1749
|
+
}
|
1750
|
+
};
|
1751
|
+
}
|
1752
|
+
|
1089
1753
|
// Copyright (c) Microsoft Corporation.
|
1090
1754
|
/**
|
1091
1755
|
* Client for connecting to a Web PubSub hub
|
1092
1756
|
*/
|
1093
1757
|
class WebPubSubServiceClient {
|
1094
1758
|
constructor(endpointOrConnectionString, credsOrHubName, hubNameOrOpts, opts) {
|
1759
|
+
var _a, _b;
|
1095
1760
|
/**
|
1096
1761
|
* The Web PubSub API version being used by this client
|
1097
1762
|
*/
|
1098
|
-
this.apiVersion = "
|
1763
|
+
this.apiVersion = "2021-10-01";
|
1099
1764
|
// unpack constructor arguments
|
1100
|
-
if (typeof credsOrHubName === "object"
|
1765
|
+
if (typeof credsOrHubName === "object") {
|
1101
1766
|
this.endpoint = endpointOrConnectionString;
|
1102
|
-
this.credential = credsOrHubName;
|
1103
1767
|
this.hubName = hubNameOrOpts;
|
1104
1768
|
this.clientOptions = opts;
|
1769
|
+
this.credential = credsOrHubName;
|
1105
1770
|
}
|
1106
1771
|
else {
|
1107
1772
|
const parsedCs = parseConnectionString(endpointOrConnectionString);
|
@@ -1110,254 +1775,337 @@ class WebPubSubServiceClient {
|
|
1110
1775
|
this.hubName = credsOrHubName;
|
1111
1776
|
this.clientOptions = hubNameOrOpts;
|
1112
1777
|
}
|
1113
|
-
const internalPipelineOptions = Object.assign(Object.assign({}, this.clientOptions), {
|
1778
|
+
const internalPipelineOptions = Object.assign(Object.assign(Object.assign({}, this.clientOptions), {
|
1779
|
+
apiVersion: this.apiVersion,
|
1114
1780
|
loggingOptions: {
|
1115
1781
|
logger: logger.info
|
1116
1782
|
}
|
1117
|
-
})
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
/**
|
1122
|
-
* Auth the client connection with userId and custom claims if any
|
1123
|
-
* @param options The options that the client has
|
1124
|
-
*/
|
1125
|
-
getAuthenticationToken(options) {
|
1126
|
-
return tslib.__awaiter(this, void 0, void 0, function* () {
|
1127
|
-
const endpoint = this.endpoint.endsWith("/") ? this.endpoint : this.endpoint + "/";
|
1128
|
-
const key = this.credential.key;
|
1129
|
-
const hub = this.hubName;
|
1130
|
-
const clientEndpoint = endpoint.replace(/(http)(s?:\/\/)/gi, "ws$2");
|
1131
|
-
const clientUrl = `${clientEndpoint}client/hubs/${hub}`;
|
1132
|
-
const audience = `${endpoint}client/hubs/${hub}`;
|
1133
|
-
const payload = { role: options === null || options === void 0 ? void 0 : options.roles };
|
1134
|
-
const signOptions = {
|
1135
|
-
audience: audience,
|
1136
|
-
expiresIn: (options === null || options === void 0 ? void 0 : options.ttl) === undefined ? "1h" : `${options.ttl}m`,
|
1137
|
-
algorithm: "HS256"
|
1138
|
-
};
|
1139
|
-
if (options === null || options === void 0 ? void 0 : options.userId) {
|
1140
|
-
signOptions.subject = options === null || options === void 0 ? void 0 : options.userId;
|
1783
|
+
}), (coreAuth.isTokenCredential(this.credential)
|
1784
|
+
? {
|
1785
|
+
credential: this.credential,
|
1786
|
+
credentialScopes: ["https://webpubsub.azure.com/.default"]
|
1141
1787
|
}
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
}
|
1788
|
+
: {}));
|
1789
|
+
this.client = new GeneratedClient(this.endpoint, internalPipelineOptions);
|
1790
|
+
if (!coreAuth.isTokenCredential(this.credential)) {
|
1791
|
+
this.client.pipeline.addPolicy(webPubSubKeyCredentialPolicy(this.credential));
|
1792
|
+
}
|
1793
|
+
if ((_a = this.clientOptions) === null || _a === void 0 ? void 0 : _a.reverseProxyEndpoint) {
|
1794
|
+
this.client.pipeline.addPolicy(webPubSubReverseProxyPolicy((_b = this.clientOptions) === null || _b === void 0 ? void 0 : _b.reverseProxyEndpoint));
|
1795
|
+
}
|
1150
1796
|
}
|
1151
1797
|
/**
|
1152
1798
|
* Get a client for a group
|
1153
|
-
* @param groupName The name of the group to connect to.
|
1799
|
+
* @param groupName - The name of the group to connect to.
|
1154
1800
|
*/
|
1155
1801
|
group(groupName) {
|
1156
1802
|
return new WebPubSubGroupImpl(this.client, this.hubName, groupName);
|
1157
1803
|
}
|
1158
|
-
sendToAll(message, options = {}) {
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
});
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
try {
|
1188
|
-
return yield this.client.webPubSub.sendToConnection(this.hubName, connectionId, contentType, contentType === "application/json" ? JSON.stringify(message) : message, updatedOptions);
|
1189
|
-
}
|
1190
|
-
finally {
|
1191
|
-
span.end();
|
1192
|
-
}
|
1193
|
-
});
|
1804
|
+
async sendToAll(message, options = {}) {
|
1805
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-sendToAll", options);
|
1806
|
+
const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
|
1807
|
+
try {
|
1808
|
+
return await this.client.webPubSub.sendToAll(this.hubName, contentType, payload, updatedOptions);
|
1809
|
+
}
|
1810
|
+
finally {
|
1811
|
+
span.end();
|
1812
|
+
}
|
1813
|
+
}
|
1814
|
+
async sendToUser(username, message, options = {}) {
|
1815
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-sendToUser", options);
|
1816
|
+
const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
|
1817
|
+
try {
|
1818
|
+
return await this.client.webPubSub.sendToUser(this.hubName, username, contentType, payload, updatedOptions);
|
1819
|
+
}
|
1820
|
+
finally {
|
1821
|
+
span.end();
|
1822
|
+
}
|
1823
|
+
}
|
1824
|
+
async sendToConnection(connectionId, message, options = {}) {
|
1825
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-sendToConnection", options);
|
1826
|
+
const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
|
1827
|
+
try {
|
1828
|
+
return await this.client.webPubSub.sendToConnection(this.hubName, connectionId, contentType, payload, updatedOptions);
|
1829
|
+
}
|
1830
|
+
finally {
|
1831
|
+
span.end();
|
1832
|
+
}
|
1194
1833
|
}
|
1195
1834
|
/**
|
1196
1835
|
* Check if a specific connection is connected to this hub
|
1197
1836
|
*
|
1198
|
-
* @param connectionId Connection id to check
|
1199
|
-
* @param options Additional options
|
1837
|
+
* @param connectionId - Connection id to check
|
1838
|
+
* @param options - Additional options
|
1200
1839
|
*/
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1840
|
+
async connectionExists(connectionId, options = {}) {
|
1841
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasConnection", options);
|
1842
|
+
let response;
|
1843
|
+
function onResponse(rawResponse, flatResponse) {
|
1844
|
+
response = rawResponse;
|
1845
|
+
if (updatedOptions.onResponse) {
|
1846
|
+
updatedOptions.onResponse(rawResponse, flatResponse);
|
1847
|
+
}
|
1848
|
+
}
|
1849
|
+
try {
|
1850
|
+
await this.client.webPubSub.connectionExists(this.hubName, connectionId, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
1851
|
+
if (response.status === 200) {
|
1852
|
+
return true;
|
1853
|
+
}
|
1854
|
+
else if (response.status === 404) {
|
1855
|
+
return false;
|
1216
1856
|
}
|
1217
|
-
|
1218
|
-
|
1857
|
+
else {
|
1858
|
+
// this is sad - wish this was handled by autorest.
|
1859
|
+
throw new coreRestPipeline.RestError(response.bodyAsText, {
|
1860
|
+
statusCode: response === null || response === void 0 ? void 0 : response.status,
|
1861
|
+
request: response === null || response === void 0 ? void 0 : response.request,
|
1862
|
+
response: response
|
1863
|
+
});
|
1219
1864
|
}
|
1220
|
-
}
|
1865
|
+
}
|
1866
|
+
finally {
|
1867
|
+
span.end();
|
1868
|
+
}
|
1221
1869
|
}
|
1222
1870
|
/**
|
1223
1871
|
* Close a specific connection to this hub
|
1224
1872
|
*
|
1225
|
-
* @param connectionId Connection id to close
|
1226
|
-
* @param options Additional options
|
1873
|
+
* @param connectionId - Connection id to close
|
1874
|
+
* @param options - Additional options
|
1227
1875
|
*/
|
1228
|
-
closeConnection(connectionId, options = {}) {
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1876
|
+
async closeConnection(connectionId, options = {}) {
|
1877
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-closeConnection", options);
|
1878
|
+
try {
|
1879
|
+
return await this.client.webPubSub.closeConnection(this.hubName, connectionId, updatedOptions);
|
1880
|
+
}
|
1881
|
+
finally {
|
1882
|
+
span.end();
|
1883
|
+
}
|
1884
|
+
}
|
1885
|
+
/**
|
1886
|
+
* Close all connections to this hub
|
1887
|
+
*
|
1888
|
+
* @param options - Additional options
|
1889
|
+
*/
|
1890
|
+
async closeAllConnections(options = {}) {
|
1891
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-closeAllConnections", options);
|
1892
|
+
try {
|
1893
|
+
return await this.client.webPubSub.closeAllConnections(this.hubName, updatedOptions);
|
1894
|
+
}
|
1895
|
+
finally {
|
1896
|
+
span.end();
|
1897
|
+
}
|
1898
|
+
}
|
1899
|
+
/**
|
1900
|
+
* Close all connections with the given user id
|
1901
|
+
*
|
1902
|
+
* @param user - User id to close
|
1903
|
+
* @param options - Additional options
|
1904
|
+
*/
|
1905
|
+
async closeUserConnections(userId, options = {}) {
|
1906
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-closeUserConnections", options);
|
1907
|
+
try {
|
1908
|
+
return await this.client.webPubSub.closeUserConnections(this.hubName, userId, updatedOptions);
|
1909
|
+
}
|
1910
|
+
finally {
|
1911
|
+
span.end();
|
1912
|
+
}
|
1238
1913
|
}
|
1239
1914
|
/**
|
1240
1915
|
* Remove a specific user from all groups they are joined to
|
1241
|
-
* @param userId The user id to remove from all groups
|
1242
|
-
* @param options Additional options
|
1916
|
+
* @param userId - The user id to remove from all groups
|
1917
|
+
* @param options - Additional options
|
1243
1918
|
*/
|
1244
|
-
removeUserFromAllGroups(userId, options = {}) {
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
}
|
1253
|
-
});
|
1919
|
+
async removeUserFromAllGroups(userId, options = {}) {
|
1920
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-removeUserFromAllGroups", options);
|
1921
|
+
try {
|
1922
|
+
await this.client.webPubSub.removeUserFromAllGroups(this.hubName, userId, updatedOptions);
|
1923
|
+
}
|
1924
|
+
finally {
|
1925
|
+
span.end();
|
1926
|
+
}
|
1254
1927
|
}
|
1255
1928
|
/**
|
1256
1929
|
* Check if a particular group exists (i.e. has active connections).
|
1257
1930
|
*
|
1258
|
-
* @param groupName The group name to check for
|
1259
|
-
* @param options Additional options
|
1931
|
+
* @param groupName - The group name to check for
|
1932
|
+
* @param options - Additional options
|
1260
1933
|
*/
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1934
|
+
async groupExists(groupName, options = {}) {
|
1935
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasGroup", options);
|
1936
|
+
let response;
|
1937
|
+
function onResponse(rawResponse, flatResponse) {
|
1938
|
+
response = rawResponse;
|
1939
|
+
if (updatedOptions.onResponse) {
|
1940
|
+
updatedOptions.onResponse(rawResponse, flatResponse);
|
1941
|
+
}
|
1942
|
+
}
|
1943
|
+
try {
|
1944
|
+
await this.client.webPubSub.groupExists(this.hubName, groupName, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
1945
|
+
if (response.status === 200) {
|
1946
|
+
return true;
|
1947
|
+
}
|
1948
|
+
else if (response.status === 404) {
|
1949
|
+
return false;
|
1275
1950
|
}
|
1276
|
-
|
1277
|
-
|
1951
|
+
else {
|
1952
|
+
throw new coreRestPipeline.RestError(response.bodyAsText, {
|
1953
|
+
statusCode: response === null || response === void 0 ? void 0 : response.status,
|
1954
|
+
request: response === null || response === void 0 ? void 0 : response.request,
|
1955
|
+
response: response
|
1956
|
+
});
|
1278
1957
|
}
|
1279
|
-
}
|
1958
|
+
}
|
1959
|
+
finally {
|
1960
|
+
span.end();
|
1961
|
+
}
|
1280
1962
|
}
|
1281
1963
|
/**
|
1282
1964
|
* Check if a particular user is connected to this hub.
|
1283
1965
|
*
|
1284
|
-
* @param username The user name to check for
|
1285
|
-
* @param options Additional options
|
1966
|
+
* @param username - The user name to check for
|
1967
|
+
* @param options - Additional options
|
1286
1968
|
*/
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1969
|
+
async userExists(username, options = {}) {
|
1970
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasUser", options);
|
1971
|
+
let response;
|
1972
|
+
function onResponse(rawResponse, flatResponse) {
|
1973
|
+
response = rawResponse;
|
1974
|
+
if (updatedOptions.onResponse) {
|
1975
|
+
updatedOptions.onResponse(rawResponse, flatResponse);
|
1976
|
+
}
|
1977
|
+
}
|
1978
|
+
try {
|
1979
|
+
await this.client.webPubSub.userExists(this.hubName, username, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
1980
|
+
if (response.status === 200) {
|
1981
|
+
return true;
|
1982
|
+
}
|
1983
|
+
else if (response.status === 404) {
|
1984
|
+
return false;
|
1302
1985
|
}
|
1303
|
-
|
1304
|
-
|
1986
|
+
else {
|
1987
|
+
// this is sad - wish this was handled by autorest.
|
1988
|
+
throw new coreRestPipeline.RestError(response.bodyAsText, {
|
1989
|
+
statusCode: response === null || response === void 0 ? void 0 : response.status,
|
1990
|
+
request: response === null || response === void 0 ? void 0 : response.request,
|
1991
|
+
response: response
|
1992
|
+
});
|
1305
1993
|
}
|
1306
|
-
}
|
1994
|
+
}
|
1995
|
+
finally {
|
1996
|
+
span.end();
|
1997
|
+
}
|
1307
1998
|
}
|
1308
1999
|
/**
|
1309
2000
|
* Grant permissions to a connection
|
1310
2001
|
*
|
1311
|
-
* @param connectionId The connection id to grant permissions to
|
1312
|
-
* @param Permission The permission to grant
|
1313
|
-
* @param options Additional options
|
2002
|
+
* @param connectionId - The connection id to grant permissions to
|
2003
|
+
* @param Permission - The permission to grant
|
2004
|
+
* @param options - Additional options
|
1314
2005
|
*/
|
1315
|
-
grantPermission(connectionId, permission, options = {}) {
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
}
|
1324
|
-
});
|
2006
|
+
async grantPermission(connectionId, permission, options = {}) {
|
2007
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-grantPermission", options);
|
2008
|
+
try {
|
2009
|
+
return await this.client.webPubSub.grantPermission(this.hubName, permission, connectionId, updatedOptions);
|
2010
|
+
}
|
2011
|
+
finally {
|
2012
|
+
span.end();
|
2013
|
+
}
|
1325
2014
|
}
|
1326
2015
|
/**
|
1327
2016
|
* Revoke permissions from a connection
|
1328
2017
|
*
|
1329
|
-
* @param connectionId The connection id to revoke permissions from
|
1330
|
-
* @param Permission The permission to revoke
|
1331
|
-
* @param options Additional options
|
2018
|
+
* @param connectionId - The connection id to revoke permissions from
|
2019
|
+
* @param Permission - The permission to revoke
|
2020
|
+
* @param options - Additional options
|
2021
|
+
*/
|
2022
|
+
async revokePermission(connectionId, permission, options = {}) {
|
2023
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-revokePermission", options);
|
2024
|
+
try {
|
2025
|
+
return await this.client.webPubSub.revokePermission(this.hubName, permission, connectionId, updatedOptions);
|
2026
|
+
}
|
2027
|
+
finally {
|
2028
|
+
span.end();
|
2029
|
+
}
|
2030
|
+
}
|
2031
|
+
/**
|
2032
|
+
* Check if the connection has the specified permission
|
2033
|
+
*
|
2034
|
+
* @param connectionId - The connection id to check permission
|
2035
|
+
* @param Permission - The permission to check
|
2036
|
+
* @param options - Additional options
|
1332
2037
|
*/
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
2038
|
+
async hasPermission(connectionId, permission, options = {}) {
|
2039
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasPermission", options);
|
2040
|
+
let response;
|
2041
|
+
function onResponse(rawResponse, flatResponse) {
|
2042
|
+
response = rawResponse;
|
2043
|
+
if (updatedOptions.onResponse) {
|
2044
|
+
updatedOptions.onResponse(rawResponse, flatResponse);
|
2045
|
+
}
|
2046
|
+
}
|
2047
|
+
try {
|
2048
|
+
await this.client.webPubSub.checkPermission(this.hubName, permission, connectionId, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
2049
|
+
if (response.status === 200) {
|
2050
|
+
return true;
|
2051
|
+
}
|
2052
|
+
else if (response.status === 404) {
|
2053
|
+
return false;
|
1338
2054
|
}
|
1339
|
-
|
1340
|
-
|
2055
|
+
else {
|
2056
|
+
// this is sad - wish this was handled by autorest.
|
2057
|
+
throw new coreRestPipeline.RestError(response.bodyAsText, {
|
2058
|
+
statusCode: response === null || response === void 0 ? void 0 : response.status,
|
2059
|
+
request: response === null || response === void 0 ? void 0 : response.request,
|
2060
|
+
response: response
|
2061
|
+
});
|
1341
2062
|
}
|
1342
|
-
}
|
2063
|
+
}
|
2064
|
+
finally {
|
2065
|
+
span.end();
|
2066
|
+
}
|
1343
2067
|
}
|
1344
2068
|
/**
|
1345
|
-
*
|
2069
|
+
* Generate a token for a client to connect to the Azure Web PubSub service.
|
1346
2070
|
*
|
1347
|
-
* @param
|
1348
|
-
* @param Permission The permission to check
|
1349
|
-
* @param options Additional options
|
2071
|
+
* @param options - Additional options
|
1350
2072
|
*/
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
2073
|
+
async getClientAccessToken(options = {}) {
|
2074
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-generateClientToken", options);
|
2075
|
+
try {
|
2076
|
+
const endpoint = this.endpoint.endsWith("/") ? this.endpoint : this.endpoint + "/";
|
2077
|
+
const clientEndpoint = endpoint.replace(/(http)(s?:\/\/)/gi, "ws$2");
|
2078
|
+
const baseUrl = `${clientEndpoint}client/hubs/${this.hubName}`;
|
2079
|
+
let token;
|
2080
|
+
if (coreAuth.isTokenCredential(this.credential)) {
|
2081
|
+
const response = await this.client.webPubSub.generateClientToken(this.hubName, updatedOptions);
|
2082
|
+
token = response.token;
|
1356
2083
|
}
|
1357
|
-
|
1358
|
-
|
2084
|
+
else {
|
2085
|
+
const key = this.credential.key;
|
2086
|
+
const audience = `${endpoint}client/hubs/${this.hubName}`;
|
2087
|
+
const payload = { role: options === null || options === void 0 ? void 0 : options.roles };
|
2088
|
+
const signOptions = {
|
2089
|
+
audience: audience,
|
2090
|
+
expiresIn: (options === null || options === void 0 ? void 0 : options.expirationTimeInMinutes) === undefined
|
2091
|
+
? "1h"
|
2092
|
+
: `${options.expirationTimeInMinutes}m`,
|
2093
|
+
algorithm: "HS256"
|
2094
|
+
};
|
2095
|
+
if (options === null || options === void 0 ? void 0 : options.userId) {
|
2096
|
+
signOptions.subject = options === null || options === void 0 ? void 0 : options.userId;
|
2097
|
+
}
|
2098
|
+
token = jwt.sign(payload, key, signOptions);
|
1359
2099
|
}
|
1360
|
-
|
2100
|
+
return {
|
2101
|
+
token,
|
2102
|
+
baseUrl,
|
2103
|
+
url: `${baseUrl}?access_token=${token}`
|
2104
|
+
};
|
2105
|
+
}
|
2106
|
+
finally {
|
2107
|
+
span.end();
|
2108
|
+
}
|
1361
2109
|
}
|
1362
2110
|
}
|
1363
2111
|
|