@azure/notification-hubs 1.0.0-alpha.20221003.1 → 1.0.0-alpha.20221013.2
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 +27 -43
- package/dist/index.cjs +390 -310
- 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 +16 -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 +3 -1
- package/dist-esm/src/serializers/notificationHubJobSerializer.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 +5 -4
- package/types/3.1/notification-hubs.d.ts +52 -36
- package/types/latest/notification-hubs.d.ts +56 -36
- 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 +14 -37
- package/types/src/notificationHubsClient.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.7";
|
|
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$
|
|
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$i = "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$h = "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);
|
|
@@ -937,7 +1187,7 @@ async function createOrUpdateRegistrationDescription(context, registration, oper
|
|
|
937
1187
|
}
|
|
938
1188
|
|
|
939
1189
|
// Copyright (c) Microsoft Corporation.
|
|
940
|
-
const OPERATION_NAME$
|
|
1190
|
+
const OPERATION_NAME$d = "createOrUpdateRegistration";
|
|
941
1191
|
/**
|
|
942
1192
|
* Creates or updates a registration.
|
|
943
1193
|
* @param context - The Notification Hubs client.
|
|
@@ -946,13 +1196,13 @@ const OPERATION_NAME$g = "createOrUpdateRegistration";
|
|
|
946
1196
|
* @returns The created or updated registration description.
|
|
947
1197
|
*/
|
|
948
1198
|
function createOrUpdateRegistration(context, registration, options = {}) {
|
|
949
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1199
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$d}`, options, async (updatedOptions) => {
|
|
950
1200
|
return createOrUpdateRegistrationDescription(context, registration, "createOrUpdate", updatedOptions);
|
|
951
1201
|
});
|
|
952
1202
|
}
|
|
953
1203
|
|
|
954
1204
|
// Copyright (c) Microsoft Corporation.
|
|
955
|
-
const OPERATION_NAME$
|
|
1205
|
+
const OPERATION_NAME$c = "createRegistrationId";
|
|
956
1206
|
/**
|
|
957
1207
|
* Creates a new registration ID.
|
|
958
1208
|
* @param context - The Notification Hubs client.
|
|
@@ -960,10 +1210,10 @@ const OPERATION_NAME$f = "createRegistrationId";
|
|
|
960
1210
|
* @returns The newly created registration ID.
|
|
961
1211
|
*/
|
|
962
1212
|
function createRegistrationId(context, options = {}) {
|
|
963
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1213
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$c}`, options, async (updatedOptions) => {
|
|
964
1214
|
const endpoint = context.requestUrl();
|
|
965
1215
|
endpoint.pathname += "/registrationIDs";
|
|
966
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1216
|
+
const headers = await context.createHeaders(OPERATION_NAME$c);
|
|
967
1217
|
headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
|
|
968
1218
|
const request = createRequest(endpoint, "POST", headers, updatedOptions);
|
|
969
1219
|
const response = await sendRequest(context, request, 201);
|
|
@@ -976,7 +1226,7 @@ function createRegistrationId(context, options = {}) {
|
|
|
976
1226
|
}
|
|
977
1227
|
|
|
978
1228
|
// Copyright (c) Microsoft Corporation.
|
|
979
|
-
const OPERATION_NAME$
|
|
1229
|
+
const OPERATION_NAME$b = "createRegistration";
|
|
980
1230
|
/**
|
|
981
1231
|
* Creates a new registration. This method generates a registration ID,
|
|
982
1232
|
* which you can subsequently use to retrieve, update, and delete this registration.
|
|
@@ -986,7 +1236,7 @@ const OPERATION_NAME$e = "createRegistration";
|
|
|
986
1236
|
* @returns The newly created registration description.
|
|
987
1237
|
*/
|
|
988
1238
|
function createRegistration(context, registration, options = {}) {
|
|
989
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1239
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$b}`, options, async (updatedOptions) => {
|
|
990
1240
|
if (registration.registrationId) {
|
|
991
1241
|
throw new coreRestPipeline.RestError("registrationId must not be set during a create operation", {
|
|
992
1242
|
statusCode: 400,
|
|
@@ -997,7 +1247,7 @@ function createRegistration(context, registration, options = {}) {
|
|
|
997
1247
|
}
|
|
998
1248
|
|
|
999
1249
|
// Copyright (c) Microsoft Corporation.
|
|
1000
|
-
const OPERATION_NAME$
|
|
1250
|
+
const OPERATION_NAME$a = "deleteInstallation";
|
|
1001
1251
|
/**
|
|
1002
1252
|
* Deletes an installation from a Notification Hub.
|
|
1003
1253
|
* @param context - The Notification Hubs client.
|
|
@@ -1006,10 +1256,10 @@ const OPERATION_NAME$d = "deleteInstallation";
|
|
|
1006
1256
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1007
1257
|
*/
|
|
1008
1258
|
function deleteInstallation(context, installationId, options = {}) {
|
|
1009
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1259
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$a}`, options, async (updatedOptions) => {
|
|
1010
1260
|
const endpoint = context.requestUrl();
|
|
1011
1261
|
endpoint.pathname += `/installations/${installationId}`;
|
|
1012
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1262
|
+
const headers = await context.createHeaders(OPERATION_NAME$a);
|
|
1013
1263
|
const request = createRequest(endpoint, "DELETE", headers, updatedOptions);
|
|
1014
1264
|
const response = await sendRequest(context, request, 204);
|
|
1015
1265
|
return parseNotificationResponse(response);
|
|
@@ -1017,7 +1267,7 @@ function deleteInstallation(context, installationId, options = {}) {
|
|
|
1017
1267
|
}
|
|
1018
1268
|
|
|
1019
1269
|
// Copyright (c) Microsoft Corporation.
|
|
1020
|
-
const OPERATION_NAME$
|
|
1270
|
+
const OPERATION_NAME$9 = "deleteRegistration";
|
|
1021
1271
|
/**
|
|
1022
1272
|
* Deletes a registration with the given registration ID.
|
|
1023
1273
|
* @param context - The Notification Hubs client.
|
|
@@ -1026,10 +1276,10 @@ const OPERATION_NAME$c = "deleteRegistration";
|
|
|
1026
1276
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1027
1277
|
*/
|
|
1028
1278
|
function deleteRegistration(context, registrationId, options = {}) {
|
|
1029
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1279
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$9}`, options, async (updatedOptions) => {
|
|
1030
1280
|
const endpoint = context.requestUrl();
|
|
1031
1281
|
endpoint.pathname += `/registrations/${registrationId}`;
|
|
1032
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1282
|
+
const headers = await context.createHeaders(OPERATION_NAME$9);
|
|
1033
1283
|
headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
|
|
1034
1284
|
headers.set("If-Match", isDefined(options.etag) ? `"${options.etag}"` : "*");
|
|
1035
1285
|
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
@@ -1039,7 +1289,7 @@ function deleteRegistration(context, registrationId, options = {}) {
|
|
|
1039
1289
|
}
|
|
1040
1290
|
|
|
1041
1291
|
// Copyright (c) Microsoft Corporation.
|
|
1042
|
-
const OPERATION_NAME$
|
|
1292
|
+
const OPERATION_NAME$8 = "getFeedbackContainerUrl";
|
|
1043
1293
|
/**
|
|
1044
1294
|
* Retrieves an Azure Storage container URL. The container has feedback data for the notification hub.
|
|
1045
1295
|
* The caller can then use the Azure Storage Services SDK to retrieve the contents of the container.
|
|
@@ -1048,10 +1298,10 @@ const OPERATION_NAME$b = "getFeedbackContainerUrl";
|
|
|
1048
1298
|
* @returns The URL of the Azure Storage Container containing the feedback data.
|
|
1049
1299
|
*/
|
|
1050
1300
|
function getFeedbackContainerUrl(context, options = {}) {
|
|
1051
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1301
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$8}`, options, async (updatedOptions) => {
|
|
1052
1302
|
const endpoint = context.requestUrl();
|
|
1053
1303
|
endpoint.pathname += "/feedbackcontainer";
|
|
1054
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1304
|
+
const headers = await context.createHeaders(OPERATION_NAME$8);
|
|
1055
1305
|
headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
|
|
1056
1306
|
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
1057
1307
|
const response = await sendRequest(context, request, 200);
|
|
@@ -1060,7 +1310,7 @@ function getFeedbackContainerUrl(context, options = {}) {
|
|
|
1060
1310
|
}
|
|
1061
1311
|
|
|
1062
1312
|
// Copyright (c) Microsoft Corporation.
|
|
1063
|
-
const OPERATION_NAME$
|
|
1313
|
+
const OPERATION_NAME$7 = "getInstallation";
|
|
1064
1314
|
/**
|
|
1065
1315
|
* Gets an Azure Notification Hub installation by the installation ID.
|
|
1066
1316
|
* @param context - The Notification Hubs client.
|
|
@@ -1069,10 +1319,10 @@ const OPERATION_NAME$a = "getInstallation";
|
|
|
1069
1319
|
* @returns The installation that matches the installation ID.
|
|
1070
1320
|
*/
|
|
1071
1321
|
function getInstallation(context, installationId, options = {}) {
|
|
1072
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1322
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$7}`, options, async (updatedOptions) => {
|
|
1073
1323
|
const endpoint = context.requestUrl();
|
|
1074
1324
|
endpoint.pathname += `/installations/${installationId}`;
|
|
1075
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1325
|
+
const headers = await context.createHeaders(OPERATION_NAME$7);
|
|
1076
1326
|
headers.set("Content-Type", "application/json");
|
|
1077
1327
|
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
1078
1328
|
const response = await sendRequest(context, request, 200);
|
|
@@ -1080,101 +1330,6 @@ function getInstallation(context, installationId, options = {}) {
|
|
|
1080
1330
|
});
|
|
1081
1331
|
}
|
|
1082
1332
|
|
|
1083
|
-
// Copyright (c) Microsoft Corporation.
|
|
1084
|
-
/**
|
|
1085
|
-
* @internal
|
|
1086
|
-
* Serializes a NotificationHubJob into an Atom XML entry.
|
|
1087
|
-
* @param entry - The NotificationHubJob to turn into an Atom XML entry.
|
|
1088
|
-
* @returns An Atom XML entry containing the notification hub job.
|
|
1089
|
-
*/
|
|
1090
|
-
function serializeNotificationHubJobEntry(entry) {
|
|
1091
|
-
const job = {
|
|
1092
|
-
Type: entry.type,
|
|
1093
|
-
OutputContainerUri: { __cdata: entry.outputContainerUrl },
|
|
1094
|
-
ImportFileUri: isDefined(entry.importFileUrl) ? { __cdata: entry.importFileUrl } : undefined,
|
|
1095
|
-
};
|
|
1096
|
-
const requestObject = serializeToAtomXmlRequest("NotificationHubJob", job);
|
|
1097
|
-
return coreXml.stringifyXML(requestObject, { rootName: "entry", cdataPropName: "__cdata" });
|
|
1098
|
-
}
|
|
1099
|
-
/**
|
|
1100
|
-
* Parses an Atom XML of an notification hub job entry.
|
|
1101
|
-
* @param bodyText - The incoming Atom XML entry to parse into a notification hub job.
|
|
1102
|
-
* @returns A parsed NotificationHubJob.
|
|
1103
|
-
*/
|
|
1104
|
-
async function parseNotificationHubJobEntry(bodyText) {
|
|
1105
|
-
const xml = await coreXml.parseXML(bodyText, { includeRoot: true });
|
|
1106
|
-
const content = xml.entry.content.NotificationHubJob;
|
|
1107
|
-
return createNotificationHubJob(content);
|
|
1108
|
-
}
|
|
1109
|
-
/**
|
|
1110
|
-
* Parses an Atom XML feed of notification hub jobs.
|
|
1111
|
-
* @param bodyText - The incoming Atom XML feed to parse into notification hub jobs.
|
|
1112
|
-
* @returns A list of notification hub jobs.
|
|
1113
|
-
*/
|
|
1114
|
-
async function parseNotificationHubJobFeed(bodyText) {
|
|
1115
|
-
const xml = await coreXml.parseXML(bodyText, { includeRoot: true });
|
|
1116
|
-
const results = [];
|
|
1117
|
-
if (!isDefined(xml.feed.entry)) {
|
|
1118
|
-
return results;
|
|
1119
|
-
}
|
|
1120
|
-
const entries = Array.isArray(xml.feed.entry) ? xml.feed.entry : [xml.feed.entry];
|
|
1121
|
-
for (const item of entries) {
|
|
1122
|
-
results.push(createNotificationHubJob(item.content.NotificationHubJob));
|
|
1123
|
-
}
|
|
1124
|
-
return results;
|
|
1125
|
-
}
|
|
1126
|
-
function createInputOutputProperties(content) {
|
|
1127
|
-
const props = {};
|
|
1128
|
-
for (const item of content["d3p1:KeyValueOfstringstring"]) {
|
|
1129
|
-
props[item["d3p1:Key"]] = item["d3p1:Value"];
|
|
1130
|
-
}
|
|
1131
|
-
return props;
|
|
1132
|
-
}
|
|
1133
|
-
function createNotificationHubJob(content) {
|
|
1134
|
-
let outputProperties;
|
|
1135
|
-
if (isDefined(content["OutputProperties"])) {
|
|
1136
|
-
outputProperties = createInputOutputProperties(content["OutputProperties"]);
|
|
1137
|
-
}
|
|
1138
|
-
let inputProperties;
|
|
1139
|
-
if (isDefined(content["InputProperties"])) {
|
|
1140
|
-
inputProperties = createInputOutputProperties(content["InputProperties"]);
|
|
1141
|
-
}
|
|
1142
|
-
return {
|
|
1143
|
-
jobId: getStringOrUndefined(content["JobId"]),
|
|
1144
|
-
type: getString(content["Type"], "type"),
|
|
1145
|
-
status: getStringOrUndefined(content["Status"]),
|
|
1146
|
-
progress: getFloatOrUndefined(content["Progress"]),
|
|
1147
|
-
outputContainerUrl: getString(content["OutputContainerUri"], "outputContainerUrl"),
|
|
1148
|
-
importFileUrl: getStringOrUndefined(content["ImportFileUri"]),
|
|
1149
|
-
failure: getStringOrUndefined(content["Failure"]),
|
|
1150
|
-
createdAt: getDateOrUndefined(content["CreatedAt"]),
|
|
1151
|
-
updatedAt: getDateOrUndefined(content["UpdatedAt"]),
|
|
1152
|
-
inputProperties,
|
|
1153
|
-
outputProperties,
|
|
1154
|
-
};
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
// Copyright (c) Microsoft Corporation.
|
|
1158
|
-
const OPERATION_NAME$9 = "getNotificationHubJob";
|
|
1159
|
-
/**
|
|
1160
|
-
* Gets a Notification Hub Job by the ID.
|
|
1161
|
-
* @param context - The Notification Hubs client.
|
|
1162
|
-
* @param jobId - The Notification Hub Job ID.
|
|
1163
|
-
* @param options - The operation options.
|
|
1164
|
-
* @returns The Notification Hub Job with the matching ID.
|
|
1165
|
-
*/
|
|
1166
|
-
function getNotificationHubJob(context, jobId, options = {}) {
|
|
1167
|
-
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$9}`, options, async (updatedOptions) => {
|
|
1168
|
-
const endpoint = context.requestUrl();
|
|
1169
|
-
endpoint.pathname += `/jobs/${jobId}`;
|
|
1170
|
-
const headers = await context.createHeaders(OPERATION_NAME$9);
|
|
1171
|
-
headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
|
|
1172
|
-
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
1173
|
-
const response = await sendRequest(context, request, 200);
|
|
1174
|
-
return parseNotificationHubJobEntry(response.bodyAsText);
|
|
1175
|
-
});
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
1333
|
// Copyright (c) Microsoft Corporation.
|
|
1179
1334
|
/**
|
|
1180
1335
|
* @internal
|
|
@@ -1223,15 +1378,16 @@ async function parseNotificationDetails(bodyText) {
|
|
|
1223
1378
|
};
|
|
1224
1379
|
}
|
|
1225
1380
|
function parseOutcomeCounts(counts) {
|
|
1381
|
+
const items = Array.isArray(counts) ? counts : [counts];
|
|
1226
1382
|
const results = [];
|
|
1227
|
-
for (const item of
|
|
1383
|
+
for (const item of items) {
|
|
1228
1384
|
results.push({ state: item["Name"], count: getInteger(item["Count"], "Count") });
|
|
1229
1385
|
}
|
|
1230
1386
|
return results;
|
|
1231
1387
|
}
|
|
1232
1388
|
|
|
1233
1389
|
// Copyright (c) Microsoft Corporation.
|
|
1234
|
-
const OPERATION_NAME$
|
|
1390
|
+
const OPERATION_NAME$6 = "getNotificationOutcomeDetails";
|
|
1235
1391
|
/**
|
|
1236
1392
|
* Retrieves the results of a send operation. This can retrieve intermediate results if the send is being processed
|
|
1237
1393
|
* or final results if the Send* has completed. This API can only be called for Standard SKU and above.
|
|
@@ -1241,10 +1397,10 @@ const OPERATION_NAME$8 = "getNotificationOutcomeDetails";
|
|
|
1241
1397
|
* @returns The results of the send operation.
|
|
1242
1398
|
*/
|
|
1243
1399
|
function getNotificationOutcomeDetails(context, notificationId, options = {}) {
|
|
1244
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1400
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$6}`, options, async (updatedOptions) => {
|
|
1245
1401
|
const endpoint = context.requestUrl();
|
|
1246
1402
|
endpoint.pathname += `/messages/${notificationId}`;
|
|
1247
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1403
|
+
const headers = await context.createHeaders(OPERATION_NAME$6);
|
|
1248
1404
|
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
1249
1405
|
const response = await sendRequest(context, request, 200);
|
|
1250
1406
|
return parseNotificationDetails(response.bodyAsText);
|
|
@@ -1252,7 +1408,7 @@ function getNotificationOutcomeDetails(context, notificationId, options = {}) {
|
|
|
1252
1408
|
}
|
|
1253
1409
|
|
|
1254
1410
|
// Copyright (c) Microsoft Corporation.
|
|
1255
|
-
const OPERATION_NAME$
|
|
1411
|
+
const OPERATION_NAME$5 = "getRegistration";
|
|
1256
1412
|
/**
|
|
1257
1413
|
* Gets a registration by the given registration ID.
|
|
1258
1414
|
* @param context - The Notification Hubs client.
|
|
@@ -1261,10 +1417,10 @@ const OPERATION_NAME$7 = "getRegistration";
|
|
|
1261
1417
|
* @returns A RegistrationDescription that has the given registration ID.
|
|
1262
1418
|
*/
|
|
1263
1419
|
function getRegistration(context, registrationId, options = {}) {
|
|
1264
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1420
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$5}`, options, async (updatedOptions) => {
|
|
1265
1421
|
const endpoint = context.requestUrl();
|
|
1266
1422
|
endpoint.pathname += `/registrations/${registrationId}`;
|
|
1267
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1423
|
+
const headers = await context.createHeaders(OPERATION_NAME$5);
|
|
1268
1424
|
headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
|
|
1269
1425
|
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
1270
1426
|
const response = await sendRequest(context, request, 200);
|
|
@@ -1273,7 +1429,7 @@ function getRegistration(context, registrationId, options = {}) {
|
|
|
1273
1429
|
}
|
|
1274
1430
|
|
|
1275
1431
|
// Copyright (c) Microsoft Corporation.
|
|
1276
|
-
const OPERATION_NAME$
|
|
1432
|
+
const OPERATION_NAME$4 = "listNotificationHubJobs";
|
|
1277
1433
|
/**
|
|
1278
1434
|
* Gets all Notification Hub Jobs for this Notification Hub.
|
|
1279
1435
|
* @param context - The Notification Hubs client.xs
|
|
@@ -1281,10 +1437,10 @@ const OPERATION_NAME$6 = "listNotificationHubJobs";
|
|
|
1281
1437
|
* @returns An array of all Notification Hub Jobs for this Notification Hub.
|
|
1282
1438
|
*/
|
|
1283
1439
|
function listNotificationHubJobs(context, options = {}) {
|
|
1284
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1440
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$4}`, options, async (updatedOptions) => {
|
|
1285
1441
|
const endpoint = context.requestUrl();
|
|
1286
1442
|
endpoint.pathname += "/jobs";
|
|
1287
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1443
|
+
const headers = await context.createHeaders(OPERATION_NAME$4);
|
|
1288
1444
|
headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
|
|
1289
1445
|
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
1290
1446
|
const response = await sendRequest(context, request, 200);
|
|
@@ -1293,7 +1449,7 @@ function listNotificationHubJobs(context, options = {}) {
|
|
|
1293
1449
|
}
|
|
1294
1450
|
|
|
1295
1451
|
// Copyright (c) Microsoft Corporation.
|
|
1296
|
-
const OPERATION_NAME$
|
|
1452
|
+
const OPERATION_NAME$3 = "listRegistrationsByTag";
|
|
1297
1453
|
/**
|
|
1298
1454
|
* Lists all registrations with the matching tag.
|
|
1299
1455
|
* @param context - The Notification Hubs client.
|
|
@@ -1302,7 +1458,7 @@ const OPERATION_NAME$5 = "listRegistrationsByTag";
|
|
|
1302
1458
|
* @returns A paged async iterable containing the matching registrations for the notification hub.
|
|
1303
1459
|
*/
|
|
1304
1460
|
function listRegistrationsByTag(context, tag, options = {}) {
|
|
1305
|
-
const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext
|
|
1461
|
+
const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext.${OPERATION_NAME$3}`, options);
|
|
1306
1462
|
try {
|
|
1307
1463
|
const iter = listRegistrationsByTagAll(context, tag, updatedOptions);
|
|
1308
1464
|
return {
|
|
@@ -1364,7 +1520,7 @@ async function _listRegistrationsByTag(context, tag, options, continuationToken)
|
|
|
1364
1520
|
if (continuationToken !== undefined) {
|
|
1365
1521
|
endpoint.searchParams.set("continuationtoken", continuationToken);
|
|
1366
1522
|
}
|
|
1367
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1523
|
+
const headers = await context.createHeaders(OPERATION_NAME$3);
|
|
1368
1524
|
const request = createRequest(endpoint, "GET", headers, options);
|
|
1369
1525
|
const response = await sendRequest(context, request, 200);
|
|
1370
1526
|
const registrations = await registrationDescriptionParser.parseRegistrationFeed(response.bodyAsText);
|
|
@@ -1376,7 +1532,7 @@ async function _listRegistrationsByTag(context, tag, options, continuationToken)
|
|
|
1376
1532
|
}
|
|
1377
1533
|
|
|
1378
1534
|
// Copyright (c) Microsoft Corporation.
|
|
1379
|
-
const OPERATION_NAME$
|
|
1535
|
+
const OPERATION_NAME$2 = "listRegistrations";
|
|
1380
1536
|
/**
|
|
1381
1537
|
* Gets all registrations for the notification hub with the given query options.
|
|
1382
1538
|
* @param context - The Notification Hubs client.
|
|
@@ -1384,7 +1540,7 @@ const OPERATION_NAME$4 = "listRegistrations";
|
|
|
1384
1540
|
* @returns A paged async iterable containing all of the registrations for the notification hub.
|
|
1385
1541
|
*/
|
|
1386
1542
|
function listRegistrations(context, options = {}) {
|
|
1387
|
-
const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext
|
|
1543
|
+
const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext.${OPERATION_NAME$2}`, options);
|
|
1388
1544
|
try {
|
|
1389
1545
|
const iter = listRegistrationsAll(context, updatedOptions);
|
|
1390
1546
|
return {
|
|
@@ -1449,7 +1605,7 @@ async function _listRegistrations(context, options, continuationToken) {
|
|
|
1449
1605
|
if (continuationToken !== undefined) {
|
|
1450
1606
|
endpoint.searchParams.set("continuationtoken", continuationToken);
|
|
1451
1607
|
}
|
|
1452
|
-
const headers = await context.createHeaders(OPERATION_NAME$
|
|
1608
|
+
const headers = await context.createHeaders(OPERATION_NAME$2);
|
|
1453
1609
|
const request = createRequest(endpoint, "GET", headers, options);
|
|
1454
1610
|
const response = await sendRequest(context, request, 200);
|
|
1455
1611
|
const registrations = await registrationDescriptionParser.parseRegistrationFeed(response.bodyAsText);
|
|
@@ -1461,53 +1617,28 @@ async function _listRegistrations(context, options, continuationToken) {
|
|
|
1461
1617
|
}
|
|
1462
1618
|
|
|
1463
1619
|
// Copyright (c) Microsoft Corporation.
|
|
1464
|
-
|
|
1620
|
+
// Licensed under the MIT license.
|
|
1465
1621
|
/**
|
|
1466
1622
|
* @internal
|
|
1467
1623
|
*/
|
|
1468
|
-
function
|
|
1469
|
-
return
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
headers.set("ServiceBusNotification-Format", notification.platform);
|
|
1481
|
-
if (tags) {
|
|
1482
|
-
let tagExpression = null;
|
|
1483
|
-
if (Array.isArray(tags)) {
|
|
1484
|
-
tagExpression = tags.join("||");
|
|
1485
|
-
}
|
|
1486
|
-
else {
|
|
1487
|
-
tagExpression = tags;
|
|
1488
|
-
}
|
|
1489
|
-
headers.set("ServiceBusNotification-Tags", tagExpression);
|
|
1490
|
-
}
|
|
1491
|
-
const request = createRequest(endpoint, "POST", headers, updatedOptions);
|
|
1492
|
-
request.body = notification.body;
|
|
1493
|
-
const response = await sendRequest(context, request, 201);
|
|
1494
|
-
return parseNotificationSendResponse(response);
|
|
1495
|
-
});
|
|
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}--`);
|
|
1496
1636
|
}
|
|
1497
|
-
|
|
1498
|
-
// Copyright (c) Microsoft Corporation.
|
|
1499
1637
|
/**
|
|
1500
|
-
*
|
|
1501
|
-
* NOTE: This is only available in Standard SKU Azure Notification Hubs.
|
|
1502
|
-
* @param context - The Notification Hubs client.
|
|
1503
|
-
* @param scheduledTime - The Date to send the push notification.
|
|
1504
|
-
* @param notification - The notification to send to the matching devices.
|
|
1505
|
-
* @param options - Configuration options for the direct send operation which can contain custom headers
|
|
1506
|
-
* which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
|
|
1507
|
-
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1638
|
+
* @internal
|
|
1508
1639
|
*/
|
|
1509
|
-
function
|
|
1510
|
-
return
|
|
1640
|
+
function normalizeTags(tags) {
|
|
1641
|
+
return Array.isArray(tags) ? tags.join("||") : tags;
|
|
1511
1642
|
}
|
|
1512
1643
|
|
|
1513
1644
|
// Copyright (c) Microsoft Corporation.
|
|
@@ -1516,56 +1647,20 @@ function scheduleBroadcastNotification(context, scheduledTime, notification, opt
|
|
|
1516
1647
|
* NOTE: This is only available in Standard SKU Azure Notification Hubs.
|
|
1517
1648
|
* @param context - The Notification Hubs client.
|
|
1518
1649
|
* @param scheduledTime - The Date to send the push notification.
|
|
1519
|
-
* @param tags - The tags used to target the device for push notifications in either an array or tag expression.
|
|
1520
1650
|
* @param notification - The notification to send to the matching devices.
|
|
1521
|
-
* @param options -
|
|
1522
|
-
* 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.
|
|
1523
1652
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1524
1653
|
*/
|
|
1525
|
-
function scheduleNotification(context, scheduledTime,
|
|
1526
|
-
return
|
|
1527
|
-
}
|
|
1528
|
-
|
|
1529
|
-
// Copyright (c) Microsoft Corporation.
|
|
1530
|
-
/**
|
|
1531
|
-
* @internal
|
|
1532
|
-
*/
|
|
1533
|
-
function sendNotificationPayload(context, notification, method, pushHandle, tags, options = {}) {
|
|
1534
|
-
return tracingClient.withSpan(`NotificationHubsClientContext-${method}`, options, async (updatedOptions) => {
|
|
1654
|
+
function scheduleNotification(context, scheduledTime, notification, options = {}) {
|
|
1655
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.scheduleNotification`, options, async (updatedOptions) => {
|
|
1535
1656
|
const endpoint = context.requestUrl();
|
|
1536
|
-
endpoint.pathname += "/
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
}
|
|
1540
|
-
const headers = await context.createHeaders(method);
|
|
1541
|
-
if (notification.headers) {
|
|
1542
|
-
for (const headerName of Object.keys(notification.headers)) {
|
|
1543
|
-
headers.set(headerName, notification.headers[headerName]);
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1546
|
-
if (pushHandle) {
|
|
1547
|
-
endpoint.searchParams.append("direct", "true");
|
|
1548
|
-
if (notification.platform === "browser") {
|
|
1549
|
-
const browserHandle = pushHandle;
|
|
1550
|
-
headers.set("ServiceBusNotification-DeviceHandle", browserHandle.endpoint);
|
|
1551
|
-
headers.set("Auth", browserHandle.auth);
|
|
1552
|
-
headers.set("P256DH", browserHandle.p256dh);
|
|
1553
|
-
}
|
|
1554
|
-
else {
|
|
1555
|
-
headers.set("ServiceBusNotification-DeviceHandle", pushHandle);
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1657
|
+
endpoint.pathname += "/schedulednotifications/";
|
|
1658
|
+
const headers = await context.createHeaders("scheduleNotification", notification.headers);
|
|
1659
|
+
headers.set("ServiceBusNotification-ScheduleTime", scheduledTime.toISOString());
|
|
1558
1660
|
headers.set("Content-Type", notification.contentType);
|
|
1559
1661
|
headers.set("ServiceBusNotification-Format", notification.platform);
|
|
1560
|
-
if (tags) {
|
|
1561
|
-
|
|
1562
|
-
if (Array.isArray(tags)) {
|
|
1563
|
-
tagExpression = tags.join("||");
|
|
1564
|
-
}
|
|
1565
|
-
else {
|
|
1566
|
-
tagExpression = tags;
|
|
1567
|
-
}
|
|
1568
|
-
headers.set("ServiceBusNotification-Tags", tagExpression);
|
|
1662
|
+
if (options.tags) {
|
|
1663
|
+
headers.set("ServiceBusNotification-Tags", normalizeTags(options.tags));
|
|
1569
1664
|
}
|
|
1570
1665
|
const request = createRequest(endpoint, "POST", headers, updatedOptions);
|
|
1571
1666
|
request.body = notification.body;
|
|
@@ -1576,64 +1671,76 @@ function sendNotificationPayload(context, notification, method, pushHandle, tags
|
|
|
1576
1671
|
|
|
1577
1672
|
// Copyright (c) Microsoft Corporation.
|
|
1578
1673
|
/**
|
|
1579
|
-
*
|
|
1580
|
-
* @param
|
|
1581
|
-
* @
|
|
1582
|
-
* @param options - Configuration options for the direct send operation which can contain custom headers
|
|
1583
|
-
* which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
|
|
1584
|
-
* @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.
|
|
1585
1677
|
*/
|
|
1586
|
-
function
|
|
1587
|
-
return
|
|
1678
|
+
function isSendNotificationOptions(options) {
|
|
1679
|
+
return coreUtil.objectHasProperty(options, "tags") || coreUtil.objectHasProperty(options, "enableTestSend");
|
|
1588
1680
|
}
|
|
1589
|
-
|
|
1590
|
-
// Copyright (c) Microsoft Corporation.
|
|
1591
1681
|
/**
|
|
1592
|
-
*
|
|
1593
|
-
* @param
|
|
1594
|
-
* @
|
|
1595
|
-
* @param notification - The notification to send to the device.
|
|
1596
|
-
* @param options - The options for sending a direct notification.
|
|
1597
|
-
* @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.
|
|
1598
1685
|
*/
|
|
1599
|
-
function
|
|
1600
|
-
return
|
|
1686
|
+
function isDirectSendNotificationOptions(options) {
|
|
1687
|
+
return coreUtil.objectHasProperty(options, "deviceHandle");
|
|
1601
1688
|
}
|
|
1602
1689
|
|
|
1603
1690
|
// Copyright (c) Microsoft Corporation.
|
|
1604
1691
|
/**
|
|
1605
1692
|
* Sends push notifications to devices that match the given tags or tag expression.
|
|
1606
1693
|
* @param context - The Notification Hubs client.
|
|
1607
|
-
* @param tags - The tags used to target the device for push notifications in either an array or tag expression.
|
|
1608
1694
|
* @param notification - The notification to send to the matching devices.
|
|
1609
|
-
* @param options -
|
|
1610
|
-
* 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.
|
|
1611
1696
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1612
1697
|
*/
|
|
1613
|
-
function sendNotification(context,
|
|
1614
|
-
return
|
|
1615
|
-
}
|
|
1616
|
-
|
|
1617
|
-
// Copyright (c) Microsoft Corporation.
|
|
1618
|
-
const OPERATION_NAME$2 = "submitNotificationHubJob";
|
|
1619
|
-
/**
|
|
1620
|
-
* Submits a Notification Hub Job.
|
|
1621
|
-
* Note: this is available to Standard SKU namespace and above.
|
|
1622
|
-
* @param context - The Notification Hubs client.
|
|
1623
|
-
* @param job - The notification hub job to submit.
|
|
1624
|
-
* @param options - The operation options.
|
|
1625
|
-
* @returns The notification hub job details including job ID and status.
|
|
1626
|
-
*/
|
|
1627
|
-
function submitNotificationHubJob(context, job, options = {}) {
|
|
1628
|
-
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) => {
|
|
1629
1700
|
const endpoint = context.requestUrl();
|
|
1630
|
-
endpoint.pathname += "/
|
|
1631
|
-
|
|
1632
|
-
|
|
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);
|
|
1633
1740
|
const request = createRequest(endpoint, "POST", headers, updatedOptions);
|
|
1634
|
-
request.body =
|
|
1741
|
+
request.body = body;
|
|
1635
1742
|
const response = await sendRequest(context, request, 201);
|
|
1636
|
-
return
|
|
1743
|
+
return parseNotificationSendResponse(response);
|
|
1637
1744
|
});
|
|
1638
1745
|
}
|
|
1639
1746
|
|
|
@@ -1648,7 +1755,7 @@ const OPERATION_NAME$1 = "updateInstallation";
|
|
|
1648
1755
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1649
1756
|
*/
|
|
1650
1757
|
function updateInstallation(context, installationId, installationPatches, options = {}) {
|
|
1651
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1758
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$1}`, options, async (updatedOptions) => {
|
|
1652
1759
|
const endpoint = context.requestUrl();
|
|
1653
1760
|
endpoint.pathname += `/installations/${installationId}`;
|
|
1654
1761
|
const headers = await context.createHeaders(OPERATION_NAME$1);
|
|
@@ -1670,7 +1777,7 @@ const OPERATION_NAME = "updateRegistration";
|
|
|
1670
1777
|
* @returns The updated registration description.
|
|
1671
1778
|
*/
|
|
1672
1779
|
function updateRegistration(context, registration, options = {}) {
|
|
1673
|
-
return tracingClient.withSpan(`NotificationHubsClientContext
|
|
1780
|
+
return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME}`, options, async (updatedOptions) => {
|
|
1674
1781
|
if (!registration.etag) {
|
|
1675
1782
|
throw new coreRestPipeline.RestError("ETag is required for registration update", { statusCode: 400 });
|
|
1676
1783
|
}
|
|
@@ -1802,61 +1909,25 @@ class NotificationHubsServiceClient {
|
|
|
1802
1909
|
listRegistrationsByTag(tag, options = {}) {
|
|
1803
1910
|
return listRegistrationsByTag(this._client, tag, options);
|
|
1804
1911
|
}
|
|
1805
|
-
/**
|
|
1806
|
-
* Sends a direct push notification to a device with the given push handle.
|
|
1807
|
-
* @param pushHandle - The push handle which is the unique identifier for the device.
|
|
1808
|
-
* @param notification - The notification to send to the device.
|
|
1809
|
-
* @param options - The options for sending a direct notification.
|
|
1810
|
-
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1811
|
-
*/
|
|
1812
|
-
sendDirectNotification(pushHandle, notification, options = {}) {
|
|
1813
|
-
return sendDirectNotification(this._client, pushHandle, notification, options);
|
|
1814
|
-
}
|
|
1815
1912
|
/**
|
|
1816
1913
|
* Sends push notifications to devices that match the given tags or tag expression.
|
|
1817
|
-
* @param tags - The tags used to target the device for push notifications in either an array or tag expression.
|
|
1818
1914
|
* @param notification - The notification to send to the matching devices.
|
|
1819
|
-
* @param options -
|
|
1820
|
-
* 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.
|
|
1821
1916
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1822
1917
|
*/
|
|
1823
|
-
sendNotification(
|
|
1824
|
-
return sendNotification(this._client,
|
|
1825
|
-
}
|
|
1826
|
-
/**
|
|
1827
|
-
* Sends push notifications to all devices on the Notification Hub.
|
|
1828
|
-
* @param notification - The notification to send to all devices.
|
|
1829
|
-
* @param options - Configuration options for the direct send operation which can contain custom headers
|
|
1830
|
-
* which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
|
|
1831
|
-
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1832
|
-
*/
|
|
1833
|
-
sendBroadcastNotification(notification, options = {}) {
|
|
1834
|
-
return sendBroadcastNotification(this._client, notification, options);
|
|
1918
|
+
sendNotification(notification, options = { enableTestSend: false }) {
|
|
1919
|
+
return sendNotification(this._client, notification, options);
|
|
1835
1920
|
}
|
|
1836
1921
|
/**
|
|
1837
1922
|
* Schedules a push notification to devices that match the given tags or tag expression at the specified time.
|
|
1838
1923
|
* NOTE: This is only available in Standard SKU Azure Notification Hubs.
|
|
1839
1924
|
* @param scheduledTime - The Date to send the push notification.
|
|
1840
|
-
* @param tags - The tags used to target the device for push notifications in either an array or tag expression.
|
|
1841
1925
|
* @param notification - The notification to send to the matching devices.
|
|
1842
|
-
* @param options -
|
|
1843
|
-
* 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.
|
|
1844
1927
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1845
1928
|
*/
|
|
1846
|
-
scheduleNotification(scheduledTime,
|
|
1847
|
-
return scheduleNotification(this._client, scheduledTime,
|
|
1848
|
-
}
|
|
1849
|
-
/**
|
|
1850
|
-
* Schedules a push notification to all devices registered on the Notification Hub.
|
|
1851
|
-
* NOTE: This is only available in Standard SKU Azure Notification Hubs.
|
|
1852
|
-
* @param scheduledTime - The Date to send the push notification.
|
|
1853
|
-
* @param notification - The notification to send to the matching devices.
|
|
1854
|
-
* @param options - Configuration options for the direct send operation which can contain custom headers
|
|
1855
|
-
* which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
|
|
1856
|
-
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1857
|
-
*/
|
|
1858
|
-
scheduleBroadcastNotification(scheduledTime, notification, options = {}) {
|
|
1859
|
-
return scheduleBroadcastNotification(this._client, scheduledTime, notification, options);
|
|
1929
|
+
scheduleNotification(scheduledTime, notification, options = {}) {
|
|
1930
|
+
return scheduleNotification(this._client, scheduledTime, notification, options);
|
|
1860
1931
|
}
|
|
1861
1932
|
/**
|
|
1862
1933
|
* Cancels the scheduled notification with the given notification ID.
|
|
@@ -1895,6 +1966,15 @@ class NotificationHubsServiceClient {
|
|
|
1895
1966
|
getNotificationHubJob(jobId, options = {}) {
|
|
1896
1967
|
return getNotificationHubJob(this._client, jobId, options);
|
|
1897
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
|
+
}
|
|
1898
1978
|
/**
|
|
1899
1979
|
* Submits a Notification Hub Job. Note this is available to Standard SKU namespace and above.
|
|
1900
1980
|
* @param job - The notification hub job to submit.
|