@azure/service-bus 7.6.0-beta.2 → 7.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +321 -55
- package/dist/index.js.map +1 -1
- package/dist-esm/src/core/managementClient.js +96 -50
- package/dist-esm/src/core/managementClient.js.map +1 -1
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/log.js +5 -0
- package/dist-esm/src/log.js.map +1 -1
- package/dist-esm/src/models.js.map +1 -1
- package/dist-esm/src/receivers/receiver.js +2 -2
- package/dist-esm/src/receivers/receiver.js.map +1 -1
- package/dist-esm/src/receivers/sessionReceiver.js +2 -2
- package/dist-esm/src/receivers/sessionReceiver.js.map +1 -1
- package/dist-esm/src/serializers/ruleResourceSerializer.js.map +1 -1
- package/dist-esm/src/serviceBusClient.js +14 -0
- package/dist-esm/src/serviceBusClient.js.map +1 -1
- package/dist-esm/src/serviceBusRuleManager.js +211 -0
- package/dist-esm/src/serviceBusRuleManager.js.map +1 -0
- package/dist-esm/src/util/constants.js +1 -1
- package/dist-esm/src/util/constants.js.map +1 -1
- package/dist-esm/src/util/typeGuards.js.map +1 -1
- package/package.json +8 -8
- package/types/3.1/service-bus.d.ts +68 -5
- package/types/latest/service-bus.d.ts +70 -5
- package/CHANGELOG.md +0 -647
package/dist/index.js
CHANGED
|
@@ -105,6 +105,11 @@ const receiverLogger = createServiceBusLogger("service-bus:receiver");
|
|
|
105
105
|
* @internal
|
|
106
106
|
*/
|
|
107
107
|
const senderLogger = createServiceBusLogger("service-bus:sender");
|
|
108
|
+
/**
|
|
109
|
+
* Logging for ServiceBusRuleManagers
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
const ruleManagerLogger = createServiceBusLogger("service-bus:rulemanager");
|
|
108
113
|
/**
|
|
109
114
|
* Logging for connection management
|
|
110
115
|
* @internal
|
|
@@ -176,7 +181,7 @@ function isError(err) {
|
|
|
176
181
|
*/
|
|
177
182
|
const packageJsonInfo = {
|
|
178
183
|
name: "@azure/service-bus",
|
|
179
|
-
version: "7.6.0
|
|
184
|
+
version: "7.6.0",
|
|
180
185
|
};
|
|
181
186
|
/**
|
|
182
187
|
* @internal
|
|
@@ -5359,6 +5364,16 @@ const errorInvalidMessageTypeSingleOrArray = "Provided value for 'messages' must
|
|
|
5359
5364
|
const errorInvalidMessageTypeSingle = "Provided value for 'message' must be of type: ServiceBusMessage or AmqpAnnotatedMessage.";
|
|
5360
5365
|
|
|
5361
5366
|
// Copyright (c) Microsoft Corporation.
|
|
5367
|
+
/**
|
|
5368
|
+
* @internal
|
|
5369
|
+
*/
|
|
5370
|
+
const sqlRuleProperties = ["sqlExpression"];
|
|
5371
|
+
function isSqlRuleFilter(obj) {
|
|
5372
|
+
if (obj) {
|
|
5373
|
+
return sqlRuleProperties.some((validProperty) => isObjectWithProperties(obj, [validProperty]));
|
|
5374
|
+
}
|
|
5375
|
+
return false;
|
|
5376
|
+
}
|
|
5362
5377
|
/**
|
|
5363
5378
|
* @internal
|
|
5364
5379
|
*/
|
|
@@ -5373,6 +5388,12 @@ const correlationProperties = [
|
|
|
5373
5388
|
"contentType",
|
|
5374
5389
|
"applicationProperties",
|
|
5375
5390
|
];
|
|
5391
|
+
function isCorrelationRuleFilter(obj) {
|
|
5392
|
+
if (obj) {
|
|
5393
|
+
return correlationProperties.some((validProperty) => isObjectWithProperties(obj, [validProperty]));
|
|
5394
|
+
}
|
|
5395
|
+
return false;
|
|
5396
|
+
}
|
|
5376
5397
|
/**
|
|
5377
5398
|
* @internal
|
|
5378
5399
|
* Describes the ServiceBus Management Client that talks
|
|
@@ -5458,6 +5479,18 @@ class ManagementClient extends LinkEntity {
|
|
|
5458
5479
|
? data[index].value
|
|
5459
5480
|
: undefined;
|
|
5460
5481
|
}
|
|
5482
|
+
_decodeApplicationPropertiesMap(obj) {
|
|
5483
|
+
if (!rheaPromise.types.is_map(obj)) {
|
|
5484
|
+
throw new Error("object to decode is not of Map types");
|
|
5485
|
+
}
|
|
5486
|
+
const array = obj.value;
|
|
5487
|
+
const result = {};
|
|
5488
|
+
for (let i = 0; i < array.length; i += 2) {
|
|
5489
|
+
const key = array[i].value;
|
|
5490
|
+
result[key] = array[i + 1].value;
|
|
5491
|
+
}
|
|
5492
|
+
return result;
|
|
5493
|
+
}
|
|
5461
5494
|
async _makeManagementRequest(request, internalLogger, sendRequestOptions = {}) {
|
|
5462
5495
|
var _a;
|
|
5463
5496
|
if (request.message_id === undefined) {
|
|
@@ -5531,10 +5564,11 @@ class ManagementClient extends LinkEntity {
|
|
|
5531
5564
|
* also fetch even Deferred messages (but not Deadlettered message).
|
|
5532
5565
|
*
|
|
5533
5566
|
* @param messageCount - The number of messages to retrieve. Default value `1`.
|
|
5567
|
+
* @param omitMessageBody - Whether to omit message body when peeking. Default value `false`.
|
|
5534
5568
|
*/
|
|
5535
|
-
async peek(messageCount, options) {
|
|
5569
|
+
async peek(messageCount, omitMessageBody, options) {
|
|
5536
5570
|
throwErrorIfConnectionClosed(this._context);
|
|
5537
|
-
return this.peekBySequenceNumber(this._lastPeekedSequenceNumber.add(1), messageCount, undefined, options);
|
|
5571
|
+
return this.peekBySequenceNumber(this._lastPeekedSequenceNumber.add(1), messageCount, undefined, omitMessageBody, options);
|
|
5538
5572
|
}
|
|
5539
5573
|
/**
|
|
5540
5574
|
* Fetches the next batch of active messages in the current MessageSession. The first call to
|
|
@@ -5547,10 +5581,11 @@ class ManagementClient extends LinkEntity {
|
|
|
5547
5581
|
*
|
|
5548
5582
|
* @param sessionId - The sessionId from which messages need to be peeked.
|
|
5549
5583
|
* @param messageCount - The number of messages to retrieve. Default value `1`.
|
|
5584
|
+
* @param omitMessageBody - Whether to omit message body when peeking Default value `false`.
|
|
5550
5585
|
*/
|
|
5551
|
-
async peekMessagesBySession(sessionId, messageCount, options) {
|
|
5586
|
+
async peekMessagesBySession(sessionId, messageCount, omitMessageBody, options) {
|
|
5552
5587
|
throwErrorIfConnectionClosed(this._context);
|
|
5553
|
-
return this.peekBySequenceNumber(this._lastPeekedSequenceNumber.add(1), messageCount, sessionId, options);
|
|
5588
|
+
return this.peekBySequenceNumber(this._lastPeekedSequenceNumber.add(1), messageCount, sessionId, omitMessageBody, options);
|
|
5554
5589
|
}
|
|
5555
5590
|
/**
|
|
5556
5591
|
* Peeks the desired number of messages from the specified sequence number.
|
|
@@ -5558,8 +5593,9 @@ class ManagementClient extends LinkEntity {
|
|
|
5558
5593
|
* @param fromSequenceNumber - The sequence number from where to read the message.
|
|
5559
5594
|
* @param messageCount - The number of messages to retrieve. Default value `1`.
|
|
5560
5595
|
* @param sessionId - The sessionId from which messages need to be peeked.
|
|
5596
|
+
* @param omitMessageBody - Whether to omit message body when peeking. Default value `false`.
|
|
5561
5597
|
*/
|
|
5562
|
-
async peekBySequenceNumber(fromSequenceNumber, maxMessageCount, sessionId, options) {
|
|
5598
|
+
async peekBySequenceNumber(fromSequenceNumber, maxMessageCount, sessionId, omitMessageBody, options) {
|
|
5563
5599
|
var _a;
|
|
5564
5600
|
throwErrorIfConnectionClosed(this._context);
|
|
5565
5601
|
const connId = this._context.connectionId;
|
|
@@ -5580,6 +5616,10 @@ class ManagementClient extends LinkEntity {
|
|
|
5580
5616
|
if (isDefined(sessionId)) {
|
|
5581
5617
|
messageBody[coreAmqp.Constants.sessionIdMapKey] = sessionId;
|
|
5582
5618
|
}
|
|
5619
|
+
if (isDefined(omitMessageBody)) {
|
|
5620
|
+
const omitMessageBodyKey = "omit-message-body"; // TODO: Service Bus specific. Put it somewhere
|
|
5621
|
+
messageBody[omitMessageBodyKey] = rheaPromise.types.wrap_boolean(omitMessageBody);
|
|
5622
|
+
}
|
|
5583
5623
|
const request = {
|
|
5584
5624
|
body: messageBody,
|
|
5585
5625
|
reply_to: this.replyTo,
|
|
@@ -6063,8 +6103,10 @@ class ManagementClient extends LinkEntity {
|
|
|
6063
6103
|
try {
|
|
6064
6104
|
const request = {
|
|
6065
6105
|
body: {
|
|
6066
|
-
top:
|
|
6067
|
-
|
|
6106
|
+
top: (options === null || options === void 0 ? void 0 : options.maxCount)
|
|
6107
|
+
? rheaPromise.types.wrap_int(options.maxCount)
|
|
6108
|
+
: rheaPromise.types.wrap_int(max32BitNumber),
|
|
6109
|
+
skip: (options === null || options === void 0 ? void 0 : options.skip) ? rheaPromise.types.wrap_int(options.skip) : rheaPromise.types.wrap_int(0),
|
|
6068
6110
|
},
|
|
6069
6111
|
reply_to: this.replyTo,
|
|
6070
6112
|
application_properties: {
|
|
@@ -6084,6 +6126,7 @@ class ManagementClient extends LinkEntity {
|
|
|
6084
6126
|
const rules = [];
|
|
6085
6127
|
result.forEach((x) => {
|
|
6086
6128
|
const ruleDescriptor = x["rule-description"];
|
|
6129
|
+
let filter;
|
|
6087
6130
|
// We use the first three elements of the `ruleDescriptor.value` to get filter, action, name
|
|
6088
6131
|
if (!ruleDescriptor ||
|
|
6089
6132
|
!ruleDescriptor.descriptor ||
|
|
@@ -6094,21 +6137,35 @@ class ManagementClient extends LinkEntity {
|
|
|
6094
6137
|
}
|
|
6095
6138
|
const filtersRawData = ruleDescriptor.value[0];
|
|
6096
6139
|
const actionsRawData = ruleDescriptor.value[1];
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6140
|
+
let sqlRuleAction;
|
|
6141
|
+
if (actionsRawData.descriptor.value === coreAmqp.Constants.descriptorCodes.sqlRuleActionList &&
|
|
6142
|
+
Array.isArray(actionsRawData.value) &&
|
|
6143
|
+
actionsRawData.value.length) {
|
|
6144
|
+
sqlRuleAction = {
|
|
6145
|
+
sqlExpression: this._safelyGetTypedValueFromArray(actionsRawData.value, 0),
|
|
6146
|
+
};
|
|
6147
|
+
}
|
|
6148
|
+
else {
|
|
6149
|
+
sqlRuleAction = {};
|
|
6150
|
+
}
|
|
6100
6151
|
switch (filtersRawData.descriptor.value) {
|
|
6101
6152
|
case coreAmqp.Constants.descriptorCodes.trueFilterList:
|
|
6102
|
-
|
|
6153
|
+
filter = {
|
|
6154
|
+
sqlExpression: "1=1",
|
|
6155
|
+
};
|
|
6103
6156
|
break;
|
|
6104
6157
|
case coreAmqp.Constants.descriptorCodes.falseFilterList:
|
|
6105
|
-
|
|
6158
|
+
filter = {
|
|
6159
|
+
sqlExpression: "1=0",
|
|
6160
|
+
};
|
|
6106
6161
|
break;
|
|
6107
6162
|
case coreAmqp.Constants.descriptorCodes.sqlFilterList:
|
|
6108
|
-
|
|
6163
|
+
filter = {
|
|
6164
|
+
sqlExpression: this._safelyGetTypedValueFromArray(filtersRawData.value, 0),
|
|
6165
|
+
};
|
|
6109
6166
|
break;
|
|
6110
6167
|
case coreAmqp.Constants.descriptorCodes.correlationFilterList:
|
|
6111
|
-
|
|
6168
|
+
filter = {
|
|
6112
6169
|
correlationId: this._safelyGetTypedValueFromArray(filtersRawData.value, 0),
|
|
6113
6170
|
messageId: this._safelyGetTypedValueFromArray(filtersRawData.value, 1),
|
|
6114
6171
|
to: this._safelyGetTypedValueFromArray(filtersRawData.value, 2),
|
|
@@ -6117,18 +6174,21 @@ class ManagementClient extends LinkEntity {
|
|
|
6117
6174
|
sessionId: this._safelyGetTypedValueFromArray(filtersRawData.value, 5),
|
|
6118
6175
|
replyToSessionId: this._safelyGetTypedValueFromArray(filtersRawData.value, 6),
|
|
6119
6176
|
contentType: this._safelyGetTypedValueFromArray(filtersRawData.value, 7),
|
|
6120
|
-
applicationProperties:
|
|
6177
|
+
applicationProperties: Array.isArray(filtersRawData.value) &&
|
|
6178
|
+
filtersRawData.value.length > 8 &&
|
|
6179
|
+
filtersRawData.value[8]
|
|
6180
|
+
? this._decodeApplicationPropertiesMap(filtersRawData.value[8])
|
|
6181
|
+
: undefined,
|
|
6121
6182
|
};
|
|
6122
6183
|
break;
|
|
6123
6184
|
default:
|
|
6124
|
-
|
|
6125
|
-
break;
|
|
6126
|
-
}
|
|
6127
|
-
if (actionsRawData.descriptor.value === coreAmqp.Constants.descriptorCodes.sqlRuleActionList &&
|
|
6128
|
-
Array.isArray(actionsRawData.value) &&
|
|
6129
|
-
actionsRawData.value.length) {
|
|
6130
|
-
rule.action = this._safelyGetTypedValueFromArray(actionsRawData.value, 0);
|
|
6185
|
+
throw new Error(`${this.logPrefix} Found unexpected descriptor code for the filter: ${filtersRawData.descriptor.value}`);
|
|
6131
6186
|
}
|
|
6187
|
+
const rule = {
|
|
6188
|
+
name: ruleDescriptor.value[2].value,
|
|
6189
|
+
filter,
|
|
6190
|
+
action: sqlRuleAction,
|
|
6191
|
+
};
|
|
6132
6192
|
rules.push(rule);
|
|
6133
6193
|
});
|
|
6134
6194
|
return rules;
|
|
@@ -6179,37 +6239,28 @@ class ManagementClient extends LinkEntity {
|
|
|
6179
6239
|
ruleName = String(ruleName);
|
|
6180
6240
|
throwTypeErrorIfParameterIsEmptyString(this._context.connectionId, "ruleName", ruleName);
|
|
6181
6241
|
throwTypeErrorIfParameterMissing(this._context.connectionId, "filter", filter);
|
|
6182
|
-
if (
|
|
6183
|
-
|
|
6184
|
-
!correlationProperties.some((validProperty) => isObjectWithProperties(filter, [validProperty]))) {
|
|
6185
|
-
throw new TypeError(`The parameter "filter" should be either a boolean, string or implement the CorrelationRuleFilter interface.`);
|
|
6242
|
+
if (!isSqlRuleFilter(filter) && !isCorrelationRuleFilter(filter)) {
|
|
6243
|
+
throw new TypeError(`The parameter "filter" should implement either the SqlRuleFilter or the CorrelationRuleFilter interface.`);
|
|
6186
6244
|
}
|
|
6187
6245
|
try {
|
|
6188
6246
|
const ruleDescription = {};
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
subject: filter.subject,
|
|
6207
|
-
"session-id": filter.sessionId,
|
|
6208
|
-
"reply-to-session-id": filter.replyToSessionId,
|
|
6209
|
-
"content-type": filter.contentType,
|
|
6210
|
-
applicationProperties: filter.applicationProperties,
|
|
6211
|
-
};
|
|
6212
|
-
break;
|
|
6247
|
+
if (isSqlRuleFilter(filter)) {
|
|
6248
|
+
ruleDescription["sql-filter"] = {
|
|
6249
|
+
expression: filter.sqlExpression,
|
|
6250
|
+
};
|
|
6251
|
+
}
|
|
6252
|
+
else {
|
|
6253
|
+
ruleDescription["correlation-filter"] = {
|
|
6254
|
+
"correlation-id": filter.correlationId,
|
|
6255
|
+
"message-id": filter.messageId,
|
|
6256
|
+
to: filter.to,
|
|
6257
|
+
"reply-to": filter.replyTo,
|
|
6258
|
+
label: filter.subject,
|
|
6259
|
+
"session-id": filter.sessionId,
|
|
6260
|
+
"reply-to-session-id": filter.replyToSessionId,
|
|
6261
|
+
"content-type": filter.contentType,
|
|
6262
|
+
properties: filter.applicationProperties,
|
|
6263
|
+
};
|
|
6213
6264
|
}
|
|
6214
6265
|
if (sqlRuleActionExpression !== undefined) {
|
|
6215
6266
|
ruleDescription["sql-rule-action"] = {
|
|
@@ -8432,12 +8483,12 @@ class ServiceBusReceiverImpl {
|
|
|
8432
8483
|
if (options.fromSequenceNumber) {
|
|
8433
8484
|
return this._context
|
|
8434
8485
|
.getManagementClient(this.entityPath)
|
|
8435
|
-
.peekBySequenceNumber(options.fromSequenceNumber, maxMessageCount, undefined, managementRequestOptions);
|
|
8486
|
+
.peekBySequenceNumber(options.fromSequenceNumber, maxMessageCount, undefined, options.omitMessageBody, managementRequestOptions);
|
|
8436
8487
|
}
|
|
8437
8488
|
else {
|
|
8438
8489
|
return this._context
|
|
8439
8490
|
.getManagementClient(this.entityPath)
|
|
8440
|
-
.peek(maxMessageCount, managementRequestOptions);
|
|
8491
|
+
.peek(maxMessageCount, options.omitMessageBody, managementRequestOptions);
|
|
8441
8492
|
}
|
|
8442
8493
|
};
|
|
8443
8494
|
const config = {
|
|
@@ -8740,12 +8791,12 @@ class ServiceBusSessionReceiverImpl {
|
|
|
8740
8791
|
if (options.fromSequenceNumber) {
|
|
8741
8792
|
return this._context
|
|
8742
8793
|
.getManagementClient(this.entityPath)
|
|
8743
|
-
.peekBySequenceNumber(options.fromSequenceNumber, maxMessageCount, this.sessionId, managementRequestOptions);
|
|
8794
|
+
.peekBySequenceNumber(options.fromSequenceNumber, maxMessageCount, this.sessionId, options.omitMessageBody, managementRequestOptions);
|
|
8744
8795
|
}
|
|
8745
8796
|
else {
|
|
8746
8797
|
return this._context
|
|
8747
8798
|
.getManagementClient(this.entityPath)
|
|
8748
|
-
.peekMessagesBySession(this.sessionId, maxMessageCount, managementRequestOptions);
|
|
8799
|
+
.peekMessagesBySession(this.sessionId, maxMessageCount, options.omitMessageBody, managementRequestOptions);
|
|
8749
8800
|
}
|
|
8750
8801
|
};
|
|
8751
8802
|
const config = {
|
|
@@ -8915,6 +8966,208 @@ class ServiceBusSessionReceiverImpl {
|
|
|
8915
8966
|
}
|
|
8916
8967
|
}
|
|
8917
8968
|
|
|
8969
|
+
// Copyright (c) Microsoft Corporation.
|
|
8970
|
+
/**
|
|
8971
|
+
* @internal
|
|
8972
|
+
*/
|
|
8973
|
+
class ServiceBusRuleManagerImpl {
|
|
8974
|
+
/**
|
|
8975
|
+
* @internal
|
|
8976
|
+
* @throws Error if the underlying connection is closed.
|
|
8977
|
+
*/
|
|
8978
|
+
constructor(_context, _entityPath, _retryOptions = {}) {
|
|
8979
|
+
this._context = _context;
|
|
8980
|
+
this._entityPath = _entityPath;
|
|
8981
|
+
this._retryOptions = _retryOptions;
|
|
8982
|
+
/**
|
|
8983
|
+
* Denotes if close() was called on this sender
|
|
8984
|
+
*/
|
|
8985
|
+
this._isClosed = false;
|
|
8986
|
+
throwErrorIfConnectionClosed(_context);
|
|
8987
|
+
this.entityPath = _entityPath;
|
|
8988
|
+
this.name = getUniqueName("ruleManager");
|
|
8989
|
+
}
|
|
8990
|
+
get isClosed() {
|
|
8991
|
+
return this._isClosed || this._context.wasConnectionCloseCalled;
|
|
8992
|
+
}
|
|
8993
|
+
async createRule(ruleName, filter, ruleActionOrOperationOptions, options) {
|
|
8994
|
+
let sqlRuleAction = undefined;
|
|
8995
|
+
let operOptions;
|
|
8996
|
+
if (ruleActionOrOperationOptions) {
|
|
8997
|
+
if (isSqlRuleAction(ruleActionOrOperationOptions)) {
|
|
8998
|
+
// Overload#2 - where the sqlExpression in the ruleAction is defined
|
|
8999
|
+
sqlRuleAction = ruleActionOrOperationOptions;
|
|
9000
|
+
operOptions = options;
|
|
9001
|
+
}
|
|
9002
|
+
else {
|
|
9003
|
+
// Overload#1 - where the sqlExpression in the ruleAction is undefined
|
|
9004
|
+
operOptions = Object.assign(Object.assign({}, ruleActionOrOperationOptions), options);
|
|
9005
|
+
}
|
|
9006
|
+
}
|
|
9007
|
+
const { span } = createServiceBusSpan("ServiceBusRuleManager.createRule", operOptions, this.entityPath, this._context.config.host, {
|
|
9008
|
+
kind: coreTracing.SpanKind.CLIENT,
|
|
9009
|
+
});
|
|
9010
|
+
try {
|
|
9011
|
+
const addRuleOperationPromise = async () => {
|
|
9012
|
+
return this._context
|
|
9013
|
+
.getManagementClient(this._entityPath)
|
|
9014
|
+
.addRule(ruleName, filter, sqlRuleAction === null || sqlRuleAction === void 0 ? void 0 : sqlRuleAction.sqlExpression, Object.assign(Object.assign({}, operOptions), { associatedLinkName: this.name, requestName: "addRule", timeoutInMs: this._retryOptions.timeoutInMs }));
|
|
9015
|
+
};
|
|
9016
|
+
const config = {
|
|
9017
|
+
operation: addRuleOperationPromise,
|
|
9018
|
+
connectionId: this._context.connectionId,
|
|
9019
|
+
operationType: coreAmqp.RetryOperationType.management,
|
|
9020
|
+
retryOptions: this._retryOptions,
|
|
9021
|
+
abortSignal: operOptions === null || operOptions === void 0 ? void 0 : operOptions.abortSignal,
|
|
9022
|
+
};
|
|
9023
|
+
const result = coreAmqp.retry(config);
|
|
9024
|
+
span.setStatus({ code: coreTracing.SpanStatusCode.OK });
|
|
9025
|
+
return result;
|
|
9026
|
+
}
|
|
9027
|
+
catch (error) {
|
|
9028
|
+
span.setStatus({
|
|
9029
|
+
code: coreTracing.SpanStatusCode.ERROR,
|
|
9030
|
+
message: error.message,
|
|
9031
|
+
});
|
|
9032
|
+
throw error;
|
|
9033
|
+
}
|
|
9034
|
+
finally {
|
|
9035
|
+
span.end();
|
|
9036
|
+
}
|
|
9037
|
+
}
|
|
9038
|
+
/**
|
|
9039
|
+
* Get all rules associated with the subscription.
|
|
9040
|
+
*/
|
|
9041
|
+
async getRules(options) {
|
|
9042
|
+
const { span } = createServiceBusSpan("ServiceBusRuleManager.getRules", options, this.entityPath, this._context.config.host, {
|
|
9043
|
+
kind: coreTracing.SpanKind.CLIENT,
|
|
9044
|
+
});
|
|
9045
|
+
try {
|
|
9046
|
+
const getRulesOperationPromise = async () => {
|
|
9047
|
+
return this._context.getManagementClient(this._entityPath).getRules(Object.assign(Object.assign({}, options), { associatedLinkName: this.name, requestName: "getRules", timeoutInMs: this._retryOptions.timeoutInMs }));
|
|
9048
|
+
};
|
|
9049
|
+
const config = {
|
|
9050
|
+
operation: getRulesOperationPromise,
|
|
9051
|
+
connectionId: this._context.connectionId,
|
|
9052
|
+
operationType: coreAmqp.RetryOperationType.management,
|
|
9053
|
+
retryOptions: this._retryOptions,
|
|
9054
|
+
abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal,
|
|
9055
|
+
};
|
|
9056
|
+
const result = coreAmqp.retry(config);
|
|
9057
|
+
span.setStatus({ code: coreTracing.SpanStatusCode.OK });
|
|
9058
|
+
return result;
|
|
9059
|
+
}
|
|
9060
|
+
catch (error) {
|
|
9061
|
+
span.setStatus({
|
|
9062
|
+
code: coreTracing.SpanStatusCode.ERROR,
|
|
9063
|
+
message: error.message,
|
|
9064
|
+
});
|
|
9065
|
+
throw error;
|
|
9066
|
+
}
|
|
9067
|
+
finally {
|
|
9068
|
+
span.end();
|
|
9069
|
+
}
|
|
9070
|
+
}
|
|
9071
|
+
listRulesPage(marker, options = {}) {
|
|
9072
|
+
var _a;
|
|
9073
|
+
return tslib.__asyncGenerator(this, arguments, function* listRulesPage_1() {
|
|
9074
|
+
do {
|
|
9075
|
+
const rules = yield tslib.__await(this.getRules(Object.assign({ skip: Number(marker), maxCount: (_a = options.maxPageSize) !== null && _a !== void 0 ? _a : 100 }, options)));
|
|
9076
|
+
if (rules.length > 0) {
|
|
9077
|
+
yield yield tslib.__await(rules);
|
|
9078
|
+
marker = String(Number(marker !== null && marker !== void 0 ? marker : 0) + rules.length);
|
|
9079
|
+
}
|
|
9080
|
+
else {
|
|
9081
|
+
break;
|
|
9082
|
+
}
|
|
9083
|
+
} while (marker);
|
|
9084
|
+
});
|
|
9085
|
+
}
|
|
9086
|
+
listRulesAll(options = {}) {
|
|
9087
|
+
return tslib.__asyncGenerator(this, arguments, function* listRulesAll_1() {
|
|
9088
|
+
var e_1, _a;
|
|
9089
|
+
let marker;
|
|
9090
|
+
try {
|
|
9091
|
+
for (var _b = tslib.__asyncValues(this.listRulesPage(marker, options)), _c; _c = yield tslib.__await(_b.next()), !_c.done;) {
|
|
9092
|
+
const segment = _c.value;
|
|
9093
|
+
yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(segment)));
|
|
9094
|
+
}
|
|
9095
|
+
}
|
|
9096
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
9097
|
+
finally {
|
|
9098
|
+
try {
|
|
9099
|
+
if (_c && !_c.done && (_a = _b.return)) yield tslib.__await(_a.call(_b));
|
|
9100
|
+
}
|
|
9101
|
+
finally { if (e_1) throw e_1.error; }
|
|
9102
|
+
}
|
|
9103
|
+
});
|
|
9104
|
+
}
|
|
9105
|
+
/**
|
|
9106
|
+
* Returns an async iterable iterator to list all the rules
|
|
9107
|
+
* under the specified subscription.
|
|
9108
|
+
*
|
|
9109
|
+
* .byPage() returns an async iterable iterator to list the rules in pages.
|
|
9110
|
+
*
|
|
9111
|
+
* @returns An asyncIterableIterator that supports paging.
|
|
9112
|
+
*/
|
|
9113
|
+
listRules(
|
|
9114
|
+
// eslint-disable-next-line @azure/azure-sdk/ts-naming-options
|
|
9115
|
+
options) {
|
|
9116
|
+
ruleManagerLogger.verbose(`Performing operation - listRules() with options: %j`, options);
|
|
9117
|
+
const iter = this.listRulesAll(options);
|
|
9118
|
+
return {
|
|
9119
|
+
/**
|
|
9120
|
+
*/
|
|
9121
|
+
next() {
|
|
9122
|
+
return iter.next();
|
|
9123
|
+
},
|
|
9124
|
+
/**
|
|
9125
|
+
*/
|
|
9126
|
+
[Symbol.asyncIterator]() {
|
|
9127
|
+
return this;
|
|
9128
|
+
},
|
|
9129
|
+
/**
|
|
9130
|
+
*/
|
|
9131
|
+
byPage: (settings = {}) => {
|
|
9132
|
+
return this.listRulesPage(undefined, Object.assign({ maxPageSize: settings.maxPageSize }, options));
|
|
9133
|
+
},
|
|
9134
|
+
};
|
|
9135
|
+
}
|
|
9136
|
+
/**
|
|
9137
|
+
* Deletes a rule.
|
|
9138
|
+
*/
|
|
9139
|
+
async deleteRule(ruleName, options) {
|
|
9140
|
+
const { span } = createServiceBusSpan("ServiceBusRuleManager.deleteRule", options, this.entityPath, this._context.config.host, {
|
|
9141
|
+
kind: coreTracing.SpanKind.CLIENT,
|
|
9142
|
+
});
|
|
9143
|
+
try {
|
|
9144
|
+
const removeRuleOperationPromise = async () => {
|
|
9145
|
+
return this._context.getManagementClient(this._entityPath).removeRule(ruleName, Object.assign(Object.assign({}, options), { associatedLinkName: this.name, requestName: "removeRule", timeoutInMs: this._retryOptions.timeoutInMs }));
|
|
9146
|
+
};
|
|
9147
|
+
const config = {
|
|
9148
|
+
operation: removeRuleOperationPromise,
|
|
9149
|
+
connectionId: this._context.connectionId,
|
|
9150
|
+
operationType: coreAmqp.RetryOperationType.management,
|
|
9151
|
+
retryOptions: this._retryOptions,
|
|
9152
|
+
abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal,
|
|
9153
|
+
};
|
|
9154
|
+
const result = coreAmqp.retry(config);
|
|
9155
|
+
span.setStatus({ code: coreTracing.SpanStatusCode.OK });
|
|
9156
|
+
return result;
|
|
9157
|
+
}
|
|
9158
|
+
catch (error) {
|
|
9159
|
+
span.setStatus({
|
|
9160
|
+
code: coreTracing.SpanStatusCode.ERROR,
|
|
9161
|
+
message: error.message,
|
|
9162
|
+
});
|
|
9163
|
+
throw error;
|
|
9164
|
+
}
|
|
9165
|
+
finally {
|
|
9166
|
+
span.end();
|
|
9167
|
+
}
|
|
9168
|
+
}
|
|
9169
|
+
}
|
|
9170
|
+
|
|
8918
9171
|
// Copyright (c) Microsoft Corporation.
|
|
8919
9172
|
/**
|
|
8920
9173
|
* @internal
|
|
@@ -10132,6 +10385,19 @@ class ServiceBusClient {
|
|
|
10132
10385
|
: 5 * 60 * 1000;
|
|
10133
10386
|
return new ServiceBusReceiverImpl(this._connectionContext, entityPathWithSubQueue, receiveMode, maxLockAutoRenewDurationInMs, (_a = options === null || options === void 0 ? void 0 : options.skipParsingBodyAsJson) !== null && _a !== void 0 ? _a : false, this._clientOptions.retryOptions);
|
|
10134
10387
|
}
|
|
10388
|
+
/**
|
|
10389
|
+
* Creates an instance of {@link ServiceBusRuleManager} that is used to manage
|
|
10390
|
+
* the rules for a subscription.
|
|
10391
|
+
*
|
|
10392
|
+
* @param topicName - the topic to create {@link ServiceBusRuleManager}
|
|
10393
|
+
* @param subscriptionName - the subscription specific to the specified topic to create a {@link ServiceBusRuleManager} for.
|
|
10394
|
+
* @returns a {@link ServiceBusRuleManager} scoped to the specified subscription and topic.
|
|
10395
|
+
*/
|
|
10396
|
+
createRuleManager(topicName, subscriptionName) {
|
|
10397
|
+
validateEntityPath(this._connectionContext.config, topicName);
|
|
10398
|
+
const { entityPath } = extractReceiverArguments(topicName, subscriptionName);
|
|
10399
|
+
return new ServiceBusRuleManagerImpl(this._connectionContext, entityPath, this._clientOptions.retryOptions);
|
|
10400
|
+
}
|
|
10135
10401
|
async acceptSession(queueOrTopicName1, optionsOrSubscriptionNameOrSessionId2, optionsOrSessionId3,
|
|
10136
10402
|
// eslint-disable-next-line @azure/azure-sdk/ts-naming-options
|
|
10137
10403
|
options4) {
|