diff --git a/sdk/communication/communication-job-router/review/communication-job-router.api.md b/sdk/communication/communication-job-router/review/communication-job-router.api.md index 67e68df7f6dd..931b0c5151d6 100644 --- a/sdk/communication/communication-job-router/review/communication-job-router.api.md +++ b/sdk/communication/communication-job-router/review/communication-job-router.api.md @@ -85,14 +85,16 @@ export interface CompleteJobOptions extends JobRouterCompleteJobActionOptionalPa export interface ConditionalQueueSelectorAttachment extends QueueSelectorAttachment { condition: RouterRuleUnion; kind: "conditional"; - labelSelectors: QueueSelector[]; + // Warning: (ae-forgotten-export) The symbol "QueueSelector_2" needs to be exported by the entry point index.d.ts + labelSelectors: QueueSelector_2[]; } // @public export interface ConditionalWorkerSelectorAttachment extends WorkerSelectorAttachment { condition: RouterRuleUnion; kind: "conditional"; - labelSelectors: WorkerSelector[]; + // Warning: (ae-forgotten-export) The symbol "WorkerSelector_2" needs to be exported by the entry point index.d.ts + labelSelectors: WorkerSelector_2[]; } // @public @@ -125,19 +127,15 @@ export interface CreateJobOptions extends JobRouterUpsertJobOptionalParams { channelReference?: string; classificationPolicyId?: string; dispositionCode?: string; - labels?: { - [propertyName: string]: any; - }; + labels?: JSONObject; notes?: { [propertyName: string]: string; }; priority?: number; queueId?: string; - requestedWorkerSelectors?: WorkerSelector[]; + requestedWorkerSelectors?: WorkerSelector_2[]; scheduledTimeUtc?: Date; - tags?: { - [propertyName: string]: any; - }; + tags?: JSONObject; unavailableForMatching?: boolean; } @@ -145,9 +143,7 @@ export interface CreateJobOptions extends JobRouterUpsertJobOptionalParams { export interface CreateQueueOptions extends JobRouterAdministrationUpsertQueueOptionalParams { distributionPolicyId?: string; exceptionPolicyId?: string; - labels?: { - [propertyName: string]: any; - }; + labels?: JSONObject; name?: string; } @@ -157,15 +153,9 @@ export interface CreateWorkerOptions extends JobRouterUpsertWorkerOptionalParams channelConfigurations?: { [propertyName: string]: ChannelConfiguration; }; - labels?: { - [propertyName: string]: any; - }; - queueAssignments?: { - [propertyName: string]: Record; - }; - tags?: { - [propertyName: string]: any; - }; + labels?: JSONObject; + queueAssignments?: JSONObject; + tags?: JSONObject; totalCapacity?: number; } @@ -220,8 +210,10 @@ export interface ExceptionAction { kind: "cancel" | "manual-reclassify" | "reclassify"; } +// Warning: (ae-forgotten-export) The symbol "ReclassifyExceptionAction_2" needs to be exported by the entry point index.d.ts +// // @public (undocumented) -export type ExceptionActionUnion = ExceptionAction | CancelExceptionAction | ManualReclassifyExceptionAction | ReclassifyExceptionAction; +export type ExceptionActionUnion = ExceptionAction | CancelExceptionAction | ManualReclassifyExceptionAction | ReclassifyExceptionAction_2; // @public export interface ExceptionPolicy { @@ -308,29 +300,56 @@ export interface JobPositionDetails { queueLength: number; } +// Warning: (ae-forgotten-export) The symbol "JobQueue_2" needs to be exported by the entry point index.d.ts +// // @public -export interface JobQueue { - distributionPolicyId?: string; - exceptionPolicyId?: string; - readonly id?: string; - labels?: { - [propertyName: string]: any; - }; - name?: string; +export interface JobQueue extends Omit { + labels?: JSONObject; } // @public export interface JobQueueItem { etag?: string; - jobQueue?: JobQueue; + jobQueue?: JobQueue_2; } // @public (undocumented) -export interface JobQueueResponse extends JobQueue { +export interface JobQueueResponse extends JobQueue_2 { // (undocumented) readonly id: string; } +// @public +export class JobRouterAdministrationClient { + constructor(connectionString: string, jobRouterAdministrationClientOptions?: JobRouterAdministrationClientOptions); + constructor(endpoint: string, credential: KeyCredential | TokenCredential, routerAdministrationClientOptions?: JobRouterAdministrationClientOptions); + constructor(endpoint: string, credential: CommunicationTokenCredential, routerAdministrationClientOptions?: JobRouterAdministrationClientOptions); + createClassificationPolicy(classificationPolicyId: string, options?: CreateClassificationPolicyOptions): Promise; + createDistributionPolicy(distributionPolicyId: string, options?: CreateDistributionPolicyOptions): Promise; + createExceptionPolicy(exceptionPolicyId: string, options?: CreateExceptionPolicyOptions): Promise; + createQueue(queueId: string, options?: CreateQueueOptions): Promise; + deleteClassificationPolicy(classificationPolicyId: string, options?: OperationOptions): Promise; + deleteDistributionPolicy(distributionPolicyId: string, options?: OperationOptions): Promise; + deleteExceptionPolicy(exceptionPolicyId: string, options?: OperationOptions): Promise; + deleteQueue(queueId: string, options?: OperationOptions): Promise; + getClassificationPolicy(classificationPolicyId: string, options?: OperationOptions): Promise; + getDistributionPolicy(distributionPolicyId: string, options?: OperationOptions): Promise; + getExceptionPolicy(exceptionPolicyId: string, options?: OperationOptions): Promise; + getQueue(queueId: string, options?: OperationOptions): Promise; + listClassificationPolicies(options?: ListClassificationPoliciesOptions): PagedAsyncIterableIterator; + listDistributionPolicies(options?: ListDistributionPoliciesOptions): PagedAsyncIterableIterator; + listExceptionPolicies(options?: ListExceptionPoliciesOptions): PagedAsyncIterableIterator; + listQueues(options?: ListQueuesOptions): PagedAsyncIterableIterator; + updateClassificationPolicy(classificationPolicyId: string, options?: UpdateClassificationPolicyOptions): Promise; + updateDistributionPolicy(distributionPolicyId: string, options?: UpdateDistributionPolicyOptions): Promise; + updateExceptionPolicy(exceptionPolicyId: string, options?: UpdateExceptionPolicyOptions): Promise; + updateQueue(queueId: string, options?: UpdateQueueOptions): Promise; +} + +// @public +export interface JobRouterAdministrationClientOptions extends CommonClientOptions { +} + // @public export interface JobRouterAdministrationUpsertClassificationPolicyOptionalParams extends coreClient.OperationOptions { } @@ -353,10 +372,49 @@ export interface JobRouterCancelJobActionOptionalParams extends coreClient.Opera note?: string; } +// Warning: (ae-forgotten-export) The symbol "JobRouterCancelJobActionResponse_2" needs to be exported by the entry point index.d.ts +// +// @public +export interface JobRouterCancelJobActionResponse extends Omit { + body?: JSONValue; +} + // @public -export type JobRouterCancelJobActionResponse = { - body: any; -}; +export class JobRouterClient { + constructor(connectionString: string, routerClientOptions?: JobRouterClientOptions); + constructor(endpoint: string, credential: KeyCredential | TokenCredential, routerClientOptions?: JobRouterClientOptions); + constructor(endpoint: string, credential: CommunicationTokenCredential, routerClientOptions?: JobRouterClientOptions); + acceptJobOffer(workerId: string, offerId: string, options?: OperationOptions): Promise; + cancelJob(jobId: string, options?: CancelJobOptions): Promise; + // Warning: (ae-forgotten-export) The symbol "JobRouterCloseJobActionResponse_2" needs to be exported by the entry point index.d.ts + closeJob(jobId: string, assignmentId: string, options?: CloseJobOptions): Promise; + // Warning: (ae-forgotten-export) The symbol "JobRouterCompleteJobActionResponse_2" needs to be exported by the entry point index.d.ts + completeJob(jobId: string, assignmentId: string, options?: CompleteJobOptions): Promise; + createJob(jobId: string, options?: CreateJobOptions): Promise; + createWorker(workerId: string, options?: CreateWorkerOptions): Promise; + // Warning: (ae-forgotten-export) The symbol "JobRouterDeclineJobActionResponse_2" needs to be exported by the entry point index.d.ts + declineJobOffer(workerId: string, offerId: string, options?: DeclineJobOfferOptions): Promise; + deleteJob(jobId: string, options?: OperationOptions): Promise; + deleteWorker(workerId: string, options?: OperationOptions): Promise; + deregisterWorker(workerId: string, options?: OperationOptions): Promise; + getJob(jobId: string, options?: OperationOptions): Promise; + getQueuePosition(jobId: string, options?: OperationOptions): Promise; + getQueueStatistics(queueId: string, options?: OperationOptions): Promise; + getWorker(workerId: string, options?: OperationOptions): Promise; + listJobs(options?: ListJobsOptions): PagedAsyncIterableIterator; + listWorkers(options?: ListWorkersOptions): PagedAsyncIterableIterator; + // Warning: (ae-forgotten-export) The symbol "JobRouterReclassifyJobActionResponse_2" needs to be exported by the entry point index.d.ts + reclassifyJob(jobId: string, options?: ReclassifyJobOptions): Promise; + registerWorker(workerId: string, options?: OperationOptions): Promise; + unassignJob(jobId: string, assignmentId: string, options?: OperationOptions): Promise; + updateJob(jobId: string, options?: UpdateJobOptions): Promise; + updateWorker(workerId: string, options?: UpdateWorkerOptions): Promise; +} + +// @public +export interface JobRouterClientOptions extends CommonClientOptions { + headers?: JSONObject; +} // @public export interface JobRouterCloseJobActionOptionalParams extends coreClient.OperationOptions { @@ -366,9 +424,9 @@ export interface JobRouterCloseJobActionOptionalParams extends coreClient.Operat } // @public -export type JobRouterCloseJobActionResponse = { - body: any; -}; +export interface JobRouterCloseJobActionResponse extends Omit { + body?: JSONValue; +} // @public export interface JobRouterCompleteJobActionOptionalParams extends coreClient.OperationOptions { @@ -376,9 +434,9 @@ export interface JobRouterCompleteJobActionOptionalParams extends coreClient.Ope } // @public -export type JobRouterCompleteJobActionResponse = { - body: any; -}; +export interface JobRouterCompleteJobActionResponse extends Omit { + body?: JSONValue; +} // @public export interface JobRouterDeclineJobActionOptionalParams extends coreClient.OperationOptions { @@ -386,19 +444,21 @@ export interface JobRouterDeclineJobActionOptionalParams extends coreClient.Oper } // @public -export type JobRouterDeclineJobActionResponse = { - body: any; -}; +export interface JobRouterDeclineJobActionResponse extends Omit { + body?: JSONValue; +} +// Warning: (ae-forgotten-export) The symbol "JobRouterReclassifyJobActionOptionalParams_2" needs to be exported by the entry point index.d.ts +// // @public -export interface JobRouterReclassifyJobActionOptionalParams extends coreClient.OperationOptions { - reclassifyJobRequest?: any; +export interface JobRouterReclassifyJobActionOptionalParams extends Omit { + body?: JSONValue; } // @public -export type JobRouterReclassifyJobActionResponse = { - body: any; -}; +export interface JobRouterReclassifyJobActionResponse extends Omit { + body?: JSONValue; +} // @public export interface JobRouterUpsertJobOptionalParams extends coreClient.OperationOptions { @@ -411,6 +471,19 @@ export interface JobRouterUpsertWorkerOptionalParams extends coreClient.Operatio // @public export type JobStateSelector = "all" | "pendingClassification" | "queued" | "assigned" | "completed" | "closed" | "cancelled" | "classificationFailed" | "created" | "pendingSchedule" | "scheduled" | "scheduleFailed" | "waitingForActivation" | "active"; +// @public (undocumented) +export interface JSONArray extends ArrayLike { +} + +// @public (undocumented) +export interface JSONObject { + // (undocumented) + [key: string]: JSONValue; +} + +// @public (undocumented) +export type JSONValue = boolean | number | string | null | JSONArray | JSONObject; + // @public export type LabelOperator = "equal" | "notEqual" | "lessThan" | "lessThanEqual" | "greaterThan" | "greaterThanEqual"; @@ -469,7 +542,7 @@ export interface ManualReclassifyExceptionAction extends ExceptionAction { kind: "manual-reclassify"; priority?: number; queueId?: string; - workerSelectors?: WorkerSelector[]; + workerSelectors?: WorkerSelector_2[]; } // @public @@ -500,10 +573,8 @@ export interface QueueLengthExceptionTrigger extends JobExceptionTrigger { } // @public -export interface QueueSelector { - key: string; - labelOperator: LabelOperator; - value?: any; +export interface QueueSelector extends Omit { + value?: JSONValue; } // @public @@ -526,22 +597,18 @@ export interface QueueStatistics { // @public export interface QueueWeightedAllocation { - labelSelectors: QueueSelector[]; + labelSelectors: QueueSelector_2[]; weight: number; } // @public -export interface ReclassifyExceptionAction extends ExceptionAction { - classificationPolicyId?: string; - kind: "reclassify"; - labelsToUpsert?: { - [propertyName: string]: any; - }; +export interface ReclassifyExceptionAction extends Omit { + lablabelsToUpsertels?: JSONObject; } // @public -export interface ReclassifyJobOptions extends JobRouterReclassifyJobActionOptionalParams { - reclassifyJobRequest?: Record; +export interface ReclassifyJobOptions extends JobRouterReclassifyJobActionOptionalParams_2 { + reclassifyJobRequest?: JSONObject; } // @public @@ -549,112 +616,22 @@ export interface RoundRobinMode extends DistributionMode { kind: "round-robin"; } +// Warning: (ae-forgotten-export) The symbol "RouterJob_2" needs to be exported by the entry point index.d.ts +// // @public -export class RouterAdministrationClient { - constructor(connectionString: string, routerAdministrationClientOptions?: RouterAdministrationClientOptions); - constructor(endpoint: string, credential: KeyCredential | TokenCredential, routerAdministrationClientOptions?: RouterAdministrationClientOptions); - constructor(endpoint: string, credential: CommunicationTokenCredential, routerAdministrationClientOptions?: RouterAdministrationClientOptions); - createClassificationPolicy(classificationPolicyId: string, options?: CreateClassificationPolicyOptions): Promise; - createDistributionPolicy(distributionPolicyId: string, options?: CreateDistributionPolicyOptions): Promise; - createExceptionPolicy(exceptionPolicyId: string, options?: CreateExceptionPolicyOptions): Promise; - createQueue(queueId: string, options?: CreateQueueOptions): Promise; - deleteClassificationPolicy(classificationPolicyId: string, options?: OperationOptions): Promise; - deleteDistributionPolicy(distributionPolicyId: string, options?: OperationOptions): Promise; - deleteExceptionPolicy(exceptionPolicyId: string, options?: OperationOptions): Promise; - deleteQueue(queueId: string, options?: OperationOptions): Promise; - getClassificationPolicy(classificationPolicyId: string, options?: OperationOptions): Promise; - getDistributionPolicy(distributionPolicyId: string, options?: OperationOptions): Promise; - getExceptionPolicy(exceptionPolicyId: string, options?: OperationOptions): Promise; - getQueue(queueId: string, options?: OperationOptions): Promise; - listClassificationPolicies(options?: ListClassificationPoliciesOptions): PagedAsyncIterableIterator; - listDistributionPolicies(options?: ListDistributionPoliciesOptions): PagedAsyncIterableIterator; - listExceptionPolicies(options?: ListExceptionPoliciesOptions): PagedAsyncIterableIterator; - listQueues(options?: ListQueuesOptions): PagedAsyncIterableIterator; - updateClassificationPolicy(classificationPolicyId: string, options?: UpdateClassificationPolicyOptions): Promise; - updateDistributionPolicy(distributionPolicyId: string, options?: UpdateDistributionPolicyOptions): Promise; - updateExceptionPolicy(exceptionPolicyId: string, options?: UpdateExceptionPolicyOptions): Promise; - updateQueue(queueId: string, options?: UpdateQueueOptions): Promise; -} - -// @public -export interface RouterAdministrationClientOptions extends CommonClientOptions { - headers?: { - [propertyName: string]: any; - }; -} - -// @public -export class RouterClient { - constructor(connectionString: string, routerClientOptions?: RouterClientOptions); - constructor(endpoint: string, credential: KeyCredential | TokenCredential, routerClientOptions?: RouterClientOptions); - constructor(endpoint: string, credential: CommunicationTokenCredential, routerClientOptions?: RouterClientOptions); - acceptJobOffer(workerId: string, offerId: string, options?: OperationOptions): Promise; - cancelJob(jobId: string, options?: CancelJobOptions): Promise; - closeJob(jobId: string, assignmentId: string, options?: CloseJobOptions): Promise; - completeJob(jobId: string, assignmentId: string, options?: CompleteJobOptions): Promise; - createJob(jobId: string, options?: CreateJobOptions): Promise; - createWorker(workerId: string, options?: CreateWorkerOptions): Promise; - declineJobOffer(workerId: string, offerId: string, options?: DeclineJobOfferOptions): Promise; - deleteJob(jobId: string, options?: OperationOptions): Promise; - deleteWorker(workerId: string, options?: OperationOptions): Promise; - deregisterWorker(workerId: string, options?: OperationOptions): Promise; - getJob(jobId: string, options?: OperationOptions): Promise; - getQueuePosition(jobId: string, options?: OperationOptions): Promise; - getQueueStatistics(queueId: string, options?: OperationOptions): Promise; - getWorker(workerId: string, options?: OperationOptions): Promise; - listJobs(options?: ListJobsOptions): PagedAsyncIterableIterator; - listWorkers(options?: ListWorkersOptions): PagedAsyncIterableIterator; - reclassifyJob(jobId: string, options?: ReclassifyJobOptions): Promise; - registerWorker(workerId: string, options?: OperationOptions): Promise; - unassignJob(jobId: string, assignmentId: string, options?: OperationOptions): Promise; - updateJob(jobId: string, options?: UpdateJobOptions): Promise; - updateWorker(workerId: string, options?: UpdateWorkerOptions): Promise; -} - -// @public -export interface RouterClientOptions extends CommonClientOptions { - headers?: { - [propertyName: string]: any; - }; -} - -// @public -export interface RouterJob { - readonly assignments?: { - [propertyName: string]: JobAssignment; - }; - readonly attachedWorkerSelectors?: WorkerSelector[]; - channelId?: string; - channelReference?: string; - classificationPolicyId?: string; - dispositionCode?: string; - readonly enqueueTimeUtc?: Date; - readonly id?: string; - readonly jobStatus?: RouterJobStatus; - labels?: { - [propertyName: string]: any; - }; - notes?: { - [propertyName: string]: string; - }; - priority?: number; - queueId?: string; - requestedWorkerSelectors?: WorkerSelector[]; - scheduledTimeUtc?: Date; - tags?: { - [propertyName: string]: any; - }; - unavailableForMatching?: boolean; +export interface RouterJob extends Omit { + labels?: JSONObject; + tags?: JSONObject; } // @public export interface RouterJobItem { etag?: string; - routerJob?: RouterJob; + routerJob?: RouterJob_2; } // @public (undocumented) -export interface RouterJobResponse extends RouterJob { +export interface RouterJobResponse extends RouterJob_2 { // (undocumented) readonly id: string; } @@ -667,40 +644,28 @@ export interface RouterRule { kind: "direct-map-rule" | "expression-rule" | "azure-function-rule" | "static-rule" | "webhook-rule"; } +// Warning: (ae-forgotten-export) The symbol "StaticRule_2" needs to be exported by the entry point index.d.ts +// // @public (undocumented) -export type RouterRuleUnion = RouterRule | DirectMapRule | ExpressionRule | FunctionRule | StaticRule | WebhookRule; +export type RouterRuleUnion = RouterRule | DirectMapRule | ExpressionRule | FunctionRule | StaticRule_2 | WebhookRule; +// Warning: (ae-forgotten-export) The symbol "RouterWorker_2" needs to be exported by the entry point index.d.ts +// // @public -export interface RouterWorker { - readonly assignedJobs?: WorkerAssignment[]; - availableForOffers?: boolean; - channelConfigurations?: { - [propertyName: string]: ChannelConfiguration; - }; - readonly id?: string; - labels?: { - [propertyName: string]: any; - }; - readonly loadRatio?: number; - readonly offers?: JobOffer[]; - queueAssignments?: { - [propertyName: string]: any; - }; - readonly state?: RouterWorkerState; - tags?: { - [propertyName: string]: any; - }; - totalCapacity?: number; +export interface RouterWorker extends Omit { + labels?: JSONObject; + queueAssignments?: JSONObject; + tags?: JSONObject; } // @public export interface RouterWorkerItem { etag?: string; - routerWorker?: RouterWorker; + routerWorker?: RouterWorker_2; } // @public (undocumented) -export interface RouterWorkerResponse extends RouterWorker { +export interface RouterWorkerResponse extends RouterWorker_2 { // (undocumented) readonly id: string; } @@ -734,19 +699,18 @@ export type ScoringRuleParameterSelector = "jobLabels" | "workerSelectors"; // @public export interface StaticQueueSelectorAttachment extends QueueSelectorAttachment { kind: "static"; - labelSelector: QueueSelector; + labelSelector: QueueSelector_2; } // @public -export interface StaticRule extends RouterRule { - kind: "static-rule"; - value?: any; +export interface StaticRule extends Omit { + value?: JSONValue; } // @public export interface StaticWorkerSelectorAttachment extends WorkerSelectorAttachment { kind: "static"; - labelSelector: WorkerSelector; + labelSelector: WorkerSelector_2; } // @public @@ -785,19 +749,15 @@ export interface UpdateJobOptions extends JobRouterUpsertJobOptionalParams { channelReference?: string; classificationPolicyId?: string; dispositionCode?: string; - labels?: { - [propertyName: string]: any; - }; + labels?: JSONObject; notes?: { [propertyName: string]: string; }; priority?: number; queueId?: string; - requestedWorkerSelectors?: WorkerSelector[]; + requestedWorkerSelectors?: WorkerSelector_2[]; scheduledTimeUtc?: Date; - tags?: { - [propertyName: string]: any; - }; + tags?: JSONObject; unavailableForMatching?: boolean; } @@ -805,9 +765,7 @@ export interface UpdateJobOptions extends JobRouterUpsertJobOptionalParams { export interface UpdateQueueOptions extends JobRouterAdministrationUpsertQueueOptionalParams { distributionPolicyId?: string; exceptionPolicyId?: string; - labels?: { - [propertyName: string]: any; - }; + labels?: JSONObject; name?: string; } @@ -817,15 +775,9 @@ export interface UpdateWorkerOptions extends JobRouterUpsertWorkerOptionalParams channelConfigurations?: { [propertyName: string]: ChannelConfiguration; }; - labels?: { - [propertyName: string]: any; - }; - queueAssignments?: { - [propertyName: string]: Record; - }; - tags?: { - [propertyName: string]: any; - }; + labels?: JSONObject; + queueAssignments?: JSONObject; + tags?: JSONObject; totalCapacity?: number; } @@ -864,14 +816,8 @@ export interface WorkerAssignment { } // @public -export interface WorkerSelector { - expedite?: boolean; - readonly expireTime?: Date; - key: string; - labelOperator: LabelOperator; - readonly state?: WorkerSelectorState; - ttlSeconds?: number; - value?: any; +export interface WorkerSelector extends Omit { + value?: JSONValue; } // @public @@ -890,7 +836,7 @@ export type WorkerStateSelector = "active" | "draining" | "inactive" | "all"; // @public export interface WorkerWeightedAllocation { - labelSelectors: WorkerSelector[]; + labelSelectors: WorkerSelector_2[]; weight: number; } diff --git a/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_Create.ts b/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_Create.ts index f540c8a94655..12cdc65677c9 100644 --- a/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_Create.ts +++ b/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_Create.ts @@ -10,7 +10,8 @@ import { ExceptionPolicy, JobQueue, QueueLengthExceptionTrigger, - RouterAdministrationClient } from "@azure/communication-job-router"; + JobRouterAdministrationClient, +} from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -18,11 +19,11 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // Create an classification policy async function createClassificationPolicy(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); const distributionPolicyId = "distribution-policy-123"; const distributionPolicyRequest: DistributionPolicy = { @@ -31,17 +32,20 @@ async function createClassificationPolicy(): Promise { kind: "longest-idle", minConcurrentOffers: 1, maxConcurrentOffers: 1, - bypassSelectors: false + bypassSelectors: false, }, - offerTtlSeconds: 15 + offerTtlSeconds: 15, }; - await routerAdministrationClient.createDistributionPolicy(distributionPolicyId, distributionPolicyRequest); + await routerAdministrationClient.createDistributionPolicy( + distributionPolicyId, + distributionPolicyRequest + ); // define exception trigger for queue over flow const queueLengthExceptionTrigger: QueueLengthExceptionTrigger = { kind: "queue-length", - threshold: 100 - } + threshold: 100, + }; const exceptionPolicyId = "exception-policy-123"; const exceptionPolicyRequest: ExceptionPolicy = { @@ -54,13 +58,13 @@ async function createClassificationPolicy(): Promise { kind: "reclassify", classificationPolicyId: "Main", labelsToUpsert: { - escalated: true - } - } + escalated: true, + }, + }, }, - trigger: queueLengthExceptionTrigger - } - } + trigger: queueLengthExceptionTrigger, + }, + }, }; await routerAdministrationClient.createExceptionPolicy(exceptionPolicyId, exceptionPolicyRequest); @@ -70,7 +74,7 @@ async function createClassificationPolicy(): Promise { distributionPolicyId: "distribution-policy-123", name: "Main", labels: {}, - exceptionPolicyId: "exception-policy-123" + exceptionPolicyId: "exception-policy-123", }; await routerAdministrationClient.createQueue(queueId, queueRequest); @@ -86,24 +90,25 @@ async function createClassificationPolicy(): Promise { { key: "foo", labelOperator: "equal", - value: { "default": 10 } - } - ] - } + value: { default: 10 }, + }, + ], + }, ], prioritizationRule: { kind: "static-rule", - value: { "default": 2 } - } + value: { default: 2 }, + }, }; - const request = classificationPolicyRequest; - const result = await routerAdministrationClient.createClassificationPolicy(classificationPolicyId, request); + const result = await routerAdministrationClient.createClassificationPolicy( + classificationPolicyId, + request + ); console.log("classification policy: " + result); - -}; +} void createClassificationPolicy(); diff --git a/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_Delete.ts b/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_Delete.ts index 3dd32a9f5b93..fded82e92180 100644 --- a/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_Delete.ts +++ b/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_Delete.ts @@ -4,7 +4,7 @@ /** * @summary Classification policy crud */ -import { RouterAdministrationClient } from "@azure/communication-job-router"; +import { JobRouterAdministrationClient } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -12,19 +12,17 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // Delete classification policy async function deleteClassificationPolicy(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); - - const policyId = "classification-policy-123" + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); + const policyId = "classification-policy-123"; const result = await routerAdministrationClient.deleteClassificationPolicy(policyId); console.log("classification policy: " + result); - -}; +} deleteClassificationPolicy().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_Get.ts b/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_Get.ts index 3bde026bd22f..0037282ab4df 100644 --- a/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_Get.ts +++ b/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_Get.ts @@ -4,7 +4,7 @@ /** * @summary Classification policy crud */ -import { RouterAdministrationClient } from "@azure/communication-job-router"; +import { JobRouterAdministrationClient } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -12,21 +12,18 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // Get a classification policy async function getClassificationPolicy(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); - - const policyId = "classification-policy-123" + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); + const policyId = "classification-policy-123"; const result = await routerAdministrationClient.getClassificationPolicy(policyId); console.log("classification policy: " + result); - -}; +} void getClassificationPolicy(); - diff --git a/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_List.ts b/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_List.ts index a8c3a158d949..912a409ecea8 100644 --- a/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_List.ts +++ b/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_List.ts @@ -4,7 +4,10 @@ /** * @summary Classification policy crud */ -import { ClassificationPolicyItem, RouterAdministrationClient } from "@azure/communication-job-router"; +import { + ClassificationPolicyItem, + JobRouterAdministrationClient, +} from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -13,17 +16,19 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // List classification policies async function listClassificationPolicies(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); let pagesCount = 1; const maxPageSize = 3; const receivedPagedItems: ClassificationPolicyItem[] = []; - for await (const page of routerAdministrationClient.listClassificationPolicies({ maxPageSize: maxPageSize }).byPage()) { + for await (const page of routerAdministrationClient + .listClassificationPolicies({ maxPageSize: maxPageSize }) + .byPage()) { ++pagesCount; console.log("page: " + pagesCount); @@ -36,8 +41,6 @@ async function listClassificationPolicies(): Promise { let pageSize = receivedPagedItems.length; assert.isAtMost(pageSize, maxPageSize); } - -}; +} listClassificationPolicies().catch(console.error); - diff --git a/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_Update.ts b/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_Update.ts index dae6ec04ef8b..087403acc772 100644 --- a/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_Update.ts +++ b/sdk/communication/communication-job-router/samples-dev/ClassificationPolicy_Update.ts @@ -4,7 +4,10 @@ /** * @summary Classification policy crud */ -import { ClassificationPolicyResponse, RouterAdministrationClient } from "@azure/communication-job-router"; +import { + ClassificationPolicyResponse, + JobRouterAdministrationClient, +} from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -12,12 +15,11 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - - // Update a classification policy async function updateClassificationPolicy(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); const classificationPolicyRequest: ClassificationPolicyResponse = { id: "classification-policy-123", @@ -30,24 +32,22 @@ async function updateClassificationPolicy(): Promise { { key: "foo", labelOperator: "lessThan", - value: { "default": 5 } - } - ] - } + value: { default: 5 }, + }, + ], + }, ], prioritizationRule: { kind: "static-rule", - value: { "default": 20 } - } + value: { default: 20 }, + }, }; - const request = classificationPolicyRequest; const result = await routerAdministrationClient.updateClassificationPolicy(request.id, request); console.log("classification policy: " + result); - -}; +} void updateClassificationPolicy(); diff --git a/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_Create.ts b/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_Create.ts index 8853b3e518f8..7d08d4e74f20 100644 --- a/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_Create.ts +++ b/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_Create.ts @@ -5,16 +5,16 @@ */ // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; -import { DistributionPolicy, RouterAdministrationClient } from "@azure/communication-job-router"; +import { DistributionPolicy, JobRouterAdministrationClient } from "@azure/communication-job-router"; dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // Create an distribution policy async function createDistributionPolicy(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); const id = "distribution-policy-123"; const distributionPolicyRequest: DistributionPolicy = { @@ -23,18 +23,16 @@ async function createDistributionPolicy(): Promise { kind: "longest-idle", minConcurrentOffers: 1, maxConcurrentOffers: 5, - bypassSelectors: false + bypassSelectors: false, }, - offerTtlSeconds: 120 + offerTtlSeconds: 120, }; - const request = distributionPolicyRequest; const result = await routerAdministrationClient.createDistributionPolicy(id, request); console.log("distribution policy: " + result); - -}; +} createDistributionPolicy().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_Delete.ts b/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_Delete.ts index 1b1f5389b3a2..eaf45420587b 100644 --- a/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_Delete.ts +++ b/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_Delete.ts @@ -5,24 +5,22 @@ */ // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; -import { RouterAdministrationClient } from "@azure/communication-job-router"; +import { JobRouterAdministrationClient } from "@azure/communication-job-router"; dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // Delete distribution policy async function deleteDistributionPolicy(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); - - const policyId = "distribution-policy-123" + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); + const policyId = "distribution-policy-123"; const result = await routerAdministrationClient.deleteDistributionPolicy(policyId); console.log("distribution policy: " + result); - -}; +} deleteDistributionPolicy().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_Get.ts b/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_Get.ts index b5d76b15f83f..c771e5c2fe4f 100644 --- a/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_Get.ts +++ b/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_Get.ts @@ -5,26 +5,23 @@ */ // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; -import { RouterAdministrationClient } from "@azure/communication-job-router"; +import { JobRouterAdministrationClient } from "@azure/communication-job-router"; dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // Get a distribution policy async function getDistributionPolicy(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); - - const policyId = "distribution-policy-123" + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); + const policyId = "distribution-policy-123"; const result = await routerAdministrationClient.getDistributionPolicy(policyId); console.log("distribution policy: " + result); - -}; +} getDistributionPolicy().catch(console.error); - diff --git a/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_List.ts b/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_List.ts index 9b289c5e659b..44394ef6df9b 100644 --- a/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_List.ts +++ b/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_List.ts @@ -5,7 +5,10 @@ */ // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; -import { DistributionPolicyItem, RouterAdministrationClient } from "@azure/communication-job-router"; +import { + DistributionPolicyItem, + JobRouterAdministrationClient, +} from "@azure/communication-job-router"; import { assert } from "chai"; dotenv.config(); @@ -14,13 +17,16 @@ const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; // List distribution policies async function listDistributionPolicies(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); let pagesCount = 1; const maxPageSize = 3; const receivedPagedItems: DistributionPolicyItem[] = []; - for await (const page of routerAdministrationClient.listDistributionPolicies({ maxPageSize: maxPageSize }).byPage()) { + for await (const page of routerAdministrationClient + .listDistributionPolicies({ maxPageSize: maxPageSize }) + .byPage()) { ++pagesCount; console.log("page: " + pagesCount); for (const policy of page) { @@ -32,7 +38,6 @@ async function listDistributionPolicies(): Promise { let pageSize = receivedPagedItems.length; assert.isAtMost(pageSize, maxPageSize); } - -}; +} listDistributionPolicies().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_Update.ts b/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_Update.ts index 7dae183e0ab5..e1e2dad38e07 100644 --- a/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_Update.ts +++ b/sdk/communication/communication-job-router/samples-dev/DistributionPolicy_Update.ts @@ -5,7 +5,10 @@ */ // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; -import { DistributionPolicyResponse, RouterAdministrationClient } from "@azure/communication-job-router"; +import { + DistributionPolicyResponse, + JobRouterAdministrationClient, +} from "@azure/communication-job-router"; dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; @@ -13,7 +16,8 @@ const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; // Update a distribution policy async function updateDistributionPolicy(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); const distributionPolicyRequest: DistributionPolicyResponse = { id: "distribution-policy-123", @@ -21,18 +25,16 @@ async function updateDistributionPolicy(): Promise { kind: "longest-idle", minConcurrentOffers: 1, maxConcurrentOffers: 1, - bypassSelectors: false + bypassSelectors: false, }, - offerTtlSeconds: 15 + offerTtlSeconds: 15, }; - const request = distributionPolicyRequest; const result = await routerAdministrationClient.updateDistributionPolicy(request.id, request); console.log("distribution policy: " + result); - -}; +} updateDistributionPolicy().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_Create.ts b/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_Create.ts index 46be5218d0aa..cc68e34fd3f4 100644 --- a/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_Create.ts +++ b/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_Create.ts @@ -3,7 +3,7 @@ /** * @summary Exception policy crud */ -import { RouterAdministrationClient } from "@azure/communication-job-router"; +import { JobRouterAdministrationClient } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -12,17 +12,17 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // Create an exception policy async function createExceptionPolicy(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); // define exception trigger for queue over flow const queueLengthExceptionTrigger: QueueLengthExceptionTrigger = { kind: "queue-length", - threshold: 10 - } + threshold: 10, + }; const id = "exception-policy-123"; const exceptionPolicyRequest: ExceptionPolicy = { @@ -35,22 +35,20 @@ async function createExceptionPolicy(): Promise { kind: "reclassify", classificationPolicyId: "Main", labelsToUpsert: { - escalated: true - } - } + escalated: true, + }, + }, }, - trigger: queueLengthExceptionTrigger - } - } + trigger: queueLengthExceptionTrigger, + }, + }, }; - const request = exceptionPolicyRequest; const result = await routerAdministrationClient.createExceptionPolicy(id, request); console.log("exception policy: " + result); - -}; +} createExceptionPolicy().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_Delete.ts b/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_Delete.ts index 6c509f2bb926..c5723f5dd919 100644 --- a/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_Delete.ts +++ b/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_Delete.ts @@ -3,7 +3,7 @@ /** * @summary Exception policy crud */ -import { RouterAdministrationClient } from "@azure/communication-job-router"; +import { JobRouterAdministrationClient } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -14,15 +14,14 @@ const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; // Delete exception policy async function deleteExceptionPolicy(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); - - const policyId = "exception-policy-123" + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); + const policyId = "exception-policy-123"; const result = await routerAdministrationClient.deleteExceptionPolicy(policyId); console.log("exception policy: " + result); - -}; +} deleteExceptionPolicy().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_Get.ts b/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_Get.ts index 407e64dc75d2..790f6f988636 100644 --- a/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_Get.ts +++ b/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_Get.ts @@ -3,7 +3,7 @@ /** * @summary Exception policy crud */ -import { RouterAdministrationClient } from "@azure/communication-job-router"; +import { JobRouterAdministrationClient } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -15,14 +15,14 @@ const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; async function getExceptionPolicy(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); - const policyId = "exception-policy-123" + const policyId = "exception-policy-123"; const result = await routerAdministrationClient.getExceptionPolicy(policyId); console.log("exception policy: " + result); - -}; +} getExceptionPolicy().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_List.ts b/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_List.ts index 6037d27ed32e..5202976d6aa8 100644 --- a/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_List.ts +++ b/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_List.ts @@ -6,23 +6,28 @@ // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; -import { ExceptionPolicyItem, RouterAdministrationClient } from "@azure/communication-job-router"; +import { + ExceptionPolicyItem, + JobRouterAdministrationClient, +} from "@azure/communication-job-router"; import { assert } from "chai"; dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // List exception policies async function listExceptionPolicies(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); let pagesCount = 1; const maxPageSize = 3; const receivedPagedItems: ExceptionPolicyItem[] = []; - for await (const page of routerAdministrationClient.listExceptionPolicies({ maxPageSize: maxPageSize }).byPage()) { + for await (const page of routerAdministrationClient + .listExceptionPolicies({ maxPageSize: maxPageSize }) + .byPage()) { ++pagesCount; console.log("page: " + pagesCount); for (const policy of page) { @@ -34,8 +39,6 @@ async function listExceptionPolicies(): Promise { let pageSize = receivedPagedItems.length; assert.isAtMost(pageSize, maxPageSize); } - -}; +} listExceptionPolicies().catch(console.error); - diff --git a/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_Update.ts b/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_Update.ts index a440f30796b2..c5149f2bec25 100644 --- a/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_Update.ts +++ b/sdk/communication/communication-job-router/samples-dev/ExceptionPolicy_Update.ts @@ -6,23 +6,26 @@ // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; -import { ExceptionPolicyResponse, QueueLengthExceptionTrigger, RouterAdministrationClient } from "@azure/communication-job-router"; +import { + ExceptionPolicyResponse, + QueueLengthExceptionTrigger, + JobRouterAdministrationClient, +} from "@azure/communication-job-router"; dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - - // Update a exception policy async function updateExceptionPolicy(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); // define exception trigger for queue over flow const queueLengthExceptionTrigger: QueueLengthExceptionTrigger = { kind: "queue-length", - threshold: 100 - } + threshold: 100, + }; const exceptionPolicyRequest: ExceptionPolicyResponse = { id: "exception-policy-123", @@ -34,22 +37,20 @@ async function updateExceptionPolicy(): Promise { kind: "reclassify", classificationPolicyId: "Main", labelsToUpsert: { - escalated: true - } - } + escalated: true, + }, + }, }, - trigger: queueLengthExceptionTrigger - } - } + trigger: queueLengthExceptionTrigger, + }, + }, }; - const request = exceptionPolicyRequest; const result = await routerAdministrationClient.updateExceptionPolicy(request.id, request); console.log("exception policy: " + result); - -}; +} updateExceptionPolicy().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/JobQueue_Create.ts b/sdk/communication/communication-job-router/samples-dev/JobQueue_Create.ts index b5e7450e2f45..8099e28544ff 100644 --- a/sdk/communication/communication-job-router/samples-dev/JobQueue_Create.ts +++ b/sdk/communication/communication-job-router/samples-dev/JobQueue_Create.ts @@ -3,7 +3,11 @@ /** * @summary job queue crud */ -import { JobQueue, DistributionPolicy, RouterAdministrationClient } from "@azure/communication-job-router"; +import { + JobQueue, + DistributionPolicy, + JobRouterAdministrationClient, +} from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -11,37 +15,38 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // Create a router jobQueue async function createJobQueue(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); - const distributionPolicyId = "distribution-policy-123" + const distributionPolicyId = "distribution-policy-123"; const distributionPolicyRequest: DistributionPolicy = { name: "distribution-policy-123", mode: { kind: "longest-idle", minConcurrentOffers: 1, maxConcurrentOffers: 1, - bypassSelectors: false + bypassSelectors: false, }, - offerTtlSeconds: 15 + offerTtlSeconds: 15, }; - await routerAdministrationClient.createDistributionPolicy(distributionPolicyId, distributionPolicyRequest); + await routerAdministrationClient.createDistributionPolicy( + distributionPolicyId, + distributionPolicyRequest + ); const queueId = "queue-123"; const request: JobQueue = { id: "queue-123", distributionPolicyId: distributionPolicyId, - name: "Main" + name: "Main", }; - const result = await routerAdministrationClient.createQueue(queueId, request); console.log("router jobQueue: " + result); - -}; +} createJobQueue().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/JobQueue_Delete.ts b/sdk/communication/communication-job-router/samples-dev/JobQueue_Delete.ts index 267268b875e1..65bcd4b2017d 100644 --- a/sdk/communication/communication-job-router/samples-dev/JobQueue_Delete.ts +++ b/sdk/communication/communication-job-router/samples-dev/JobQueue_Delete.ts @@ -3,7 +3,7 @@ /** * @summary job queue crud */ -import { RouterAdministrationClient } from "@azure/communication-job-router"; +import { JobRouterAdministrationClient } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -11,22 +11,17 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - - // Delete router jobQueue async function deleteJobQueue(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); - - const entityId = "queue-123" + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); + const entityId = "queue-123"; const result = await routerAdministrationClient.deleteQueue(entityId); console.log("router jobQueue: " + result); - -}; +} deleteJobQueue().catch(console.error); - - diff --git a/sdk/communication/communication-job-router/samples-dev/JobQueue_Get.ts b/sdk/communication/communication-job-router/samples-dev/JobQueue_Get.ts index cc1915486821..0f30cc3dfa32 100644 --- a/sdk/communication/communication-job-router/samples-dev/JobQueue_Get.ts +++ b/sdk/communication/communication-job-router/samples-dev/JobQueue_Get.ts @@ -3,7 +3,7 @@ /** * @summary job queue crud */ -import { RouterAdministrationClient } from "@azure/communication-job-router"; +import { JobRouterAdministrationClient } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -11,22 +11,18 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - - // Get a router jobQueue async function getJobQueue(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); - - const entityId = "router-jobQueue-123" + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); + const entityId = "router-jobQueue-123"; const result = await routerAdministrationClient.getQueue(entityId); console.log("router jobQueue: " + result); - -}; +} getJobQueue().catch(console.error); - diff --git a/sdk/communication/communication-job-router/samples-dev/JobQueue_GetStatistics.ts b/sdk/communication/communication-job-router/samples-dev/JobQueue_GetStatistics.ts index f854fe11a726..ef6b28976925 100644 --- a/sdk/communication/communication-job-router/samples-dev/JobQueue_GetStatistics.ts +++ b/sdk/communication/communication-job-router/samples-dev/JobQueue_GetStatistics.ts @@ -6,25 +6,22 @@ // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; -import { RouterClient } from "@azure/communication-job-router"; +import { JobRouterClient } from "@azure/communication-job-router"; dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // Get a router jobQueue's statistics async function getJobQueueStatistics(): Promise { // Create the Router Client - const routerClient: RouterClient = new RouterClient(connectionString); - - const entityId = "router-jobQueue-123" + const routerClient: JobRouterClient = new JobRouterClient(connectionString); + const entityId = "router-jobQueue-123"; const result = await routerClient.getQueueStatistics(entityId); console.log("router jobQueue: " + result); - -}; +} getJobQueueStatistics().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/JobQueue_List.ts b/sdk/communication/communication-job-router/samples-dev/JobQueue_List.ts index 2b1a58fa61e2..68be8c3043c2 100644 --- a/sdk/communication/communication-job-router/samples-dev/JobQueue_List.ts +++ b/sdk/communication/communication-job-router/samples-dev/JobQueue_List.ts @@ -3,7 +3,7 @@ /** * @summary job queue crud */ -import { JobQueueItem, RouterAdministrationClient } from "@azure/communication-job-router"; +import { JobQueueItem, JobRouterAdministrationClient } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -12,17 +12,19 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // List exception policies async function listJobQueues(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); let pagesCount = 1; const maxPageSize = 3; const receivedPagedItems: JobQueueItem[] = []; - for await (const page of routerAdministrationClient.listQueues( { maxPageSize: maxPageSize }).byPage()) { + for await (const page of routerAdministrationClient + .listQueues({ maxPageSize: maxPageSize }) + .byPage()) { ++pagesCount; console.log("page: " + pagesCount); for (const queue of page) { @@ -34,8 +36,6 @@ async function listJobQueues(): Promise { let pageSize = receivedPagedItems.length; assert.isAtMost(pageSize, maxPageSize); } - -}; +} listJobQueues().catch(console.error); - diff --git a/sdk/communication/communication-job-router/samples-dev/JobQueue_Update.ts b/sdk/communication/communication-job-router/samples-dev/JobQueue_Update.ts index 418d8fb9c873..a84fee3f1d9c 100644 --- a/sdk/communication/communication-job-router/samples-dev/JobQueue_Update.ts +++ b/sdk/communication/communication-job-router/samples-dev/JobQueue_Update.ts @@ -3,7 +3,7 @@ /** * @summary job queue crud */ -import { JobQueueResponse, RouterAdministrationClient } from "@azure/communication-job-router"; +import { JobQueueResponse, JobRouterAdministrationClient } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -11,24 +11,22 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - - // Update a router jobQueue async function updateJobQueue(): Promise { // Create the Router Client - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); const request: JobQueueResponse = { id: "queue-123", distributionPolicyId: "distribution-policy-123", name: "MainNewName", - labels: {} + labels: {}, }; const result = await routerAdministrationClient.updateQueue(request.id, request); console.log("router jobQueue: " + result); - -}; +} updateJobQueue().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/QuickStart.ts b/sdk/communication/communication-job-router/samples-dev/QuickStart.ts index f6376848a0fb..d3f01618fe30 100644 --- a/sdk/communication/communication-job-router/samples-dev/QuickStart.ts +++ b/sdk/communication/communication-job-router/samples-dev/QuickStart.ts @@ -3,7 +3,14 @@ /** * @summary Quick start workflow for creating queue, job and worker, routing/matching job with worker */ -import { DistributionPolicy, JobQueue, RouterJob, RouterAdministrationClient, RouterClient, RouterWorkerResponse } from "@azure/communication-job-router"; +import { + DistributionPolicy, + JobQueue, + RouterJob, + JobRouterAdministrationClient, + JobRouterClient, + RouterWorkerResponse, +} from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -11,25 +18,28 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - async function quickStart(): Promise { // Create the Router Client - const routerClient: RouterClient = new RouterClient(connectionString); - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); + const routerClient: JobRouterClient = new JobRouterClient(connectionString); + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); // Create a Distribution Policy - const distributionPolicyId = "distribution-policy-123" + const distributionPolicyId = "distribution-policy-123"; const distributionPolicyRequest: DistributionPolicy = { name: "distribution-policy-123", mode: { kind: "longest-idle", minConcurrentOffers: 1, maxConcurrentOffers: 1, - bypassSelectors: false + bypassSelectors: false, }, - offerTtlSeconds: 15 + offerTtlSeconds: 15, }; - await routerAdministrationClient.createDistributionPolicy(distributionPolicyId, distributionPolicyRequest); + await routerAdministrationClient.createDistributionPolicy( + distributionPolicyId, + distributionPolicyRequest + ); // Create a Queue const queueId = "queue-123"; @@ -37,7 +47,7 @@ async function quickStart(): Promise { id: "queue-123", distributionPolicyId: distributionPolicyId, name: "Main", - labels: {} + labels: {}, }; await routerAdministrationClient.createQueue(queueId, queueRequest); @@ -47,14 +57,14 @@ async function quickStart(): Promise { id: "router-job-123", channelId: "ChatChannel", queueId: queueRequest.id, - labels: {} + labels: {}, }; await routerClient.createJob(jobId, jobRequest); // Register a Worker - // Register a worker associated with the queue that was just created. We will assign labels to the - // worker to include all relevant information for example, skills, which will be used to determine + // Register a worker associated with the queue that was just created. We will assign labels to the + // worker to include all relevant information for example, skills, which will be used to determine // whether a job can be offered to a worker or not. const workerRequest: RouterWorkerResponse = { id: "router-worker-123", @@ -66,30 +76,29 @@ async function quickStart(): Promise { labels: {}, channelConfigurations: { CustomChatChannel: { - capacityCostPerJob: 10 + capacityCostPerJob: 10, }, CustomVoiceChannel: { - capacityCostPerJob: 100 - } - } + capacityCostPerJob: 100, + }, + }, }; await routerClient.registerWorker(workerRequest.id); // Check offers to a Worker - // Once the worker has been registered, Router will send an offer to the worker if the worker satisfies requirements + // Once the worker has been registered, Router will send an offer to the worker if the worker satisfies requirements // for a job. See Offer flow https://docs.microsoft.com/azure/communication-services/concepts/router/concepts#offer - // + // // We should get a RouterWorkerOfferIssued from our EventGrid subscription. - + // However, we could also wait a few seconds and then query the worker directly against the Job Router API to see if // an offer was issued to it. const workerResult = await routerClient.getWorker(workerRequest.id); - for await (let offer of workerResult.offers!) - { + for await (let offer of workerResult.offers!) { console.log(`Worker ${workerRequest.id} has an active offer for job ${offer.jobId}`); } - + // Accepting an offer // Once a worker receives an offer, it can take two possible actions: accept or decline. We are going to accept the offer. // fetching the offer id @@ -101,53 +110,53 @@ async function quickStart(): Promise { var acceptJobOfferResult = await routerClient.acceptJobOffer(workerRequest.id, offerId); console.log(`Offer: ${jobOffer.id} sent to worker: ${workerRequest.id} has been accepted`); - console.log(`Job has been assigned to worker: ${workerRequest.id} with assignment: ${acceptJobOfferResult.assignmentId}`); + console.log( + `Job has been assigned to worker: ${workerRequest.id} with assignment: ${acceptJobOfferResult.assignmentId}` + ); // verify job assignment is populated when querying job var updatedJob = await routerClient.getJob(jobId); console.log(`Job assignment has been successful: - ${updatedJob.jobStatus == "assigned" && updatedJob.assignments!.hasOwnProperty(acceptJobOfferResult.assignmentId)}`); - + ${ + updatedJob.jobStatus == "assigned" && + updatedJob.assignments!.hasOwnProperty(acceptJobOfferResult.assignmentId) + }`); // Completing a job // Once the worker is done with the job, the worker has to mark the job as `completed`. - var completeJob = await routerClient.completeJob(jobId, acceptJobOfferResult.assignmentId, - { - note : `Job has been completed by ${workerRequest.id} at ${new Date()}` + var completeJob = await routerClient.completeJob(jobId, acceptJobOfferResult.assignmentId, { + note: `Job has been completed by ${workerRequest.id} at ${new Date()}`, }); console.log(`Job has been successfully completed: ${completeJob}`); - + // Closing a job - // After a job has been completed, the worker can perform wrap up actions to the job before closing the job and finally + // After a job has been completed, the worker can perform wrap up actions to the job before closing the job and finally // releasing its capacity to accept more incoming jobs - var closeJob = await routerClient.closeJob(jobId, acceptJobOfferResult.assignmentId, - { - note : `Job has been closed by ${workerRequest.id} at ${new Date()}` - }); + var closeJob = await routerClient.closeJob(jobId, acceptJobOfferResult.assignmentId, { + note: `Job has been closed by ${workerRequest.id} at ${new Date()}`, + }); console.log(`Job has been successfully closed: ${closeJob}`); - // Optionally, a job can also be set up to be marked as closed in the future. var t = new Date(); t.setSeconds(t.getSeconds() + 2); var closeJobInFuture = await routerClient.closeJob(jobId, acceptJobOfferResult.assignmentId, { closeTime: t, // this will mark the job as closed after 2 seconds - note: `Job has been marked to close in the future by ${workerRequest.id} at ${t}` + note: `Job has been marked to close in the future by ${workerRequest.id} at ${t}`, }); console.log(`Job has been marked to close: ${closeJobInFuture}`); // You'll received a 202 in that case await delay(2000); - updatedJob = await routerClient.getJob(jobId); console.log(`Updated job status: ${updatedJob.jobStatus == "closed"}`); -}; +} function delay(ms: number) { - return new Promise( resolve => setTimeout(resolve, ms) ); + return new Promise((resolve) => setTimeout(resolve, ms)); } quickStart().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/RouterJob_Create.ts b/sdk/communication/communication-job-router/samples-dev/RouterJob_Create.ts index 0204eab4caa6..6ad20ad3dd08 100644 --- a/sdk/communication/communication-job-router/samples-dev/RouterJob_Create.ts +++ b/sdk/communication/communication-job-router/samples-dev/RouterJob_Create.ts @@ -3,7 +3,13 @@ /** * @summary router job crud */ -import { DistributionPolicy, RouterJob, JobQueue, RouterAdministrationClient, RouterClient } from "@azure/communication-job-router"; +import { + DistributionPolicy, + RouterJob, + JobQueue, + JobRouterAdministrationClient, + JobRouterClient, +} from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -11,32 +17,35 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // Create a router job async function createRouterJob(): Promise { // Create the Router Client - const routerClient: RouterClient = new RouterClient(connectionString); - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); + const routerClient: JobRouterClient = new JobRouterClient(connectionString); + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); - const distributionPolicyId = "distribution-policy-123" + const distributionPolicyId = "distribution-policy-123"; const distributionPolicyRequest: DistributionPolicy = { name: "distribution-policy-123", mode: { kind: "longest-idle", minConcurrentOffers: 1, maxConcurrentOffers: 1, - bypassSelectors: false + bypassSelectors: false, }, - offerTtlSeconds: 15 + offerTtlSeconds: 15, }; - await routerAdministrationClient.createDistributionPolicy(distributionPolicyId, distributionPolicyRequest); + await routerAdministrationClient.createDistributionPolicy( + distributionPolicyId, + distributionPolicyRequest + ); const queueId = "queue-123"; const queueRequest: JobQueue = { id: "queue-123", distributionPolicyId: distributionPolicyId, name: "Main", - labels: {} + labels: {}, }; await routerAdministrationClient.createQueue(queueId, queueRequest); @@ -45,13 +54,12 @@ async function createRouterJob(): Promise { id: "router-job-123", channelId: "ChatChannel", queueId: queueRequest.id, - labels: {} + labels: {}, }; const result = await routerClient.createJob(jobId, request); console.log("router job: " + result); - -}; +} createRouterJob().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/RouterJob_Delete.ts b/sdk/communication/communication-job-router/samples-dev/RouterJob_Delete.ts index 0c236daeea97..77976eca062d 100644 --- a/sdk/communication/communication-job-router/samples-dev/RouterJob_Delete.ts +++ b/sdk/communication/communication-job-router/samples-dev/RouterJob_Delete.ts @@ -3,7 +3,7 @@ /** * @summary router job crud */ -import { RouterClient } from "@azure/communication-job-router"; +import { JobRouterClient } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -11,19 +11,16 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - - // Delete router job async function deleteRouterJob(): Promise { // Create the Router Client - const routerClient: RouterClient = new RouterClient(connectionString); + const routerClient: JobRouterClient = new JobRouterClient(connectionString); - const entityId = "router-job-123" + const entityId = "router-job-123"; const result = await routerClient.deleteJob(entityId); console.log("router job: " + result); - -}; +} deleteRouterJob().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/RouterJob_Get.ts b/sdk/communication/communication-job-router/samples-dev/RouterJob_Get.ts index 1b164abbb2b4..4d5fa1662944 100644 --- a/sdk/communication/communication-job-router/samples-dev/RouterJob_Get.ts +++ b/sdk/communication/communication-job-router/samples-dev/RouterJob_Get.ts @@ -3,7 +3,7 @@ /** * @summary router job crud */ -import { RouterClient } from "@azure/communication-job-router"; +import { JobRouterClient } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -11,21 +11,17 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // Get a router job async function getRouterJob(): Promise { // Create the Router Client - const routerClient: RouterClient = new RouterClient(connectionString); - - const entityId = "router-job-123" + const routerClient: JobRouterClient = new JobRouterClient(connectionString); + const entityId = "router-job-123"; const result = await routerClient.getJob(entityId); console.log("router job: " + result); - -}; +} getRouterJob().catch(console.error); - diff --git a/sdk/communication/communication-job-router/samples-dev/RouterJob_List.ts b/sdk/communication/communication-job-router/samples-dev/RouterJob_List.ts index 7f716e545acb..6e01d8d6ba49 100644 --- a/sdk/communication/communication-job-router/samples-dev/RouterJob_List.ts +++ b/sdk/communication/communication-job-router/samples-dev/RouterJob_List.ts @@ -3,7 +3,7 @@ /** * @summary router job crud */ -import { RouterJobItem, RouterClient } from "@azure/communication-job-router"; +import { RouterJobItem, JobRouterClient } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -12,17 +12,18 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // List exception policies async function listRouterJobs(): Promise { // Create the Router Client - const routerClient: RouterClient = new RouterClient(connectionString); + const routerClient: JobRouterClient = new JobRouterClient(connectionString); let pagesCount = 1; const maxPageSize = 3; const receivedPagedItems: RouterJobItem[] = []; - for await (const page of routerClient.listJobs({ jobStateSelector: "queued", maxPageSize: maxPageSize }).byPage()) { + for await (const page of routerClient + .listJobs({ jobStateSelector: "queued", maxPageSize: maxPageSize }) + .byPage()) { ++pagesCount; console.log("page: " + pagesCount); for (const policy of page) { @@ -34,7 +35,6 @@ async function listRouterJobs(): Promise { let pageSize = receivedPagedItems.length; assert.isAtMost(pageSize, maxPageSize); } -}; +} listRouterJobs().catch(console.error); - diff --git a/sdk/communication/communication-job-router/samples-dev/RouterJob_Update.ts b/sdk/communication/communication-job-router/samples-dev/RouterJob_Update.ts index 5b8794ae43fe..8e7ccfde6950 100644 --- a/sdk/communication/communication-job-router/samples-dev/RouterJob_Update.ts +++ b/sdk/communication/communication-job-router/samples-dev/RouterJob_Update.ts @@ -3,7 +3,12 @@ /** * @summary router job crud */ -import { RouterAdministrationClient, RouterClient, JobQueueResponse, RouterJobResponse } from "@azure/communication-job-router"; +import { + JobRouterAdministrationClient, + JobRouterClient, + JobQueueResponse, + RouterJobResponse, +} from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -11,33 +16,31 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // Update a router job async function updateRouterJob(): Promise { // Create the Router Client - const routerClient: RouterClient = new RouterClient(connectionString); - const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString); + const routerClient: JobRouterClient = new JobRouterClient(connectionString); + const routerAdministrationClient: JobRouterAdministrationClient = + new JobRouterAdministrationClient(connectionString); const queueRequest: JobQueueResponse = { id: "queue-2", distributionPolicyId: "distribution-policy-123", name: "Main", - labels: {} + labels: {}, }; await routerAdministrationClient.createQueue(queueRequest.id, queueRequest); - const request: RouterJobResponse = { id: "router-job-123", channelId: "general", queueId: queueRequest.id, - labels: {} + labels: {}, }; const result = await routerClient.updateJob(request.id, request); console.log("router job: " + result); - -}; +} updateRouterJob().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/RouterWorker_Create.ts b/sdk/communication/communication-job-router/samples-dev/RouterWorker_Create.ts index 8d621cc0fbbf..c9e6089c6c1f 100644 --- a/sdk/communication/communication-job-router/samples-dev/RouterWorker_Create.ts +++ b/sdk/communication/communication-job-router/samples-dev/RouterWorker_Create.ts @@ -3,7 +3,7 @@ /** * @summary router worker crud */ -import { RouterClient, RouterWorker } from "@azure/communication-job-router"; +import { JobRouterClient, RouterWorker } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -11,11 +11,10 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // Create a router worker async function createRouterWorker(): Promise { // Create the Router Client - const routerClient: RouterClient = new RouterClient(connectionString); + const routerClient: JobRouterClient = new JobRouterClient(connectionString); const id = "router-worker-123"; const request: RouterWorker = { @@ -25,24 +24,22 @@ async function createRouterWorker(): Promise { totalCapacity: 100, queueAssignments: { MainQueue: {}, - SecondaryQueue: {} + SecondaryQueue: {}, }, labels: {}, channelConfigurations: { CustomChatChannel: { - capacityCostPerJob: 10 + capacityCostPerJob: 10, }, CustomVoiceChannel: { - capacityCostPerJob: 100 - } - } + capacityCostPerJob: 100, + }, + }, }; - const result = await routerClient.createWorker(id, request); console.log("router worker: " + result); - -}; +} createRouterWorker().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/RouterWorker_Delete.ts b/sdk/communication/communication-job-router/samples-dev/RouterWorker_Delete.ts index 7f7b328321ee..1ee1319ed498 100644 --- a/sdk/communication/communication-job-router/samples-dev/RouterWorker_Delete.ts +++ b/sdk/communication/communication-job-router/samples-dev/RouterWorker_Delete.ts @@ -3,7 +3,7 @@ /** * @summary router worker crud */ -import { RouterClient } from "@azure/communication-job-router"; +import { JobRouterClient } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -11,19 +11,16 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // Delete router worker async function deleteRouterWorker(): Promise { // Create the Router Client - const routerClient: RouterClient = new RouterClient(connectionString); - - const entityId = "router-worker-123" + const routerClient: JobRouterClient = new JobRouterClient(connectionString); + const entityId = "router-worker-123"; const result = await routerClient.deleteWorker(entityId); console.log("router worker: " + result); - -}; +} deleteRouterWorker().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/RouterWorker_Deregister.ts b/sdk/communication/communication-job-router/samples-dev/RouterWorker_Deregister.ts index 083fd274bb12..cbea19f4f5f5 100644 --- a/sdk/communication/communication-job-router/samples-dev/RouterWorker_Deregister.ts +++ b/sdk/communication/communication-job-router/samples-dev/RouterWorker_Deregister.ts @@ -3,7 +3,7 @@ /** * @summary router worker crud */ -import { RouterClient } from "@azure/communication-job-router"; +import { JobRouterClient } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -11,20 +11,17 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // De-register a router worker async function deregisterRouterWorker(): Promise { // Create the Router Client - const routerClient: RouterClient = new RouterClient(connectionString); - - const entityId = "router-worker-123" + const routerClient: JobRouterClient = new JobRouterClient(connectionString); + const entityId = "router-worker-123"; const result = await routerClient.deregisterWorker(entityId); console.log("router worker: " + result); - -}; +} deregisterRouterWorker().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/RouterWorker_Get.ts b/sdk/communication/communication-job-router/samples-dev/RouterWorker_Get.ts index 6ebcbac76694..2f8e7ca2643c 100644 --- a/sdk/communication/communication-job-router/samples-dev/RouterWorker_Get.ts +++ b/sdk/communication/communication-job-router/samples-dev/RouterWorker_Get.ts @@ -3,7 +3,7 @@ /** * @summary router worker crud */ -import { RouterClient } from "@azure/communication-job-router"; +import { JobRouterClient } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -15,16 +15,13 @@ const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; async function getRouterWorker(): Promise { // Create the Router Client - const routerClient: RouterClient = new RouterClient(connectionString); - - const entityId = "router-worker-123" + const routerClient: JobRouterClient = new JobRouterClient(connectionString); + const entityId = "router-worker-123"; const result = await routerClient.getWorker(entityId); console.log("router worker: " + result); - -}; +} getRouterWorker().catch(console.error); - diff --git a/sdk/communication/communication-job-router/samples-dev/RouterWorker_List.ts b/sdk/communication/communication-job-router/samples-dev/RouterWorker_List.ts index 6b9eb7058256..e0c37c2e86c7 100644 --- a/sdk/communication/communication-job-router/samples-dev/RouterWorker_List.ts +++ b/sdk/communication/communication-job-router/samples-dev/RouterWorker_List.ts @@ -3,7 +3,7 @@ /** * @summary router worker crud */ -import { RouterClient, RouterWorkerItem } from "@azure/communication-job-router"; +import { JobRouterClient, RouterWorkerItem } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -12,17 +12,16 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // List exception policies async function listRouterWorkers(): Promise { // Create the Router Client - const routerClient: RouterClient = new RouterClient(connectionString); + const routerClient: JobRouterClient = new JobRouterClient(connectionString); let pagesCount = 1; const maxPageSize = 3; const receivedPagedItems: RouterWorkerItem[] = []; - for await (const page of routerClient.listWorkers( { maxPageSize: maxPageSize }).byPage()) { + for await (const page of routerClient.listWorkers({ maxPageSize: maxPageSize }).byPage()) { ++pagesCount; console.log("page: " + pagesCount); for (const policy of page) { @@ -34,7 +33,6 @@ async function listRouterWorkers(): Promise { let pageSize = receivedPagedItems.length; assert.isAtMost(pageSize, maxPageSize); } - -}; +} listRouterWorkers().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/RouterWorker_Register.ts b/sdk/communication/communication-job-router/samples-dev/RouterWorker_Register.ts index 5d25ea4898ef..33a1064b6500 100644 --- a/sdk/communication/communication-job-router/samples-dev/RouterWorker_Register.ts +++ b/sdk/communication/communication-job-router/samples-dev/RouterWorker_Register.ts @@ -3,7 +3,7 @@ /** * @summary router worker crud */ -import { RouterClient } from "@azure/communication-job-router"; +import { JobRouterClient } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -11,20 +11,17 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // Register a router worker async function registerRouterWorker(): Promise { // Create the Router Client - const routerClient: RouterClient = new RouterClient(connectionString); - - const entityId = "router-worker-123" + const routerClient: JobRouterClient = new JobRouterClient(connectionString); + const entityId = "router-worker-123"; const result = await routerClient.registerWorker(entityId); console.log("router worker: " + result); - -}; +} registerRouterWorker().catch(console.error); diff --git a/sdk/communication/communication-job-router/samples-dev/RouterWorker_Update.ts b/sdk/communication/communication-job-router/samples-dev/RouterWorker_Update.ts index 84d76e821be0..36c01d7beeaf 100644 --- a/sdk/communication/communication-job-router/samples-dev/RouterWorker_Update.ts +++ b/sdk/communication/communication-job-router/samples-dev/RouterWorker_Update.ts @@ -3,7 +3,7 @@ /** * @summary router worker crud */ -import { RouterClient, RouterWorkerResponse } from "@azure/communication-job-router"; +import { JobRouterClient, RouterWorkerResponse } from "@azure/communication-job-router"; // Load the .env file (you will need to set these environment variables) import * as dotenv from "dotenv"; @@ -11,11 +11,10 @@ dotenv.config(); const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || ""; - // Update a router worker async function updateRouterWorker(): Promise { // Create the Router Client - const routerClient: RouterClient = new RouterClient(connectionString); + const routerClient: JobRouterClient = new JobRouterClient(connectionString); const request: RouterWorkerResponse = { id: "router-worker-123", @@ -23,22 +22,21 @@ async function updateRouterWorker(): Promise { totalCapacity: 50, queueAssignments: { MainQueue: {}, - SecondaryQueue: {} + SecondaryQueue: {}, }, channelConfigurations: { CustomChatChannel: { - capacityCostPerJob: 2 + capacityCostPerJob: 2, }, CustomVoiceChannel: { - capacityCostPerJob: 5 - } - } + capacityCostPerJob: 5, + }, + }, }; const result = await routerClient.updateWorker(request.id, request); console.log("router worker: " + result); - -}; +} updateRouterWorker().catch(console.error); diff --git a/sdk/communication/communication-job-router/src/index.ts b/sdk/communication/communication-job-router/src/index.ts index 15eaada1344d..b8c9fdc42900 100644 --- a/sdk/communication/communication-job-router/src/index.ts +++ b/sdk/communication/communication-job-router/src/index.ts @@ -4,5 +4,5 @@ export * from "./models/options"; export * from "./models/models"; export * from "./models/responses"; -export * from "./routerClient"; -export * from "./routerAdministrationClient"; +export * from "./jobRouterClient"; +export * from "./jobRouterAdministrationClient"; diff --git a/sdk/communication/communication-job-router/src/routerAdministrationClient.ts b/sdk/communication/communication-job-router/src/jobRouterAdministrationClient.ts similarity index 95% rename from sdk/communication/communication-job-router/src/routerAdministrationClient.ts rename to sdk/communication/communication-job-router/src/jobRouterAdministrationClient.ts index 393b30431441..96a193bb0e86 100644 --- a/sdk/communication/communication-job-router/src/routerAdministrationClient.ts +++ b/sdk/communication/communication-job-router/src/jobRouterAdministrationClient.ts @@ -29,7 +29,7 @@ import { ListDistributionPoliciesOptions, ListExceptionPoliciesOptions, ListQueuesOptions, - RouterAdministrationClientOptions, + JobRouterAdministrationClientOptions as JobRouterAdministrationClientOptions, UpdateClassificationPolicyOptions, UpdateDistributionPolicyOptions, UpdateExceptionPolicyOptions, @@ -48,29 +48,29 @@ import { SDK_VERSION } from "./constants"; import { logger } from "./models/logger"; /** - * Checks whether the type of a value is {@link RouterAdministrationClientOptions} or not. + * Checks whether the type of a value is {@link JobRouterAdministrationClientOptions} or not. * * @param options - The value being checked. */ const isRouterAdministrationClientOptions = ( options: any -): options is RouterAdministrationClientOptions => !!options && !isKeyCredential(options); +): options is JobRouterAdministrationClientOptions => !!options && !isKeyCredential(options); /** * The client to do router operations */ -export class RouterAdministrationClient { +export class JobRouterAdministrationClient { private readonly client: JobRouterApiClient; /** * Initializes a new instance of the RouterClient class. * @param connectionString - Connection string to connect to an Azure Communication Service resource. * Example: "endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret"; - * @param routerAdministrationClientOptions - Optional. Options to configure the HTTP pipeline. + * @param jobRouterAdministrationClientOptions - Optional. Options to configure the HTTP pipeline. */ constructor( connectionString: string, - routerAdministrationClientOptions?: RouterAdministrationClientOptions + jobRouterAdministrationClientOptions?: JobRouterAdministrationClientOptions ); /** @@ -83,7 +83,7 @@ export class RouterAdministrationClient { constructor( endpoint: string, credential: KeyCredential | TokenCredential, - routerAdministrationClientOptions?: RouterAdministrationClientOptions + routerAdministrationClientOptions?: JobRouterAdministrationClientOptions ); /** @@ -95,7 +95,7 @@ export class RouterAdministrationClient { constructor( endpoint: string, credential: CommunicationTokenCredential, - routerAdministrationClientOptions?: RouterAdministrationClientOptions + routerAdministrationClientOptions?: JobRouterAdministrationClientOptions ); /** @@ -111,8 +111,8 @@ export class RouterAdministrationClient { | KeyCredential | TokenCredential | CommunicationTokenCredential - | RouterAdministrationClientOptions, - maybeOptions: RouterAdministrationClientOptions = {} + | JobRouterAdministrationClientOptions, + maybeOptions: JobRouterAdministrationClientOptions = {} ) { const { url, credential } = parseClientArguments(connectionStringOrUrl, credentialOrOptions); const options = isRouterAdministrationClientOptions(credentialOrOptions) diff --git a/sdk/communication/communication-job-router/src/routerClient.ts b/sdk/communication/communication-job-router/src/jobRouterClient.ts similarity index 96% rename from sdk/communication/communication-job-router/src/routerClient.ts rename to sdk/communication/communication-job-router/src/jobRouterClient.ts index fb9c1695b205..13681af8aeb1 100644 --- a/sdk/communication/communication-job-router/src/routerClient.ts +++ b/sdk/communication/communication-job-router/src/jobRouterClient.ts @@ -40,24 +40,24 @@ import { ListJobsOptions, ListWorkersOptions, ReclassifyJobOptions, - RouterClientOptions, + JobRouterClientOptions, UpdateJobOptions, UpdateWorkerOptions, } from "./models/options"; import { RouterJobResponse, RouterWorkerResponse, UnassignJobResult } from "./models/responses"; /** - * Checks whether the type of a value is {@link RouterClientOptions} or not. + * Checks whether the type of a value is {@link JobRouterClientOptions} or not. * * @param options - The value being checked. */ -const isRouterClientOptions = (options: any): options is RouterClientOptions => +const isRouterClientOptions = (options: any): options is JobRouterClientOptions => !!options && !isKeyCredential(options); /** * The client to do router operations */ -export class RouterClient { +export class JobRouterClient { private readonly client: JobRouterApiClient; /** @@ -66,7 +66,7 @@ export class RouterClient { * Example: "endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret"; * @param routerClientOptions - Optional. Options to configure the HTTP pipeline. */ - constructor(connectionString: string, routerClientOptions?: RouterClientOptions); + constructor(connectionString: string, routerClientOptions?: JobRouterClientOptions); /** * Initializes a new instance of the RouterClient class using an Azure KeyCredential. @@ -78,7 +78,7 @@ export class RouterClient { constructor( endpoint: string, credential: KeyCredential | TokenCredential, - routerClientOptions?: RouterClientOptions + routerClientOptions?: JobRouterClientOptions ); /** @@ -90,7 +90,7 @@ export class RouterClient { constructor( endpoint: string, credential: CommunicationTokenCredential, - routerClientOptions?: RouterClientOptions + routerClientOptions?: JobRouterClientOptions ); /** @@ -106,8 +106,8 @@ export class RouterClient { | KeyCredential | TokenCredential | CommunicationTokenCredential - | RouterClientOptions, - maybeOptions: RouterClientOptions = {} + | JobRouterClientOptions, + maybeOptions: JobRouterClientOptions = {} ) { const { url, credential } = parseClientArguments(connectionStringOrUrl, credentialOrOptions); const options = isRouterClientOptions(credentialOrOptions) ? credentialOrOptions : maybeOptions; diff --git a/sdk/communication/communication-job-router/src/models/models.ts b/sdk/communication/communication-job-router/src/models/models.ts index d18b286ec146..b1051e72f6b7 100644 --- a/sdk/communication/communication-job-router/src/models/models.ts +++ b/sdk/communication/communication-job-router/src/models/models.ts @@ -1,14 +1,84 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -/** - * Arguments for retrieving the next page of search results. - */ +import { + RouterJob as RouterJobGenerated, + WorkerSelector as WorkerSelectorGenerated, + JobQueue as JobQueueGenerated, + RouterWorker as RouterWorkerGenerated, + QueueSelector as QueueSelectorGenerated, + StaticRule as StaticRuleGenerated, + ReclassifyExceptionAction as ReclassifyExceptionActionGenerated, + JobRouterReclassifyJobActionOptionalParams as JobRouterReclassifyJobActionOptionalParamsGenerated, +} from "../generated/src/models"; + +/* Safer types to use instead of any */ +export type JSONValue = boolean | number | string | null | JSONArray | JSONObject; +export interface JSONObject { + [key: string]: JSONValue; +} +export interface JSONArray extends ArrayLike {} + +/** A unit of work to be routed */ +export interface RouterJob extends Omit { + /** A set of key/value pairs that are identifying attributes used by the rules engines to make decisions. */ + labels?: JSONObject; + /** A set of non-identifying attributes attached to this job */ + tags?: JSONObject; +} + +/** Describes a condition that must be met against a set of labels for worker selection */ +export interface WorkerSelector extends Omit { + /** The value to compare against the actual label value with the given operator */ + value?: JSONValue; +} + +/** A queue that can contain jobs to be routed. */ +export interface JobQueue extends Omit { + /** A set of key/value pairs that are identifying attributes used by the rules engines to make decisions. */ + labels?: JSONObject; +} + +/** An entity for jobs to be routed to */ +export interface RouterWorker + extends Omit { + /** The queue(s) that this worker can receive work from. */ + queueAssignments?: JSONObject; + /** A set of key/value pairs that are identifying attributes used by the rules engines to make decisions. */ + labels?: JSONObject; + /** A set of non-identifying attributes attached to this job */ + tags?: JSONObject; +} + +/** Describes a condition that must be met against a set of labels for queue selection */ +export interface QueueSelector extends Omit { + /** The value to compare against the actual label value with the given operator */ + value?: JSONValue; +} + +/** A rule providing static rules that always return the same result, regardless of input. */ +export interface StaticRule extends Omit { + /** The static value this rule always returns. */ + value?: JSONValue; +} + +/** An action that modifies labels on a job and then reclassifies it */ +export interface ReclassifyExceptionAction + extends Omit { + /** (optional) Dictionary containing the labels to update (or add if not existing) in key-value pairs */ + lablabelsToUpsertels?: JSONObject; +} + +/** Contains response data for the reclassifyJobAction operation. */ +export interface JobRouterReclassifyJobActionOptionalParams + extends Omit { + /** The parsed response body. */ + body?: JSONValue; +} + +/** Arguments for retrieving the next page of search results. */ export interface ListPageSettings { - /** - * A token used for retrieving the next page of results when the server - * enforces pagination. - */ + /** A token used for retrieving the next page of results when the server enforces pagination. */ continuationToken?: string | null; } @@ -16,16 +86,12 @@ export { DistributionPolicy, ExceptionPolicy, ClassificationPolicy, - JobQueue, - RouterWorker, - RouterJob, ExceptionRule, JobAssignment, ChannelConfiguration, WorkerAssignment, JobOffer, RouterWorkerState, - WorkerSelector, JobPositionDetails, WorkerStateSelector, JobStateSelector, @@ -39,7 +105,6 @@ export { WorkerSelectorAttachment, QueueSelectorAttachmentUnion, QueueSelectorAttachment, - QueueSelector, QueueWeightedAllocation, WorkerWeightedAllocation, ScoringRuleOptions, @@ -47,7 +112,6 @@ export { RouterRule, DirectMapRule, ExpressionRule, - StaticRule, WebhookRule, Oauth2ClientCredential, FunctionRule, @@ -59,12 +123,10 @@ export { ExceptionAction, CancelExceptionAction, ManualReclassifyExceptionAction, - ReclassifyExceptionAction, ExceptionActionUnion, ScoringRuleParameterSelector, JobRouterUpsertJobOptionalParams, JobRouterUpsertWorkerOptionalParams, - JobRouterReclassifyJobActionOptionalParams, JobRouterDeclineJobActionOptionalParams, DeclineJobOfferRequest, ClassificationPolicyItem, @@ -86,7 +148,6 @@ export { StaticQueueSelectorAttachment, WeightedAllocationQueueSelectorAttachment, AcceptJobOfferResult, - JobRouterReclassifyJobActionResponse, UnassignJobResult, RouterJobStatus, WorkerSelectorState, diff --git a/sdk/communication/communication-job-router/src/models/options.ts b/sdk/communication/communication-job-router/src/models/options.ts index 1e3a9a2b00ea..1e1c4a13ca29 100644 --- a/sdk/communication/communication-job-router/src/models/options.ts +++ b/sdk/communication/communication-job-router/src/models/options.ts @@ -24,22 +24,20 @@ import { WorkerStateSelector, } from "../generated/src"; import { CommonClientOptions, OperationOptions } from "@azure/core-client"; +import { JSONObject } from "./models"; /** * Options to create router client. */ -export interface RouterClientOptions extends CommonClientOptions { +export interface JobRouterClientOptions extends CommonClientOptions { /** The headers to be set on requests **/ - headers?: { [propertyName: string]: any }; + headers?: JSONObject; } /** * Options to create router administration client. */ -export interface RouterAdministrationClientOptions extends CommonClientOptions { - /** The headers to be set on requests **/ - headers?: { [propertyName: string]: any }; -} +export interface JobRouterAdministrationClientOptions extends CommonClientOptions {} /** * Options to create a classification policy. @@ -166,9 +164,9 @@ export interface CreateJobOptions extends JobRouterUpsertJobOptionalParams { /** A collection of manually specified label selectors, which a worker must satisfy in order to process this job. */ requestedWorkerSelectors?: WorkerSelector[]; /** A set of key/value pairs that are identifying attributes used by the rules engines to make decisions. */ - labels?: { [propertyName: string]: any }; + labels?: JSONObject; /** A set of non-identifying attributes attached to this job */ - tags?: { [propertyName: string]: any }; + tags?: JSONObject; /** Notes attached to a job, sorted by timestamp */ notes?: { [propertyName: string]: string }; /** @@ -199,9 +197,9 @@ export interface UpdateJobOptions extends JobRouterUpsertJobOptionalParams { /** A collection of manually specified label selectors, which a worker must satisfy in order to process this job. */ requestedWorkerSelectors?: WorkerSelector[]; /** A set of key/value pairs that are identifying attributes used by the rules engines to make decisions. */ - labels?: { [propertyName: string]: any }; + labels?: JSONObject; /** A set of non-identifying attributes attached to this job */ - tags?: { [propertyName: string]: any }; + tags?: JSONObject; /** Notes attached to a job, sorted by timestamp */ notes?: { [propertyName: string]: string }; /** @@ -218,7 +216,7 @@ export interface UpdateJobOptions extends JobRouterUpsertJobOptionalParams { */ export interface ReclassifyJobOptions extends JobRouterReclassifyJobActionOptionalParams { /** Request object for reclassifying a job. */ - reclassifyJobRequest?: Record; + reclassifyJobRequest?: JSONObject; } /** @@ -294,13 +292,13 @@ export interface ListJobsOptions extends OperationOptions { */ export interface CreateWorkerOptions extends JobRouterUpsertWorkerOptionalParams { /** The queue(s) that this worker can receive work from. */ - queueAssignments?: { [propertyName: string]: Record }; + queueAssignments?: JSONObject; /** The total capacity score this worker has to manage multiple concurrent jobs. */ totalCapacity?: number; /** A set of key/value pairs that are identifying attributes used by the rules engines to make decisions. */ - labels?: { [propertyName: string]: any }; + labels?: JSONObject; /** A set of non-identifying attributes attached to this worker. */ - tags?: { [propertyName: string]: any }; + tags?: JSONObject; /** The channel(s) this worker can handle and their impact on the workers capacity. */ channelConfigurations?: { [propertyName: string]: ChannelConfiguration }; /** A flag indicating this worker is open to receive offers or not. */ @@ -312,13 +310,13 @@ export interface CreateWorkerOptions extends JobRouterUpsertWorkerOptionalParams */ export interface UpdateWorkerOptions extends JobRouterUpsertWorkerOptionalParams { /** The queue(s) that this worker can receive work from. */ - queueAssignments?: { [propertyName: string]: Record }; + queueAssignments?: JSONObject; /** The total capacity score this worker has to manage multiple concurrent jobs. */ totalCapacity?: number; /** A set of key/value pairs that are identifying attributes used by the rules engines to make decisions. */ - labels?: { [propertyName: string]: any }; + labels?: JSONObject; /** A set of non-identifying attributes attached to this worker. */ - tags?: { [propertyName: string]: any }; + tags?: JSONObject; /** The channel(s) this worker can handle and their impact on the workers capacity. */ channelConfigurations?: { [propertyName: string]: ChannelConfiguration }; /** A flag indicating this worker is open to receive offers or not. */ @@ -353,7 +351,7 @@ export interface CreateQueueOptions extends JobRouterAdministrationUpsertQueueOp /** The ID of the distribution policy that will determine how a job is distributed to workers. */ distributionPolicyId?: string; /** A set of key/value pairs that are identifying attributes used by the rules engines to make decisions. */ - labels?: { [propertyName: string]: any }; + labels?: JSONObject; /** (Optional) The ID of the exception policy that determines various job escalation rules. */ exceptionPolicyId?: string; } @@ -367,7 +365,7 @@ export interface UpdateQueueOptions extends JobRouterAdministrationUpsertQueueOp /** The ID of the distribution policy that will determine how a job is distributed to workers. */ distributionPolicyId?: string; /** A set of key/value pairs that are identifying attributes used by the rules engines to make decisions. */ - labels?: { [propertyName: string]: any }; + labels?: JSONObject; /** (Optional) The ID of the exception policy that determines various job escalation rules. */ exceptionPolicyId?: string; } diff --git a/sdk/communication/communication-job-router/src/models/responses.ts b/sdk/communication/communication-job-router/src/models/responses.ts index 6e4009f85ea7..25f456588fe8 100644 --- a/sdk/communication/communication-job-router/src/models/responses.ts +++ b/sdk/communication/communication-job-router/src/models/responses.ts @@ -10,14 +10,18 @@ import { RouterWorker, } from "../generated/src"; -export { - JobRouterCancelJobActionResponse, - JobRouterCloseJobActionResponse, - JobRouterCompleteJobActionResponse, - JobRouterDeclineJobActionResponse, - UnassignJobResult, +import { + JobRouterReclassifyJobActionResponse as JobRouterReclassifyJobActionResponseGenerated, + JobRouterCancelJobActionResponse as JobRouterCancelJobActionResponseGenerated, + JobRouterCompleteJobActionResponse as JobRouterCompleteJobActionResponseGenerated, + JobRouterCloseJobActionResponse as JobRouterCloseJobActionResponseGenerated, + JobRouterDeclineJobActionResponse as JobRouterDeclineJobActionResponseGenerated, } from "../generated/src/models"; +import { JSONValue } from "./models"; + +export { UnassignJobResult } from "../generated/src/models"; + export interface RouterJobResponse extends RouterJob { readonly id: string; } @@ -41,3 +45,38 @@ export interface DistributionPolicyResponse extends DistributionPolicy { export interface ExceptionPolicyResponse extends ExceptionPolicy { readonly id: string; } + +/** Contains response data for the reclassifyJobAction operation. */ +export interface JobRouterReclassifyJobActionResponse + extends Omit { + /** The parsed response body. */ + body?: JSONValue; +} + +/** Contains response data for the cancelJobAction operation. */ +export interface JobRouterCancelJobActionResponse + extends Omit { + /** The parsed response body. */ + body?: JSONValue; +} + +/** Contains response data for the completeJobAction operation. */ +export interface JobRouterCompleteJobActionResponse + extends Omit { + /** The parsed response body. */ + body?: JSONValue; +} + +/** Contains response data for the closeJobAction operation. */ +export interface JobRouterCloseJobActionResponse + extends Omit { + /** The parsed response body. */ + body?: JSONValue; +} + +/** Contains response data for the declineJobAction operation. */ +export interface JobRouterDeclineJobActionResponse + extends Omit { + /** The parsed response body. */ + body?: JSONValue; +} diff --git a/sdk/communication/communication-job-router/test/internal/routerClient.mocked.spec.ts b/sdk/communication/communication-job-router/test/internal/jobRouterClient.mocked.spec.ts similarity index 75% rename from sdk/communication/communication-job-router/test/internal/routerClient.mocked.spec.ts rename to sdk/communication/communication-job-router/test/internal/jobRouterClient.mocked.spec.ts index 64e330cd3e71..fd9a2620b459 100644 --- a/sdk/communication/communication-job-router/test/internal/routerClient.mocked.spec.ts +++ b/sdk/communication/communication-job-router/test/internal/jobRouterClient.mocked.spec.ts @@ -3,7 +3,7 @@ import sinon from "sinon"; import { AzureCommunicationTokenCredential } from "@azure/communication-common"; -import { RouterClient } from "../../src"; +import { JobRouterClient } from "../../src"; import { baseUri, generateToken } from "../public/utils/connection"; describe("[Mocked] RouterClient", async function () { @@ -12,6 +12,6 @@ describe("[Mocked] RouterClient", async function () { }); it("can instantiate", async function () { - new RouterClient(baseUri, new AzureCommunicationTokenCredential(generateToken())); + new JobRouterClient(baseUri, new AzureCommunicationTokenCredential(generateToken())); }); }); diff --git a/sdk/communication/communication-job-router/test/internal/utils/mockClient.ts b/sdk/communication/communication-job-router/test/internal/utils/mockClient.ts index 4108f3d1846e..99076e80e97d 100644 --- a/sdk/communication/communication-job-router/test/internal/utils/mockClient.ts +++ b/sdk/communication/communication-job-router/test/internal/utils/mockClient.ts @@ -3,10 +3,10 @@ import * as dotenv from "dotenv"; import { Recorder, env } from "@azure-tools/test-recorder"; -import { RouterAdministrationClient, RouterClient } from "../../../src"; +import { JobRouterAdministrationClient, JobRouterClient } from "../../../src"; import { Context } from "mocha"; import { isNode } from "@azure/core-util"; -import { RouterAdministrationClientOptions, RouterClientOptions } from "../../../src"; +import { JobRouterAdministrationClientOptions, JobRouterClientOptions } from "../../../src"; import { createRecorder } from "./recordedClient"; if (isNode) { @@ -14,8 +14,8 @@ if (isNode) { } export interface RecordedRouterClient { - client: RouterClient; - administrationClient: RouterAdministrationClient; + client: JobRouterClient; + administrationClient: JobRouterAdministrationClient; recorder: Recorder; } @@ -25,13 +25,13 @@ export async function createRecordedRouterClientWithConnectionString( const recorder = await createRecorder(context.currentTest); return { - client: new RouterClient( + client: new JobRouterClient( env.COMMUNICATION_CONNECTION_STRING as string, - recorder.configureClientOptions({}) as RouterClientOptions + recorder.configureClientOptions({}) as JobRouterClientOptions ), - administrationClient: new RouterAdministrationClient( + administrationClient: new JobRouterAdministrationClient( env.COMMUNICATION_CONNECTION_STRING as string, - recorder.configureClientOptions({}) as RouterAdministrationClientOptions + recorder.configureClientOptions({}) as JobRouterAdministrationClientOptions ), recorder, }; diff --git a/sdk/communication/communication-job-router/test/public/methods/classificationPolicies.spec.ts b/sdk/communication/communication-job-router/test/public/methods/classificationPolicies.spec.ts index 5e31d6d3349b..c3a555486e3a 100644 --- a/sdk/communication/communication-job-router/test/public/methods/classificationPolicies.spec.ts +++ b/sdk/communication/communication-job-router/test/public/methods/classificationPolicies.spec.ts @@ -4,7 +4,7 @@ import { Recorder } from "@azure-tools/test-recorder"; import { assert } from "chai"; import { Context } from "mocha"; -import { ClassificationPolicy, RouterAdministrationClient } from "../../../src"; +import { ClassificationPolicy, JobRouterAdministrationClient } from "../../../src"; import { getClassificationPolicyRequest, getDistributionPolicyRequest, @@ -15,7 +15,7 @@ import { createRecordedRouterClientWithConnectionString } from "../../internal/u import { timeoutMs } from "../utils/constants"; describe("RouterClient", function () { - let administrationClient: RouterAdministrationClient; + let administrationClient: JobRouterAdministrationClient; let recorder: Recorder; const testRunId = "recorded-c-policies"; diff --git a/sdk/communication/communication-job-router/test/public/methods/distributionPolicies.spec.ts b/sdk/communication/communication-job-router/test/public/methods/distributionPolicies.spec.ts index 6e0b0824d91c..a52eb18028f1 100644 --- a/sdk/communication/communication-job-router/test/public/methods/distributionPolicies.spec.ts +++ b/sdk/communication/communication-job-router/test/public/methods/distributionPolicies.spec.ts @@ -4,13 +4,13 @@ import { Recorder } from "@azure-tools/test-recorder"; import { assert } from "chai"; import { Context } from "mocha"; -import { DistributionPolicy, RouterAdministrationClient } from "../../../src"; +import { DistributionPolicy, JobRouterAdministrationClient } from "../../../src"; import { getDistributionPolicyRequest } from "../utils/testData"; import { createRecordedRouterClientWithConnectionString } from "../../internal/utils/mockClient"; import { timeoutMs } from "../utils/constants"; describe("RouterClient", function () { - let administrationClient: RouterAdministrationClient; + let administrationClient: JobRouterAdministrationClient; let recorder: Recorder; const testRunId = "recorded-d-policies"; diff --git a/sdk/communication/communication-job-router/test/public/methods/exceptionPolicies.spec.ts b/sdk/communication/communication-job-router/test/public/methods/exceptionPolicies.spec.ts index 736c8da5c172..6b15b0d0c61a 100644 --- a/sdk/communication/communication-job-router/test/public/methods/exceptionPolicies.spec.ts +++ b/sdk/communication/communication-job-router/test/public/methods/exceptionPolicies.spec.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import { Recorder } from "@azure-tools/test-recorder"; -import { ExceptionPolicy, RouterAdministrationClient } from "../../../src"; +import { ExceptionPolicy, JobRouterAdministrationClient } from "../../../src"; import { assert } from "chai"; import { createRecordedRouterClientWithConnectionString } from "../../internal/utils/mockClient"; import { Context } from "mocha"; @@ -10,7 +10,7 @@ import { getExceptionPolicyRequest } from "../utils/testData"; import { timeoutMs } from "../utils/constants"; describe("RouterClient", function () { - let administrationClient: RouterAdministrationClient; + let administrationClient: JobRouterAdministrationClient; let recorder: Recorder; const testRunId = "recorded-e-policies"; diff --git a/sdk/communication/communication-job-router/test/public/methods/jobs.spec.ts b/sdk/communication/communication-job-router/test/public/methods/jobs.spec.ts index 951b1aa2434b..d3615989f9c2 100644 --- a/sdk/communication/communication-job-router/test/public/methods/jobs.spec.ts +++ b/sdk/communication/communication-job-router/test/public/methods/jobs.spec.ts @@ -3,7 +3,7 @@ import { Recorder } from "@azure-tools/test-recorder"; import { assert } from "chai"; -import { RouterAdministrationClient, RouterClient, RouterJob } from "../../../src"; +import { JobRouterAdministrationClient, JobRouterClient, RouterJob } from "../../../src"; import { Context } from "mocha"; import { getClassificationPolicyRequest, @@ -17,8 +17,8 @@ import { sleep, timeoutMs } from "../utils/constants"; import { pollForJobQueued, retry } from "../utils/polling"; describe("RouterClient", function () { - let client: RouterClient; - let administrationClient: RouterAdministrationClient; + let client: JobRouterClient; + let administrationClient: JobRouterAdministrationClient; let recorder: Recorder; const testRunId = "recorded-jobs"; diff --git a/sdk/communication/communication-job-router/test/public/methods/queues.spec.ts b/sdk/communication/communication-job-router/test/public/methods/queues.spec.ts index 0779ef63ce23..b967aeb5c6b6 100644 --- a/sdk/communication/communication-job-router/test/public/methods/queues.spec.ts +++ b/sdk/communication/communication-job-router/test/public/methods/queues.spec.ts @@ -3,7 +3,7 @@ import { Recorder } from "@azure-tools/test-recorder"; import { assert } from "chai"; -import { JobQueue, RouterAdministrationClient } from "../../../src"; +import { JobQueue, JobRouterAdministrationClient } from "../../../src"; import { Context } from "mocha"; import { getDistributionPolicyRequest, @@ -14,7 +14,7 @@ import { createRecordedRouterClientWithConnectionString } from "../../internal/u import { timeoutMs } from "../utils/constants"; describe("RouterClient", function () { - let administrationClient: RouterAdministrationClient; + let administrationClient: JobRouterAdministrationClient; let recorder: Recorder; const testRunId = "recorded-queues"; diff --git a/sdk/communication/communication-job-router/test/public/methods/workers.spec.ts b/sdk/communication/communication-job-router/test/public/methods/workers.spec.ts index eecfd412dbe4..24e5bfb50db4 100644 --- a/sdk/communication/communication-job-router/test/public/methods/workers.spec.ts +++ b/sdk/communication/communication-job-router/test/public/methods/workers.spec.ts @@ -4,7 +4,7 @@ import { Recorder } from "@azure-tools/test-recorder"; import { assert } from "chai"; import { Context } from "mocha"; -import { RouterAdministrationClient, RouterClient, RouterWorker } from "../../../src"; +import { JobRouterAdministrationClient, JobRouterClient, RouterWorker } from "../../../src"; import { getDistributionPolicyRequest, getExceptionPolicyRequest, @@ -15,8 +15,8 @@ import { createRecordedRouterClientWithConnectionString } from "../../internal/u import { sleep, timeoutMs } from "../utils/constants"; describe("RouterClient", function () { - let client: RouterClient; - let administrationClient: RouterAdministrationClient; + let client: JobRouterClient; + let administrationClient: JobRouterAdministrationClient; let recorder: Recorder; const testRunId = "recorded-workers"; diff --git a/sdk/communication/communication-job-router/test/public/scenarios/assignmentScenario.spec.ts b/sdk/communication/communication-job-router/test/public/scenarios/assignmentScenario.spec.ts index 36dfe606a3dc..17e8cdb2f2da 100644 --- a/sdk/communication/communication-job-router/test/public/scenarios/assignmentScenario.spec.ts +++ b/sdk/communication/communication-job-router/test/public/scenarios/assignmentScenario.spec.ts @@ -10,7 +10,12 @@ import { getWorkerRequest, } from "../utils/testData"; import { assert } from "chai"; -import { JobAssignment, JobOffer, RouterAdministrationClient, RouterClient } from "../../../src"; +import { + JobAssignment, + JobOffer, + JobRouterAdministrationClient, + JobRouterClient, +} from "../../../src"; import { Context } from "mocha"; import { createRecordedRouterClientWithConnectionString } from "../../internal/utils/mockClient"; import { timeoutMs } from "../utils/constants"; @@ -18,8 +23,8 @@ import { Recorder } from "@azure-tools/test-recorder"; import { pollForJobAssignment, pollForJobOffer } from "../utils/polling"; describe("RouterClient", function () { - let client: RouterClient; - let administrationClient: RouterAdministrationClient; + let client: JobRouterClient; + let administrationClient: JobRouterAdministrationClient; let recorder: Recorder; const testRunId = "recorded-assignment-scenario"; diff --git a/sdk/communication/communication-job-router/test/public/scenarios/cancellationScenario.spec.ts b/sdk/communication/communication-job-router/test/public/scenarios/cancellationScenario.spec.ts index d611397f3ce9..28d6cce5afdd 100644 --- a/sdk/communication/communication-job-router/test/public/scenarios/cancellationScenario.spec.ts +++ b/sdk/communication/communication-job-router/test/public/scenarios/cancellationScenario.spec.ts @@ -11,14 +11,14 @@ import { import { assert } from "chai"; import { Context } from "mocha"; import { Recorder } from "@azure-tools/test-recorder"; -import { RouterAdministrationClient, RouterClient } from "../../../src"; +import { JobRouterAdministrationClient, JobRouterClient } from "../../../src"; import { createRecordedRouterClientWithConnectionString } from "../../internal/utils/mockClient"; import { pollForJobCancelled, pollForJobQueued } from "../utils/polling"; import { timeoutMs } from "../utils/constants"; describe("RouterClient", function () { - let client: RouterClient; - let administrationClient: RouterAdministrationClient; + let client: JobRouterClient; + let administrationClient: JobRouterAdministrationClient; let recorder: Recorder; const testRunId = "recorded-cancellation-scenario"; diff --git a/sdk/communication/communication-job-router/test/public/scenarios/queueingScenario.spec.ts b/sdk/communication/communication-job-router/test/public/scenarios/queueingScenario.spec.ts index 1e2093fddc7f..36e5e37ce415 100644 --- a/sdk/communication/communication-job-router/test/public/scenarios/queueingScenario.spec.ts +++ b/sdk/communication/communication-job-router/test/public/scenarios/queueingScenario.spec.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import { assert } from "chai"; -import { RouterAdministrationClient, RouterClient } from "../../../src"; +import { JobRouterAdministrationClient, JobRouterClient } from "../../../src"; import { Context } from "mocha"; import { getClassificationPolicyCombined, @@ -26,8 +26,8 @@ import { Recorder } from "@azure-tools/test-recorder"; import { pollForJobQueued, retry } from "../utils/polling"; describe("RouterClient", function () { - let client: RouterClient; - let administrationClient: RouterAdministrationClient; + let client: JobRouterClient; + let administrationClient: JobRouterAdministrationClient; let recorder: Recorder; const testRunId = "recorded-q-scenario"; diff --git a/sdk/communication/communication-job-router/test/public/utils/polling.ts b/sdk/communication/communication-job-router/test/public/utils/polling.ts index 68beb095a56f..6a887a8765cf 100644 --- a/sdk/communication/communication-job-router/test/public/utils/polling.ts +++ b/sdk/communication/communication-job-router/test/public/utils/polling.ts @@ -2,9 +2,12 @@ // Licensed under the MIT license. import { JobAssignment, JobOffer, RouterJob, RouterWorker } from "../../../src/generated/src"; -import { RouterClient } from "../../../src/routerClient"; +import { JobRouterClient } from "../../../src/jobRouterClient"; -export async function pollForJobOffer(workerId: string, client: RouterClient): Promise { +export async function pollForJobOffer( + workerId: string, + client: JobRouterClient +): Promise { let worker: RouterWorker = {}; while (worker.offers?.length === undefined || worker.offers.length < 1) { worker = await client.getWorker(workerId); @@ -15,7 +18,7 @@ export async function pollForJobOffer(workerId: string, client: RouterClient): P export async function pollForJobAssignment( jobId: string, - client: RouterClient + client: JobRouterClient ): Promise { let job: RouterJob = {}; while (job.assignments === undefined || Object.keys(job.assignments).length < 1) { @@ -25,7 +28,7 @@ export async function pollForJobAssignment( return Object.values(job.assignments)[0]; } -export async function pollForJobQueued(jobId: string, client: RouterClient): Promise { +export async function pollForJobQueued(jobId: string, client: JobRouterClient): Promise { let job: RouterJob = {}; while (job.jobStatus !== "queued") { job = await client.getJob(jobId); @@ -34,7 +37,10 @@ export async function pollForJobQueued(jobId: string, client: RouterClient): Pro return job; } -export async function pollForJobCancelled(jobId: string, client: RouterClient): Promise { +export async function pollForJobCancelled( + jobId: string, + client: JobRouterClient +): Promise { let job: RouterJob = {}; while (job.jobStatus !== "cancelled") { job = await client.getJob(jobId);