@azure/notification-hubs 1.0.0-beta.4 → 1.0.0-beta.6
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/README.md +28 -44
- package/dist/index.cjs +421 -307
- package/dist/index.cjs.map +1 -1
- package/dist-esm/src/client/beginSubmitNotificationHubJob.js +131 -0
- package/dist-esm/src/client/beginSubmitNotificationHubJob.js.map +1 -0
- package/dist-esm/src/client/cancelScheduledNotification.js +1 -1
- package/dist-esm/src/client/cancelScheduledNotification.js.map +1 -1
- package/dist-esm/src/client/createOrUpdateInstallation.js +1 -1
- package/dist-esm/src/client/createOrUpdateInstallation.js.map +1 -1
- package/dist-esm/src/client/createOrUpdateRegistration.js +1 -1
- package/dist-esm/src/client/createOrUpdateRegistration.js.map +1 -1
- package/dist-esm/src/client/createRegistration.js +1 -1
- package/dist-esm/src/client/createRegistration.js.map +1 -1
- package/dist-esm/src/client/createRegistrationId.js +1 -1
- package/dist-esm/src/client/createRegistrationId.js.map +1 -1
- package/dist-esm/src/client/deleteInstallation.js +1 -1
- package/dist-esm/src/client/deleteInstallation.js.map +1 -1
- package/dist-esm/src/client/deleteRegistration.js +1 -1
- package/dist-esm/src/client/deleteRegistration.js.map +1 -1
- package/dist-esm/src/client/getFeedbackContainerUrl.js +1 -1
- package/dist-esm/src/client/getFeedbackContainerUrl.js.map +1 -1
- package/dist-esm/src/client/getInstallation.js +1 -1
- package/dist-esm/src/client/getInstallation.js.map +1 -1
- package/dist-esm/src/client/getNotificationHubJob.js +1 -1
- package/dist-esm/src/client/getNotificationHubJob.js.map +1 -1
- package/dist-esm/src/client/getNotificationOutcomeDetails.js +1 -1
- package/dist-esm/src/client/getNotificationOutcomeDetails.js.map +1 -1
- package/dist-esm/src/client/getRegistration.js +1 -1
- package/dist-esm/src/client/getRegistration.js.map +1 -1
- package/dist-esm/src/client/index.js +2 -2
- package/dist-esm/src/client/index.js.map +1 -1
- package/dist-esm/src/client/listNotificationHubJobs.js +1 -1
- package/dist-esm/src/client/listNotificationHubJobs.js.map +1 -1
- package/dist-esm/src/client/listRegistrations.js +1 -1
- package/dist-esm/src/client/listRegistrations.js.map +1 -1
- package/dist-esm/src/client/listRegistrationsByTag.js +1 -1
- package/dist-esm/src/client/listRegistrationsByTag.js.map +1 -1
- package/dist-esm/src/client/scheduleNotification.js +20 -6
- package/dist-esm/src/client/scheduleNotification.js.map +1 -1
- package/dist-esm/src/client/sendNotification.js +53 -6
- package/dist-esm/src/client/sendNotification.js.map +1 -1
- package/dist-esm/src/client/submitNotificationHubJob.js +1 -1
- package/dist-esm/src/client/submitNotificationHubJob.js.map +1 -1
- package/dist-esm/src/client/updateInstallation.js +1 -1
- package/dist-esm/src/client/updateInstallation.js.map +1 -1
- package/dist-esm/src/client/updateRegistration.js +1 -1
- package/dist-esm/src/client/updateRegistration.js.map +1 -1
- package/dist-esm/src/models/notificationHubJob.js.map +1 -1
- package/dist-esm/src/models/options.js.map +1 -1
- package/dist-esm/src/notificationHubsClient.js +27 -45
- package/dist-esm/src/notificationHubsClient.js.map +1 -1
- package/dist-esm/src/serializers/notificationDetailsSerializer.js +2 -1
- package/dist-esm/src/serializers/notificationDetailsSerializer.js.map +1 -1
- package/dist-esm/src/serializers/notificationHubJobSerializer.js +5 -2
- package/dist-esm/src/serializers/notificationHubJobSerializer.js.map +1 -1
- package/dist-esm/src/serializers/registrationSerializer.js +2 -1
- package/dist-esm/src/serializers/registrationSerializer.js.map +1 -1
- package/dist-esm/src/utils/constants.js +1 -1
- package/dist-esm/src/utils/constants.js.map +1 -1
- package/dist-esm/src/utils/notificationUtils.js +25 -0
- package/dist-esm/src/utils/notificationUtils.js.map +1 -0
- package/dist-esm/src/utils/optionUtils.js +20 -0
- package/dist-esm/src/utils/optionUtils.js.map +1 -0
- package/package.json +6 -5
- package/types/3.1/notification-hubs.d.ts +60 -36
- package/types/latest/notification-hubs.d.ts +64 -36
- package/types/latest/tsdoc-metadata.json +1 -1
- package/types/src/client/beginSubmitNotificationHubJob.d.ts +12 -0
- package/types/src/client/beginSubmitNotificationHubJob.d.ts.map +1 -0
- package/types/src/client/index.d.ts +1 -1
- package/types/src/client/index.d.ts.map +1 -1
- package/types/src/client/scheduleNotification.d.ts +3 -5
- package/types/src/client/scheduleNotification.d.ts.map +1 -1
- package/types/src/client/sendNotification.d.ts +3 -5
- package/types/src/client/sendNotification.d.ts.map +1 -1
- package/types/src/models/notificationHubJob.d.ts +5 -0
- package/types/src/models/notificationHubJob.d.ts.map +1 -1
- package/types/src/models/options.d.ts +36 -2
- package/types/src/models/options.d.ts.map +1 -1
- package/types/src/notificationHubsClient.d.ts +22 -37
- package/types/src/notificationHubsClient.d.ts.map +1 -1
- package/types/src/serializers/notificationHubJobSerializer.d.ts.map +1 -1
- package/types/src/serializers/registrationSerializer.d.ts.map +1 -1
- package/types/src/utils/notificationUtils.d.ts +10 -0
- package/types/src/utils/notificationUtils.d.ts.map +1 -0
- package/types/src/utils/optionUtils.d.ts +14 -0
- package/types/src/utils/optionUtils.d.ts.map +1 -0
- package/dist-esm/src/client/internal/_scheduleNotificationPayload.js +0 -38
- package/dist-esm/src/client/internal/_scheduleNotificationPayload.js.map +0 -1
- package/dist-esm/src/client/internal/_sendNotificationPayload.js +0 -51
- package/dist-esm/src/client/internal/_sendNotificationPayload.js.map +0 -1
- package/dist-esm/src/client/scheduleBroadcastNotification.js +0 -17
- package/dist-esm/src/client/scheduleBroadcastNotification.js.map +0 -1
- package/dist-esm/src/client/sendBroadcastNotification.js +0 -15
- package/dist-esm/src/client/sendBroadcastNotification.js.map +0 -1
- package/dist-esm/src/client/sendDirectNotification.js +0 -15
- package/dist-esm/src/client/sendDirectNotification.js.map +0 -1
- package/types/src/client/internal/_scheduleNotificationPayload.d.ts +0 -9
- package/types/src/client/internal/_scheduleNotificationPayload.d.ts.map +0 -1
- package/types/src/client/internal/_sendNotificationPayload.d.ts +0 -10
- package/types/src/client/internal/_sendNotificationPayload.d.ts.map +0 -1
- package/types/src/client/scheduleBroadcastNotification.d.ts +0 -16
- package/types/src/client/scheduleBroadcastNotification.d.ts.map +0 -1
- package/types/src/client/sendBroadcastNotification.d.ts +0 -14
- package/types/src/client/sendBroadcastNotification.d.ts.map +0 -1
- package/types/src/client/sendDirectNotification.d.ts +0 -15
- package/types/src/client/sendDirectNotification.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -6,12 +6,15 @@ var coreRestPipeline = require('@azure/core-rest-pipeline');
|
|
|
6
6
|
var crypto = require('crypto');
|
|
7
7
|
var coreXml = require('@azure/core-xml');
|
|
8
8
|
var coreClient = require('@azure/core-client');
|
|
9
|
+
var abortController = require('@azure/abort-controller');
|
|
9
10
|
var coreTracing = require('@azure/core-tracing');
|
|
10
11
|
var tslib = require('tslib');
|
|
12
|
+
var coreUtil = require('@azure/core-util');
|
|
13
|
+
var uuid = require('uuid');
|
|
11
14
|
|
|
12
15
|
// Copyright (c) Microsoft Corporation.
|
|
13
16
|
// Licensed under the MIT license.
|
|
14
|
-
const SDK_VERSION = "1.0.0-beta.
|
|
17
|
+
const SDK_VERSION = "1.0.0-beta.6";
|
|
15
18
|
const JSON_CONTENT_TYPE = "application/json;charset=utf-8";
|
|
16
19
|
const XML_CONTENT_TYPE = "application/xml";
|
|
17
20
|
const STREAM_CONTENT_TYPE = "application/octet-stream";
|
|
@@ -179,9 +182,9 @@ class NotificationHubsServiceClient$1 extends coreClient.ServiceClient {
|
|
|
179
182
|
this.baseUrl = parsedConnection.endpoint;
|
|
180
183
|
this.sasTokenProvider = createTokenProviderFromConnection(parsedConnection.sharedAccessKey, parsedConnection.sharedAccessKeyName);
|
|
181
184
|
}
|
|
182
|
-
async createHeaders(operationName) {
|
|
185
|
+
async createHeaders(operationName, rawHeaders) {
|
|
183
186
|
const authorization = await this.sasTokenProvider.getToken(this.baseUrl);
|
|
184
|
-
const headers = coreRestPipeline.createHttpHeaders();
|
|
187
|
+
const headers = coreRestPipeline.createHttpHeaders(rawHeaders);
|
|
185
188
|
headers.set("Authorization", authorization.token);
|
|
186
189
|
headers.set("x-ms-version", API_VERSION);
|
|
187
190
|
headers.set("x-ms-azsdk-telemetry", `class=NotificationHubsServiceClient;method=${operationName}`);
|
|
@@ -509,6 +512,82 @@ async function sendRequest(context, request, successStatusCode) {
|
|
|
509
512
|
return response;
|
|
510
513
|
}
|
|
511
514
|
|
|
515
|
+
// Copyright (c) Microsoft Corporation.
|
|
516
|
+
/**
|
|
517
|
+
* @internal
|
|
518
|
+
* Serializes a NotificationHubJob into an Atom XML entry.
|
|
519
|
+
* @param entry - The NotificationHubJob to turn into an Atom XML entry.
|
|
520
|
+
* @returns An Atom XML entry containing the notification hub job.
|
|
521
|
+
*/
|
|
522
|
+
function serializeNotificationHubJobEntry(entry) {
|
|
523
|
+
const job = {
|
|
524
|
+
Type: entry.type,
|
|
525
|
+
OutputContainerUri: { __cdata: entry.outputContainerUrl },
|
|
526
|
+
ImportFileUri: isDefined(entry.importFileUrl) ? { __cdata: entry.importFileUrl } : undefined,
|
|
527
|
+
};
|
|
528
|
+
const requestObject = serializeToAtomXmlRequest("NotificationHubJob", job);
|
|
529
|
+
return coreXml.stringifyXML(requestObject, { rootName: "entry", cdataPropName: "__cdata" });
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Parses an Atom XML of an notification hub job entry.
|
|
533
|
+
* @param bodyText - The incoming Atom XML entry to parse into a notification hub job.
|
|
534
|
+
* @returns A parsed NotificationHubJob.
|
|
535
|
+
*/
|
|
536
|
+
async function parseNotificationHubJobEntry(bodyText) {
|
|
537
|
+
const xml = await coreXml.parseXML(bodyText, { includeRoot: true });
|
|
538
|
+
const content = xml.entry.content.NotificationHubJob;
|
|
539
|
+
return createNotificationHubJob(content);
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Parses an Atom XML feed of notification hub jobs.
|
|
543
|
+
* @param bodyText - The incoming Atom XML feed to parse into notification hub jobs.
|
|
544
|
+
* @returns A list of notification hub jobs.
|
|
545
|
+
*/
|
|
546
|
+
async function parseNotificationHubJobFeed(bodyText) {
|
|
547
|
+
const xml = await coreXml.parseXML(bodyText, { includeRoot: true });
|
|
548
|
+
const results = [];
|
|
549
|
+
if (!isDefined(xml.feed.entry)) {
|
|
550
|
+
return results;
|
|
551
|
+
}
|
|
552
|
+
const entries = Array.isArray(xml.feed.entry) ? xml.feed.entry : [xml.feed.entry];
|
|
553
|
+
for (const item of entries) {
|
|
554
|
+
results.push(createNotificationHubJob(item.content.NotificationHubJob));
|
|
555
|
+
}
|
|
556
|
+
return results;
|
|
557
|
+
}
|
|
558
|
+
function createInputOutputProperties(content) {
|
|
559
|
+
const props = {};
|
|
560
|
+
const keyValues = content["d3p1:KeyValueOfstringstring"];
|
|
561
|
+
const keyValueArray = Array.isArray(keyValues) ? keyValues : [keyValues];
|
|
562
|
+
for (const item of keyValueArray) {
|
|
563
|
+
props[item["d3p1:Key"]] = item["d3p1:Value"];
|
|
564
|
+
}
|
|
565
|
+
return props;
|
|
566
|
+
}
|
|
567
|
+
function createNotificationHubJob(content) {
|
|
568
|
+
let outputProperties;
|
|
569
|
+
if (isDefined(content["OutputProperties"])) {
|
|
570
|
+
outputProperties = createInputOutputProperties(content["OutputProperties"]);
|
|
571
|
+
}
|
|
572
|
+
let inputProperties;
|
|
573
|
+
if (isDefined(content["InputProperties"])) {
|
|
574
|
+
inputProperties = createInputOutputProperties(content["InputProperties"]);
|
|
575
|
+
}
|
|
576
|
+
return {
|
|
577
|
+
jobId: getStringOrUndefined(content["JobId"]),
|
|
578
|
+
type: getString(content["Type"], "type"),
|
|
579
|
+
status: getStringOrUndefined(content["Status"]),
|
|
580
|
+
progress: getFloatOrUndefined(content["Progress"]),
|
|
581
|
+
outputContainerUrl: getString(content["OutputContainerUri"], "outputContainerUrl"),
|
|
582
|
+
importFileUrl: getStringOrUndefined(content["ImportFileUri"]),
|
|
583
|
+
failure: getStringOrUndefined(content["Failure"]),
|
|
584
|
+
createdAt: getDateOrUndefined(content["CreatedAt"]),
|
|
585
|
+
updatedAt: getDateOrUndefined(content["UpdatedAt"]),
|
|
586
|
+
inputProperties,
|
|
587
|
+
outputProperties,
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
|
|
512
591
|
// Copyright (c) Microsoft Corporation.
|
|
513
592
|
/**
|
|
514
593
|
* A tracing client to handle spans.
|
|
@@ -521,7 +600,178 @@ const tracingClient = coreTracing.createTracingClient({
|
|
|
521
600
|
});
|
|
522
601
|
|
|
523
602
|
// Copyright (c) Microsoft Corporation.
|
|
524
|
-
const OPERATION_NAME$h = "
|
|
603
|
+
const OPERATION_NAME$h = "getNotificationHubJob";
|
|
604
|
+
/**
|
|
605
|
+
* Gets a Notification Hub Job by the ID.
|
|
606
|
+
* @param context - The Notification Hubs client.
|
|
607
|
+
* @param jobId - The Notification Hub Job ID.
|
|
608
|
+
* @param options - The operation options.
|
|
609
|
+
* @returns The Notification Hub Job with the matching ID.
|
|
610
|
+
*/
|
|
611
|
+
function getNotificationHubJob(context, jobId, options = {}) {
|
|
612
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$h}`, options, async (updatedOptions) => {
|
|
613
|
+
const endpoint = context.requestUrl();
|
|
614
|
+
endpoint.pathname += `/jobs/${jobId}`;
|
|
615
|
+
const headers = await context.createHeaders(OPERATION_NAME$h);
|
|
616
|
+
headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
|
|
617
|
+
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
618
|
+
const response = await sendRequest(context, request, 200);
|
|
619
|
+
return parseNotificationHubJobEntry(response.bodyAsText);
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
// Copyright (c) Microsoft Corporation.
|
|
624
|
+
const OPERATION_NAME$g = "submitNotificationHubJob";
|
|
625
|
+
/**
|
|
626
|
+
* Submits a Notification Hub Job.
|
|
627
|
+
* Note: this is available to Standard SKU namespace and above.
|
|
628
|
+
* @param context - The Notification Hubs client.
|
|
629
|
+
* @param job - The notification hub job to submit.
|
|
630
|
+
* @param options - The operation options.
|
|
631
|
+
* @returns The notification hub job details including job ID and status.
|
|
632
|
+
*/
|
|
633
|
+
function submitNotificationHubJob(context, job, options = {}) {
|
|
634
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$g}`, options, async (updatedOptions) => {
|
|
635
|
+
const endpoint = context.requestUrl();
|
|
636
|
+
endpoint.pathname += "/jobs";
|
|
637
|
+
const headers = await context.createHeaders(OPERATION_NAME$g);
|
|
638
|
+
headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
|
|
639
|
+
const request = createRequest(endpoint, "POST", headers, updatedOptions);
|
|
640
|
+
request.body = serializeNotificationHubJobEntry(job);
|
|
641
|
+
const response = await sendRequest(context, request, 201);
|
|
642
|
+
return parseNotificationHubJobEntry(response.bodyAsText);
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// Copyright (c) Microsoft Corporation.
|
|
647
|
+
/**
|
|
648
|
+
* Submits a Notification Hub job and creates a poller to poll for results.
|
|
649
|
+
* @param context - The Notification Hubs client.
|
|
650
|
+
* @param notificationHubJob - The Notification Hub import/export job to start.
|
|
651
|
+
* @param options - The operation options.
|
|
652
|
+
* @returns A poller which can be called to poll until completion of the job.
|
|
653
|
+
*/
|
|
654
|
+
async function beginSubmitNotificationHubJob(context, notificationHubJob, polledOperationOptions = {}) {
|
|
655
|
+
var _a;
|
|
656
|
+
let submittedJob = await submitNotificationHubJob(context, notificationHubJob, polledOperationOptions);
|
|
657
|
+
const state = {
|
|
658
|
+
status: "notStarted",
|
|
659
|
+
};
|
|
660
|
+
const progressCallbacks = new Map();
|
|
661
|
+
const processProgressCallbacks = async () => progressCallbacks.forEach((h) => h(state));
|
|
662
|
+
let resultPromise;
|
|
663
|
+
let cancelJob;
|
|
664
|
+
const abortController$1 = new abortController.AbortController();
|
|
665
|
+
const currentPollIntervalInMs = (_a = polledOperationOptions.updateIntervalInMs) !== null && _a !== void 0 ? _a : 2000;
|
|
666
|
+
const poller = {
|
|
667
|
+
async poll(options) {
|
|
668
|
+
submittedJob = await getNotificationHubJob(context, submittedJob.jobId, options);
|
|
669
|
+
if (submittedJob.status === "Running" || submittedJob.status === "Started") {
|
|
670
|
+
state.status = "running";
|
|
671
|
+
}
|
|
672
|
+
if (submittedJob.status === "Completed") {
|
|
673
|
+
state.status = "succeeded";
|
|
674
|
+
state.result = submittedJob;
|
|
675
|
+
}
|
|
676
|
+
if (submittedJob.status === "Failed") {
|
|
677
|
+
state.status = "failed";
|
|
678
|
+
state.error = new Error(submittedJob.failure);
|
|
679
|
+
}
|
|
680
|
+
await processProgressCallbacks();
|
|
681
|
+
if (state.status === "canceled") {
|
|
682
|
+
throw new Error("Operation was canceled");
|
|
683
|
+
}
|
|
684
|
+
if (state.status === "failed") {
|
|
685
|
+
throw state.error;
|
|
686
|
+
}
|
|
687
|
+
},
|
|
688
|
+
pollUntilDone(pollOptions) {
|
|
689
|
+
return (resultPromise !== null && resultPromise !== void 0 ? resultPromise : (resultPromise = (async () => {
|
|
690
|
+
const { abortSignal: inputAbortSignal } = pollOptions || {};
|
|
691
|
+
const { signal: abortSignal } = inputAbortSignal
|
|
692
|
+
? new abortController.AbortController([inputAbortSignal, abortController$1.signal])
|
|
693
|
+
: abortController$1;
|
|
694
|
+
if (!poller.isDone()) {
|
|
695
|
+
await poller.poll({ abortSignal });
|
|
696
|
+
while (!poller.isDone()) {
|
|
697
|
+
const delay = sleep(currentPollIntervalInMs, abortSignal);
|
|
698
|
+
cancelJob = () => abortController$1.abort();
|
|
699
|
+
await delay;
|
|
700
|
+
await poller.poll({ abortSignal });
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
switch (state.status) {
|
|
704
|
+
case "succeeded": {
|
|
705
|
+
return poller.getResult();
|
|
706
|
+
}
|
|
707
|
+
case "canceled": {
|
|
708
|
+
throw new Error("Operation was canceled");
|
|
709
|
+
}
|
|
710
|
+
case "failed": {
|
|
711
|
+
throw state.error;
|
|
712
|
+
}
|
|
713
|
+
case "notStarted":
|
|
714
|
+
case "running": {
|
|
715
|
+
// Unreachable
|
|
716
|
+
throw new Error(`polling completed without succeeding or failing`);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
})().finally(() => {
|
|
720
|
+
resultPromise = undefined;
|
|
721
|
+
})));
|
|
722
|
+
},
|
|
723
|
+
onProgress(callback) {
|
|
724
|
+
const s = Symbol();
|
|
725
|
+
progressCallbacks.set(s, callback);
|
|
726
|
+
return () => progressCallbacks.delete(s);
|
|
727
|
+
},
|
|
728
|
+
isDone() {
|
|
729
|
+
return ["succeeded", "failed", "canceled"].includes(state.status);
|
|
730
|
+
},
|
|
731
|
+
stopPolling() {
|
|
732
|
+
abortController$1.abort();
|
|
733
|
+
cancelJob === null || cancelJob === void 0 ? void 0 : cancelJob();
|
|
734
|
+
},
|
|
735
|
+
isStopped() {
|
|
736
|
+
return resultPromise === undefined;
|
|
737
|
+
},
|
|
738
|
+
getOperationState() {
|
|
739
|
+
return state;
|
|
740
|
+
},
|
|
741
|
+
getResult() {
|
|
742
|
+
return state.result;
|
|
743
|
+
},
|
|
744
|
+
toString() {
|
|
745
|
+
return JSON.stringify({ state });
|
|
746
|
+
},
|
|
747
|
+
};
|
|
748
|
+
return poller;
|
|
749
|
+
}
|
|
750
|
+
const REJECTED_ERR = new Error("The operation has been aborted");
|
|
751
|
+
function sleep(ms, signal) {
|
|
752
|
+
return new Promise((resolve, reject) => {
|
|
753
|
+
if (signal.aborted) {
|
|
754
|
+
reject(REJECTED_ERR);
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
const id = setTimeout(() => {
|
|
758
|
+
signal.removeEventListener("abort", onAbort);
|
|
759
|
+
if (signal.aborted) {
|
|
760
|
+
reject(REJECTED_ERR);
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
resolve();
|
|
764
|
+
}, ms);
|
|
765
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
766
|
+
function onAbort() {
|
|
767
|
+
clearTimeout(id);
|
|
768
|
+
reject(REJECTED_ERR);
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
// Copyright (c) Microsoft Corporation.
|
|
774
|
+
const OPERATION_NAME$f = "cancelScheduledNotification";
|
|
525
775
|
/**
|
|
526
776
|
* Cancels the scheduled notification with the given notification ID.
|
|
527
777
|
* NOTE: This is only available in Standard SKU Azure Notification Hubs.
|
|
@@ -531,10 +781,10 @@ const OPERATION_NAME$h = "cancelScheduledNotification";
|
|
|
531
781
|
* @returns A notification hub response with correlation ID and tracking ID.
|
|
532
782
|
*/
|
|
533
783
|
function cancelScheduledNotification(context, notificationId, options = {}) {
|
|
534
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
784
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$f}`, options, async (updatedOptions) => {
|
|
535
785
|
const endpoint = context.requestUrl();
|
|
536
786
|
endpoint.pathname += `/schedulednotifications/${notificationId}`;
|
|
537
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
787
|
+
const headers = await context.createHeaders(OPERATION_NAME$f);
|
|
538
788
|
const request = createRequest(endpoint, "DELETE", headers, updatedOptions);
|
|
539
789
|
const response = await sendRequest(context, request, 200);
|
|
540
790
|
return parseNotificationSendResponse(response);
|
|
@@ -542,7 +792,7 @@ function cancelScheduledNotification(context, notificationId, options = {}) {
|
|
|
542
792
|
}
|
|
543
793
|
|
|
544
794
|
// Copyright (c) Microsoft Corporation.
|
|
545
|
-
const OPERATION_NAME$
|
|
795
|
+
const OPERATION_NAME$e = "createOrUpdateInstallation";
|
|
546
796
|
/**
|
|
547
797
|
* Creates or overwrites an installation to a Notification Hub.
|
|
548
798
|
* @param context - The Notification Hubs client.
|
|
@@ -551,10 +801,10 @@ const OPERATION_NAME$g = "createOrUpdateInstallation";
|
|
|
551
801
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
552
802
|
*/
|
|
553
803
|
function createOrUpdateInstallation(context, installation, options = {}) {
|
|
554
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
804
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$e}`, options, async (updatedOptions) => {
|
|
555
805
|
const endpoint = context.requestUrl();
|
|
556
806
|
endpoint.pathname += `/installations/${installation.installationId}`;
|
|
557
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
807
|
+
const headers = await context.createHeaders(OPERATION_NAME$e);
|
|
558
808
|
headers.set("Content-Type", "application/json");
|
|
559
809
|
const request = createRequest(endpoint, "PUT", headers, updatedOptions);
|
|
560
810
|
request.body = JSON.stringify(installation);
|
|
@@ -590,7 +840,8 @@ const registrationDescriptionParser = {
|
|
|
590
840
|
if (!isDefined(xml.feed.entry)) {
|
|
591
841
|
return results;
|
|
592
842
|
}
|
|
593
|
-
|
|
843
|
+
const entries = Array.isArray(xml.feed.entry) ? xml.feed.entry : [xml.feed.entry];
|
|
844
|
+
for (const entry of entries) {
|
|
594
845
|
delete entry.content["$"];
|
|
595
846
|
const keyName = Object.keys(entry.content)[0];
|
|
596
847
|
const methodName = `create${keyName}`;
|
|
@@ -936,7 +1187,7 @@ async function createOrUpdateRegistrationDescription(context, registration, oper
|
|
|
936
1187
|
}
|
|
937
1188
|
|
|
938
1189
|
// Copyright (c) Microsoft Corporation.
|
|
939
|
-
const OPERATION_NAME$
|
|
1190
|
+
const OPERATION_NAME$d = "createOrUpdateRegistration";
|
|
940
1191
|
/**
|
|
941
1192
|
* Creates or updates a registration.
|
|
942
1193
|
* @param context - The Notification Hubs client.
|
|
@@ -945,13 +1196,13 @@ const OPERATION_NAME$f = "createOrUpdateRegistration";
|
|
|
945
1196
|
* @returns The created or updated registration description.
|
|
946
1197
|
*/
|
|
947
1198
|
function createOrUpdateRegistration(context, registration, options = {}) {
|
|
948
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1199
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$d}`, options, async (updatedOptions) => {
|
|
949
1200
|
return createOrUpdateRegistrationDescription(context, registration, "createOrUpdate", updatedOptions);
|
|
950
1201
|
});
|
|
951
1202
|
}
|
|
952
1203
|
|
|
953
1204
|
// Copyright (c) Microsoft Corporation.
|
|
954
|
-
const OPERATION_NAME$
|
|
1205
|
+
const OPERATION_NAME$c = "createRegistrationId";
|
|
955
1206
|
/**
|
|
956
1207
|
* Creates a new registration ID.
|
|
957
1208
|
* @param context - The Notification Hubs client.
|
|
@@ -959,10 +1210,10 @@ const OPERATION_NAME$e = "createRegistrationId";
|
|
|
959
1210
|
* @returns The newly created registration ID.
|
|
960
1211
|
*/
|
|
961
1212
|
function createRegistrationId(context, options = {}) {
|
|
962
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1213
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$c}`, options, async (updatedOptions) => {
|
|
963
1214
|
const endpoint = context.requestUrl();
|
|
964
1215
|
endpoint.pathname += "/registrationIDs";
|
|
965
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1216
|
+
const headers = await context.createHeaders(OPERATION_NAME$c);
|
|
966
1217
|
headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
|
|
967
1218
|
const request = createRequest(endpoint, "POST", headers, updatedOptions);
|
|
968
1219
|
const response = await sendRequest(context, request, 201);
|
|
@@ -975,7 +1226,7 @@ function createRegistrationId(context, options = {}) {
|
|
|
975
1226
|
}
|
|
976
1227
|
|
|
977
1228
|
// Copyright (c) Microsoft Corporation.
|
|
978
|
-
const OPERATION_NAME$
|
|
1229
|
+
const OPERATION_NAME$b = "createRegistration";
|
|
979
1230
|
/**
|
|
980
1231
|
* Creates a new registration. This method generates a registration ID,
|
|
981
1232
|
* which you can subsequently use to retrieve, update, and delete this registration.
|
|
@@ -985,7 +1236,7 @@ const OPERATION_NAME$d = "createRegistration";
|
|
|
985
1236
|
* @returns The newly created registration description.
|
|
986
1237
|
*/
|
|
987
1238
|
function createRegistration(context, registration, options = {}) {
|
|
988
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1239
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$b}`, options, async (updatedOptions) => {
|
|
989
1240
|
if (registration.registrationId) {
|
|
990
1241
|
throw new coreRestPipeline.RestError("registrationId must not be set during a create operation", {
|
|
991
1242
|
statusCode: 400,
|
|
@@ -996,7 +1247,7 @@ function createRegistration(context, registration, options = {}) {
|
|
|
996
1247
|
}
|
|
997
1248
|
|
|
998
1249
|
// Copyright (c) Microsoft Corporation.
|
|
999
|
-
const OPERATION_NAME$
|
|
1250
|
+
const OPERATION_NAME$a = "deleteInstallation";
|
|
1000
1251
|
/**
|
|
1001
1252
|
* Deletes an installation from a Notification Hub.
|
|
1002
1253
|
* @param context - The Notification Hubs client.
|
|
@@ -1005,10 +1256,10 @@ const OPERATION_NAME$c = "deleteInstallation";
|
|
|
1005
1256
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1006
1257
|
*/
|
|
1007
1258
|
function deleteInstallation(context, installationId, options = {}) {
|
|
1008
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1259
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$a}`, options, async (updatedOptions) => {
|
|
1009
1260
|
const endpoint = context.requestUrl();
|
|
1010
1261
|
endpoint.pathname += `/installations/${installationId}`;
|
|
1011
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1262
|
+
const headers = await context.createHeaders(OPERATION_NAME$a);
|
|
1012
1263
|
const request = createRequest(endpoint, "DELETE", headers, updatedOptions);
|
|
1013
1264
|
const response = await sendRequest(context, request, 204);
|
|
1014
1265
|
return parseNotificationResponse(response);
|
|
@@ -1016,7 +1267,29 @@ function deleteInstallation(context, installationId, options = {}) {
|
|
|
1016
1267
|
}
|
|
1017
1268
|
|
|
1018
1269
|
// Copyright (c) Microsoft Corporation.
|
|
1019
|
-
const OPERATION_NAME$
|
|
1270
|
+
const OPERATION_NAME$9 = "deleteRegistration";
|
|
1271
|
+
/**
|
|
1272
|
+
* Deletes a registration with the given registration ID.
|
|
1273
|
+
* @param context - The Notification Hubs client.
|
|
1274
|
+
* @param registrationId - The registration ID of the registration to delete.
|
|
1275
|
+
* @param options - The options for delete operations including the ETag
|
|
1276
|
+
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1277
|
+
*/
|
|
1278
|
+
function deleteRegistration(context, registrationId, options = {}) {
|
|
1279
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$9}`, options, async (updatedOptions) => {
|
|
1280
|
+
const endpoint = context.requestUrl();
|
|
1281
|
+
endpoint.pathname += `/registrations/${registrationId}`;
|
|
1282
|
+
const headers = await context.createHeaders(OPERATION_NAME$9);
|
|
1283
|
+
headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
|
|
1284
|
+
headers.set("If-Match", isDefined(options.etag) ? `"${options.etag}"` : "*");
|
|
1285
|
+
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
1286
|
+
const response = await sendRequest(context, request, 200);
|
|
1287
|
+
return parseNotificationResponse(response);
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
// Copyright (c) Microsoft Corporation.
|
|
1292
|
+
const OPERATION_NAME$8 = "getFeedbackContainerUrl";
|
|
1020
1293
|
/**
|
|
1021
1294
|
* Retrieves an Azure Storage container URL. The container has feedback data for the notification hub.
|
|
1022
1295
|
* The caller can then use the Azure Storage Services SDK to retrieve the contents of the container.
|
|
@@ -1025,10 +1298,10 @@ const OPERATION_NAME$b = "getFeedbackContainerUrl";
|
|
|
1025
1298
|
* @returns The URL of the Azure Storage Container containing the feedback data.
|
|
1026
1299
|
*/
|
|
1027
1300
|
function getFeedbackContainerUrl(context, options = {}) {
|
|
1028
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1301
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$8}`, options, async (updatedOptions) => {
|
|
1029
1302
|
const endpoint = context.requestUrl();
|
|
1030
1303
|
endpoint.pathname += "/feedbackcontainer";
|
|
1031
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1304
|
+
const headers = await context.createHeaders(OPERATION_NAME$8);
|
|
1032
1305
|
headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
|
|
1033
1306
|
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
1034
1307
|
const response = await sendRequest(context, request, 200);
|
|
@@ -1037,7 +1310,7 @@ function getFeedbackContainerUrl(context, options = {}) {
|
|
|
1037
1310
|
}
|
|
1038
1311
|
|
|
1039
1312
|
// Copyright (c) Microsoft Corporation.
|
|
1040
|
-
const OPERATION_NAME$
|
|
1313
|
+
const OPERATION_NAME$7 = "getInstallation";
|
|
1041
1314
|
/**
|
|
1042
1315
|
* Gets an Azure Notification Hub installation by the installation ID.
|
|
1043
1316
|
* @param context - The Notification Hubs client.
|
|
@@ -1046,10 +1319,10 @@ const OPERATION_NAME$a = "getInstallation";
|
|
|
1046
1319
|
* @returns The installation that matches the installation ID.
|
|
1047
1320
|
*/
|
|
1048
1321
|
function getInstallation(context, installationId, options = {}) {
|
|
1049
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1322
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$7}`, options, async (updatedOptions) => {
|
|
1050
1323
|
const endpoint = context.requestUrl();
|
|
1051
1324
|
endpoint.pathname += `/installations/${installationId}`;
|
|
1052
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1325
|
+
const headers = await context.createHeaders(OPERATION_NAME$7);
|
|
1053
1326
|
headers.set("Content-Type", "application/json");
|
|
1054
1327
|
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
1055
1328
|
const response = await sendRequest(context, request, 200);
|
|
@@ -1057,100 +1330,6 @@ function getInstallation(context, installationId, options = {}) {
|
|
|
1057
1330
|
});
|
|
1058
1331
|
}
|
|
1059
1332
|
|
|
1060
|
-
// Copyright (c) Microsoft Corporation.
|
|
1061
|
-
/**
|
|
1062
|
-
* @internal
|
|
1063
|
-
* Serializes a NotificationHubJob into an Atom XML entry.
|
|
1064
|
-
* @param entry - The NotificationHubJob to turn into an Atom XML entry.
|
|
1065
|
-
* @returns An Atom XML entry containing the notification hub job.
|
|
1066
|
-
*/
|
|
1067
|
-
function serializeNotificationHubJobEntry(entry) {
|
|
1068
|
-
const job = {
|
|
1069
|
-
Type: entry.type,
|
|
1070
|
-
OutputContainerUri: { __cdata: entry.outputContainerUrl },
|
|
1071
|
-
ImportFileUri: isDefined(entry.importFileUrl) ? { __cdata: entry.importFileUrl } : undefined,
|
|
1072
|
-
};
|
|
1073
|
-
const requestObject = serializeToAtomXmlRequest("NotificationHubJob", job);
|
|
1074
|
-
return coreXml.stringifyXML(requestObject, { rootName: "entry", cdataPropName: "__cdata" });
|
|
1075
|
-
}
|
|
1076
|
-
/**
|
|
1077
|
-
* Parses an Atom XML of an notification hub job entry.
|
|
1078
|
-
* @param bodyText - The incoming Atom XML entry to parse into a notification hub job.
|
|
1079
|
-
* @returns A parsed NotificationHubJob.
|
|
1080
|
-
*/
|
|
1081
|
-
async function parseNotificationHubJobEntry(bodyText) {
|
|
1082
|
-
const xml = await coreXml.parseXML(bodyText, { includeRoot: true });
|
|
1083
|
-
const content = xml.entry.content.NotificationHubJob;
|
|
1084
|
-
return createNotificationHubJob(content);
|
|
1085
|
-
}
|
|
1086
|
-
/**
|
|
1087
|
-
* Parses an Atom XML feed of notification hub jobs.
|
|
1088
|
-
* @param bodyText - The incoming Atom XML feed to parse into notification hub jobs.
|
|
1089
|
-
* @returns A list of notification hub jobs.
|
|
1090
|
-
*/
|
|
1091
|
-
async function parseNotificationHubJobFeed(bodyText) {
|
|
1092
|
-
const xml = await coreXml.parseXML(bodyText, { includeRoot: true });
|
|
1093
|
-
const results = [];
|
|
1094
|
-
if (!isDefined(xml.feed.entry)) {
|
|
1095
|
-
return results;
|
|
1096
|
-
}
|
|
1097
|
-
for (const item of xml.feed.entry) {
|
|
1098
|
-
results.push(createNotificationHubJob(item.content.NotificationHubJob));
|
|
1099
|
-
}
|
|
1100
|
-
return results;
|
|
1101
|
-
}
|
|
1102
|
-
function createInputOutputProperties(content) {
|
|
1103
|
-
const props = {};
|
|
1104
|
-
for (const item of content["d3p1:KeyValueOfstringstring"]) {
|
|
1105
|
-
props[item["d3p1:Key"]] = item["d3p1:Value"];
|
|
1106
|
-
}
|
|
1107
|
-
return props;
|
|
1108
|
-
}
|
|
1109
|
-
function createNotificationHubJob(content) {
|
|
1110
|
-
let outputProperties;
|
|
1111
|
-
if (isDefined(content["OutputProperties"])) {
|
|
1112
|
-
outputProperties = createInputOutputProperties(content["OutputProperties"]);
|
|
1113
|
-
}
|
|
1114
|
-
let inputProperties;
|
|
1115
|
-
if (isDefined(content["InputProperties"])) {
|
|
1116
|
-
inputProperties = createInputOutputProperties(content["InputProperties"]);
|
|
1117
|
-
}
|
|
1118
|
-
return {
|
|
1119
|
-
jobId: getStringOrUndefined(content["JobId"]),
|
|
1120
|
-
type: getString(content["Type"], "type"),
|
|
1121
|
-
status: getStringOrUndefined(content["Status"]),
|
|
1122
|
-
progress: getFloatOrUndefined(content["Progress"]),
|
|
1123
|
-
outputContainerUrl: getString(content["OutputContainerUri"], "outputContainerUrl"),
|
|
1124
|
-
importFileUrl: getStringOrUndefined(content["ImportFileUri"]),
|
|
1125
|
-
failure: getStringOrUndefined(content["Failure"]),
|
|
1126
|
-
createdAt: getDateOrUndefined(content["CreatedAt"]),
|
|
1127
|
-
updatedAt: getDateOrUndefined(content["UpdatedAt"]),
|
|
1128
|
-
inputProperties,
|
|
1129
|
-
outputProperties,
|
|
1130
|
-
};
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
// Copyright (c) Microsoft Corporation.
|
|
1134
|
-
const OPERATION_NAME$9 = "getNotificationHubJob";
|
|
1135
|
-
/**
|
|
1136
|
-
* Gets a Notification Hub Job by the ID.
|
|
1137
|
-
* @param context - The Notification Hubs client.
|
|
1138
|
-
* @param jobId - The Notification Hub Job ID.
|
|
1139
|
-
* @param options - The operation options.
|
|
1140
|
-
* @returns The Notification Hub Job with the matching ID.
|
|
1141
|
-
*/
|
|
1142
|
-
function getNotificationHubJob(context, jobId, options = {}) {
|
|
1143
|
-
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$9}`, options, async (updatedOptions) => {
|
|
1144
|
-
const endpoint = context.requestUrl();
|
|
1145
|
-
endpoint.pathname += `/jobs/${jobId}`;
|
|
1146
|
-
const headers = await context.createHeaders(OPERATION_NAME$9);
|
|
1147
|
-
headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
|
|
1148
|
-
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
1149
|
-
const response = await sendRequest(context, request, 200);
|
|
1150
|
-
return parseNotificationHubJobEntry(response.bodyAsText);
|
|
1151
|
-
});
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
1333
|
// Copyright (c) Microsoft Corporation.
|
|
1155
1334
|
/**
|
|
1156
1335
|
* @internal
|
|
@@ -1199,15 +1378,16 @@ async function parseNotificationDetails(bodyText) {
|
|
|
1199
1378
|
};
|
|
1200
1379
|
}
|
|
1201
1380
|
function parseOutcomeCounts(counts) {
|
|
1381
|
+
const items = Array.isArray(counts) ? counts : [counts];
|
|
1202
1382
|
const results = [];
|
|
1203
|
-
for (const item of
|
|
1383
|
+
for (const item of items) {
|
|
1204
1384
|
results.push({ state: item["Name"], count: getInteger(item["Count"], "Count") });
|
|
1205
1385
|
}
|
|
1206
1386
|
return results;
|
|
1207
1387
|
}
|
|
1208
1388
|
|
|
1209
1389
|
// Copyright (c) Microsoft Corporation.
|
|
1210
|
-
const OPERATION_NAME$
|
|
1390
|
+
const OPERATION_NAME$6 = "getNotificationOutcomeDetails";
|
|
1211
1391
|
/**
|
|
1212
1392
|
* Retrieves the results of a send operation. This can retrieve intermediate results if the send is being processed
|
|
1213
1393
|
* or final results if the Send* has completed. This API can only be called for Standard SKU and above.
|
|
@@ -1217,10 +1397,10 @@ const OPERATION_NAME$8 = "getNotificationOutcomeDetails";
|
|
|
1217
1397
|
* @returns The results of the send operation.
|
|
1218
1398
|
*/
|
|
1219
1399
|
function getNotificationOutcomeDetails(context, notificationId, options = {}) {
|
|
1220
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1400
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$6}`, options, async (updatedOptions) => {
|
|
1221
1401
|
const endpoint = context.requestUrl();
|
|
1222
1402
|
endpoint.pathname += `/messages/${notificationId}`;
|
|
1223
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1403
|
+
const headers = await context.createHeaders(OPERATION_NAME$6);
|
|
1224
1404
|
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
1225
1405
|
const response = await sendRequest(context, request, 200);
|
|
1226
1406
|
return parseNotificationDetails(response.bodyAsText);
|
|
@@ -1228,7 +1408,7 @@ function getNotificationOutcomeDetails(context, notificationId, options = {}) {
|
|
|
1228
1408
|
}
|
|
1229
1409
|
|
|
1230
1410
|
// Copyright (c) Microsoft Corporation.
|
|
1231
|
-
const OPERATION_NAME$
|
|
1411
|
+
const OPERATION_NAME$5 = "getRegistration";
|
|
1232
1412
|
/**
|
|
1233
1413
|
* Gets a registration by the given registration ID.
|
|
1234
1414
|
* @param context - The Notification Hubs client.
|
|
@@ -1237,10 +1417,10 @@ const OPERATION_NAME$7 = "getRegistration";
|
|
|
1237
1417
|
* @returns A RegistrationDescription that has the given registration ID.
|
|
1238
1418
|
*/
|
|
1239
1419
|
function getRegistration(context, registrationId, options = {}) {
|
|
1240
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1420
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$5}`, options, async (updatedOptions) => {
|
|
1241
1421
|
const endpoint = context.requestUrl();
|
|
1242
1422
|
endpoint.pathname += `/registrations/${registrationId}`;
|
|
1243
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1423
|
+
const headers = await context.createHeaders(OPERATION_NAME$5);
|
|
1244
1424
|
headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
|
|
1245
1425
|
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
1246
1426
|
const response = await sendRequest(context, request, 200);
|
|
@@ -1249,7 +1429,7 @@ function getRegistration(context, registrationId, options = {}) {
|
|
|
1249
1429
|
}
|
|
1250
1430
|
|
|
1251
1431
|
// Copyright (c) Microsoft Corporation.
|
|
1252
|
-
const OPERATION_NAME$
|
|
1432
|
+
const OPERATION_NAME$4 = "listNotificationHubJobs";
|
|
1253
1433
|
/**
|
|
1254
1434
|
* Gets all Notification Hub Jobs for this Notification Hub.
|
|
1255
1435
|
* @param context - The Notification Hubs client.xs
|
|
@@ -1257,10 +1437,10 @@ const OPERATION_NAME$6 = "listNotificationHubJobs";
|
|
|
1257
1437
|
* @returns An array of all Notification Hub Jobs for this Notification Hub.
|
|
1258
1438
|
*/
|
|
1259
1439
|
function listNotificationHubJobs(context, options = {}) {
|
|
1260
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1440
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$4}`, options, async (updatedOptions) => {
|
|
1261
1441
|
const endpoint = context.requestUrl();
|
|
1262
1442
|
endpoint.pathname += "/jobs";
|
|
1263
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1443
|
+
const headers = await context.createHeaders(OPERATION_NAME$4);
|
|
1264
1444
|
headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
|
|
1265
1445
|
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
1266
1446
|
const response = await sendRequest(context, request, 200);
|
|
@@ -1269,7 +1449,7 @@ function listNotificationHubJobs(context, options = {}) {
|
|
|
1269
1449
|
}
|
|
1270
1450
|
|
|
1271
1451
|
// Copyright (c) Microsoft Corporation.
|
|
1272
|
-
const OPERATION_NAME$
|
|
1452
|
+
const OPERATION_NAME$3 = "listRegistrationsByTag";
|
|
1273
1453
|
/**
|
|
1274
1454
|
* Lists all registrations with the matching tag.
|
|
1275
1455
|
* @param context - The Notification Hubs client.
|
|
@@ -1278,7 +1458,7 @@ const OPERATION_NAME$5 = "listRegistrationsByTag";
|
|
|
1278
1458
|
* @returns A paged async iterable containing the matching registrations for the notification hub.
|
|
1279
1459
|
*/
|
|
1280
1460
|
function listRegistrationsByTag(context, tag, options = {}) {
|
|
1281
|
-
const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext
|
|
1461
|
+
const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext.${OPERATION_NAME$3}`, options);
|
|
1282
1462
|
try {
|
|
1283
1463
|
const iter = listRegistrationsByTagAll(context, tag, updatedOptions);
|
|
1284
1464
|
return {
|
|
@@ -1340,7 +1520,7 @@ async function _listRegistrationsByTag(context, tag, options, continuationToken)
|
|
|
1340
1520
|
if (continuationToken !== undefined) {
|
|
1341
1521
|
endpoint.searchParams.set("continuationtoken", continuationToken);
|
|
1342
1522
|
}
|
|
1343
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1523
|
+
const headers = await context.createHeaders(OPERATION_NAME$3);
|
|
1344
1524
|
const request = createRequest(endpoint, "GET", headers, options);
|
|
1345
1525
|
const response = await sendRequest(context, request, 200);
|
|
1346
1526
|
const registrations = await registrationDescriptionParser.parseRegistrationFeed(response.bodyAsText);
|
|
@@ -1352,7 +1532,7 @@ async function _listRegistrationsByTag(context, tag, options, continuationToken)
|
|
|
1352
1532
|
}
|
|
1353
1533
|
|
|
1354
1534
|
// Copyright (c) Microsoft Corporation.
|
|
1355
|
-
const OPERATION_NAME$
|
|
1535
|
+
const OPERATION_NAME$2 = "listRegistrations";
|
|
1356
1536
|
/**
|
|
1357
1537
|
* Gets all registrations for the notification hub with the given query options.
|
|
1358
1538
|
* @param context - The Notification Hubs client.
|
|
@@ -1360,7 +1540,7 @@ const OPERATION_NAME$4 = "listRegistrations";
|
|
|
1360
1540
|
* @returns A paged async iterable containing all of the registrations for the notification hub.
|
|
1361
1541
|
*/
|
|
1362
1542
|
function listRegistrations(context, options = {}) {
|
|
1363
|
-
const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext
|
|
1543
|
+
const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext.${OPERATION_NAME$2}`, options);
|
|
1364
1544
|
try {
|
|
1365
1545
|
const iter = listRegistrationsAll(context, updatedOptions);
|
|
1366
1546
|
return {
|
|
@@ -1425,7 +1605,7 @@ async function _listRegistrations(context, options, continuationToken) {
|
|
|
1425
1605
|
if (continuationToken !== undefined) {
|
|
1426
1606
|
endpoint.searchParams.set("continuationtoken", continuationToken);
|
|
1427
1607
|
}
|
|
1428
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1608
|
+
const headers = await context.createHeaders(OPERATION_NAME$2);
|
|
1429
1609
|
const request = createRequest(endpoint, "GET", headers, options);
|
|
1430
1610
|
const response = await sendRequest(context, request, 200);
|
|
1431
1611
|
const registrations = await registrationDescriptionParser.parseRegistrationFeed(response.bodyAsText);
|
|
@@ -1437,53 +1617,28 @@ async function _listRegistrations(context, options, continuationToken) {
|
|
|
1437
1617
|
}
|
|
1438
1618
|
|
|
1439
1619
|
// Copyright (c) Microsoft Corporation.
|
|
1440
|
-
|
|
1620
|
+
// Licensed under the MIT license.
|
|
1441
1621
|
/**
|
|
1442
1622
|
* @internal
|
|
1443
1623
|
*/
|
|
1444
|
-
function
|
|
1445
|
-
return
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
headers.set("ServiceBusNotification-Format", notification.platform);
|
|
1457
|
-
if (tags) {
|
|
1458
|
-
let tagExpression = null;
|
|
1459
|
-
if (Array.isArray(tags)) {
|
|
1460
|
-
tagExpression = tags.join("||");
|
|
1461
|
-
}
|
|
1462
|
-
else {
|
|
1463
|
-
tagExpression = tags;
|
|
1464
|
-
}
|
|
1465
|
-
headers.set("ServiceBusNotification-Tags", tagExpression);
|
|
1466
|
-
}
|
|
1467
|
-
const request = createRequest(endpoint, "POST", headers, updatedOptions);
|
|
1468
|
-
request.body = notification.body;
|
|
1469
|
-
const response = await sendRequest(context, request, 201);
|
|
1470
|
-
return parseNotificationSendResponse(response);
|
|
1471
|
-
});
|
|
1624
|
+
function createMultipartDirectNotification(boundaryName, notification, deviceHandles) {
|
|
1625
|
+
return (`--${boundaryName}\r\n` +
|
|
1626
|
+
`Content-type: ${notification.contentType}\r\n` +
|
|
1627
|
+
"Content-Disposition: inline; name=notification\r\n\r\n" +
|
|
1628
|
+
notification.body +
|
|
1629
|
+
"\r\n" +
|
|
1630
|
+
`--${boundaryName}\r\n` +
|
|
1631
|
+
"Content-type: application/json\r\n" +
|
|
1632
|
+
"Content-Disposition: inline; name=devices\r\n\r\n" +
|
|
1633
|
+
JSON.stringify(deviceHandles) +
|
|
1634
|
+
"\r\n" +
|
|
1635
|
+
`--${boundaryName}--`);
|
|
1472
1636
|
}
|
|
1473
|
-
|
|
1474
|
-
// Copyright (c) Microsoft Corporation.
|
|
1475
1637
|
/**
|
|
1476
|
-
*
|
|
1477
|
-
* NOTE: This is only available in Standard SKU Azure Notification Hubs.
|
|
1478
|
-
* @param context - The Notification Hubs client.
|
|
1479
|
-
* @param scheduledTime - The Date to send the push notification.
|
|
1480
|
-
* @param notification - The notification to send to the matching devices.
|
|
1481
|
-
* @param options - Configuration options for the direct send operation which can contain custom headers
|
|
1482
|
-
* which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
|
|
1483
|
-
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1638
|
+
* @internal
|
|
1484
1639
|
*/
|
|
1485
|
-
function
|
|
1486
|
-
return
|
|
1640
|
+
function normalizeTags(tags) {
|
|
1641
|
+
return Array.isArray(tags) ? tags.join("||") : tags;
|
|
1487
1642
|
}
|
|
1488
1643
|
|
|
1489
1644
|
// Copyright (c) Microsoft Corporation.
|
|
@@ -1492,56 +1647,20 @@ function scheduleBroadcastNotification(context, scheduledTime, notification, opt
|
|
|
1492
1647
|
* NOTE: This is only available in Standard SKU Azure Notification Hubs.
|
|
1493
1648
|
* @param context - The Notification Hubs client.
|
|
1494
1649
|
* @param scheduledTime - The Date to send the push notification.
|
|
1495
|
-
* @param tags - The tags used to target the device for push notifications in either an array or tag expression.
|
|
1496
1650
|
* @param notification - The notification to send to the matching devices.
|
|
1497
|
-
* @param options -
|
|
1498
|
-
* which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
|
|
1651
|
+
* @param options - Options which include tags used to target the device for push notifications in either an array or tag expression.
|
|
1499
1652
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1500
1653
|
*/
|
|
1501
|
-
function scheduleNotification(context, scheduledTime,
|
|
1502
|
-
return
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
// Copyright (c) Microsoft Corporation.
|
|
1506
|
-
/**
|
|
1507
|
-
* @internal
|
|
1508
|
-
*/
|
|
1509
|
-
function sendNotificationPayload(context, notification, method, pushHandle, tags, options = {}) {
|
|
1510
|
-
return tracingClient.withSpan(`NotificationHubsClientContext-${method}`, options, async (updatedOptions) => {
|
|
1654
|
+
function scheduleNotification(context, scheduledTime, notification, options = {}) {
|
|
1655
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.scheduleNotification`, options, async (updatedOptions) => {
|
|
1511
1656
|
const endpoint = context.requestUrl();
|
|
1512
|
-
endpoint.pathname += "/
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
}
|
|
1516
|
-
const headers = await context.createHeaders(method);
|
|
1517
|
-
if (notification.headers) {
|
|
1518
|
-
for (const headerName of Object.keys(notification.headers)) {
|
|
1519
|
-
headers.set(headerName, notification.headers[headerName]);
|
|
1520
|
-
}
|
|
1521
|
-
}
|
|
1522
|
-
if (pushHandle) {
|
|
1523
|
-
endpoint.searchParams.append("direct", "true");
|
|
1524
|
-
if (notification.platform === "browser") {
|
|
1525
|
-
const browserHandle = pushHandle;
|
|
1526
|
-
headers.set("ServiceBusNotification-DeviceHandle", browserHandle.endpoint);
|
|
1527
|
-
headers.set("Auth", browserHandle.auth);
|
|
1528
|
-
headers.set("P256DH", browserHandle.p256dh);
|
|
1529
|
-
}
|
|
1530
|
-
else {
|
|
1531
|
-
headers.set("ServiceBusNotification-DeviceHandle", pushHandle);
|
|
1532
|
-
}
|
|
1533
|
-
}
|
|
1657
|
+
endpoint.pathname += "/schedulednotifications/";
|
|
1658
|
+
const headers = await context.createHeaders("scheduleNotification", notification.headers);
|
|
1659
|
+
headers.set("ServiceBusNotification-ScheduleTime", scheduledTime.toISOString());
|
|
1534
1660
|
headers.set("Content-Type", notification.contentType);
|
|
1535
1661
|
headers.set("ServiceBusNotification-Format", notification.platform);
|
|
1536
|
-
if (tags) {
|
|
1537
|
-
|
|
1538
|
-
if (Array.isArray(tags)) {
|
|
1539
|
-
tagExpression = tags.join("||");
|
|
1540
|
-
}
|
|
1541
|
-
else {
|
|
1542
|
-
tagExpression = tags;
|
|
1543
|
-
}
|
|
1544
|
-
headers.set("ServiceBusNotification-Tags", tagExpression);
|
|
1662
|
+
if (options.tags) {
|
|
1663
|
+
headers.set("ServiceBusNotification-Tags", normalizeTags(options.tags));
|
|
1545
1664
|
}
|
|
1546
1665
|
const request = createRequest(endpoint, "POST", headers, updatedOptions);
|
|
1547
1666
|
request.body = notification.body;
|
|
@@ -1552,64 +1671,76 @@ function sendNotificationPayload(context, notification, method, pushHandle, tags
|
|
|
1552
1671
|
|
|
1553
1672
|
// Copyright (c) Microsoft Corporation.
|
|
1554
1673
|
/**
|
|
1555
|
-
*
|
|
1556
|
-
* @param
|
|
1557
|
-
* @
|
|
1558
|
-
* @param options - Configuration options for the direct send operation which can contain custom headers
|
|
1559
|
-
* which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
|
|
1560
|
-
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1674
|
+
* Determines whether the options are of type SendNotificationOptions.
|
|
1675
|
+
* @param options - The options to test if SendNotificationOptions.
|
|
1676
|
+
* @returns true if SendNotificationOptions otherwise false.
|
|
1561
1677
|
*/
|
|
1562
|
-
function
|
|
1563
|
-
return
|
|
1678
|
+
function isSendNotificationOptions(options) {
|
|
1679
|
+
return coreUtil.objectHasProperty(options, "tags") || coreUtil.objectHasProperty(options, "enableTestSend");
|
|
1564
1680
|
}
|
|
1565
|
-
|
|
1566
|
-
// Copyright (c) Microsoft Corporation.
|
|
1567
1681
|
/**
|
|
1568
|
-
*
|
|
1569
|
-
* @param
|
|
1570
|
-
* @
|
|
1571
|
-
* @param notification - The notification to send to the device.
|
|
1572
|
-
* @param options - The options for sending a direct notification.
|
|
1573
|
-
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1682
|
+
* Determines whether the options are of type DirectSendNotificationOptions.
|
|
1683
|
+
* @param options - The options to test if DirectSendNotificationOptions.
|
|
1684
|
+
* @returns true if DirectSendNotificationOptions otherwise false.
|
|
1574
1685
|
*/
|
|
1575
|
-
function
|
|
1576
|
-
return
|
|
1686
|
+
function isDirectSendNotificationOptions(options) {
|
|
1687
|
+
return coreUtil.objectHasProperty(options, "deviceHandle");
|
|
1577
1688
|
}
|
|
1578
1689
|
|
|
1579
1690
|
// Copyright (c) Microsoft Corporation.
|
|
1580
1691
|
/**
|
|
1581
1692
|
* Sends push notifications to devices that match the given tags or tag expression.
|
|
1582
1693
|
* @param context - The Notification Hubs client.
|
|
1583
|
-
* @param tags - The tags used to target the device for push notifications in either an array or tag expression.
|
|
1584
1694
|
* @param notification - The notification to send to the matching devices.
|
|
1585
|
-
* @param options -
|
|
1586
|
-
* which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
|
|
1695
|
+
* @param options - Options for the notification including tags, device handles and whether to enable test send.
|
|
1587
1696
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1588
1697
|
*/
|
|
1589
|
-
function sendNotification(context,
|
|
1590
|
-
return
|
|
1591
|
-
}
|
|
1592
|
-
|
|
1593
|
-
// Copyright (c) Microsoft Corporation.
|
|
1594
|
-
const OPERATION_NAME$2 = "submitNotificationHubJob";
|
|
1595
|
-
/**
|
|
1596
|
-
* Submits a Notification Hub Job.
|
|
1597
|
-
* Note: this is available to Standard SKU namespace and above.
|
|
1598
|
-
* @param context - The Notification Hubs client.
|
|
1599
|
-
* @param job - The notification hub job to submit.
|
|
1600
|
-
* @param options - The operation options.
|
|
1601
|
-
* @returns The notification hub job details including job ID and status.
|
|
1602
|
-
*/
|
|
1603
|
-
function submitNotificationHubJob(context, job, options = {}) {
|
|
1604
|
-
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$2}`, options, async (updatedOptions) => {
|
|
1698
|
+
function sendNotification(context, notification, options = { enableTestSend: false }) {
|
|
1699
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.sendNotification`, options, async (updatedOptions) => {
|
|
1605
1700
|
const endpoint = context.requestUrl();
|
|
1606
|
-
endpoint.pathname += "/
|
|
1607
|
-
|
|
1608
|
-
|
|
1701
|
+
endpoint.pathname += "/messages/";
|
|
1702
|
+
// Check if batch direct send
|
|
1703
|
+
if (isDirectSendNotificationOptions(options) && Array.isArray(options.deviceHandle)) {
|
|
1704
|
+
endpoint.pathname += "$batch";
|
|
1705
|
+
}
|
|
1706
|
+
// Check for test send
|
|
1707
|
+
if (isSendNotificationOptions(options) && options.enableTestSend) {
|
|
1708
|
+
endpoint.searchParams.append("test", "true");
|
|
1709
|
+
}
|
|
1710
|
+
const headers = await context.createHeaders("sendNotification", notification.headers);
|
|
1711
|
+
headers.set("ServiceBusNotification-Format", notification.platform);
|
|
1712
|
+
let body = notification.body;
|
|
1713
|
+
let contentType = notification.contentType;
|
|
1714
|
+
// Check for direct batch send
|
|
1715
|
+
if (isDirectSendNotificationOptions(options) && Array.isArray(options.deviceHandle)) {
|
|
1716
|
+
endpoint.searchParams.append("direct", "true");
|
|
1717
|
+
const boundary = `nh-boundary-${uuid.v4()}`;
|
|
1718
|
+
contentType = `multipart/mixed; boundary = "${boundary}"`;
|
|
1719
|
+
body = createMultipartDirectNotification(boundary, notification, options.deviceHandle);
|
|
1720
|
+
}
|
|
1721
|
+
else if (isDirectSendNotificationOptions(options)) {
|
|
1722
|
+
endpoint.searchParams.append("direct", "true");
|
|
1723
|
+
if (notification.platform === "browser") {
|
|
1724
|
+
const browserHandle = options.deviceHandle;
|
|
1725
|
+
headers.set("ServiceBusNotification-DeviceHandle", browserHandle.endpoint);
|
|
1726
|
+
headers.set("Auth", browserHandle.auth);
|
|
1727
|
+
headers.set("P256DH", browserHandle.p256dh);
|
|
1728
|
+
}
|
|
1729
|
+
else {
|
|
1730
|
+
headers.set("ServiceBusNotification-DeviceHandle", options.deviceHandle);
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
else if (isSendNotificationOptions(options)) {
|
|
1734
|
+
if (options.tags) {
|
|
1735
|
+
headers.set("ServiceBusNotification-Tags", normalizeTags(options.tags));
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
headers.set("Content-Type", contentType);
|
|
1739
|
+
headers.set("ServiceBusNotification-Format", notification.platform);
|
|
1609
1740
|
const request = createRequest(endpoint, "POST", headers, updatedOptions);
|
|
1610
|
-
request.body =
|
|
1741
|
+
request.body = body;
|
|
1611
1742
|
const response = await sendRequest(context, request, 201);
|
|
1612
|
-
return
|
|
1743
|
+
return parseNotificationSendResponse(response);
|
|
1613
1744
|
});
|
|
1614
1745
|
}
|
|
1615
1746
|
|
|
@@ -1624,7 +1755,7 @@ const OPERATION_NAME$1 = "updateInstallation";
|
|
|
1624
1755
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1625
1756
|
*/
|
|
1626
1757
|
function updateInstallation(context, installationId, installationPatches, options = {}) {
|
|
1627
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1758
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$1}`, options, async (updatedOptions) => {
|
|
1628
1759
|
const endpoint = context.requestUrl();
|
|
1629
1760
|
endpoint.pathname += `/installations/${installationId}`;
|
|
1630
1761
|
const headers = await context.createHeaders(OPERATION_NAME$1);
|
|
@@ -1646,7 +1777,7 @@ const OPERATION_NAME = "updateRegistration";
|
|
|
1646
1777
|
* @returns The updated registration description.
|
|
1647
1778
|
*/
|
|
1648
1779
|
function updateRegistration(context, registration, options = {}) {
|
|
1649
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1780
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME}`, options, async (updatedOptions) => {
|
|
1650
1781
|
if (!registration.etag) {
|
|
1651
1782
|
throw new coreRestPipeline.RestError("ETag is required for registration update", { statusCode: 400 });
|
|
1652
1783
|
}
|
|
@@ -1742,6 +1873,16 @@ class NotificationHubsServiceClient {
|
|
|
1742
1873
|
updateRegistration(registration, options = {}) {
|
|
1743
1874
|
return updateRegistration(this._client, registration, options);
|
|
1744
1875
|
}
|
|
1876
|
+
/**
|
|
1877
|
+
* Deletes a registration with the given registration ID.
|
|
1878
|
+
* @param context - The Notification Hubs client.
|
|
1879
|
+
* @param registrationId - The registration ID of the registration to delete.
|
|
1880
|
+
* @param options - The options for delete operations including the ETag
|
|
1881
|
+
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1882
|
+
*/
|
|
1883
|
+
deleteRegistration(registrationId, options = {}) {
|
|
1884
|
+
return deleteRegistration(this._client, registrationId, options);
|
|
1885
|
+
}
|
|
1745
1886
|
/**
|
|
1746
1887
|
* Gets a registration by the given registration ID.
|
|
1747
1888
|
* @param registrationId - The ID of the registration to get.
|
|
@@ -1768,61 +1909,25 @@ class NotificationHubsServiceClient {
|
|
|
1768
1909
|
listRegistrationsByTag(tag, options = {}) {
|
|
1769
1910
|
return listRegistrationsByTag(this._client, tag, options);
|
|
1770
1911
|
}
|
|
1771
|
-
/**
|
|
1772
|
-
* Sends a direct push notification to a device with the given push handle.
|
|
1773
|
-
* @param pushHandle - The push handle which is the unique identifier for the device.
|
|
1774
|
-
* @param notification - The notification to send to the device.
|
|
1775
|
-
* @param options - The options for sending a direct notification.
|
|
1776
|
-
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1777
|
-
*/
|
|
1778
|
-
sendDirectNotification(pushHandle, notification, options = {}) {
|
|
1779
|
-
return sendDirectNotification(this._client, pushHandle, notification, options);
|
|
1780
|
-
}
|
|
1781
1912
|
/**
|
|
1782
1913
|
* Sends push notifications to devices that match the given tags or tag expression.
|
|
1783
|
-
* @param tags - The tags used to target the device for push notifications in either an array or tag expression.
|
|
1784
1914
|
* @param notification - The notification to send to the matching devices.
|
|
1785
|
-
* @param options -
|
|
1786
|
-
* which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
|
|
1787
|
-
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1788
|
-
*/
|
|
1789
|
-
sendNotification(tags, notification, options = {}) {
|
|
1790
|
-
return sendNotification(this._client, tags, notification, options);
|
|
1791
|
-
}
|
|
1792
|
-
/**
|
|
1793
|
-
* Sends push notifications to all devices on the Notification Hub.
|
|
1794
|
-
* @param notification - The notification to send to all devices.
|
|
1795
|
-
* @param options - Configuration options for the direct send operation which can contain custom headers
|
|
1796
|
-
* which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
|
|
1915
|
+
* @param options - Options for the notification including tags, device handles and whether to enable test send.
|
|
1797
1916
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1798
1917
|
*/
|
|
1799
|
-
|
|
1800
|
-
return
|
|
1918
|
+
sendNotification(notification, options = { enableTestSend: false }) {
|
|
1919
|
+
return sendNotification(this._client, notification, options);
|
|
1801
1920
|
}
|
|
1802
1921
|
/**
|
|
1803
1922
|
* Schedules a push notification to devices that match the given tags or tag expression at the specified time.
|
|
1804
1923
|
* NOTE: This is only available in Standard SKU Azure Notification Hubs.
|
|
1805
1924
|
* @param scheduledTime - The Date to send the push notification.
|
|
1806
|
-
* @param tags - The tags used to target the device for push notifications in either an array or tag expression.
|
|
1807
1925
|
* @param notification - The notification to send to the matching devices.
|
|
1808
|
-
* @param options -
|
|
1809
|
-
* which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
|
|
1926
|
+
* @param options - Options which include tags used to target the device for push notifications in either an array or tag expression.
|
|
1810
1927
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1811
1928
|
*/
|
|
1812
|
-
scheduleNotification(scheduledTime,
|
|
1813
|
-
return scheduleNotification(this._client, scheduledTime,
|
|
1814
|
-
}
|
|
1815
|
-
/**
|
|
1816
|
-
* Schedules a push notification to all devices registered on the Notification Hub.
|
|
1817
|
-
* NOTE: This is only available in Standard SKU Azure Notification Hubs.
|
|
1818
|
-
* @param scheduledTime - The Date to send the push notification.
|
|
1819
|
-
* @param notification - The notification to send to the matching devices.
|
|
1820
|
-
* @param options - Configuration options for the direct send operation which can contain custom headers
|
|
1821
|
-
* which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
|
|
1822
|
-
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1823
|
-
*/
|
|
1824
|
-
scheduleBroadcastNotification(scheduledTime, notification, options = {}) {
|
|
1825
|
-
return scheduleBroadcastNotification(this._client, scheduledTime, notification, options);
|
|
1929
|
+
scheduleNotification(scheduledTime, notification, options = {}) {
|
|
1930
|
+
return scheduleNotification(this._client, scheduledTime, notification, options);
|
|
1826
1931
|
}
|
|
1827
1932
|
/**
|
|
1828
1933
|
* Cancels the scheduled notification with the given notification ID.
|
|
@@ -1861,6 +1966,15 @@ class NotificationHubsServiceClient {
|
|
|
1861
1966
|
getNotificationHubJob(jobId, options = {}) {
|
|
1862
1967
|
return getNotificationHubJob(this._client, jobId, options);
|
|
1863
1968
|
}
|
|
1969
|
+
/**
|
|
1970
|
+
* Submits a Notification Hub job and creates a poller to poll for results.
|
|
1971
|
+
* @param notificationHubJob - The Notification Hub import/export job to start.
|
|
1972
|
+
* @param options - The operation options.
|
|
1973
|
+
* @returns A poller which can be called to poll until completion of the job.
|
|
1974
|
+
*/
|
|
1975
|
+
beginSubmitNotificationHubJob(notificationHubJob, options = {}) {
|
|
1976
|
+
return beginSubmitNotificationHubJob(this._client, notificationHubJob, options);
|
|
1977
|
+
}
|
|
1864
1978
|
/**
|
|
1865
1979
|
* Submits a Notification Hub Job. Note this is available to Standard SKU namespace and above.
|
|
1866
1980
|
* @param job - The notification hub job to submit.
|