diff --git a/sdk/communication/communication-job-router/api-extractor.json b/sdk/communication/communication-job-router/api-extractor.json index bb2541acad88..b16b0d108a9d 100644 --- a/sdk/communication/communication-job-router/api-extractor.json +++ b/sdk/communication/communication-job-router/api-extractor.json @@ -28,4 +28,4 @@ } } } -} +} \ No newline at end of file diff --git a/sdk/communication/communication-job-router/package.json b/sdk/communication/communication-job-router/package.json index 71a75a55290b..0890a2ab5780 100644 --- a/sdk/communication/communication-job-router/package.json +++ b/sdk/communication/communication-job-router/package.json @@ -128,4 +128,4 @@ "ts-node": "^10.0.0", "esm": "^3.2.18" } -} +} \ No newline at end of file diff --git a/sdk/communication/communication-job-router/src/azureCommunicationRoutingServiceClient.ts b/sdk/communication/communication-job-router/src/azureCommunicationRoutingServiceClient.ts new file mode 100644 index 000000000000..b81741f25401 --- /dev/null +++ b/sdk/communication/communication-job-router/src/azureCommunicationRoutingServiceClient.ts @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { getClient, ClientOptions } from "@azure-rest/core-client"; +import { logger } from "./logger"; +import { AzureCommunicationRoutingServiceClient } from "./clientDefinitions"; + +/** + * Initialize a new instance of `AzureCommunicationRoutingServiceClient` + * @param endpoint - A sequence of textual characters. + * @param options - the parameter for all optional parameters + */ +export default function createClient( + endpoint: string, + options: ClientOptions = {} +): AzureCommunicationRoutingServiceClient { + const baseUrl = options.baseUrl ?? `${endpoint}`; + options.apiVersion = options.apiVersion ?? "2023-11-01"; + const userAgentInfo = `azsdk-js-communication-job-router-rest/1.0.0-beta.1`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}` + : `${userAgentInfo}`; + options = { + ...options, + userAgentOptions: { + userAgentPrefix, + }, + loggingOptions: { + logger: options.loggingOptions?.logger ?? logger.info, + }, + }; + + const client = getClient( + baseUrl, + options + ) as AzureCommunicationRoutingServiceClient; + + return client; +} diff --git a/sdk/communication/communication-job-router/src/clientDefinitions.ts b/sdk/communication/communication-job-router/src/clientDefinitions.ts new file mode 100644 index 000000000000..82249d5298bb --- /dev/null +++ b/sdk/communication/communication-job-router/src/clientDefinitions.ts @@ -0,0 +1,435 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { + UpsertClassificationPolicyParameters, + GetClassificationPolicyParameters, + DeleteClassificationPolicyParameters, + ListClassificationPoliciesParameters, + UpsertDistributionPolicyParameters, + GetDistributionPolicyParameters, + DeleteDistributionPolicyParameters, + ListDistributionPoliciesParameters, + UpsertExceptionPolicyParameters, + GetExceptionPolicyParameters, + DeleteExceptionPolicyParameters, + ListExceptionPoliciesParameters, + UpsertQueueParameters, + GetQueueParameters, + DeleteQueueParameters, + ListQueuesParameters, + UpsertJobParameters, + GetJobParameters, + DeleteJobParameters, + ReclassifyParameters, + CancelParameters, + CompleteParameters, + CloseParameters, + ListJobsParameters, + GetInQueuePositionParameters, + UnassignParameters, + AcceptParameters, + DeclineParameters, + GetQueueStatisticsParameters, + UpsertWorkerParameters, + GetWorkerParameters, + DeleteWorkerParameters, + ListWorkersParameters, +} from "./parameters"; +import { + UpsertClassificationPolicy200Response, + UpsertClassificationPolicy201Response, + UpsertClassificationPolicyDefaultResponse, + GetClassificationPolicy200Response, + GetClassificationPolicyDefaultResponse, + DeleteClassificationPolicy204Response, + DeleteClassificationPolicyDefaultResponse, + ListClassificationPolicies200Response, + ListClassificationPoliciesDefaultResponse, + UpsertDistributionPolicy200Response, + UpsertDistributionPolicy201Response, + UpsertDistributionPolicyDefaultResponse, + GetDistributionPolicy200Response, + GetDistributionPolicyDefaultResponse, + DeleteDistributionPolicy204Response, + DeleteDistributionPolicyDefaultResponse, + ListDistributionPolicies200Response, + ListDistributionPoliciesDefaultResponse, + UpsertExceptionPolicy200Response, + UpsertExceptionPolicy201Response, + UpsertExceptionPolicyDefaultResponse, + GetExceptionPolicy200Response, + GetExceptionPolicyDefaultResponse, + DeleteExceptionPolicy204Response, + DeleteExceptionPolicyDefaultResponse, + ListExceptionPolicies200Response, + ListExceptionPoliciesDefaultResponse, + UpsertQueue200Response, + UpsertQueue201Response, + UpsertQueueDefaultResponse, + GetQueue200Response, + GetQueueDefaultResponse, + DeleteQueue204Response, + DeleteQueueDefaultResponse, + ListQueues200Response, + ListQueuesDefaultResponse, + UpsertJob200Response, + UpsertJob201Response, + UpsertJobDefaultResponse, + GetJob200Response, + GetJobDefaultResponse, + DeleteJob204Response, + DeleteJobDefaultResponse, + Reclassify200Response, + ReclassifyDefaultResponse, + Cancel200Response, + CancelDefaultResponse, + Complete200Response, + CompleteDefaultResponse, + Close200Response, + CloseDefaultResponse, + ListJobs200Response, + ListJobsDefaultResponse, + GetInQueuePosition200Response, + GetInQueuePositionDefaultResponse, + Unassign200Response, + UnassignDefaultResponse, + Accept200Response, + AcceptDefaultResponse, + Decline200Response, + DeclineDefaultResponse, + GetQueueStatistics200Response, + GetQueueStatisticsDefaultResponse, + UpsertWorker200Response, + UpsertWorker201Response, + UpsertWorkerDefaultResponse, + GetWorker200Response, + GetWorkerDefaultResponse, + DeleteWorker204Response, + DeleteWorkerDefaultResponse, + ListWorkers200Response, + ListWorkersDefaultResponse, +} from "./responses"; +import { Client, StreamableMethod } from "@azure-rest/core-client"; + +export interface UpsertClassificationPolicy { + /** Creates or updates a classification policy. */ + patch( + options: UpsertClassificationPolicyParameters + ): StreamableMethod< + | UpsertClassificationPolicy200Response + | UpsertClassificationPolicy201Response + | UpsertClassificationPolicyDefaultResponse + >; + /** Retrieves an existing classification policy by Id. */ + get( + options?: GetClassificationPolicyParameters + ): StreamableMethod< + GetClassificationPolicy200Response | GetClassificationPolicyDefaultResponse + >; + /** Delete a classification policy by Id. */ + delete( + options?: DeleteClassificationPolicyParameters + ): StreamableMethod< + | DeleteClassificationPolicy204Response + | DeleteClassificationPolicyDefaultResponse + >; +} + +export interface ListClassificationPolicies { + /** Retrieves existing classification policies. */ + get( + options?: ListClassificationPoliciesParameters + ): StreamableMethod< + | ListClassificationPolicies200Response + | ListClassificationPoliciesDefaultResponse + >; +} + +export interface UpsertDistributionPolicy { + /** Creates or updates a distribution policy. */ + patch( + options: UpsertDistributionPolicyParameters + ): StreamableMethod< + | UpsertDistributionPolicy200Response + | UpsertDistributionPolicy201Response + | UpsertDistributionPolicyDefaultResponse + >; + /** Retrieves an existing distribution policy by Id. */ + get( + options?: GetDistributionPolicyParameters + ): StreamableMethod< + GetDistributionPolicy200Response | GetDistributionPolicyDefaultResponse + >; + /** Delete a distribution policy by Id. */ + delete( + options?: DeleteDistributionPolicyParameters + ): StreamableMethod< + | DeleteDistributionPolicy204Response + | DeleteDistributionPolicyDefaultResponse + >; +} + +export interface ListDistributionPolicies { + /** Retrieves existing distribution policies. */ + get( + options?: ListDistributionPoliciesParameters + ): StreamableMethod< + | ListDistributionPolicies200Response + | ListDistributionPoliciesDefaultResponse + >; +} + +export interface UpsertExceptionPolicy { + /** Creates or updates a exception policy. */ + patch( + options: UpsertExceptionPolicyParameters + ): StreamableMethod< + | UpsertExceptionPolicy200Response + | UpsertExceptionPolicy201Response + | UpsertExceptionPolicyDefaultResponse + >; + /** Retrieves an existing exception policy by Id. */ + get( + options?: GetExceptionPolicyParameters + ): StreamableMethod< + GetExceptionPolicy200Response | GetExceptionPolicyDefaultResponse + >; + /** Deletes a exception policy by Id. */ + delete( + options?: DeleteExceptionPolicyParameters + ): StreamableMethod< + DeleteExceptionPolicy204Response | DeleteExceptionPolicyDefaultResponse + >; +} + +export interface ListExceptionPolicies { + /** Retrieves existing exception policies. */ + get( + options?: ListExceptionPoliciesParameters + ): StreamableMethod< + ListExceptionPolicies200Response | ListExceptionPoliciesDefaultResponse + >; +} + +export interface UpsertQueue { + /** Creates or updates a queue. */ + patch( + options: UpsertQueueParameters + ): StreamableMethod< + UpsertQueue200Response | UpsertQueue201Response | UpsertQueueDefaultResponse + >; + /** Retrieves an existing queue by Id. */ + get( + options?: GetQueueParameters + ): StreamableMethod; + /** Deletes a queue by Id. */ + delete( + options?: DeleteQueueParameters + ): StreamableMethod; +} + +export interface ListQueues { + /** Retrieves existing queues. */ + get( + options?: ListQueuesParameters + ): StreamableMethod; +} + +export interface UpsertJob { + /** Creates or updates a router job. */ + patch( + options: UpsertJobParameters + ): StreamableMethod< + UpsertJob200Response | UpsertJob201Response | UpsertJobDefaultResponse + >; + /** Retrieves an existing job by Id. */ + get( + options?: GetJobParameters + ): StreamableMethod; + /** Deletes a job and all of its traces. */ + delete( + options?: DeleteJobParameters + ): StreamableMethod; +} + +export interface Reclassify { + /** Reclassify a job. */ + post( + options?: ReclassifyParameters + ): StreamableMethod; +} + +export interface Cancel { + /** Submits request to cancel an existing job by Id while supplying free-form cancellation reason. */ + post( + options?: CancelParameters + ): StreamableMethod; +} + +export interface Complete { + /** Completes an assigned job. */ + post( + options?: CompleteParameters + ): StreamableMethod; +} + +export interface Close { + /** Closes a completed job. */ + post( + options?: CloseParameters + ): StreamableMethod; +} + +export interface ListJobs { + /** Retrieves list of jobs based on filter parameters. */ + get( + options?: ListJobsParameters + ): StreamableMethod; +} + +export interface GetInQueuePosition { + /** Gets a job's position details. */ + get( + options?: GetInQueuePositionParameters + ): StreamableMethod< + GetInQueuePosition200Response | GetInQueuePositionDefaultResponse + >; +} + +export interface Unassign { + /** Un-assign a job. */ + post( + options?: UnassignParameters + ): StreamableMethod; +} + +export interface Accept { + /** Accepts an offer to work on a job and returns a 409/Conflict if another agent accepted the job already. */ + post( + options?: AcceptParameters + ): StreamableMethod; +} + +export interface Decline { + /** Declines an offer to work on a job. */ + post( + options?: DeclineParameters + ): StreamableMethod; +} + +export interface GetQueueStatistics { + /** Retrieves a queue's statistics. */ + get( + options?: GetQueueStatisticsParameters + ): StreamableMethod< + GetQueueStatistics200Response | GetQueueStatisticsDefaultResponse + >; +} + +export interface UpsertWorker { + /** Creates or updates a worker. */ + patch( + options: UpsertWorkerParameters + ): StreamableMethod< + | UpsertWorker200Response + | UpsertWorker201Response + | UpsertWorkerDefaultResponse + >; + /** Retrieves an existing worker by Id. */ + get( + options?: GetWorkerParameters + ): StreamableMethod; + /** Deletes a worker and all of its traces. */ + delete( + options?: DeleteWorkerParameters + ): StreamableMethod; +} + +export interface ListWorkers { + /** Retrieves existing workers. */ + get( + options?: ListWorkersParameters + ): StreamableMethod; +} + +export interface Routes { + /** Resource for '/routing/classificationPolicies/\{classificationPolicyId\}' has methods for the following verbs: patch, get, delete */ + ( + path: "/routing/classificationPolicies/{classificationPolicyId}", + classificationPolicyId: string + ): UpsertClassificationPolicy; + /** Resource for '/routing/classificationPolicies' has methods for the following verbs: get */ + (path: "/routing/classificationPolicies"): ListClassificationPolicies; + /** Resource for '/routing/distributionPolicies/\{distributionPolicyId\}' has methods for the following verbs: patch, get, delete */ + ( + path: "/routing/distributionPolicies/{distributionPolicyId}", + distributionPolicyId: string + ): UpsertDistributionPolicy; + /** Resource for '/routing/distributionPolicies' has methods for the following verbs: get */ + (path: "/routing/distributionPolicies"): ListDistributionPolicies; + /** Resource for '/routing/exceptionPolicies/\{exceptionPolicyId\}' has methods for the following verbs: patch, get, delete */ + ( + path: "/routing/exceptionPolicies/{exceptionPolicyId}", + exceptionPolicyId: string + ): UpsertExceptionPolicy; + /** Resource for '/routing/exceptionPolicies' has methods for the following verbs: get */ + (path: "/routing/exceptionPolicies"): ListExceptionPolicies; + /** Resource for '/routing/queues/\{queueId\}' has methods for the following verbs: patch, get, delete */ + (path: "/routing/queues/{queueId}", queueId: string): UpsertQueue; + /** Resource for '/routing/queues' has methods for the following verbs: get */ + (path: "/routing/queues"): ListQueues; + /** Resource for '/routing/jobs/\{jobId\}' has methods for the following verbs: patch, get, delete */ + (path: "/routing/jobs/{jobId}", jobId: string): UpsertJob; + /** Resource for '/routing/jobs/\{jobId\}:reclassify' has methods for the following verbs: post */ + (path: "/routing/jobs/{jobId}:reclassify", jobId: string): Reclassify; + /** Resource for '/routing/jobs/\{jobId\}:cancel' has methods for the following verbs: post */ + (path: "/routing/jobs/{jobId}:cancel", jobId: string): Cancel; + /** Resource for '/routing/jobs/\{jobId\}/assignments/\{assignmentId\}:complete' has methods for the following verbs: post */ + ( + path: "/routing/jobs/{jobId}/assignments/{assignmentId}:complete", + jobId: string, + assignmentId: string + ): Complete; + /** Resource for '/routing/jobs/\{jobId\}/assignments/\{assignmentId\}:close' has methods for the following verbs: post */ + ( + path: "/routing/jobs/{jobId}/assignments/{assignmentId}:close", + jobId: string, + assignmentId: string + ): Close; + /** Resource for '/routing/jobs' has methods for the following verbs: get */ + (path: "/routing/jobs"): ListJobs; + /** Resource for '/routing/jobs/\{jobId\}/position' has methods for the following verbs: get */ + (path: "/routing/jobs/{jobId}/position", jobId: string): GetInQueuePosition; + /** Resource for '/routing/jobs/\{jobId\}/assignments/\{assignmentId\}:unassign' has methods for the following verbs: post */ + ( + path: "/routing/jobs/{jobId}/assignments/{assignmentId}:unassign", + jobId: string, + assignmentId: string + ): Unassign; + /** Resource for '/routing/workers/\{workerId\}/offers/\{offerId\}:accept' has methods for the following verbs: post */ + ( + path: "/routing/workers/{workerId}/offers/{offerId}:accept", + workerId: string, + offerId: string + ): Accept; + /** Resource for '/routing/workers/\{workerId\}/offers/\{offerId\}:decline' has methods for the following verbs: post */ + ( + path: "/routing/workers/{workerId}/offers/{offerId}:decline", + workerId: string, + offerId: string + ): Decline; + /** Resource for '/routing/queues/\{queueId\}/statistics' has methods for the following verbs: get */ + ( + path: "/routing/queues/{queueId}/statistics", + queueId: string + ): GetQueueStatistics; + /** Resource for '/routing/workers/\{workerId\}' has methods for the following verbs: patch, get, delete */ + (path: "/routing/workers/{workerId}", workerId: string): UpsertWorker; + /** Resource for '/routing/workers' has methods for the following verbs: get */ + (path: "/routing/workers"): ListWorkers; +} + +export type AzureCommunicationRoutingServiceClient = Client & { + path: Routes; +}; diff --git a/sdk/communication/communication-job-router/src/clientUtils.ts b/sdk/communication/communication-job-router/src/clientUtils.ts deleted file mode 100644 index ee222135d0ec..000000000000 --- a/sdk/communication/communication-job-router/src/clientUtils.ts +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -/// - -import { PageSettings, PagedAsyncIterableIterator } from "@azure/core-paging"; - -export type Transformer = (input: TFrom) => TTo; -export class TransformingPagedAsyncIterableIterator< - TElement, - TTransformed, - TPage = TElement[], - TTransformedPage = TTransformed[], - TPageSettings = PageSettings -> { - constructor( - private internalIterator: PagedAsyncIterableIterator, - private transform: Transformer - ) {} - - async next(): Promise> { - const internalResult = await this.internalIterator.next(); - - const generatedItem = internalResult?.value as TElement | undefined; - const transformedItem = - generatedItem === undefined ? ({} as TTransformed) : this.transform(generatedItem); - - return Promise.resolve({ value: transformedItem, done: internalResult.done }); - } - - [Symbol.asyncIterator](): TransformingPagedAsyncIterableIterator< - TElement, - TTransformed, - TPage, - TTransformedPage, - TPageSettings - > { - return this; - } - - async *byPage(settings?: TPageSettings): AsyncIterableIterator { - const internalResult = await this.internalIterator.byPage(settings); - - for await (const generatedPage of internalResult) { - const transformedPage = [] as TTransformedPage; - - (generatedPage as Array).forEach((generatedItem) => { - const transformedItem = - generatedItem === undefined ? ({} as TTransformed) : this.transform(generatedItem); - (transformedPage as Array).push(transformedItem); - }); - - yield transformedPage; - } - } -} diff --git a/sdk/communication/communication-job-router/src/constants.ts b/sdk/communication/communication-job-router/src/constants.ts deleted file mode 100644 index 0d6f50644cc2..000000000000 --- a/sdk/communication/communication-job-router/src/constants.ts +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -export const SDK_VERSION: string = "V2022-07-18-preview"; diff --git a/sdk/communication/communication-job-router/src/generated/src/index.ts b/sdk/communication/communication-job-router/src/generated/src/index.ts deleted file mode 100644 index 66969a8e7221..000000000000 --- a/sdk/communication/communication-job-router/src/generated/src/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -/// -export { getContinuationToken } from "./pagingHelper"; -export * from "./models"; -export { JobRouterApiClient } from "./jobRouterApiClient"; -export * from "./operationsInterfaces"; diff --git a/sdk/communication/communication-job-router/src/generated/src/jobRouterApiClient.ts b/sdk/communication/communication-job-router/src/generated/src/jobRouterApiClient.ts deleted file mode 100644 index 22474037868e..000000000000 --- a/sdk/communication/communication-job-router/src/generated/src/jobRouterApiClient.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import * as coreClient from "@azure/core-client"; -import { - PipelineRequest, - PipelineResponse, - SendRequest -} from "@azure/core-rest-pipeline"; -import { JobRouterAdministrationImpl, JobRouterImpl } from "./operations"; -import { JobRouterAdministration, JobRouter } from "./operationsInterfaces"; -import { JobRouterApiClientOptionalParams } from "./models"; - -export class JobRouterApiClient extends coreClient.ServiceClient { - endpoint: string; - apiVersion: string; - - /** - * Initializes a new instance of the JobRouterApiClient class. - * @param endpoint The endpoint of the Azure Communication resource. - * @param options The parameter options - */ - constructor(endpoint: string, options?: JobRouterApiClientOptionalParams) { - if (endpoint === undefined) { - throw new Error("'endpoint' cannot be null"); - } - - // Initializing default values for options - if (!options) { - options = {}; - } - const defaults: JobRouterApiClientOptionalParams = { - requestContentType: "application/json; charset=utf-8" - }; - - const packageDetails = `azsdk-js-communication-job-router/1.0.0-beta.1`; - const userAgentPrefix = - options.userAgentOptions && options.userAgentOptions.userAgentPrefix - ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` - : `${packageDetails}`; - - const optionsWithDefaults = { - ...defaults, - ...options, - userAgentOptions: { - userAgentPrefix - }, - endpoint: options.endpoint ?? options.baseUri ?? "{endpoint}" - }; - super(optionsWithDefaults); - // Parameter assignments - this.endpoint = endpoint; - - // Assigning values to Constant parameters - this.apiVersion = options.apiVersion || "2022-07-18-preview"; - this.jobRouterAdministration = new JobRouterAdministrationImpl(this); - this.jobRouter = new JobRouterImpl(this); - this.addCustomApiVersionPolicy(options.apiVersion); - } - - /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ - private addCustomApiVersionPolicy(apiVersion?: string) { - if (!apiVersion) { - return; - } - const apiVersionPolicy = { - name: "CustomApiVersionPolicy", - async sendRequest( - request: PipelineRequest, - next: SendRequest - ): Promise { - const param = request.url.split("?"); - if (param.length > 1) { - const newParams = param[1].split("&").map((item) => { - if (item.indexOf("api-version") > -1) { - return "api-version=" + apiVersion; - } else { - return item; - } - }); - request.url = param[0] + "?" + newParams.join("&"); - } - return next(request); - } - }; - this.pipeline.addPolicy(apiVersionPolicy); - } - - jobRouterAdministration: JobRouterAdministration; - jobRouter: JobRouter; -} diff --git a/sdk/communication/communication-job-router/src/generated/src/models/index.ts b/sdk/communication/communication-job-router/src/generated/src/models/index.ts deleted file mode 100644 index 0432a5bc3391..000000000000 --- a/sdk/communication/communication-job-router/src/generated/src/models/index.ts +++ /dev/null @@ -1,1523 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import * as coreClient from "@azure/core-client"; - -export type QueueSelectorAttachmentUnion = - | QueueSelectorAttachment - | ConditionalQueueSelectorAttachment - | PassThroughQueueSelectorAttachment - | RuleEngineQueueSelectorAttachment - | StaticQueueSelectorAttachment - | WeightedAllocationQueueSelectorAttachment; -export type RouterRuleUnion = - | RouterRule - | DirectMapRouterRule - | ExpressionRouterRule - | FunctionRouterRule - | StaticRouterRule - | WebhookRouterRule; -export type WorkerSelectorAttachmentUnion = - | WorkerSelectorAttachment - | ConditionalWorkerSelectorAttachment - | PassThroughWorkerSelectorAttachment - | RuleEngineWorkerSelectorAttachment - | StaticWorkerSelectorAttachment - | WeightedAllocationWorkerSelectorAttachment; -export type DistributionModeUnion = - | DistributionMode - | BestWorkerMode - | LongestIdleMode - | RoundRobinMode; -export type ExceptionTriggerUnion = - | ExceptionTrigger - | QueueLengthExceptionTrigger - | WaitTimeExceptionTrigger; -export type ExceptionActionUnion = - | ExceptionAction - | CancelExceptionAction - | ManualReclassifyExceptionAction - | ReclassifyExceptionAction; - -/** A container for the rules that govern how jobs are classified. */ -export interface ClassificationPolicy { - /** - * Unique identifier of this policy. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly id?: string; - /** Friendly name of this policy. */ - name?: string; - /** The fallback queue to select if the queue selector doesn't find a match. */ - fallbackQueueId?: string; - /** The queue selectors to resolve a queue for a given job. */ - queueSelectors?: QueueSelectorAttachmentUnion[]; - /** - * A rule of one of the following types: - * - * StaticRule: A rule providing static rules that always return the same result, regardless of input. - * DirectMapRule: A rule that return the same labels as the input labels. - * ExpressionRule: A rule providing inline expression rules. - * AzureFunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. - * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. - */ - prioritizationRule?: RouterRuleUnion; - /** The worker label selectors to attach to a given job. */ - workerSelectors?: WorkerSelectorAttachmentUnion[]; -} - -/** An attachment of queue selectors to resolve a queue to a job from a classification policy */ -export interface QueueSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: - | "conditional" - | "pass-through" - | "rule-engine" - | "static" - | "weighted-allocation-queue-selector"; -} - -/** - * A rule of one of the following types: - * - * StaticRule: A rule providing static rules that always return the same result, regardless of input. - * DirectMapRule: A rule that return the same labels as the input labels. - * ExpressionRule: A rule providing inline expression rules. - * AzureFunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. - * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. - */ -export interface RouterRule { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: - | "direct-map-rule" - | "expression-rule" - | "azure-function-rule" - | "static-rule" - | "webhook-rule"; -} - -/** An attachment which attaches worker selectors to a job */ -export interface WorkerSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: - | "conditional" - | "pass-through" - | "rule-engine" - | "static" - | "weighted-allocation-worker-selector"; -} - -/** The Communication Services error. */ -export interface CommunicationErrorResponse { - /** The Communication Services error. */ - error: CommunicationError; -} - -/** The Communication Services error. */ -export interface CommunicationError { - /** The error code. */ - code: string; - /** The error message. */ - message: string; - /** - * The error target. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly target?: string; - /** - * Further details about specific errors that led to this error. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly details?: CommunicationError[]; - /** - * The inner error if any. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly innerError?: CommunicationError; -} - -/** A paged collection of classification policies. */ -export interface ClassificationPolicyCollection { - value: ClassificationPolicyItem[]; - /** NOTE: This property will not be serialized. It can only be populated by the server. */ - readonly nextLink?: string; -} - -/** Paged instance of ClassificationPolicy */ -export interface ClassificationPolicyItem { - /** A container for the rules that govern how jobs are classified. */ - classificationPolicy?: ClassificationPolicy; - /** (Optional) The Concurrency Token. */ - etag?: string; -} - -/** Policy governing how jobs are distributed to workers */ -export interface DistributionPolicy { - /** - * The unique identifier of the policy. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly id?: string; - /** The human readable name of the policy. */ - name?: string; - /** The number of seconds after which any offers created under this policy will be expired. */ - offerExpiresAfterSeconds?: number; - /** Abstract base class for defining a distribution mode */ - mode?: DistributionModeUnion; -} - -/** Abstract base class for defining a distribution mode */ -export interface DistributionMode { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "best-worker" | "longest-idle" | "round-robin"; - /** Governs the minimum desired number of active concurrent offers a job can have. */ - minConcurrentOffers?: number; - /** Governs the maximum number of active concurrent offers a job can have. */ - maxConcurrentOffers?: number; - /** - * (Optional) - * If set to true, then router will match workers to jobs even if they don't match label selectors. - * Warning: You may get workers that are not qualified for the job they are matched with if you set this - * variable to true. This flag is intended more for temporary usage. - * By default, set to false. - */ - bypassSelectors?: boolean; -} - -/** A paged collection of distribution policies. */ -export interface DistributionPolicyCollection { - value: DistributionPolicyItem[]; - /** NOTE: This property will not be serialized. It can only be populated by the server. */ - readonly nextLink?: string; -} - -/** Paged instance of DistributionPolicy */ -export interface DistributionPolicyItem { - /** Policy governing how jobs are distributed to workers */ - distributionPolicy?: DistributionPolicy; - /** (Optional) The Concurrency Token. */ - etag?: string; -} - -/** A policy that defines actions to execute when exception are triggered. */ -export interface ExceptionPolicy { - /** - * The Id of the exception policy - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly id?: string; - /** (Optional) The name of the exception policy. */ - name?: string; - /** (Optional) A dictionary collection of exception rules on the exception policy. Key is the Id of each exception rule. */ - exceptionRules?: { [propertyName: string]: ExceptionRule }; -} - -/** A rule that defines actions to execute upon a specific trigger. */ -export interface ExceptionRule { - /** The trigger for this exception rule */ - trigger: ExceptionTriggerUnion; - /** A dictionary collection of actions to perform once the exception is triggered. Key is the Id of each exception action. */ - actions: { [propertyName: string]: ExceptionActionUnion }; -} - -/** The trigger for this exception rule */ -export interface ExceptionTrigger { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "queue-length" | "wait-time"; -} - -/** The action to take when the exception is triggered */ -export interface ExceptionAction { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "cancel" | "manual-reclassify" | "reclassify"; -} - -/** A paged collection of exception policies. */ -export interface ExceptionPolicyCollection { - value: ExceptionPolicyItem[]; - /** NOTE: This property will not be serialized. It can only be populated by the server. */ - readonly nextLink?: string; -} - -/** Paged instance of ExceptionPolicy */ -export interface ExceptionPolicyItem { - /** A policy that defines actions to execute when exception are triggered. */ - exceptionPolicy?: ExceptionPolicy; - /** (Optional) The Concurrency Token. */ - etag?: string; -} - -/** A unit of work to be routed */ -export interface RouterJob { - /** - * The id of the job. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly id?: string; - /** Reference to an external parent context, eg. call ID. */ - channelReference?: string; - /** - * The status of the Job. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly status?: RouterJobStatus; - /** - * The time a job was queued in UTC. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly enqueuedAt?: Date; - /** The channel identifier. eg. voice, chat, etc. */ - channelId?: string; - /** The Id of the Classification policy used for classifying a job. */ - classificationPolicyId?: string; - /** The Id of the Queue that this job is queued to. */ - queueId?: string; - /** The priority of this job. */ - priority?: number; - /** Reason code for cancelled or closed jobs. */ - dispositionCode?: string; - /** A collection of manually specified label selectors, which a worker must satisfy in order to process this job. */ - requestedWorkerSelectors?: RouterWorkerSelector[]; - /** - * A collection of label selectors attached by a classification policy, which a worker must satisfy in order to process this job. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly attachedWorkerSelectors?: RouterWorkerSelector[]; - /** A set of key/value pairs that are identifying attributes used by the rules engines to make decisions. */ - labels?: { [propertyName: string]: any }; - /** - * A collection of the assignments of the job. - * Key is AssignmentId. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly assignments?: { [propertyName: string]: RouterJobAssignment }; - /** A set of non-identifying attributes attached to this job */ - tags?: { [propertyName: string]: any }; - /** Notes attached to a job, sorted by timestamp */ - notes?: { [propertyName: string]: string }; - /** - * If set, job will be scheduled to be enqueued at a given time - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly scheduledAt?: Date; - matchingMode?: JobMatchingMode; -} - -/** Describes a condition that must be met against a set of labels for worker selection */ -export interface RouterWorkerSelector { - /** The label key to query against */ - key: string; - /** Describes how the value of the label is compared to the value defined on the label selector */ - labelOperator: LabelOperator; - /** The value to compare against the actual label value with the given operator */ - value?: any; - /** Describes how long this label selector is valid in seconds. */ - expiresAfterSeconds?: number; - /** Pushes the job to the front of the queue as long as this selector is active. */ - expedite?: boolean; - /** - * The status of the worker selector. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly status?: RouterWorkerSelectorStatus; - /** - * The time at which this worker selector expires in UTC - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly expiresAt?: Date; -} - -/** Assignment details of a job to a worker */ -export interface RouterJobAssignment { - /** The Id of the job assignment. */ - assignmentId: string; - /** The Id of the Worker assigned to the job. */ - workerId?: string; - /** The assignment time of the job in UTC. */ - assignedAt: Date; - /** The time the job was marked as completed after being assigned in UTC. */ - completedAt?: Date; - /** The time the job was marked as closed after being completed in UTC. */ - closedAt?: Date; -} - -export interface JobMatchingMode { - modeType?: JobMatchModeType; - /** Anything */ - queueAndMatchMode?: any; - scheduleAndSuspendMode?: ScheduleAndSuspendMode; - /** Anything */ - suspendMode?: any; -} - -export interface ScheduleAndSuspendMode { - scheduleAt?: Date; -} - -/** Request payload for deleting a job */ -export interface CancelJobRequest { - /** (Optional) A note that will be appended to the jobs' Notes collection with the current timestamp. */ - note?: string; - /** - * Indicates the outcome of the job, populate this field with your own custom values. - * If not provided, default value of "Cancelled" is set. - */ - dispositionCode?: string; -} - -/** Request payload for completing jobs */ -export interface CompleteJobRequest { - /** The assignment within the job to complete. */ - assignmentId: string; - /** (Optional) A note that will be appended to the jobs' Notes collection with the current timestamp. */ - note?: string; -} - -/** Request payload for closing jobs */ -export interface CloseJobRequest { - /** The assignment within which the job is to be closed. */ - assignmentId: string; - /** Indicates the outcome of the job, populate this field with your own custom values. */ - dispositionCode?: string; - /** - * If not provided, worker capacity is released immediately along with a JobClosedEvent notification. - * If provided, worker capacity is released along with a JobClosedEvent notification at a future time in UTC. - */ - closeAt?: Date; - /** (Optional) A note that will be appended to the jobs' Notes collection with the current timestamp. */ - note?: string; -} - -/** A paged collection of jobs. */ -export interface RouterJobCollection { - value: RouterJobItem[]; - /** NOTE: This property will not be serialized. It can only be populated by the server. */ - readonly nextLink?: string; -} - -/** Paged instance of RouterJob */ -export interface RouterJobItem { - /** A unit of work to be routed */ - job?: RouterJob; - /** (Optional) The Concurrency Token. */ - etag?: string; -} - -/** Position and estimated wait time for a job. */ -export interface RouterJobPositionDetails { - /** Id of the job these details are about. */ - jobId: string; - /** Position of the job in question within that queue. */ - position: number; - /** Id of the queue this job is enqueued in. */ - queueId: string; - /** Length of the queue: total number of enqueued jobs. */ - queueLength: number; - /** Estimated wait time of the job rounded up to the nearest minute */ - estimatedWaitTimeMinutes: number; -} - -/** Request payload for unassigning a job. */ -export interface UnassignJobRequest { - /** If WaitForActivation is true, then the job is not queued for re-matching with a worker. */ - suspendMatching?: boolean; -} - -/** Response payload after a job has been successfully unassigned. */ -export interface UnassignJobResult { - /** The Id of the job unassigned. */ - jobId: string; - /** The number of times a job is unassigned. At a maximum 3. */ - unassignmentCount: number; -} - -/** Response containing Id's for the worker, job, and assignment from an accepted offer */ -export interface AcceptJobOfferResult { - /** The assignment Id that assigns a worker that has accepted an offer to a job. */ - assignmentId: string; - /** The Id of the job assigned. */ - jobId: string; - /** The Id of the worker that has been assigned this job. */ - workerId: string; -} - -/** Request payload for declining offers */ -export interface DeclineJobOfferRequest { - /** - * If the RetryOfferAt is not provided, then this job will not be offered again to the worker who declined this job unless - * the worker is de-registered and re-registered. If a RetryOfferAt time is provided, then the job will be re-matched to - * eligible workers at the retry time in UTC. The worker that declined the job will also be eligible for the job at that time. - */ - retryOfferAt?: Date; -} - -/** A queue that can contain jobs to be routed. */ -export interface RouterQueue { - /** - * The Id of this queue - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly id?: string; - /** The name of this queue. */ - name?: string; - /** 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 }; - /** (Optional) The ID of the exception policy that determines various job escalation rules. */ - exceptionPolicyId?: string; -} - -/** A paged collection of queues. */ -export interface RouterQueueCollection { - value: RouterQueueItem[]; - /** NOTE: This property will not be serialized. It can only be populated by the server. */ - readonly nextLink?: string; -} - -/** Paged instance of RouterQueue */ -export interface RouterQueueItem { - /** A queue that can contain jobs to be routed. */ - queue?: RouterQueue; - /** (Optional) The Concurrency Token. */ - etag?: string; -} - -/** Statistics for the queue */ -export interface RouterQueueStatistics { - /** Id of the queue these details are about. */ - queueId: string; - /** Length of the queue: total number of enqueued jobs. */ - length: number; - /** The estimated wait time of this queue rounded up to the nearest minute, grouped by job priority */ - estimatedWaitTimeMinutes?: { [propertyName: string]: number }; - /** The wait time of the job that has been enqueued in this queue for the longest. */ - longestJobWaitTimeMinutes?: number; -} - -/** An entity for jobs to be routed to */ -export interface RouterWorker { - /** NOTE: This property will not be serialized. It can only be populated by the server. */ - readonly id?: string; - /** - * The current state of the worker. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly state?: RouterWorkerState; - /** The queue(s) that this worker can receive work from. */ - queueAssignments?: { [propertyName: string]: any }; - /** 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 }; - /** A set of non-identifying attributes attached to this worker. */ - tags?: { [propertyName: string]: any }; - /** The channel(s) this worker can handle and their impact on the workers capacity. */ - channelConfigurations?: { [propertyName: string]: ChannelConfiguration }; - /** - * A list of active offers issued to this worker. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly offers?: RouterJobOffer[]; - /** - * A list of assigned jobs attached to this worker. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly assignedJobs?: RouterWorkerAssignment[]; - /** - * A value indicating the workers capacity. A value of '1' means all capacity is consumed. A value of '0' means no capacity is currently consumed. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly loadRatio?: number; - /** A flag indicating this worker is open to receive offers or not. */ - availableForOffers?: boolean; -} - -/** Represents the capacity a job in this channel will consume from a worker */ -export interface ChannelConfiguration { - /** The amount of capacity that an instance of a job of this channel will consume of the total worker capacity. */ - capacityCostPerJob: number; - /** The maximum number of jobs that can be supported concurrently for this channel. */ - maxNumberOfJobs?: number; -} - -/** An offer of a job to a worker */ -export interface RouterJobOffer { - /** The Id of the offer. */ - offerId: string; - /** The Id of the job. */ - jobId: string; - /** The capacity cost consumed by the job offer. */ - capacityCost: number; - /** The time the offer was created in UTC. */ - offeredAt?: Date; - /** The time that the offer will expire in UTC. */ - expiresAt?: Date; -} - -/** The assignment for a worker to a job */ -export interface RouterWorkerAssignment { - /** The Id of the assignment. */ - assignmentId: string; - /** The Id of the Job assigned. */ - jobId: string; - /** The amount of capacity this assignment has consumed on the worker. */ - capacityCost: number; - /** The assignment time of the job in UTC. */ - assignedAt: Date; -} - -/** A paged collection of workers. */ -export interface RouterWorkerCollection { - value: RouterWorkerItem[]; - /** NOTE: This property will not be serialized. It can only be populated by the server. */ - readonly nextLink?: string; -} - -/** Paged instance of RouterWorker */ -export interface RouterWorkerItem { - /** An entity for jobs to be routed to */ - worker?: RouterWorker; - /** (Optional) The Concurrency Token. */ - etag?: string; -} - -/** Encapsulates all options that can be passed as parameters for scoring rule with BestWorkerMode */ -export interface ScoringRuleOptions { - /** (Optional) Set batch size when AllowScoringBatchOfWorkers is set to true. Defaults to 20 if not configured. */ - batchSize?: number; - /** - * (Optional) List of extra parameters from the job that will be sent as part of the payload to scoring rule. - * If not set, the job's labels (sent in the payload as `job`) and the job's worker selectors (sent in the payload as `selectors`) - * are added to the payload of the scoring rule by default. - * Note: Worker labels are always sent with scoring payload. - */ - scoringParameters?: ScoringRuleParameterSelector[]; - /** - * (Optional) - * If set to true, will score workers in batches, and the parameter name of the worker labels will be sent as `workers`. - * By default, set to false and the parameter name for the worker labels will be sent as `worker`. - * Note: If enabled, use BatchSize to set batch size. - */ - allowScoringBatchOfWorkers?: boolean; - /** - * (Optional) - * If false, will sort scores by ascending order. By default, set to true. - */ - descendingOrder?: boolean; -} - -/** Describes a condition that must be met against a set of labels for queue selection */ -export interface RouterQueueSelector { - /** The label key to query against */ - key: string; - /** Describes how the value of the label is compared to the value defined on the label selector */ - labelOperator: LabelOperator; - /** The value to compare against the actual label value with the given operator */ - value?: any; -} - -/** Credentials used to access Azure function rule */ -export interface FunctionRouterRuleCredential { - /** (Optional) Access key scoped to a particular function */ - functionKey?: string; - /** - * (Optional) Access key scoped to a Azure Function app. - * This key grants access to all functions under the app. - */ - appKey?: string; - /** - * (Optional) Client id, when AppKey is provided - * In context of Azure function, this is usually the name of the key - */ - clientId?: string; -} - -/** - * OAuth2.0 Credentials used to Contoso's Authorization server. - * Reference: https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/ - */ -export interface Oauth2ClientCredential { - /** ClientId for Contoso Authorization server. */ - clientId?: string; - /** Client secret for Contoso Authorization server. */ - clientSecret?: string; -} - -/** Contains the weight percentage and queue selectors to be applied if selected for weighted distributions. */ -export interface QueueWeightedAllocation { - /** The percentage of this weight, expressed as a fraction of 1. */ - weight: number; - /** A collection of queue selectors that will be applied if this allocation is selected. */ - queueSelectors: RouterQueueSelector[]; -} - -/** Contains the weight percentage and worker selectors to be applied if selected for weighted distributions. */ -export interface WorkerWeightedAllocation { - /** The percentage of this weight, expressed as a fraction of 1. */ - weight: number; - /** A collection of worker selectors that will be applied if this allocation is selected. */ - workerSelectors: RouterWorkerSelector[]; -} - -/** Describes a set of queue selectors that will be attached if the given condition resolves to true */ -export interface ConditionalQueueSelectorAttachment - extends QueueSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "conditional"; - /** - * A rule of one of the following types: - * - * StaticRule: A rule providing static rules that always return the same result, regardless of input. - * DirectMapRule: A rule that return the same labels as the input labels. - * ExpressionRule: A rule providing inline expression rules. - * AzureFunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. - * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. - */ - condition: RouterRuleUnion; - /** The queue selectors to attach */ - queueSelectors: RouterQueueSelector[]; -} - -/** Attaches a queue selector where the value is passed through from the job label with the same key */ -export interface PassThroughQueueSelectorAttachment - extends QueueSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "pass-through"; - /** The label key to query against */ - key: string; - /** Describes how the value of the label is compared to the value pass through */ - labelOperator: LabelOperator; -} - -/** Attaches queue selectors to a job when the RouterRule is resolved */ -export interface RuleEngineQueueSelectorAttachment - extends QueueSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "rule-engine"; - /** - * A rule of one of the following types: - * - * StaticRule: A rule providing static rules that always return the same result, regardless of input. - * DirectMapRule: A rule that return the same labels as the input labels. - * ExpressionRule: A rule providing inline expression rules. - * AzureFunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. - * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. - */ - rule: RouterRuleUnion; -} - -/** Describes a queue selector that will be attached to the job */ -export interface StaticQueueSelectorAttachment extends QueueSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "static"; - /** Describes a condition that must be met against a set of labels for queue selection */ - queueSelector: RouterQueueSelector; -} - -/** Describes multiple sets of queue selectors, of which one will be selected and attached according to a weighting */ -export interface WeightedAllocationQueueSelectorAttachment - extends QueueSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "weighted-allocation-queue-selector"; - /** A collection of percentage based weighted allocations. */ - allocations: QueueWeightedAllocation[]; -} - -/** A rule that return the same labels as the input labels. */ -export interface DirectMapRouterRule extends RouterRule { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "direct-map-rule"; -} - -/** A rule providing inline expression rules. */ -export interface ExpressionRouterRule extends RouterRule { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "expression-rule"; - /** The expression language to compile to and execute */ - language?: ExpressionRouterRuleLanguage; - /** The string containing the expression to evaluate. Should contain return statement with calculated values. */ - expression: string; -} - -/** A rule providing a binding to an HTTP Triggered Azure Function. */ -export interface FunctionRouterRule extends RouterRule { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "azure-function-rule"; - /** URL for Azure Function */ - functionUri: string; - /** Credentials used to access Azure function rule */ - credential?: FunctionRouterRuleCredential; -} - -/** A rule providing static rules that always return the same result, regardless of input. */ -export interface StaticRouterRule extends RouterRule { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "static-rule"; - /** The static value this rule always returns. */ - value?: any; -} - -/** A rule providing a binding to an external web server. */ -export interface WebhookRouterRule extends RouterRule { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "webhook-rule"; - /** Uri for Authorization Server. */ - authorizationServerUri?: string; - /** - * OAuth2.0 Credentials used to Contoso's Authorization server. - * Reference: https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/ - */ - clientCredential?: Oauth2ClientCredential; - /** Uri for Contoso's Web Server. */ - webhookUri?: string; -} - -/** Describes a set of worker selectors that will be attached if the given condition resolves to true */ -export interface ConditionalWorkerSelectorAttachment - extends WorkerSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "conditional"; - /** - * A rule of one of the following types: - * - * StaticRule: A rule providing static rules that always return the same result, regardless of input. - * DirectMapRule: A rule that return the same labels as the input labels. - * ExpressionRule: A rule providing inline expression rules. - * AzureFunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. - * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. - */ - condition: RouterRuleUnion; - /** The worker selectors to attach */ - workerSelectors: RouterWorkerSelector[]; -} - -/** Attaches a worker selector where the value is passed through from the job label with the same key */ -export interface PassThroughWorkerSelectorAttachment - extends WorkerSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "pass-through"; - /** The label key to query against */ - key: string; - /** Describes how the value of the label is compared to the value pass through */ - labelOperator: LabelOperator; - /** Describes how long the attached label selector is valid in seconds. */ - expiresAfterSeconds?: number; -} - -/** Attaches worker selectors to a job when a RouterRule is resolved */ -export interface RuleEngineWorkerSelectorAttachment - extends WorkerSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "rule-engine"; - /** - * A rule of one of the following types: - * - * StaticRule: A rule providing static rules that always return the same result, regardless of input. - * DirectMapRule: A rule that return the same labels as the input labels. - * ExpressionRule: A rule providing inline expression rules. - * AzureFunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. - * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. - */ - rule: RouterRuleUnion; -} - -/** Describes a worker selector that will be attached to the job */ -export interface StaticWorkerSelectorAttachment - extends WorkerSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "static"; - /** Describes a condition that must be met against a set of labels for worker selection */ - workerSelector: RouterWorkerSelector; -} - -/** Describes multiple sets of worker selectors, of which one will be selected and attached according to a weighting */ -export interface WeightedAllocationWorkerSelectorAttachment - extends WorkerSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "weighted-allocation-worker-selector"; - /** A collection of percentage based weighted allocations. */ - allocations: WorkerWeightedAllocation[]; -} - -/** Jobs are distributed to the worker with the strongest abilities available. */ -export interface BestWorkerMode extends DistributionMode { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "best-worker"; - /** - * A rule of one of the following types: - * - * StaticRule: A rule providing static rules that always return the same result, regardless of input. - * DirectMapRule: A rule that return the same labels as the input labels. - * ExpressionRule: A rule providing inline expression rules. - * AzureFunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. - * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. - */ - scoringRule?: RouterRuleUnion; - /** Encapsulates all options that can be passed as parameters for scoring rule with BestWorkerMode */ - scoringRuleOptions?: ScoringRuleOptions; -} - -/** Jobs are directed to the worker who has been idle longest. */ -export interface LongestIdleMode extends DistributionMode { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "longest-idle"; -} - -/** Jobs are distributed in order to workers, starting with the worker that is after the last worker to receive a job. */ -export interface RoundRobinMode extends DistributionMode { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "round-robin"; -} - -/** Trigger for an exception action on exceeding queue length */ -export interface QueueLengthExceptionTrigger extends ExceptionTrigger { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "queue-length"; - /** Threshold of number of jobs ahead in the queue to for this trigger to fire. */ - threshold: number; -} - -/** Trigger for an exception action on exceeding wait time */ -export interface WaitTimeExceptionTrigger extends ExceptionTrigger { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "wait-time"; - /** Threshold for wait time for this trigger. */ - thresholdSeconds: number; -} - -/** An action that marks a job as cancelled */ -export interface CancelExceptionAction extends ExceptionAction { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "cancel"; - /** (Optional) A note that will be appended to the jobs' Notes collection with th current timestamp. */ - note?: string; - /** (Optional) Indicates the outcome of the job, populate this field with your own custom values. */ - dispositionCode?: string; -} - -/** An action that manually reclassifies a job by providing the queue, priority and worker selectors. */ -export interface ManualReclassifyExceptionAction extends ExceptionAction { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "manual-reclassify"; - /** Updated QueueId. */ - queueId?: string; - /** Updated Priority. */ - priority?: number; - /** Updated WorkerSelectors. */ - workerSelectors?: RouterWorkerSelector[]; -} - -/** An action that modifies labels on a job and then reclassifies it */ -export interface ReclassifyExceptionAction extends ExceptionAction { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "reclassify"; - /** (optional) The new classification policy that will determine queue, priority and worker selectors. */ - classificationPolicyId?: string; - /** (optional) Dictionary containing the labels to update (or add if not existing) in key-value pairs */ - labelsToUpsert?: { [propertyName: string]: any }; -} - -/** Known values of {@link RouterJobStatus} that the service accepts. */ -export enum KnownRouterJobStatus { - /** PendingClassification */ - PendingClassification = "pendingClassification", - /** Queued */ - Queued = "queued", - /** Assigned */ - Assigned = "assigned", - /** Completed */ - Completed = "completed", - /** Closed */ - Closed = "closed", - /** Cancelled */ - Cancelled = "cancelled", - /** ClassificationFailed */ - ClassificationFailed = "classificationFailed", - /** Created */ - Created = "created", - /** PendingSchedule */ - PendingSchedule = "pendingSchedule", - /** Scheduled */ - Scheduled = "scheduled", - /** ScheduleFailed */ - ScheduleFailed = "scheduleFailed", - /** WaitingForActivation */ - WaitingForActivation = "waitingForActivation" -} - -/** - * Defines values for RouterJobStatus. \ - * {@link KnownRouterJobStatus} can be used interchangeably with RouterJobStatus, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **pendingClassification** \ - * **queued** \ - * **assigned** \ - * **completed** \ - * **closed** \ - * **cancelled** \ - * **classificationFailed** \ - * **created** \ - * **pendingSchedule** \ - * **scheduled** \ - * **scheduleFailed** \ - * **waitingForActivation** - */ -export type RouterJobStatus = string; - -/** Known values of {@link LabelOperator} that the service accepts. */ -export enum KnownLabelOperator { - /** Equal */ - Equal = "equal", - /** NotEqual */ - NotEqual = "notEqual", - /** LessThan */ - LessThan = "lessThan", - /** LessThanEqual */ - LessThanEqual = "lessThanEqual", - /** GreaterThan */ - GreaterThan = "greaterThan", - /** GreaterThanEqual */ - GreaterThanEqual = "greaterThanEqual" -} - -/** - * Defines values for LabelOperator. \ - * {@link KnownLabelOperator} can be used interchangeably with LabelOperator, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **equal** \ - * **notEqual** \ - * **lessThan** \ - * **lessThanEqual** \ - * **greaterThan** \ - * **greaterThanEqual** - */ -export type LabelOperator = string; - -/** Known values of {@link RouterWorkerSelectorStatus} that the service accepts. */ -export enum KnownRouterWorkerSelectorStatus { - /** Active */ - Active = "active", - /** Expired */ - Expired = "expired" -} - -/** - * Defines values for RouterWorkerSelectorStatus. \ - * {@link KnownRouterWorkerSelectorStatus} can be used interchangeably with RouterWorkerSelectorStatus, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **active** \ - * **expired** - */ -export type RouterWorkerSelectorStatus = string; - -/** Known values of {@link JobMatchModeType} that the service accepts. */ -export enum KnownJobMatchModeType { - /** QueueAndMatchMode */ - QueueAndMatchMode = "queueAndMatchMode", - /** ScheduleAndSuspendMode */ - ScheduleAndSuspendMode = "scheduleAndSuspendMode", - /** SuspendMode */ - SuspendMode = "suspendMode" -} - -/** - * Defines values for JobMatchModeType. \ - * {@link KnownJobMatchModeType} can be used interchangeably with JobMatchModeType, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **queueAndMatchMode** \ - * **scheduleAndSuspendMode** \ - * **suspendMode** - */ -export type JobMatchModeType = string; - -/** Known values of {@link RouterJobStatusSelector} that the service accepts. */ -export enum KnownRouterJobStatusSelector { - /** All */ - All = "all", - /** PendingClassification */ - PendingClassification = "pendingClassification", - /** Queued */ - Queued = "queued", - /** Assigned */ - Assigned = "assigned", - /** Completed */ - Completed = "completed", - /** Closed */ - Closed = "closed", - /** Cancelled */ - Cancelled = "cancelled", - /** ClassificationFailed */ - ClassificationFailed = "classificationFailed", - /** Created */ - Created = "created", - /** PendingSchedule */ - PendingSchedule = "pendingSchedule", - /** Scheduled */ - Scheduled = "scheduled", - /** ScheduleFailed */ - ScheduleFailed = "scheduleFailed", - /** WaitingForActivation */ - WaitingForActivation = "waitingForActivation", - /** Active */ - Active = "active" -} - -/** - * Defines values for RouterJobStatusSelector. \ - * {@link KnownRouterJobStatusSelector} can be used interchangeably with RouterJobStatusSelector, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **all** \ - * **pendingClassification** \ - * **queued** \ - * **assigned** \ - * **completed** \ - * **closed** \ - * **cancelled** \ - * **classificationFailed** \ - * **created** \ - * **pendingSchedule** \ - * **scheduled** \ - * **scheduleFailed** \ - * **waitingForActivation** \ - * **active** - */ -export type RouterJobStatusSelector = string; - -/** Known values of {@link RouterWorkerState} that the service accepts. */ -export enum KnownRouterWorkerState { - /** Active */ - Active = "active", - /** Draining */ - Draining = "draining", - /** Inactive */ - Inactive = "inactive" -} - -/** - * Defines values for RouterWorkerState. \ - * {@link KnownRouterWorkerState} can be used interchangeably with RouterWorkerState, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **active** \ - * **draining** \ - * **inactive** - */ -export type RouterWorkerState = string; - -/** Known values of {@link RouterWorkerStateSelector} that the service accepts. */ -export enum KnownRouterWorkerStateSelector { - /** Active */ - Active = "active", - /** Draining */ - Draining = "draining", - /** Inactive */ - Inactive = "inactive", - /** All */ - All = "all" -} - -/** - * Defines values for RouterWorkerStateSelector. \ - * {@link KnownRouterWorkerStateSelector} can be used interchangeably with RouterWorkerStateSelector, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **active** \ - * **draining** \ - * **inactive** \ - * **all** - */ -export type RouterWorkerStateSelector = string; - -/** Known values of {@link ScoringRuleParameterSelector} that the service accepts. */ -export enum KnownScoringRuleParameterSelector { - /** JobLabels */ - JobLabels = "jobLabels", - /** WorkerSelectors */ - WorkerSelectors = "workerSelectors" -} - -/** - * Defines values for ScoringRuleParameterSelector. \ - * {@link KnownScoringRuleParameterSelector} can be used interchangeably with ScoringRuleParameterSelector, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **jobLabels** \ - * **workerSelectors** - */ -export type ScoringRuleParameterSelector = string; - -/** Known values of {@link ExpressionRouterRuleLanguage} that the service accepts. */ -export enum KnownExpressionRouterRuleLanguage { - /** PowerFx */ - PowerFx = "powerFx" -} - -/** - * Defines values for ExpressionRouterRuleLanguage. \ - * {@link KnownExpressionRouterRuleLanguage} can be used interchangeably with ExpressionRouterRuleLanguage, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **powerFx** - */ -export type ExpressionRouterRuleLanguage = string; - -/** Optional parameters. */ -export interface JobRouterAdministrationUpsertClassificationPolicyOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the upsertClassificationPolicy operation. */ -export type JobRouterAdministrationUpsertClassificationPolicyResponse = ClassificationPolicy; - -/** Optional parameters. */ -export interface JobRouterAdministrationGetClassificationPolicyOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the getClassificationPolicy operation. */ -export type JobRouterAdministrationGetClassificationPolicyResponse = ClassificationPolicy; - -/** Optional parameters. */ -export interface JobRouterAdministrationDeleteClassificationPolicyOptionalParams - extends coreClient.OperationOptions {} - -/** Optional parameters. */ -export interface JobRouterAdministrationListClassificationPoliciesOptionalParams - extends coreClient.OperationOptions { - /** Maximum page size */ - maxpagesize?: number; -} - -/** Contains response data for the listClassificationPolicies operation. */ -export type JobRouterAdministrationListClassificationPoliciesResponse = ClassificationPolicyCollection; - -/** Optional parameters. */ -export interface JobRouterAdministrationUpsertDistributionPolicyOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the upsertDistributionPolicy operation. */ -export type JobRouterAdministrationUpsertDistributionPolicyResponse = DistributionPolicy; - -/** Optional parameters. */ -export interface JobRouterAdministrationGetDistributionPolicyOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the getDistributionPolicy operation. */ -export type JobRouterAdministrationGetDistributionPolicyResponse = DistributionPolicy; - -/** Optional parameters. */ -export interface JobRouterAdministrationDeleteDistributionPolicyOptionalParams - extends coreClient.OperationOptions {} - -/** Optional parameters. */ -export interface JobRouterAdministrationListDistributionPoliciesOptionalParams - extends coreClient.OperationOptions { - /** Maximum page size */ - maxpagesize?: number; -} - -/** Contains response data for the listDistributionPolicies operation. */ -export type JobRouterAdministrationListDistributionPoliciesResponse = DistributionPolicyCollection; - -/** Optional parameters. */ -export interface JobRouterAdministrationUpsertExceptionPolicyOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the upsertExceptionPolicy operation. */ -export type JobRouterAdministrationUpsertExceptionPolicyResponse = ExceptionPolicy; - -/** Optional parameters. */ -export interface JobRouterAdministrationGetExceptionPolicyOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the getExceptionPolicy operation. */ -export type JobRouterAdministrationGetExceptionPolicyResponse = ExceptionPolicy; - -/** Optional parameters. */ -export interface JobRouterAdministrationDeleteExceptionPolicyOptionalParams - extends coreClient.OperationOptions {} - -/** Optional parameters. */ -export interface JobRouterAdministrationListExceptionPoliciesOptionalParams - extends coreClient.OperationOptions { - /** Number of objects to return per page */ - maxpagesize?: number; -} - -/** Contains response data for the listExceptionPolicies operation. */ -export type JobRouterAdministrationListExceptionPoliciesResponse = ExceptionPolicyCollection; - -/** Optional parameters. */ -export interface JobRouterAdministrationUpsertQueueOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the upsertQueue operation. */ -export type JobRouterAdministrationUpsertQueueResponse = RouterQueue; - -/** Optional parameters. */ -export interface JobRouterAdministrationGetQueueOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the getQueue operation. */ -export type JobRouterAdministrationGetQueueResponse = RouterQueue; - -/** Optional parameters. */ -export interface JobRouterAdministrationDeleteQueueOptionalParams - extends coreClient.OperationOptions {} - -/** Optional parameters. */ -export interface JobRouterAdministrationListQueuesOptionalParams - extends coreClient.OperationOptions { - /** Number of objects to return per page */ - maxpagesize?: number; -} - -/** Contains response data for the listQueues operation. */ -export type JobRouterAdministrationListQueuesResponse = RouterQueueCollection; - -/** Optional parameters. */ -export interface JobRouterAdministrationListClassificationPoliciesNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listClassificationPoliciesNext operation. */ -export type JobRouterAdministrationListClassificationPoliciesNextResponse = ClassificationPolicyCollection; - -/** Optional parameters. */ -export interface JobRouterAdministrationListDistributionPoliciesNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listDistributionPoliciesNext operation. */ -export type JobRouterAdministrationListDistributionPoliciesNextResponse = DistributionPolicyCollection; - -/** Optional parameters. */ -export interface JobRouterAdministrationListExceptionPoliciesNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listExceptionPoliciesNext operation. */ -export type JobRouterAdministrationListExceptionPoliciesNextResponse = ExceptionPolicyCollection; - -/** Optional parameters. */ -export interface JobRouterAdministrationListQueuesNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listQueuesNext operation. */ -export type JobRouterAdministrationListQueuesNextResponse = RouterQueueCollection; - -/** Optional parameters. */ -export interface JobRouterUpsertJobOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the upsertJob operation. */ -export type JobRouterUpsertJobResponse = RouterJob; - -/** Optional parameters. */ -export interface JobRouterGetJobOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the getJob operation. */ -export type JobRouterGetJobResponse = RouterJob; - -/** Optional parameters. */ -export interface JobRouterDeleteJobOptionalParams - extends coreClient.OperationOptions {} - -/** Optional parameters. */ -export interface JobRouterReclassifyJobActionOptionalParams - extends coreClient.OperationOptions { - /** Request object for reclassifying a job. */ - reclassifyJobRequest?: any; -} - -/** Contains response data for the reclassifyJobAction operation. */ -export type JobRouterReclassifyJobActionResponse = { - /** The parsed response body. */ - body: any; -}; - -/** Optional parameters. */ -export interface JobRouterCancelJobActionOptionalParams - extends coreClient.OperationOptions { - /** (Optional) A note that will be appended to the jobs' Notes collection with the current timestamp. */ - note?: string; - /** - * Indicates the outcome of the job, populate this field with your own custom values. - * If not provided, default value of "Cancelled" is set. - */ - dispositionCode?: string; -} - -/** Contains response data for the cancelJobAction operation. */ -export type JobRouterCancelJobActionResponse = { - /** The parsed response body. */ - body: any; -}; - -/** Optional parameters. */ -export interface JobRouterCompleteJobActionOptionalParams - extends coreClient.OperationOptions { - /** (Optional) A note that will be appended to the jobs' Notes collection with the current timestamp. */ - note?: string; -} - -/** Contains response data for the completeJobAction operation. */ -export type JobRouterCompleteJobActionResponse = { - /** The parsed response body. */ - body: any; -}; - -/** Optional parameters. */ -export interface JobRouterCloseJobActionOptionalParams - extends coreClient.OperationOptions { - /** Indicates the outcome of the job, populate this field with your own custom values. */ - dispositionCode?: string; - /** - * If not provided, worker capacity is released immediately along with a JobClosedEvent notification. - * If provided, worker capacity is released along with a JobClosedEvent notification at a future time in UTC. - */ - closeAt?: Date; - /** (Optional) A note that will be appended to the jobs' Notes collection with the current timestamp. */ - note?: string; -} - -/** Contains response data for the closeJobAction operation. */ -export type JobRouterCloseJobActionResponse = { - /** The parsed response body. */ - body: any; -}; - -/** Optional parameters. */ -export interface JobRouterListJobsOptionalParams - extends coreClient.OperationOptions { - /** Number of objects to return per page */ - maxpagesize?: number; - /** If specified, filter jobs by status. */ - status?: RouterJobStatusSelector; - /** If specified, filter jobs by queue. */ - queueId?: string; - /** If specified, filter jobs by channel. */ - channelId?: string; - /** If specified, filter jobs by classificationPolicy. */ - classificationPolicyId?: string; - /** If specified, filter on jobs that was scheduled before or at given timestamp. Range: (-Inf, scheduledBefore] */ - scheduledBefore?: Date; - /** If specified, filter on jobs that was scheduled at or after given value. Range: [scheduledAfter, +Inf). */ - scheduledAfter?: Date; -} - -/** Contains response data for the listJobs operation. */ -export type JobRouterListJobsResponse = RouterJobCollection; - -/** Optional parameters. */ -export interface JobRouterGetInQueuePositionOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the getInQueuePosition operation. */ -export type JobRouterGetInQueuePositionResponse = RouterJobPositionDetails; - -/** Optional parameters. */ -export interface JobRouterUnassignJobActionOptionalParams - extends coreClient.OperationOptions { - /** Request body for unassign route */ - unassignJobRequest?: UnassignJobRequest; -} - -/** Contains response data for the unassignJobAction operation. */ -export type JobRouterUnassignJobActionResponse = UnassignJobResult; - -/** Optional parameters. */ -export interface JobRouterAcceptJobActionOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the acceptJobAction operation. */ -export type JobRouterAcceptJobActionResponse = AcceptJobOfferResult; - -/** Optional parameters. */ -export interface JobRouterDeclineJobActionOptionalParams - extends coreClient.OperationOptions { - /** Request model for declining offer */ - declineJobOfferRequest?: DeclineJobOfferRequest; -} - -/** Contains response data for the declineJobAction operation. */ -export type JobRouterDeclineJobActionResponse = { - /** The parsed response body. */ - body: any; -}; - -/** Optional parameters. */ -export interface JobRouterGetQueueStatisticsOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the getQueueStatistics operation. */ -export type JobRouterGetQueueStatisticsResponse = RouterQueueStatistics; - -/** Optional parameters. */ -export interface JobRouterUpsertWorkerOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the upsertWorker operation. */ -export type JobRouterUpsertWorkerResponse = RouterWorker; - -/** Optional parameters. */ -export interface JobRouterGetWorkerOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the getWorker operation. */ -export type JobRouterGetWorkerResponse = RouterWorker; - -/** Optional parameters. */ -export interface JobRouterDeleteWorkerOptionalParams - extends coreClient.OperationOptions {} - -/** Optional parameters. */ -export interface JobRouterListWorkersOptionalParams - extends coreClient.OperationOptions { - /** Number of objects to return per page */ - maxpagesize?: number; - /** If specified, select workers who are assigned to this queue */ - queueId?: string; - /** If specified, select workers who have a channel configuration with this channel */ - channelId?: string; - /** If specified, select workers by worker state. */ - state?: RouterWorkerStateSelector; - /** - * If set to true, select only workers who have capacity for the channel specified by `channelId` or for any channel - * if `channelId` not specified. If set to false, then will return all workers including workers without any capacity for jobs. Defaults to false. - */ - hasCapacity?: boolean; -} - -/** Contains response data for the listWorkers operation. */ -export type JobRouterListWorkersResponse = RouterWorkerCollection; - -/** Optional parameters. */ -export interface JobRouterListJobsNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listJobsNext operation. */ -export type JobRouterListJobsNextResponse = RouterJobCollection; - -/** Optional parameters. */ -export interface JobRouterListWorkersNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listWorkersNext operation. */ -export type JobRouterListWorkersNextResponse = RouterWorkerCollection; - -/** Optional parameters. */ -export interface JobRouterApiClientOptionalParams - extends coreClient.ServiceClientOptions { - /** Api Version */ - apiVersion?: string; - /** Overrides client endpoint. */ - endpoint?: string; -} diff --git a/sdk/communication/communication-job-router/src/generated/src/models/mappers.ts b/sdk/communication/communication-job-router/src/generated/src/models/mappers.ts deleted file mode 100644 index e43c778ec32c..000000000000 --- a/sdk/communication/communication-job-router/src/generated/src/models/mappers.ts +++ /dev/null @@ -1,2303 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import * as coreClient from "@azure/core-client"; - -export const ClassificationPolicy: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ClassificationPolicy", - modelProperties: { - id: { - serializedName: "id", - readOnly: true, - type: { - name: "String" - } - }, - name: { - serializedName: "name", - type: { - name: "String" - } - }, - fallbackQueueId: { - serializedName: "fallbackQueueId", - type: { - name: "String" - } - }, - queueSelectors: { - serializedName: "queueSelectors", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "QueueSelectorAttachment" - } - } - } - }, - prioritizationRule: { - serializedName: "prioritizationRule", - type: { - name: "Composite", - className: "RouterRule" - } - }, - workerSelectors: { - serializedName: "workerSelectors", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "WorkerSelectorAttachment" - } - } - } - } - } - } -}; - -export const QueueSelectorAttachment: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "QueueSelectorAttachment", - uberParent: "QueueSelectorAttachment", - polymorphicDiscriminator: { - serializedName: "kind", - clientName: "kind" - }, - modelProperties: { - kind: { - serializedName: "kind", - required: true, - type: { - name: "String" - } - } - } - } -}; - -export const RouterRule: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "RouterRule", - uberParent: "RouterRule", - polymorphicDiscriminator: { - serializedName: "kind", - clientName: "kind" - }, - modelProperties: { - kind: { - serializedName: "kind", - required: true, - type: { - name: "String" - } - } - } - } -}; - -export const WorkerSelectorAttachment: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "WorkerSelectorAttachment", - uberParent: "WorkerSelectorAttachment", - polymorphicDiscriminator: { - serializedName: "kind", - clientName: "kind" - }, - modelProperties: { - kind: { - serializedName: "kind", - required: true, - type: { - name: "String" - } - } - } - } -}; - -export const CommunicationErrorResponse: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "CommunicationErrorResponse", - modelProperties: { - error: { - serializedName: "error", - type: { - name: "Composite", - className: "CommunicationError" - } - } - } - } -}; - -export const CommunicationError: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "CommunicationError", - modelProperties: { - code: { - serializedName: "code", - required: true, - type: { - name: "String" - } - }, - message: { - serializedName: "message", - required: true, - type: { - name: "String" - } - }, - target: { - serializedName: "target", - readOnly: true, - type: { - name: "String" - } - }, - details: { - serializedName: "details", - readOnly: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "CommunicationError" - } - } - } - }, - innerError: { - serializedName: "innererror", - type: { - name: "Composite", - className: "CommunicationError" - } - } - } - } -}; - -export const ClassificationPolicyCollection: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ClassificationPolicyCollection", - modelProperties: { - value: { - serializedName: "value", - required: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "ClassificationPolicyItem" - } - } - } - }, - nextLink: { - serializedName: "nextLink", - readOnly: true, - type: { - name: "String" - } - } - } - } -}; - -export const ClassificationPolicyItem: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ClassificationPolicyItem", - modelProperties: { - classificationPolicy: { - serializedName: "classificationPolicy", - type: { - name: "Composite", - className: "ClassificationPolicy" - } - }, - etag: { - serializedName: "etag", - type: { - name: "String" - } - } - } - } -}; - -export const DistributionPolicy: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "DistributionPolicy", - modelProperties: { - id: { - serializedName: "id", - readOnly: true, - type: { - name: "String" - } - }, - name: { - serializedName: "name", - type: { - name: "String" - } - }, - offerExpiresAfterSeconds: { - serializedName: "offerExpiresAfterSeconds", - type: { - name: "Number" - } - }, - mode: { - serializedName: "mode", - type: { - name: "Composite", - className: "DistributionMode" - } - } - } - } -}; - -export const DistributionMode: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "DistributionMode", - uberParent: "DistributionMode", - polymorphicDiscriminator: { - serializedName: "kind", - clientName: "kind" - }, - modelProperties: { - kind: { - serializedName: "kind", - required: true, - type: { - name: "String" - } - }, - minConcurrentOffers: { - serializedName: "minConcurrentOffers", - type: { - name: "Number" - } - }, - maxConcurrentOffers: { - serializedName: "maxConcurrentOffers", - type: { - name: "Number" - } - }, - bypassSelectors: { - serializedName: "bypassSelectors", - type: { - name: "Boolean" - } - } - } - } -}; - -export const DistributionPolicyCollection: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "DistributionPolicyCollection", - modelProperties: { - value: { - serializedName: "value", - required: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "DistributionPolicyItem" - } - } - } - }, - nextLink: { - serializedName: "nextLink", - readOnly: true, - type: { - name: "String" - } - } - } - } -}; - -export const DistributionPolicyItem: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "DistributionPolicyItem", - modelProperties: { - distributionPolicy: { - serializedName: "distributionPolicy", - type: { - name: "Composite", - className: "DistributionPolicy" - } - }, - etag: { - serializedName: "etag", - type: { - name: "String" - } - } - } - } -}; - -export const ExceptionPolicy: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ExceptionPolicy", - modelProperties: { - id: { - serializedName: "id", - readOnly: true, - type: { - name: "String" - } - }, - name: { - serializedName: "name", - type: { - name: "String" - } - }, - exceptionRules: { - serializedName: "exceptionRules", - type: { - name: "Dictionary", - value: { type: { name: "Composite", className: "ExceptionRule" } } - } - } - } - } -}; - -export const ExceptionRule: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ExceptionRule", - modelProperties: { - trigger: { - serializedName: "trigger", - type: { - name: "Composite", - className: "ExceptionTrigger" - } - }, - actions: { - serializedName: "actions", - required: true, - type: { - name: "Dictionary", - value: { type: { name: "Composite", className: "ExceptionAction" } } - } - } - } - } -}; - -export const ExceptionTrigger: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ExceptionTrigger", - uberParent: "ExceptionTrigger", - polymorphicDiscriminator: { - serializedName: "kind", - clientName: "kind" - }, - modelProperties: { - kind: { - serializedName: "kind", - required: true, - type: { - name: "String" - } - } - } - } -}; - -export const ExceptionAction: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ExceptionAction", - uberParent: "ExceptionAction", - polymorphicDiscriminator: { - serializedName: "kind", - clientName: "kind" - }, - modelProperties: { - kind: { - serializedName: "kind", - required: true, - type: { - name: "String" - } - } - } - } -}; - -export const ExceptionPolicyCollection: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ExceptionPolicyCollection", - modelProperties: { - value: { - serializedName: "value", - required: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "ExceptionPolicyItem" - } - } - } - }, - nextLink: { - serializedName: "nextLink", - readOnly: true, - type: { - name: "String" - } - } - } - } -}; - -export const ExceptionPolicyItem: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ExceptionPolicyItem", - modelProperties: { - exceptionPolicy: { - serializedName: "exceptionPolicy", - type: { - name: "Composite", - className: "ExceptionPolicy" - } - }, - etag: { - serializedName: "etag", - type: { - name: "String" - } - } - } - } -}; - -export const RouterJob: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "RouterJob", - modelProperties: { - id: { - serializedName: "id", - readOnly: true, - type: { - name: "String" - } - }, - channelReference: { - serializedName: "channelReference", - type: { - name: "String" - } - }, - status: { - serializedName: "status", - readOnly: true, - type: { - name: "String" - } - }, - enqueuedAt: { - serializedName: "enqueuedAt", - readOnly: true, - type: { - name: "DateTime" - } - }, - channelId: { - serializedName: "channelId", - type: { - name: "String" - } - }, - classificationPolicyId: { - serializedName: "classificationPolicyId", - type: { - name: "String" - } - }, - queueId: { - serializedName: "queueId", - type: { - name: "String" - } - }, - priority: { - serializedName: "priority", - type: { - name: "Number" - } - }, - dispositionCode: { - serializedName: "dispositionCode", - type: { - name: "String" - } - }, - requestedWorkerSelectors: { - serializedName: "requestedWorkerSelectors", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "RouterWorkerSelector" - } - } - } - }, - attachedWorkerSelectors: { - serializedName: "attachedWorkerSelectors", - readOnly: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "RouterWorkerSelector" - } - } - } - }, - labels: { - serializedName: "labels", - type: { - name: "Dictionary", - value: { type: { name: "any" } } - } - }, - assignments: { - serializedName: "assignments", - readOnly: true, - type: { - name: "Dictionary", - value: { - type: { name: "Composite", className: "RouterJobAssignment" } - } - } - }, - tags: { - serializedName: "tags", - type: { - name: "Dictionary", - value: { type: { name: "any" } } - } - }, - notes: { - serializedName: "notes", - type: { - name: "Dictionary", - value: { type: { name: "String" } } - } - }, - scheduledAt: { - serializedName: "scheduledAt", - readOnly: true, - type: { - name: "DateTime" - } - }, - matchingMode: { - serializedName: "matchingMode", - type: { - name: "Composite", - className: "JobMatchingMode" - } - } - } - } -}; - -export const RouterWorkerSelector: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "RouterWorkerSelector", - modelProperties: { - key: { - constraints: { - MaxLength: 500 - }, - serializedName: "key", - required: true, - type: { - name: "String" - } - }, - labelOperator: { - serializedName: "labelOperator", - required: true, - type: { - name: "String" - } - }, - value: { - serializedName: "value", - type: { - name: "any" - } - }, - expiresAfterSeconds: { - serializedName: "expiresAfterSeconds", - type: { - name: "Number" - } - }, - expedite: { - serializedName: "expedite", - type: { - name: "Boolean" - } - }, - status: { - serializedName: "status", - readOnly: true, - type: { - name: "String" - } - }, - expiresAt: { - serializedName: "expiresAt", - readOnly: true, - type: { - name: "DateTime" - } - } - } - } -}; - -export const RouterJobAssignment: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "RouterJobAssignment", - modelProperties: { - assignmentId: { - constraints: { - MinLength: 1 - }, - serializedName: "assignmentId", - required: true, - type: { - name: "String" - } - }, - workerId: { - serializedName: "workerId", - type: { - name: "String" - } - }, - assignedAt: { - serializedName: "assignedAt", - required: true, - type: { - name: "DateTime" - } - }, - completedAt: { - serializedName: "completedAt", - type: { - name: "DateTime" - } - }, - closedAt: { - serializedName: "closedAt", - type: { - name: "DateTime" - } - } - } - } -}; - -export const JobMatchingMode: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "JobMatchingMode", - modelProperties: { - modeType: { - serializedName: "modeType", - type: { - name: "String" - } - }, - queueAndMatchMode: { - serializedName: "queueAndMatchMode", - type: { - name: "any" - } - }, - scheduleAndSuspendMode: { - serializedName: "scheduleAndSuspendMode", - type: { - name: "Composite", - className: "ScheduleAndSuspendMode" - } - }, - suspendMode: { - serializedName: "suspendMode", - type: { - name: "any" - } - } - } - } -}; - -export const ScheduleAndSuspendMode: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ScheduleAndSuspendMode", - modelProperties: { - scheduleAt: { - serializedName: "scheduleAt", - type: { - name: "DateTime" - } - } - } - } -}; - -export const CancelJobRequest: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "CancelJobRequest", - modelProperties: { - note: { - constraints: { - MaxLength: 2000 - }, - serializedName: "note", - type: { - name: "String" - } - }, - dispositionCode: { - constraints: { - MaxLength: 500 - }, - serializedName: "dispositionCode", - type: { - name: "String" - } - } - } - } -}; - -export const CompleteJobRequest: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "CompleteJobRequest", - modelProperties: { - assignmentId: { - constraints: { - MaxLength: 50 - }, - serializedName: "assignmentId", - required: true, - type: { - name: "String" - } - }, - note: { - constraints: { - MaxLength: 2000 - }, - serializedName: "note", - type: { - name: "String" - } - } - } - } -}; - -export const CloseJobRequest: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "CloseJobRequest", - modelProperties: { - assignmentId: { - constraints: { - MaxLength: 50 - }, - serializedName: "assignmentId", - required: true, - type: { - name: "String" - } - }, - dispositionCode: { - constraints: { - MaxLength: 500 - }, - serializedName: "dispositionCode", - type: { - name: "String" - } - }, - closeAt: { - serializedName: "closeAt", - type: { - name: "DateTime" - } - }, - note: { - constraints: { - MaxLength: 2000 - }, - serializedName: "note", - type: { - name: "String" - } - } - } - } -}; - -export const RouterJobCollection: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "RouterJobCollection", - modelProperties: { - value: { - serializedName: "value", - required: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "RouterJobItem" - } - } - } - }, - nextLink: { - serializedName: "nextLink", - readOnly: true, - type: { - name: "String" - } - } - } - } -}; - -export const RouterJobItem: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "RouterJobItem", - modelProperties: { - job: { - serializedName: "job", - type: { - name: "Composite", - className: "RouterJob" - } - }, - etag: { - serializedName: "etag", - type: { - name: "String" - } - } - } - } -}; - -export const RouterJobPositionDetails: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "RouterJobPositionDetails", - modelProperties: { - jobId: { - constraints: { - MinLength: 1 - }, - serializedName: "jobId", - required: true, - type: { - name: "String" - } - }, - position: { - serializedName: "position", - required: true, - type: { - name: "Number" - } - }, - queueId: { - constraints: { - MinLength: 1 - }, - serializedName: "queueId", - required: true, - type: { - name: "String" - } - }, - queueLength: { - serializedName: "queueLength", - required: true, - type: { - name: "Number" - } - }, - estimatedWaitTimeMinutes: { - serializedName: "estimatedWaitTimeMinutes", - required: true, - type: { - name: "Number" - } - } - } - } -}; - -export const UnassignJobRequest: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "UnassignJobRequest", - modelProperties: { - suspendMatching: { - serializedName: "suspendMatching", - type: { - name: "Boolean" - } - } - } - } -}; - -export const UnassignJobResult: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "UnassignJobResult", - modelProperties: { - jobId: { - constraints: { - MinLength: 1 - }, - serializedName: "jobId", - required: true, - type: { - name: "String" - } - }, - unassignmentCount: { - serializedName: "unassignmentCount", - required: true, - type: { - name: "Number" - } - } - } - } -}; - -export const AcceptJobOfferResult: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "AcceptJobOfferResult", - modelProperties: { - assignmentId: { - constraints: { - MinLength: 1 - }, - serializedName: "assignmentId", - required: true, - type: { - name: "String" - } - }, - jobId: { - constraints: { - MinLength: 1 - }, - serializedName: "jobId", - required: true, - type: { - name: "String" - } - }, - workerId: { - constraints: { - MinLength: 1 - }, - serializedName: "workerId", - required: true, - type: { - name: "String" - } - } - } - } -}; - -export const DeclineJobOfferRequest: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "DeclineJobOfferRequest", - modelProperties: { - retryOfferAt: { - serializedName: "retryOfferAt", - type: { - name: "DateTime" - } - } - } - } -}; - -export const RouterQueue: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "RouterQueue", - modelProperties: { - id: { - serializedName: "id", - readOnly: true, - type: { - name: "String" - } - }, - name: { - serializedName: "name", - type: { - name: "String" - } - }, - distributionPolicyId: { - serializedName: "distributionPolicyId", - type: { - name: "String" - } - }, - labels: { - serializedName: "labels", - type: { - name: "Dictionary", - value: { type: { name: "any" } } - } - }, - exceptionPolicyId: { - serializedName: "exceptionPolicyId", - type: { - name: "String" - } - } - } - } -}; - -export const RouterQueueCollection: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "RouterQueueCollection", - modelProperties: { - value: { - serializedName: "value", - required: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "RouterQueueItem" - } - } - } - }, - nextLink: { - serializedName: "nextLink", - readOnly: true, - type: { - name: "String" - } - } - } - } -}; - -export const RouterQueueItem: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "RouterQueueItem", - modelProperties: { - queue: { - serializedName: "queue", - type: { - name: "Composite", - className: "RouterQueue" - } - }, - etag: { - serializedName: "etag", - type: { - name: "String" - } - } - } - } -}; - -export const RouterQueueStatistics: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "RouterQueueStatistics", - modelProperties: { - queueId: { - constraints: { - MinLength: 1 - }, - serializedName: "queueId", - required: true, - type: { - name: "String" - } - }, - length: { - serializedName: "length", - required: true, - type: { - name: "Number" - } - }, - estimatedWaitTimeMinutes: { - serializedName: "estimatedWaitTimeMinutes", - type: { - name: "Dictionary", - value: { type: { name: "Number" } } - } - }, - longestJobWaitTimeMinutes: { - serializedName: "longestJobWaitTimeMinutes", - type: { - name: "Number" - } - } - } - } -}; - -export const RouterWorker: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "RouterWorker", - modelProperties: { - id: { - serializedName: "id", - readOnly: true, - type: { - name: "String" - } - }, - state: { - serializedName: "state", - readOnly: true, - type: { - name: "String" - } - }, - queueAssignments: { - serializedName: "queueAssignments", - type: { - name: "Dictionary", - value: { type: { name: "any" } } - } - }, - totalCapacity: { - serializedName: "totalCapacity", - type: { - name: "Number" - } - }, - labels: { - serializedName: "labels", - type: { - name: "Dictionary", - value: { type: { name: "any" } } - } - }, - tags: { - serializedName: "tags", - type: { - name: "Dictionary", - value: { type: { name: "any" } } - } - }, - channelConfigurations: { - serializedName: "channelConfigurations", - type: { - name: "Dictionary", - value: { - type: { name: "Composite", className: "ChannelConfiguration" } - } - } - }, - offers: { - serializedName: "offers", - readOnly: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "RouterJobOffer" - } - } - } - }, - assignedJobs: { - serializedName: "assignedJobs", - readOnly: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "RouterWorkerAssignment" - } - } - } - }, - loadRatio: { - serializedName: "loadRatio", - readOnly: true, - type: { - name: "Number" - } - }, - availableForOffers: { - serializedName: "availableForOffers", - type: { - name: "Boolean" - } - } - } - } -}; - -export const ChannelConfiguration: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ChannelConfiguration", - modelProperties: { - capacityCostPerJob: { - serializedName: "capacityCostPerJob", - required: true, - type: { - name: "Number" - } - }, - maxNumberOfJobs: { - serializedName: "maxNumberOfJobs", - type: { - name: "Number" - } - } - } - } -}; - -export const RouterJobOffer: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "RouterJobOffer", - modelProperties: { - offerId: { - constraints: { - MinLength: 1 - }, - serializedName: "offerId", - required: true, - type: { - name: "String" - } - }, - jobId: { - constraints: { - MinLength: 1 - }, - serializedName: "jobId", - required: true, - type: { - name: "String" - } - }, - capacityCost: { - serializedName: "capacityCost", - required: true, - type: { - name: "Number" - } - }, - offeredAt: { - serializedName: "offeredAt", - type: { - name: "DateTime" - } - }, - expiresAt: { - serializedName: "expiresAt", - type: { - name: "DateTime" - } - } - } - } -}; - -export const RouterWorkerAssignment: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "RouterWorkerAssignment", - modelProperties: { - assignmentId: { - constraints: { - MinLength: 1 - }, - serializedName: "assignmentId", - required: true, - type: { - name: "String" - } - }, - jobId: { - constraints: { - MinLength: 1 - }, - serializedName: "jobId", - required: true, - type: { - name: "String" - } - }, - capacityCost: { - serializedName: "capacityCost", - required: true, - type: { - name: "Number" - } - }, - assignedAt: { - serializedName: "assignedAt", - required: true, - type: { - name: "DateTime" - } - } - } - } -}; - -export const RouterWorkerCollection: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "RouterWorkerCollection", - modelProperties: { - value: { - serializedName: "value", - required: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "RouterWorkerItem" - } - } - } - }, - nextLink: { - serializedName: "nextLink", - readOnly: true, - type: { - name: "String" - } - } - } - } -}; - -export const RouterWorkerItem: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "RouterWorkerItem", - modelProperties: { - worker: { - serializedName: "worker", - type: { - name: "Composite", - className: "RouterWorker" - } - }, - etag: { - serializedName: "etag", - type: { - name: "String" - } - } - } - } -}; - -export const ScoringRuleOptions: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ScoringRuleOptions", - modelProperties: { - batchSize: { - serializedName: "batchSize", - type: { - name: "Number" - } - }, - scoringParameters: { - serializedName: "scoringParameters", - type: { - name: "Sequence", - element: { - type: { - name: "String" - } - } - } - }, - allowScoringBatchOfWorkers: { - serializedName: "allowScoringBatchOfWorkers", - type: { - name: "Boolean" - } - }, - descendingOrder: { - serializedName: "descendingOrder", - type: { - name: "Boolean" - } - } - } - } -}; - -export const RouterQueueSelector: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "RouterQueueSelector", - modelProperties: { - key: { - constraints: { - MaxLength: 500 - }, - serializedName: "key", - required: true, - type: { - name: "String" - } - }, - labelOperator: { - serializedName: "labelOperator", - required: true, - type: { - name: "String" - } - }, - value: { - serializedName: "value", - type: { - name: "any" - } - } - } - } -}; - -export const FunctionRouterRuleCredential: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "FunctionRouterRuleCredential", - modelProperties: { - functionKey: { - constraints: { - MaxLength: 500 - }, - serializedName: "functionKey", - type: { - name: "String" - } - }, - appKey: { - constraints: { - MaxLength: 500 - }, - serializedName: "appKey", - type: { - name: "String" - } - }, - clientId: { - constraints: { - MaxLength: 500 - }, - serializedName: "clientId", - type: { - name: "String" - } - } - } - } -}; - -export const Oauth2ClientCredential: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "Oauth2ClientCredential", - modelProperties: { - clientId: { - constraints: { - MaxLength: 500 - }, - serializedName: "clientId", - type: { - name: "String" - } - }, - clientSecret: { - constraints: { - MaxLength: 500 - }, - serializedName: "clientSecret", - type: { - name: "String" - } - } - } - } -}; - -export const QueueWeightedAllocation: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "QueueWeightedAllocation", - modelProperties: { - weight: { - serializedName: "weight", - required: true, - type: { - name: "Number" - } - }, - queueSelectors: { - serializedName: "queueSelectors", - required: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "RouterQueueSelector" - } - } - } - } - } - } -}; - -export const WorkerWeightedAllocation: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "WorkerWeightedAllocation", - modelProperties: { - weight: { - serializedName: "weight", - required: true, - type: { - name: "Number" - } - }, - workerSelectors: { - serializedName: "workerSelectors", - required: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "RouterWorkerSelector" - } - } - } - } - } - } -}; - -export const ConditionalQueueSelectorAttachment: coreClient.CompositeMapper = { - serializedName: "conditional", - type: { - name: "Composite", - className: "ConditionalQueueSelectorAttachment", - uberParent: "QueueSelectorAttachment", - polymorphicDiscriminator: - QueueSelectorAttachment.type.polymorphicDiscriminator, - modelProperties: { - ...QueueSelectorAttachment.type.modelProperties, - condition: { - serializedName: "condition", - type: { - name: "Composite", - className: "RouterRule" - } - }, - queueSelectors: { - serializedName: "queueSelectors", - required: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "RouterQueueSelector" - } - } - } - } - } - } -}; - -export const PassThroughQueueSelectorAttachment: coreClient.CompositeMapper = { - serializedName: "pass-through", - type: { - name: "Composite", - className: "PassThroughQueueSelectorAttachment", - uberParent: "QueueSelectorAttachment", - polymorphicDiscriminator: - QueueSelectorAttachment.type.polymorphicDiscriminator, - modelProperties: { - ...QueueSelectorAttachment.type.modelProperties, - key: { - constraints: { - MaxLength: 500 - }, - serializedName: "key", - required: true, - type: { - name: "String" - } - }, - labelOperator: { - serializedName: "labelOperator", - required: true, - type: { - name: "String" - } - } - } - } -}; - -export const RuleEngineQueueSelectorAttachment: coreClient.CompositeMapper = { - serializedName: "rule-engine", - type: { - name: "Composite", - className: "RuleEngineQueueSelectorAttachment", - uberParent: "QueueSelectorAttachment", - polymorphicDiscriminator: - QueueSelectorAttachment.type.polymorphicDiscriminator, - modelProperties: { - ...QueueSelectorAttachment.type.modelProperties, - rule: { - serializedName: "rule", - type: { - name: "Composite", - className: "RouterRule" - } - } - } - } -}; - -export const StaticQueueSelectorAttachment: coreClient.CompositeMapper = { - serializedName: "static", - type: { - name: "Composite", - className: "StaticQueueSelectorAttachment", - uberParent: "QueueSelectorAttachment", - polymorphicDiscriminator: - QueueSelectorAttachment.type.polymorphicDiscriminator, - modelProperties: { - ...QueueSelectorAttachment.type.modelProperties, - queueSelector: { - serializedName: "queueSelector", - type: { - name: "Composite", - className: "RouterQueueSelector" - } - } - } - } -}; - -export const WeightedAllocationQueueSelectorAttachment: coreClient.CompositeMapper = { - serializedName: "weighted-allocation-queue-selector", - type: { - name: "Composite", - className: "WeightedAllocationQueueSelectorAttachment", - uberParent: "QueueSelectorAttachment", - polymorphicDiscriminator: - QueueSelectorAttachment.type.polymorphicDiscriminator, - modelProperties: { - ...QueueSelectorAttachment.type.modelProperties, - allocations: { - serializedName: "allocations", - required: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "QueueWeightedAllocation" - } - } - } - } - } - } -}; - -export const DirectMapRouterRule: coreClient.CompositeMapper = { - serializedName: "direct-map-rule", - type: { - name: "Composite", - className: "DirectMapRouterRule", - uberParent: "RouterRule", - polymorphicDiscriminator: RouterRule.type.polymorphicDiscriminator, - modelProperties: { - ...RouterRule.type.modelProperties - } - } -}; - -export const ExpressionRouterRule: coreClient.CompositeMapper = { - serializedName: "expression-rule", - type: { - name: "Composite", - className: "ExpressionRouterRule", - uberParent: "RouterRule", - polymorphicDiscriminator: RouterRule.type.polymorphicDiscriminator, - modelProperties: { - ...RouterRule.type.modelProperties, - language: { - serializedName: "language", - type: { - name: "String" - } - }, - expression: { - constraints: { - MaxLength: 500 - }, - serializedName: "expression", - required: true, - type: { - name: "String" - } - } - } - } -}; - -export const FunctionRouterRule: coreClient.CompositeMapper = { - serializedName: "azure-function-rule", - type: { - name: "Composite", - className: "FunctionRouterRule", - uberParent: "RouterRule", - polymorphicDiscriminator: RouterRule.type.polymorphicDiscriminator, - modelProperties: { - ...RouterRule.type.modelProperties, - functionUri: { - serializedName: "functionUri", - required: true, - type: { - name: "String" - } - }, - credential: { - serializedName: "credential", - type: { - name: "Composite", - className: "FunctionRouterRuleCredential" - } - } - } - } -}; - -export const StaticRouterRule: coreClient.CompositeMapper = { - serializedName: "static-rule", - type: { - name: "Composite", - className: "StaticRouterRule", - uberParent: "RouterRule", - polymorphicDiscriminator: RouterRule.type.polymorphicDiscriminator, - modelProperties: { - ...RouterRule.type.modelProperties, - value: { - serializedName: "value", - type: { - name: "any" - } - } - } - } -}; - -export const WebhookRouterRule: coreClient.CompositeMapper = { - serializedName: "webhook-rule", - type: { - name: "Composite", - className: "WebhookRouterRule", - uberParent: "RouterRule", - polymorphicDiscriminator: RouterRule.type.polymorphicDiscriminator, - modelProperties: { - ...RouterRule.type.modelProperties, - authorizationServerUri: { - serializedName: "authorizationServerUri", - type: { - name: "String" - } - }, - clientCredential: { - serializedName: "clientCredential", - type: { - name: "Composite", - className: "Oauth2ClientCredential" - } - }, - webhookUri: { - serializedName: "webhookUri", - type: { - name: "String" - } - } - } - } -}; - -export const ConditionalWorkerSelectorAttachment: coreClient.CompositeMapper = { - serializedName: "conditional", - type: { - name: "Composite", - className: "ConditionalWorkerSelectorAttachment", - uberParent: "WorkerSelectorAttachment", - polymorphicDiscriminator: - WorkerSelectorAttachment.type.polymorphicDiscriminator, - modelProperties: { - ...WorkerSelectorAttachment.type.modelProperties, - condition: { - serializedName: "condition", - type: { - name: "Composite", - className: "RouterRule" - } - }, - workerSelectors: { - serializedName: "workerSelectors", - required: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "RouterWorkerSelector" - } - } - } - } - } - } -}; - -export const PassThroughWorkerSelectorAttachment: coreClient.CompositeMapper = { - serializedName: "pass-through", - type: { - name: "Composite", - className: "PassThroughWorkerSelectorAttachment", - uberParent: "WorkerSelectorAttachment", - polymorphicDiscriminator: - WorkerSelectorAttachment.type.polymorphicDiscriminator, - modelProperties: { - ...WorkerSelectorAttachment.type.modelProperties, - key: { - constraints: { - MaxLength: 500 - }, - serializedName: "key", - required: true, - type: { - name: "String" - } - }, - labelOperator: { - serializedName: "labelOperator", - required: true, - type: { - name: "String" - } - }, - expiresAfterSeconds: { - serializedName: "expiresAfterSeconds", - type: { - name: "Number" - } - } - } - } -}; - -export const RuleEngineWorkerSelectorAttachment: coreClient.CompositeMapper = { - serializedName: "rule-engine", - type: { - name: "Composite", - className: "RuleEngineWorkerSelectorAttachment", - uberParent: "WorkerSelectorAttachment", - polymorphicDiscriminator: - WorkerSelectorAttachment.type.polymorphicDiscriminator, - modelProperties: { - ...WorkerSelectorAttachment.type.modelProperties, - rule: { - serializedName: "rule", - type: { - name: "Composite", - className: "RouterRule" - } - } - } - } -}; - -export const StaticWorkerSelectorAttachment: coreClient.CompositeMapper = { - serializedName: "static", - type: { - name: "Composite", - className: "StaticWorkerSelectorAttachment", - uberParent: "WorkerSelectorAttachment", - polymorphicDiscriminator: - WorkerSelectorAttachment.type.polymorphicDiscriminator, - modelProperties: { - ...WorkerSelectorAttachment.type.modelProperties, - workerSelector: { - serializedName: "workerSelector", - type: { - name: "Composite", - className: "RouterWorkerSelector" - } - } - } - } -}; - -export const WeightedAllocationWorkerSelectorAttachment: coreClient.CompositeMapper = { - serializedName: "weighted-allocation-worker-selector", - type: { - name: "Composite", - className: "WeightedAllocationWorkerSelectorAttachment", - uberParent: "WorkerSelectorAttachment", - polymorphicDiscriminator: - WorkerSelectorAttachment.type.polymorphicDiscriminator, - modelProperties: { - ...WorkerSelectorAttachment.type.modelProperties, - allocations: { - serializedName: "allocations", - required: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "WorkerWeightedAllocation" - } - } - } - } - } - } -}; - -export const BestWorkerMode: coreClient.CompositeMapper = { - serializedName: "best-worker", - type: { - name: "Composite", - className: "BestWorkerMode", - uberParent: "DistributionMode", - polymorphicDiscriminator: DistributionMode.type.polymorphicDiscriminator, - modelProperties: { - ...DistributionMode.type.modelProperties, - scoringRule: { - serializedName: "scoringRule", - type: { - name: "Composite", - className: "RouterRule" - } - }, - scoringRuleOptions: { - serializedName: "scoringRuleOptions", - type: { - name: "Composite", - className: "ScoringRuleOptions" - } - } - } - } -}; - -export const LongestIdleMode: coreClient.CompositeMapper = { - serializedName: "longest-idle", - type: { - name: "Composite", - className: "LongestIdleMode", - uberParent: "DistributionMode", - polymorphicDiscriminator: DistributionMode.type.polymorphicDiscriminator, - modelProperties: { - ...DistributionMode.type.modelProperties - } - } -}; - -export const RoundRobinMode: coreClient.CompositeMapper = { - serializedName: "round-robin", - type: { - name: "Composite", - className: "RoundRobinMode", - uberParent: "DistributionMode", - polymorphicDiscriminator: DistributionMode.type.polymorphicDiscriminator, - modelProperties: { - ...DistributionMode.type.modelProperties - } - } -}; - -export const QueueLengthExceptionTrigger: coreClient.CompositeMapper = { - serializedName: "queue-length", - type: { - name: "Composite", - className: "QueueLengthExceptionTrigger", - uberParent: "ExceptionTrigger", - polymorphicDiscriminator: ExceptionTrigger.type.polymorphicDiscriminator, - modelProperties: { - ...ExceptionTrigger.type.modelProperties, - threshold: { - serializedName: "threshold", - required: true, - type: { - name: "Number" - } - } - } - } -}; - -export const WaitTimeExceptionTrigger: coreClient.CompositeMapper = { - serializedName: "wait-time", - type: { - name: "Composite", - className: "WaitTimeExceptionTrigger", - uberParent: "ExceptionTrigger", - polymorphicDiscriminator: ExceptionTrigger.type.polymorphicDiscriminator, - modelProperties: { - ...ExceptionTrigger.type.modelProperties, - thresholdSeconds: { - serializedName: "thresholdSeconds", - required: true, - type: { - name: "Number" - } - } - } - } -}; - -export const CancelExceptionAction: coreClient.CompositeMapper = { - serializedName: "cancel", - type: { - name: "Composite", - className: "CancelExceptionAction", - uberParent: "ExceptionAction", - polymorphicDiscriminator: ExceptionAction.type.polymorphicDiscriminator, - modelProperties: { - ...ExceptionAction.type.modelProperties, - note: { - constraints: { - MaxLength: 2000 - }, - serializedName: "note", - type: { - name: "String" - } - }, - dispositionCode: { - constraints: { - MaxLength: 500 - }, - serializedName: "dispositionCode", - type: { - name: "String" - } - } - } - } -}; - -export const ManualReclassifyExceptionAction: coreClient.CompositeMapper = { - serializedName: "manual-reclassify", - type: { - name: "Composite", - className: "ManualReclassifyExceptionAction", - uberParent: "ExceptionAction", - polymorphicDiscriminator: ExceptionAction.type.polymorphicDiscriminator, - modelProperties: { - ...ExceptionAction.type.modelProperties, - queueId: { - constraints: { - MaxLength: 50 - }, - serializedName: "queueId", - type: { - name: "String" - } - }, - priority: { - serializedName: "priority", - type: { - name: "Number" - } - }, - workerSelectors: { - serializedName: "workerSelectors", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "RouterWorkerSelector" - } - } - } - } - } - } -}; - -export const ReclassifyExceptionAction: coreClient.CompositeMapper = { - serializedName: "reclassify", - type: { - name: "Composite", - className: "ReclassifyExceptionAction", - uberParent: "ExceptionAction", - polymorphicDiscriminator: ExceptionAction.type.polymorphicDiscriminator, - modelProperties: { - ...ExceptionAction.type.modelProperties, - classificationPolicyId: { - constraints: { - MaxLength: 50 - }, - serializedName: "classificationPolicyId", - type: { - name: "String" - } - }, - labelsToUpsert: { - serializedName: "labelsToUpsert", - type: { - name: "Dictionary", - value: { type: { name: "any" } } - } - } - } - } -}; - -export let discriminators = { - QueueSelectorAttachment: QueueSelectorAttachment, - RouterRule: RouterRule, - WorkerSelectorAttachment: WorkerSelectorAttachment, - DistributionMode: DistributionMode, - ExceptionTrigger: ExceptionTrigger, - ExceptionAction: ExceptionAction, - "QueueSelectorAttachment.conditional": ConditionalQueueSelectorAttachment, - "QueueSelectorAttachment.pass-through": PassThroughQueueSelectorAttachment, - "QueueSelectorAttachment.rule-engine": RuleEngineQueueSelectorAttachment, - "QueueSelectorAttachment.static": StaticQueueSelectorAttachment, - "QueueSelectorAttachment.weighted-allocation-queue-selector": WeightedAllocationQueueSelectorAttachment, - "RouterRule.direct-map-rule": DirectMapRouterRule, - "RouterRule.expression-rule": ExpressionRouterRule, - "RouterRule.azure-function-rule": FunctionRouterRule, - "RouterRule.static-rule": StaticRouterRule, - "RouterRule.webhook-rule": WebhookRouterRule, - "WorkerSelectorAttachment.conditional": ConditionalWorkerSelectorAttachment, - "WorkerSelectorAttachment.pass-through": PassThroughWorkerSelectorAttachment, - "WorkerSelectorAttachment.rule-engine": RuleEngineWorkerSelectorAttachment, - "WorkerSelectorAttachment.static": StaticWorkerSelectorAttachment, - "WorkerSelectorAttachment.weighted-allocation-worker-selector": WeightedAllocationWorkerSelectorAttachment, - "DistributionMode.best-worker": BestWorkerMode, - "DistributionMode.longest-idle": LongestIdleMode, - "DistributionMode.round-robin": RoundRobinMode, - "ExceptionTrigger.queue-length": QueueLengthExceptionTrigger, - "ExceptionTrigger.wait-time": WaitTimeExceptionTrigger, - "ExceptionAction.cancel": CancelExceptionAction, - "ExceptionAction.manual-reclassify": ManualReclassifyExceptionAction, - "ExceptionAction.reclassify": ReclassifyExceptionAction -}; diff --git a/sdk/communication/communication-job-router/src/generated/src/models/parameters.ts b/sdk/communication/communication-job-router/src/generated/src/models/parameters.ts deleted file mode 100644 index ff90c63678a2..000000000000 --- a/sdk/communication/communication-job-router/src/generated/src/models/parameters.ts +++ /dev/null @@ -1,324 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { - OperationParameter, - OperationURLParameter, - OperationQueryParameter -} from "@azure/core-client"; -import { - ClassificationPolicy as ClassificationPolicyMapper, - DistributionPolicy as DistributionPolicyMapper, - ExceptionPolicy as ExceptionPolicyMapper, - RouterQueue as RouterQueueMapper, - RouterJob as RouterJobMapper, - CancelJobRequest as CancelJobRequestMapper, - CompleteJobRequest as CompleteJobRequestMapper, - CloseJobRequest as CloseJobRequestMapper, - UnassignJobRequest as UnassignJobRequestMapper, - DeclineJobOfferRequest as DeclineJobOfferRequestMapper, - RouterWorker as RouterWorkerMapper -} from "../models/mappers"; - -export const contentType: OperationParameter = { - parameterPath: ["options", "contentType"], - mapper: { - defaultValue: "application/merge-patch+json", - isConstant: true, - serializedName: "Content-Type", - type: { - name: "String" - } - } -}; - -export const patch: OperationParameter = { - parameterPath: "patch", - mapper: ClassificationPolicyMapper -}; - -export const accept: OperationParameter = { - parameterPath: "accept", - mapper: { - defaultValue: "application/json", - isConstant: true, - serializedName: "Accept", - type: { - name: "String" - } - } -}; - -export const endpoint: OperationURLParameter = { - parameterPath: "endpoint", - mapper: { - serializedName: "endpoint", - required: true, - type: { - name: "String" - } - }, - skipEncoding: true -}; - -export const id: OperationURLParameter = { - parameterPath: "id", - mapper: { - serializedName: "id", - required: true, - type: { - name: "String" - } - } -}; - -export const apiVersion: OperationQueryParameter = { - parameterPath: "apiVersion", - mapper: { - defaultValue: "2022-07-18-preview", - isConstant: true, - serializedName: "api-version", - type: { - name: "String" - } - } -}; - -export const maxpagesize: OperationQueryParameter = { - parameterPath: ["options", "maxpagesize"], - mapper: { - serializedName: "maxpagesize", - type: { - name: "Number" - } - } -}; - -export const patch1: OperationParameter = { - parameterPath: "patch", - mapper: DistributionPolicyMapper -}; - -export const patch2: OperationParameter = { - parameterPath: "patch", - mapper: ExceptionPolicyMapper -}; - -export const patch3: OperationParameter = { - parameterPath: "patch", - mapper: RouterQueueMapper -}; - -export const nextLink: OperationURLParameter = { - parameterPath: "nextLink", - mapper: { - serializedName: "nextLink", - required: true, - type: { - name: "String" - } - }, - skipEncoding: true -}; - -export const patch4: OperationParameter = { - parameterPath: "patch", - mapper: RouterJobMapper -}; - -export const contentType1: OperationParameter = { - parameterPath: ["options", "contentType"], - mapper: { - defaultValue: "application/json", - isConstant: true, - serializedName: "Content-Type", - type: { - name: "String" - } - } -}; - -export const reclassifyJobRequest: OperationParameter = { - parameterPath: ["options", "reclassifyJobRequest"], - mapper: { - serializedName: "reclassifyJobRequest", - type: { - name: "any" - } - } -}; - -export const note: OperationParameter = { - parameterPath: ["options", "note"], - mapper: CancelJobRequestMapper -}; - -export const dispositionCode: OperationParameter = { - parameterPath: ["options", "dispositionCode"], - mapper: CancelJobRequestMapper -}; - -export const assignmentId: OperationParameter = { - parameterPath: "assignmentId", - mapper: CompleteJobRequestMapper -}; - -export const note1: OperationParameter = { - parameterPath: ["options", "note"], - mapper: CompleteJobRequestMapper -}; - -export const assignmentId1: OperationParameter = { - parameterPath: "assignmentId", - mapper: CloseJobRequestMapper -}; - -export const dispositionCode1: OperationParameter = { - parameterPath: ["options", "dispositionCode"], - mapper: CloseJobRequestMapper -}; - -export const closeAt: OperationParameter = { - parameterPath: ["options", "closeAt"], - mapper: CloseJobRequestMapper -}; - -export const note2: OperationParameter = { - parameterPath: ["options", "note"], - mapper: CloseJobRequestMapper -}; - -export const status: OperationQueryParameter = { - parameterPath: ["options", "status"], - mapper: { - defaultValue: "all", - serializedName: "status", - type: { - name: "String" - } - } -}; - -export const queueId: OperationQueryParameter = { - parameterPath: ["options", "queueId"], - mapper: { - serializedName: "queueId", - type: { - name: "String" - } - } -}; - -export const channelId: OperationQueryParameter = { - parameterPath: ["options", "channelId"], - mapper: { - serializedName: "channelId", - type: { - name: "String" - } - } -}; - -export const classificationPolicyId: OperationQueryParameter = { - parameterPath: ["options", "classificationPolicyId"], - mapper: { - serializedName: "classificationPolicyId", - type: { - name: "String" - } - } -}; - -export const scheduledBefore: OperationQueryParameter = { - parameterPath: ["options", "scheduledBefore"], - mapper: { - serializedName: "scheduledBefore", - type: { - name: "DateTime" - } - } -}; - -export const scheduledAfter: OperationQueryParameter = { - parameterPath: ["options", "scheduledAfter"], - mapper: { - serializedName: "scheduledAfter", - type: { - name: "DateTime" - } - } -}; - -export const unassignJobRequest: OperationParameter = { - parameterPath: ["options", "unassignJobRequest"], - mapper: UnassignJobRequestMapper -}; - -export const assignmentId2: OperationURLParameter = { - parameterPath: "assignmentId", - mapper: { - serializedName: "assignmentId", - required: true, - type: { - name: "String" - } - } -}; - -export const workerId: OperationURLParameter = { - parameterPath: "workerId", - mapper: { - serializedName: "workerId", - required: true, - type: { - name: "String" - } - } -}; - -export const offerId: OperationURLParameter = { - parameterPath: "offerId", - mapper: { - serializedName: "offerId", - required: true, - type: { - name: "String" - } - } -}; - -export const declineJobOfferRequest: OperationParameter = { - parameterPath: ["options", "declineJobOfferRequest"], - mapper: DeclineJobOfferRequestMapper -}; - -export const patch5: OperationParameter = { - parameterPath: "patch", - mapper: RouterWorkerMapper -}; - -export const state: OperationQueryParameter = { - parameterPath: ["options", "state"], - mapper: { - defaultValue: "all", - serializedName: "state", - type: { - name: "String" - } - } -}; - -export const hasCapacity: OperationQueryParameter = { - parameterPath: ["options", "hasCapacity"], - mapper: { - serializedName: "hasCapacity", - type: { - name: "Boolean" - } - } -}; diff --git a/sdk/communication/communication-job-router/src/generated/src/operations/index.ts b/sdk/communication/communication-job-router/src/generated/src/operations/index.ts deleted file mode 100644 index 86c3dbb3e1bb..000000000000 --- a/sdk/communication/communication-job-router/src/generated/src/operations/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export * from "./jobRouterAdministration"; -export * from "./jobRouter"; diff --git a/sdk/communication/communication-job-router/src/generated/src/operations/jobRouter.ts b/sdk/communication/communication-job-router/src/generated/src/operations/jobRouter.ts deleted file mode 100644 index a4786cec7af6..000000000000 --- a/sdk/communication/communication-job-router/src/generated/src/operations/jobRouter.ts +++ /dev/null @@ -1,954 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { tracingClient } from "../tracing"; -import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; -import { setContinuationToken } from "../pagingHelper"; -import { JobRouter } from "../operationsInterfaces"; -import * as coreClient from "@azure/core-client"; -import * as Mappers from "../models/mappers"; -import * as Parameters from "../models/parameters"; -import { JobRouterApiClient } from "../jobRouterApiClient"; -import { - RouterJobItem, - JobRouterListJobsNextOptionalParams, - JobRouterListJobsOptionalParams, - JobRouterListJobsResponse, - RouterWorkerItem, - JobRouterListWorkersNextOptionalParams, - JobRouterListWorkersOptionalParams, - JobRouterListWorkersResponse, - RouterJob, - JobRouterUpsertJobOptionalParams, - JobRouterUpsertJobResponse, - JobRouterGetJobOptionalParams, - JobRouterGetJobResponse, - JobRouterDeleteJobOptionalParams, - JobRouterReclassifyJobActionOptionalParams, - JobRouterReclassifyJobActionResponse, - JobRouterCancelJobActionOptionalParams, - JobRouterCancelJobActionResponse, - JobRouterCompleteJobActionOptionalParams, - JobRouterCompleteJobActionResponse, - JobRouterCloseJobActionOptionalParams, - JobRouterCloseJobActionResponse, - JobRouterGetInQueuePositionOptionalParams, - JobRouterGetInQueuePositionResponse, - JobRouterUnassignJobActionOptionalParams, - JobRouterUnassignJobActionResponse, - JobRouterAcceptJobActionOptionalParams, - JobRouterAcceptJobActionResponse, - JobRouterDeclineJobActionOptionalParams, - JobRouterDeclineJobActionResponse, - JobRouterGetQueueStatisticsOptionalParams, - JobRouterGetQueueStatisticsResponse, - RouterWorker, - JobRouterUpsertWorkerOptionalParams, - JobRouterUpsertWorkerResponse, - JobRouterGetWorkerOptionalParams, - JobRouterGetWorkerResponse, - JobRouterDeleteWorkerOptionalParams, - JobRouterListJobsNextResponse, - JobRouterListWorkersNextResponse -} from "../models"; - -/// -/** Class containing JobRouter operations. */ -export class JobRouterImpl implements JobRouter { - private readonly client: JobRouterApiClient; - - /** - * Initialize a new instance of the class JobRouter class. - * @param client Reference to the service client - */ - constructor(client: JobRouterApiClient) { - this.client = client; - } - - /** - * Retrieves list of jobs based on filter parameters - * @param options The options parameters. - */ - public listJobs( - options?: JobRouterListJobsOptionalParams - ): PagedAsyncIterableIterator { - const iter = this.listJobsPagingAll(options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listJobsPagingPage(options, settings); - } - }; - } - - private async *listJobsPagingPage( - options?: JobRouterListJobsOptionalParams, - settings?: PageSettings - ): AsyncIterableIterator { - let result: JobRouterListJobsResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._listJobs(options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listJobsNext(continuationToken, options); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listJobsPagingAll( - options?: JobRouterListJobsOptionalParams - ): AsyncIterableIterator { - for await (const page of this.listJobsPagingPage(options)) { - yield* page; - } - } - - /** - * Retrieves existing workers. - * @param options The options parameters. - */ - public listWorkers( - options?: JobRouterListWorkersOptionalParams - ): PagedAsyncIterableIterator { - const iter = this.listWorkersPagingAll(options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listWorkersPagingPage(options, settings); - } - }; - } - - private async *listWorkersPagingPage( - options?: JobRouterListWorkersOptionalParams, - settings?: PageSettings - ): AsyncIterableIterator { - let result: JobRouterListWorkersResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._listWorkers(options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listWorkersNext(continuationToken, options); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listWorkersPagingAll( - options?: JobRouterListWorkersOptionalParams - ): AsyncIterableIterator { - for await (const page of this.listWorkersPagingPage(options)) { - yield* page; - } - } - - /** - * Creates or updates a router job. - * @param id Id of the job. - * @param patch Model of job properties to be created or patched. See also: - * https://datatracker.ietf.org/doc/html/rfc7386. - * @param options The options parameters. - */ - async upsertJob( - id: string, - patch: RouterJob, - options?: JobRouterUpsertJobOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.upsertJob", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, patch, options }, - upsertJobOperationSpec - ) as Promise; - } - ); - } - - /** - * Retrieves an existing job by Id - * @param id Id of the job to retrieve - * @param options The options parameters. - */ - async getJob( - id: string, - options?: JobRouterGetJobOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.getJob", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, options }, - getJobOperationSpec - ) as Promise; - } - ); - } - - /** - * Deletes a job and all of its traces. - * @param id Id of the job - * @param options The options parameters. - */ - async deleteJob( - id: string, - options?: JobRouterDeleteJobOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.deleteJob", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, options }, - deleteJobOperationSpec - ) as Promise; - } - ); - } - - /** - * Reclassify a job. - * @param id Id of the job - * @param options The options parameters. - */ - async reclassifyJobAction( - id: string, - options?: JobRouterReclassifyJobActionOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.reclassifyJobAction", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, options }, - reclassifyJobActionOperationSpec - ) as Promise; - } - ); - } - - /** - * Submits request to cancel an existing job by Id while supplying free-form cancellation reason. - * @param id Id of the job - * @param options The options parameters. - */ - async cancelJobAction( - id: string, - options?: JobRouterCancelJobActionOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.cancelJobAction", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, options }, - cancelJobActionOperationSpec - ) as Promise; - } - ); - } - - /** - * Completes an assigned job. - * @param id Id of the job - * @param assignmentId The assignment within the job to complete. - * @param options The options parameters. - */ - async completeJobAction( - id: string, - assignmentId: string, - options?: JobRouterCompleteJobActionOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.completeJobAction", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, assignmentId, options }, - completeJobActionOperationSpec - ) as Promise; - } - ); - } - - /** - * Closes a completed job. - * @param id Id of the job - * @param assignmentId The assignment within which the job is to be closed. - * @param options The options parameters. - */ - async closeJobAction( - id: string, - assignmentId: string, - options?: JobRouterCloseJobActionOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.closeJobAction", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, assignmentId, options }, - closeJobActionOperationSpec - ) as Promise; - } - ); - } - - /** - * Retrieves list of jobs based on filter parameters - * @param options The options parameters. - */ - private async _listJobs( - options?: JobRouterListJobsOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient._listJobs", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { options }, - listJobsOperationSpec - ) as Promise; - } - ); - } - - /** - * Gets a job's position details. - * @param id Id of the job - * @param options The options parameters. - */ - async getInQueuePosition( - id: string, - options?: JobRouterGetInQueuePositionOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.getInQueuePosition", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, options }, - getInQueuePositionOperationSpec - ) as Promise; - } - ); - } - - /** - * Un-assign a job. - * @param id Id of the job to un-assign - * @param assignmentId Id of the assignment to un-assign - * @param options The options parameters. - */ - async unassignJobAction( - id: string, - assignmentId: string, - options?: JobRouterUnassignJobActionOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.unassignJobAction", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, assignmentId, options }, - unassignJobActionOperationSpec - ) as Promise; - } - ); - } - - /** - * Accepts an offer to work on a job and returns a 409/Conflict if another agent accepted the job - * already. - * @param workerId Id of the worker - * @param offerId Id of the offer - * @param options The options parameters. - */ - async acceptJobAction( - workerId: string, - offerId: string, - options?: JobRouterAcceptJobActionOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.acceptJobAction", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { workerId, offerId, options }, - acceptJobActionOperationSpec - ) as Promise; - } - ); - } - - /** - * Declines an offer to work on a job. - * @param workerId Id of the worker - * @param offerId Id of the offer - * @param options The options parameters. - */ - async declineJobAction( - workerId: string, - offerId: string, - options?: JobRouterDeclineJobActionOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.declineJobAction", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { workerId, offerId, options }, - declineJobActionOperationSpec - ) as Promise; - } - ); - } - - /** - * Retrieves a queue's statistics - * @param id Id of the queue to retrieve statistics - * @param options The options parameters. - */ - async getQueueStatistics( - id: string, - options?: JobRouterGetQueueStatisticsOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.getQueueStatistics", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, options }, - getQueueStatisticsOperationSpec - ) as Promise; - } - ); - } - - /** - * Creates or updates a worker. - * @param workerId Id of the worker - * @param patch Model of worker properties to be created or patched. See also: - * https://datatracker.ietf.org/doc/html/rfc7386 - * @param options The options parameters. - */ - async upsertWorker( - workerId: string, - patch: RouterWorker, - options?: JobRouterUpsertWorkerOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.upsertWorker", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { workerId, patch, options }, - upsertWorkerOperationSpec - ) as Promise; - } - ); - } - - /** - * Retrieves an existing worker by Id - * @param workerId Id of the worker to retrieve - * @param options The options parameters. - */ - async getWorker( - workerId: string, - options?: JobRouterGetWorkerOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.getWorker", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { workerId, options }, - getWorkerOperationSpec - ) as Promise; - } - ); - } - - /** - * Deletes a worker and all of its traces. - * @param workerId Id of the worker to delete - * @param options The options parameters. - */ - async deleteWorker( - workerId: string, - options?: JobRouterDeleteWorkerOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.deleteWorker", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { workerId, options }, - deleteWorkerOperationSpec - ) as Promise; - } - ); - } - - /** - * Retrieves existing workers. - * @param options The options parameters. - */ - private async _listWorkers( - options?: JobRouterListWorkersOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient._listWorkers", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { options }, - listWorkersOperationSpec - ) as Promise; - } - ); - } - - /** - * ListJobsNext - * @param nextLink The nextLink from the previous successful call to the ListJobs method. - * @param options The options parameters. - */ - private async _listJobsNext( - nextLink: string, - options?: JobRouterListJobsNextOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient._listJobsNext", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { nextLink, options }, - listJobsNextOperationSpec - ) as Promise; - } - ); - } - - /** - * ListWorkersNext - * @param nextLink The nextLink from the previous successful call to the ListWorkers method. - * @param options The options parameters. - */ - private async _listWorkersNext( - nextLink: string, - options?: JobRouterListWorkersNextOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient._listWorkersNext", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { nextLink, options }, - listWorkersNextOperationSpec - ) as Promise; - } - ); - } -} -// Operation Specifications -const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); - -const upsertJobOperationSpec: coreClient.OperationSpec = { - path: "/routing/jobs/{id}", - httpMethod: "PATCH", - responses: { - 200: { - bodyMapper: Mappers.RouterJob - }, - 201: { - bodyMapper: Mappers.RouterJob - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - requestBody: Parameters.patch4, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer -}; -const getJobOperationSpec: coreClient.OperationSpec = { - path: "/routing/jobs/{id}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.RouterJob - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.accept], - serializer -}; -const deleteJobOperationSpec: coreClient.OperationSpec = { - path: "/routing/jobs/{id}", - httpMethod: "DELETE", - responses: { - 204: {}, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.accept], - serializer -}; -const reclassifyJobActionOperationSpec: coreClient.OperationSpec = { - path: "/routing/jobs/{id}:reclassify", - httpMethod: "POST", - responses: { - 200: { - bodyMapper: { type: { name: "any" } } - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - requestBody: Parameters.reclassifyJobRequest, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.accept, Parameters.contentType1], - mediaType: "json", - serializer -}; -const cancelJobActionOperationSpec: coreClient.OperationSpec = { - path: "/routing/jobs/{id}:cancel", - httpMethod: "POST", - responses: { - 200: { - bodyMapper: { type: { name: "any" } } - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - requestBody: { - parameterPath: { - note: ["options", "note"], - dispositionCode: ["options", "dispositionCode"] - }, - mapper: Mappers.CancelJobRequest - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.accept, Parameters.contentType1], - mediaType: "json", - serializer -}; -const completeJobActionOperationSpec: coreClient.OperationSpec = { - path: "/routing/jobs/{id}:complete", - httpMethod: "POST", - responses: { - 200: { - bodyMapper: { type: { name: "any" } } - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - requestBody: { - parameterPath: { - assignmentId: ["assignmentId"], - note: ["options", "note"] - }, - mapper: { ...Mappers.CompleteJobRequest, required: true } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.accept, Parameters.contentType1], - mediaType: "json", - serializer -}; -const closeJobActionOperationSpec: coreClient.OperationSpec = { - path: "/routing/jobs/{id}:close", - httpMethod: "POST", - responses: { - 200: { - bodyMapper: { type: { name: "any" } } - }, - 202: { - bodyMapper: { type: { name: "any" } } - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - requestBody: { - parameterPath: { - assignmentId: ["assignmentId"], - dispositionCode: ["options", "dispositionCode"], - closeAt: ["options", "closeAt"], - note: ["options", "note"] - }, - mapper: { ...Mappers.CloseJobRequest, required: true } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.accept, Parameters.contentType1], - mediaType: "json", - serializer -}; -const listJobsOperationSpec: coreClient.OperationSpec = { - path: "/routing/jobs", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.RouterJobCollection - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [ - Parameters.apiVersion, - Parameters.maxpagesize, - Parameters.status, - Parameters.queueId, - Parameters.channelId, - Parameters.classificationPolicyId, - Parameters.scheduledBefore, - Parameters.scheduledAfter - ], - urlParameters: [Parameters.endpoint], - headerParameters: [Parameters.accept], - serializer -}; -const getInQueuePositionOperationSpec: coreClient.OperationSpec = { - path: "/routing/jobs/{id}/position", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.RouterJobPositionDetails - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.accept], - serializer -}; -const unassignJobActionOperationSpec: coreClient.OperationSpec = { - path: "/routing/jobs/{id}/assignments/{assignmentId}:unassign", - httpMethod: "POST", - responses: { - 200: { - bodyMapper: Mappers.UnassignJobResult - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - requestBody: Parameters.unassignJobRequest, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id, Parameters.assignmentId2], - headerParameters: [Parameters.accept, Parameters.contentType1], - mediaType: "json", - serializer -}; -const acceptJobActionOperationSpec: coreClient.OperationSpec = { - path: "/routing/workers/{workerId}/offers/{offerId}:accept", - httpMethod: "POST", - responses: { - 200: { - bodyMapper: Mappers.AcceptJobOfferResult - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.workerId, Parameters.offerId], - headerParameters: [Parameters.accept], - serializer -}; -const declineJobActionOperationSpec: coreClient.OperationSpec = { - path: "/routing/workers/{workerId}/offers/{offerId}:decline", - httpMethod: "POST", - responses: { - 200: { - bodyMapper: { type: { name: "any" } } - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - requestBody: Parameters.declineJobOfferRequest, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.workerId, Parameters.offerId], - headerParameters: [Parameters.accept, Parameters.contentType1], - mediaType: "json", - serializer -}; -const getQueueStatisticsOperationSpec: coreClient.OperationSpec = { - path: "/routing/queues/{id}/statistics", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.RouterQueueStatistics - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.accept], - serializer -}; -const upsertWorkerOperationSpec: coreClient.OperationSpec = { - path: "/routing/workers/{workerId}", - httpMethod: "PATCH", - responses: { - 200: { - bodyMapper: Mappers.RouterWorker - }, - 201: { - bodyMapper: Mappers.RouterWorker - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - requestBody: Parameters.patch5, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.workerId], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer -}; -const getWorkerOperationSpec: coreClient.OperationSpec = { - path: "/routing/workers/{workerId}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.RouterWorker - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.workerId], - headerParameters: [Parameters.accept], - serializer -}; -const deleteWorkerOperationSpec: coreClient.OperationSpec = { - path: "/routing/workers/{workerId}", - httpMethod: "DELETE", - responses: { - 204: {}, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.workerId], - headerParameters: [Parameters.accept], - serializer -}; -const listWorkersOperationSpec: coreClient.OperationSpec = { - path: "/routing/workers", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.RouterWorkerCollection - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [ - Parameters.apiVersion, - Parameters.maxpagesize, - Parameters.queueId, - Parameters.channelId, - Parameters.state, - Parameters.hasCapacity - ], - urlParameters: [Parameters.endpoint], - headerParameters: [Parameters.accept], - serializer -}; -const listJobsNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.RouterJobCollection - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - urlParameters: [Parameters.endpoint, Parameters.nextLink], - headerParameters: [Parameters.accept], - serializer -}; -const listWorkersNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.RouterWorkerCollection - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - urlParameters: [Parameters.endpoint, Parameters.nextLink], - headerParameters: [Parameters.accept], - serializer -}; diff --git a/sdk/communication/communication-job-router/src/generated/src/operations/jobRouterAdministration.ts b/sdk/communication/communication-job-router/src/generated/src/operations/jobRouterAdministration.ts deleted file mode 100644 index 99aa87ef7ed8..000000000000 --- a/sdk/communication/communication-job-router/src/generated/src/operations/jobRouterAdministration.ts +++ /dev/null @@ -1,1064 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { tracingClient } from "../tracing"; -import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; -import { setContinuationToken } from "../pagingHelper"; -import { JobRouterAdministration } from "../operationsInterfaces"; -import * as coreClient from "@azure/core-client"; -import * as Mappers from "../models/mappers"; -import * as Parameters from "../models/parameters"; -import { JobRouterApiClient } from "../jobRouterApiClient"; -import { - ClassificationPolicyItem, - JobRouterAdministrationListClassificationPoliciesNextOptionalParams, - JobRouterAdministrationListClassificationPoliciesOptionalParams, - JobRouterAdministrationListClassificationPoliciesResponse, - DistributionPolicyItem, - JobRouterAdministrationListDistributionPoliciesNextOptionalParams, - JobRouterAdministrationListDistributionPoliciesOptionalParams, - JobRouterAdministrationListDistributionPoliciesResponse, - ExceptionPolicyItem, - JobRouterAdministrationListExceptionPoliciesNextOptionalParams, - JobRouterAdministrationListExceptionPoliciesOptionalParams, - JobRouterAdministrationListExceptionPoliciesResponse, - RouterQueueItem, - JobRouterAdministrationListQueuesNextOptionalParams, - JobRouterAdministrationListQueuesOptionalParams, - JobRouterAdministrationListQueuesResponse, - ClassificationPolicy, - JobRouterAdministrationUpsertClassificationPolicyOptionalParams, - JobRouterAdministrationUpsertClassificationPolicyResponse, - JobRouterAdministrationGetClassificationPolicyOptionalParams, - JobRouterAdministrationGetClassificationPolicyResponse, - JobRouterAdministrationDeleteClassificationPolicyOptionalParams, - DistributionPolicy, - JobRouterAdministrationUpsertDistributionPolicyOptionalParams, - JobRouterAdministrationUpsertDistributionPolicyResponse, - JobRouterAdministrationGetDistributionPolicyOptionalParams, - JobRouterAdministrationGetDistributionPolicyResponse, - JobRouterAdministrationDeleteDistributionPolicyOptionalParams, - ExceptionPolicy, - JobRouterAdministrationUpsertExceptionPolicyOptionalParams, - JobRouterAdministrationUpsertExceptionPolicyResponse, - JobRouterAdministrationGetExceptionPolicyOptionalParams, - JobRouterAdministrationGetExceptionPolicyResponse, - JobRouterAdministrationDeleteExceptionPolicyOptionalParams, - RouterQueue, - JobRouterAdministrationUpsertQueueOptionalParams, - JobRouterAdministrationUpsertQueueResponse, - JobRouterAdministrationGetQueueOptionalParams, - JobRouterAdministrationGetQueueResponse, - JobRouterAdministrationDeleteQueueOptionalParams, - JobRouterAdministrationListClassificationPoliciesNextResponse, - JobRouterAdministrationListDistributionPoliciesNextResponse, - JobRouterAdministrationListExceptionPoliciesNextResponse, - JobRouterAdministrationListQueuesNextResponse -} from "../models"; - -/// -/** Class containing JobRouterAdministration operations. */ -export class JobRouterAdministrationImpl implements JobRouterAdministration { - private readonly client: JobRouterApiClient; - - /** - * Initialize a new instance of the class JobRouterAdministration class. - * @param client Reference to the service client - */ - constructor(client: JobRouterApiClient) { - this.client = client; - } - - /** - * Retrieves existing classification policies - * @param options The options parameters. - */ - public listClassificationPolicies( - options?: JobRouterAdministrationListClassificationPoliciesOptionalParams - ): PagedAsyncIterableIterator { - const iter = this.listClassificationPoliciesPagingAll(options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listClassificationPoliciesPagingPage(options, settings); - } - }; - } - - private async *listClassificationPoliciesPagingPage( - options?: JobRouterAdministrationListClassificationPoliciesOptionalParams, - settings?: PageSettings - ): AsyncIterableIterator { - let result: JobRouterAdministrationListClassificationPoliciesResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._listClassificationPolicies(options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listClassificationPoliciesNext( - continuationToken, - options - ); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listClassificationPoliciesPagingAll( - options?: JobRouterAdministrationListClassificationPoliciesOptionalParams - ): AsyncIterableIterator { - for await (const page of this.listClassificationPoliciesPagingPage( - options - )) { - yield* page; - } - } - - /** - * Retrieves existing distribution policies - * @param options The options parameters. - */ - public listDistributionPolicies( - options?: JobRouterAdministrationListDistributionPoliciesOptionalParams - ): PagedAsyncIterableIterator { - const iter = this.listDistributionPoliciesPagingAll(options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listDistributionPoliciesPagingPage(options, settings); - } - }; - } - - private async *listDistributionPoliciesPagingPage( - options?: JobRouterAdministrationListDistributionPoliciesOptionalParams, - settings?: PageSettings - ): AsyncIterableIterator { - let result: JobRouterAdministrationListDistributionPoliciesResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._listDistributionPolicies(options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listDistributionPoliciesNext( - continuationToken, - options - ); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listDistributionPoliciesPagingAll( - options?: JobRouterAdministrationListDistributionPoliciesOptionalParams - ): AsyncIterableIterator { - for await (const page of this.listDistributionPoliciesPagingPage(options)) { - yield* page; - } - } - - /** - * Retrieves existing exception policies - * @param options The options parameters. - */ - public listExceptionPolicies( - options?: JobRouterAdministrationListExceptionPoliciesOptionalParams - ): PagedAsyncIterableIterator { - const iter = this.listExceptionPoliciesPagingAll(options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listExceptionPoliciesPagingPage(options, settings); - } - }; - } - - private async *listExceptionPoliciesPagingPage( - options?: JobRouterAdministrationListExceptionPoliciesOptionalParams, - settings?: PageSettings - ): AsyncIterableIterator { - let result: JobRouterAdministrationListExceptionPoliciesResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._listExceptionPolicies(options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listExceptionPoliciesNext( - continuationToken, - options - ); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listExceptionPoliciesPagingAll( - options?: JobRouterAdministrationListExceptionPoliciesOptionalParams - ): AsyncIterableIterator { - for await (const page of this.listExceptionPoliciesPagingPage(options)) { - yield* page; - } - } - - /** - * Retrieves existing queues - * @param options The options parameters. - */ - public listQueues( - options?: JobRouterAdministrationListQueuesOptionalParams - ): PagedAsyncIterableIterator { - const iter = this.listQueuesPagingAll(options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listQueuesPagingPage(options, settings); - } - }; - } - - private async *listQueuesPagingPage( - options?: JobRouterAdministrationListQueuesOptionalParams, - settings?: PageSettings - ): AsyncIterableIterator { - let result: JobRouterAdministrationListQueuesResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._listQueues(options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listQueuesNext(continuationToken, options); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listQueuesPagingAll( - options?: JobRouterAdministrationListQueuesOptionalParams - ): AsyncIterableIterator { - for await (const page of this.listQueuesPagingPage(options)) { - yield* page; - } - } - - /** - * Creates or updates a classification policy. - * @param id Id of the classification policy - * @param patch Model of classification policy properties to be patched. See also: - * https://datatracker.ietf.org/doc/html/rfc7386 - * @param options The options parameters. - */ - async upsertClassificationPolicy( - id: string, - patch: ClassificationPolicy, - options?: JobRouterAdministrationUpsertClassificationPolicyOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.upsertClassificationPolicy", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, patch, options }, - upsertClassificationPolicyOperationSpec - ) as Promise; - } - ); - } - - /** - * Retrieves an existing classification policy by Id - * @param id Id of the classification policy - * @param options The options parameters. - */ - async getClassificationPolicy( - id: string, - options?: JobRouterAdministrationGetClassificationPolicyOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.getClassificationPolicy", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, options }, - getClassificationPolicyOperationSpec - ) as Promise; - } - ); - } - - /** - * Delete a classification policy by Id - * @param id Id of the classification policy - * @param options The options parameters. - */ - async deleteClassificationPolicy( - id: string, - options?: JobRouterAdministrationDeleteClassificationPolicyOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.deleteClassificationPolicy", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, options }, - deleteClassificationPolicyOperationSpec - ) as Promise; - } - ); - } - - /** - * Retrieves existing classification policies - * @param options The options parameters. - */ - private async _listClassificationPolicies( - options?: JobRouterAdministrationListClassificationPoliciesOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient._listClassificationPolicies", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { options }, - listClassificationPoliciesOperationSpec - ) as Promise; - } - ); - } - - /** - * Creates or updates a distribution policy. - * @param id Id of the distribution policy - * @param patch Model of distribution policy properties to be patched. See also: - * https://datatracker.ietf.org/doc/html/rfc7386 - * @param options The options parameters. - */ - async upsertDistributionPolicy( - id: string, - patch: DistributionPolicy, - options?: JobRouterAdministrationUpsertDistributionPolicyOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.upsertDistributionPolicy", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, patch, options }, - upsertDistributionPolicyOperationSpec - ) as Promise; - } - ); - } - - /** - * Retrieves an existing distribution policy by Id - * @param id Id of the distribution policy - * @param options The options parameters. - */ - async getDistributionPolicy( - id: string, - options?: JobRouterAdministrationGetDistributionPolicyOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.getDistributionPolicy", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, options }, - getDistributionPolicyOperationSpec - ) as Promise; - } - ); - } - - /** - * Delete a distribution policy by Id - * @param id Id of the distribution policy - * @param options The options parameters. - */ - async deleteDistributionPolicy( - id: string, - options?: JobRouterAdministrationDeleteDistributionPolicyOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.deleteDistributionPolicy", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, options }, - deleteDistributionPolicyOperationSpec - ) as Promise; - } - ); - } - - /** - * Retrieves existing distribution policies - * @param options The options parameters. - */ - private async _listDistributionPolicies( - options?: JobRouterAdministrationListDistributionPoliciesOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient._listDistributionPolicies", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { options }, - listDistributionPoliciesOperationSpec - ) as Promise; - } - ); - } - - /** - * Creates or updates a exception policy. - * @param id Id of the exception policy - * @param patch Model of exception policy properties to be patched. See also: - * https://datatracker.ietf.org/doc/html/rfc7386 - * @param options The options parameters. - */ - async upsertExceptionPolicy( - id: string, - patch: ExceptionPolicy, - options?: JobRouterAdministrationUpsertExceptionPolicyOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.upsertExceptionPolicy", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, patch, options }, - upsertExceptionPolicyOperationSpec - ) as Promise; - } - ); - } - - /** - * Retrieves an existing exception policy by Id - * @param id Id of the exception policy to retrieve - * @param options The options parameters. - */ - async getExceptionPolicy( - id: string, - options?: JobRouterAdministrationGetExceptionPolicyOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.getExceptionPolicy", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, options }, - getExceptionPolicyOperationSpec - ) as Promise; - } - ); - } - - /** - * Deletes a exception policy by Id - * @param id Id of the exception policy to delete - * @param options The options parameters. - */ - async deleteExceptionPolicy( - id: string, - options?: JobRouterAdministrationDeleteExceptionPolicyOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.deleteExceptionPolicy", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, options }, - deleteExceptionPolicyOperationSpec - ) as Promise; - } - ); - } - - /** - * Retrieves existing exception policies - * @param options The options parameters. - */ - private async _listExceptionPolicies( - options?: JobRouterAdministrationListExceptionPoliciesOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient._listExceptionPolicies", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { options }, - listExceptionPoliciesOperationSpec - ) as Promise; - } - ); - } - - /** - * Creates or updates a queue. - * @param id Id of the queue - * @param patch Model of queue properties to be patched. See also: - * https://datatracker.ietf.org/doc/html/rfc7386 - * @param options The options parameters. - */ - async upsertQueue( - id: string, - patch: RouterQueue, - options?: JobRouterAdministrationUpsertQueueOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.upsertQueue", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, patch, options }, - upsertQueueOperationSpec - ) as Promise; - } - ); - } - - /** - * Retrieves an existing queue by Id - * @param id Id of the queue to retrieve - * @param options The options parameters. - */ - async getQueue( - id: string, - options?: JobRouterAdministrationGetQueueOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.getQueue", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, options }, - getQueueOperationSpec - ) as Promise; - } - ); - } - - /** - * Deletes a queue by Id - * @param id Id of the queue to delete - * @param options The options parameters. - */ - async deleteQueue( - id: string, - options?: JobRouterAdministrationDeleteQueueOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient.deleteQueue", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { id, options }, - deleteQueueOperationSpec - ) as Promise; - } - ); - } - - /** - * Retrieves existing queues - * @param options The options parameters. - */ - private async _listQueues( - options?: JobRouterAdministrationListQueuesOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient._listQueues", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { options }, - listQueuesOperationSpec - ) as Promise; - } - ); - } - - /** - * ListClassificationPoliciesNext - * @param nextLink The nextLink from the previous successful call to the ListClassificationPolicies - * method. - * @param options The options parameters. - */ - private async _listClassificationPoliciesNext( - nextLink: string, - options?: JobRouterAdministrationListClassificationPoliciesNextOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient._listClassificationPoliciesNext", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { nextLink, options }, - listClassificationPoliciesNextOperationSpec - ) as Promise< - JobRouterAdministrationListClassificationPoliciesNextResponse - >; - } - ); - } - - /** - * ListDistributionPoliciesNext - * @param nextLink The nextLink from the previous successful call to the ListDistributionPolicies - * method. - * @param options The options parameters. - */ - private async _listDistributionPoliciesNext( - nextLink: string, - options?: JobRouterAdministrationListDistributionPoliciesNextOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient._listDistributionPoliciesNext", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { nextLink, options }, - listDistributionPoliciesNextOperationSpec - ) as Promise< - JobRouterAdministrationListDistributionPoliciesNextResponse - >; - } - ); - } - - /** - * ListExceptionPoliciesNext - * @param nextLink The nextLink from the previous successful call to the ListExceptionPolicies method. - * @param options The options parameters. - */ - private async _listExceptionPoliciesNext( - nextLink: string, - options?: JobRouterAdministrationListExceptionPoliciesNextOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient._listExceptionPoliciesNext", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { nextLink, options }, - listExceptionPoliciesNextOperationSpec - ) as Promise; - } - ); - } - - /** - * ListQueuesNext - * @param nextLink The nextLink from the previous successful call to the ListQueues method. - * @param options The options parameters. - */ - private async _listQueuesNext( - nextLink: string, - options?: JobRouterAdministrationListQueuesNextOptionalParams - ): Promise { - return tracingClient.withSpan( - "JobRouterApiClient._listQueuesNext", - options ?? {}, - async (options) => { - return this.client.sendOperationRequest( - { nextLink, options }, - listQueuesNextOperationSpec - ) as Promise; - } - ); - } -} -// Operation Specifications -const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); - -const upsertClassificationPolicyOperationSpec: coreClient.OperationSpec = { - path: "/routing/classificationPolicies/{id}", - httpMethod: "PATCH", - responses: { - 200: { - bodyMapper: Mappers.ClassificationPolicy - }, - 201: { - bodyMapper: Mappers.ClassificationPolicy - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - requestBody: Parameters.patch, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer -}; -const getClassificationPolicyOperationSpec: coreClient.OperationSpec = { - path: "/routing/classificationPolicies/{id}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.ClassificationPolicy - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.accept], - serializer -}; -const deleteClassificationPolicyOperationSpec: coreClient.OperationSpec = { - path: "/routing/classificationPolicies/{id}", - httpMethod: "DELETE", - responses: { - 204: {}, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.accept], - serializer -}; -const listClassificationPoliciesOperationSpec: coreClient.OperationSpec = { - path: "/routing/classificationPolicies", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.ClassificationPolicyCollection - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion, Parameters.maxpagesize], - urlParameters: [Parameters.endpoint], - headerParameters: [Parameters.accept], - serializer -}; -const upsertDistributionPolicyOperationSpec: coreClient.OperationSpec = { - path: "/routing/distributionPolicies/{id}", - httpMethod: "PATCH", - responses: { - 200: { - bodyMapper: Mappers.DistributionPolicy - }, - 201: { - bodyMapper: Mappers.DistributionPolicy - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - requestBody: Parameters.patch1, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer -}; -const getDistributionPolicyOperationSpec: coreClient.OperationSpec = { - path: "/routing/distributionPolicies/{id}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.DistributionPolicy - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.accept], - serializer -}; -const deleteDistributionPolicyOperationSpec: coreClient.OperationSpec = { - path: "/routing/distributionPolicies/{id}", - httpMethod: "DELETE", - responses: { - 204: {}, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.accept], - serializer -}; -const listDistributionPoliciesOperationSpec: coreClient.OperationSpec = { - path: "/routing/distributionPolicies", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.DistributionPolicyCollection - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion, Parameters.maxpagesize], - urlParameters: [Parameters.endpoint], - headerParameters: [Parameters.accept], - serializer -}; -const upsertExceptionPolicyOperationSpec: coreClient.OperationSpec = { - path: "/routing/exceptionPolicies/{id}", - httpMethod: "PATCH", - responses: { - 200: { - bodyMapper: Mappers.ExceptionPolicy - }, - 201: { - bodyMapper: Mappers.ExceptionPolicy - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - requestBody: Parameters.patch2, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer -}; -const getExceptionPolicyOperationSpec: coreClient.OperationSpec = { - path: "/routing/exceptionPolicies/{id}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.ExceptionPolicy - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.accept], - serializer -}; -const deleteExceptionPolicyOperationSpec: coreClient.OperationSpec = { - path: "/routing/exceptionPolicies/{id}", - httpMethod: "DELETE", - responses: { - 204: {}, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.accept], - serializer -}; -const listExceptionPoliciesOperationSpec: coreClient.OperationSpec = { - path: "/routing/exceptionPolicies", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.ExceptionPolicyCollection - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion, Parameters.maxpagesize], - urlParameters: [Parameters.endpoint], - headerParameters: [Parameters.accept], - serializer -}; -const upsertQueueOperationSpec: coreClient.OperationSpec = { - path: "/routing/queues/{id}", - httpMethod: "PATCH", - responses: { - 200: { - bodyMapper: Mappers.RouterQueue - }, - 201: { - bodyMapper: Mappers.RouterQueue - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - requestBody: Parameters.patch3, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer -}; -const getQueueOperationSpec: coreClient.OperationSpec = { - path: "/routing/queues/{id}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.RouterQueue - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.accept], - serializer -}; -const deleteQueueOperationSpec: coreClient.OperationSpec = { - path: "/routing/queues/{id}", - httpMethod: "DELETE", - responses: { - 204: {}, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.endpoint, Parameters.id], - headerParameters: [Parameters.accept], - serializer -}; -const listQueuesOperationSpec: coreClient.OperationSpec = { - path: "/routing/queues", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.RouterQueueCollection - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - queryParameters: [Parameters.apiVersion, Parameters.maxpagesize], - urlParameters: [Parameters.endpoint], - headerParameters: [Parameters.accept], - serializer -}; -const listClassificationPoliciesNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.ClassificationPolicyCollection - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - urlParameters: [Parameters.endpoint, Parameters.nextLink], - headerParameters: [Parameters.accept], - serializer -}; -const listDistributionPoliciesNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.DistributionPolicyCollection - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - urlParameters: [Parameters.endpoint, Parameters.nextLink], - headerParameters: [Parameters.accept], - serializer -}; -const listExceptionPoliciesNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.ExceptionPolicyCollection - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - urlParameters: [Parameters.endpoint, Parameters.nextLink], - headerParameters: [Parameters.accept], - serializer -}; -const listQueuesNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.RouterQueueCollection - }, - default: { - bodyMapper: Mappers.CommunicationErrorResponse - } - }, - urlParameters: [Parameters.endpoint, Parameters.nextLink], - headerParameters: [Parameters.accept], - serializer -}; diff --git a/sdk/communication/communication-job-router/src/generated/src/operationsInterfaces/index.ts b/sdk/communication/communication-job-router/src/generated/src/operationsInterfaces/index.ts deleted file mode 100644 index 86c3dbb3e1bb..000000000000 --- a/sdk/communication/communication-job-router/src/generated/src/operationsInterfaces/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export * from "./jobRouterAdministration"; -export * from "./jobRouter"; diff --git a/sdk/communication/communication-job-router/src/generated/src/operationsInterfaces/jobRouter.ts b/sdk/communication/communication-job-router/src/generated/src/operationsInterfaces/jobRouter.ts deleted file mode 100644 index 28e7cfbc8c54..000000000000 --- a/sdk/communication/communication-job-router/src/generated/src/operationsInterfaces/jobRouter.ts +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PagedAsyncIterableIterator } from "@azure/core-paging"; -import { - RouterJobItem, - JobRouterListJobsOptionalParams, - RouterWorkerItem, - JobRouterListWorkersOptionalParams, - RouterJob, - JobRouterUpsertJobOptionalParams, - JobRouterUpsertJobResponse, - JobRouterGetJobOptionalParams, - JobRouterGetJobResponse, - JobRouterDeleteJobOptionalParams, - JobRouterReclassifyJobActionOptionalParams, - JobRouterReclassifyJobActionResponse, - JobRouterCancelJobActionOptionalParams, - JobRouterCancelJobActionResponse, - JobRouterCompleteJobActionOptionalParams, - JobRouterCompleteJobActionResponse, - JobRouterCloseJobActionOptionalParams, - JobRouterCloseJobActionResponse, - JobRouterGetInQueuePositionOptionalParams, - JobRouterGetInQueuePositionResponse, - JobRouterUnassignJobActionOptionalParams, - JobRouterUnassignJobActionResponse, - JobRouterAcceptJobActionOptionalParams, - JobRouterAcceptJobActionResponse, - JobRouterDeclineJobActionOptionalParams, - JobRouterDeclineJobActionResponse, - JobRouterGetQueueStatisticsOptionalParams, - JobRouterGetQueueStatisticsResponse, - RouterWorker, - JobRouterUpsertWorkerOptionalParams, - JobRouterUpsertWorkerResponse, - JobRouterGetWorkerOptionalParams, - JobRouterGetWorkerResponse, - JobRouterDeleteWorkerOptionalParams -} from "../models"; - -/// -/** Interface representing a JobRouter. */ -export interface JobRouter { - /** - * Retrieves list of jobs based on filter parameters - * @param options The options parameters. - */ - listJobs( - options?: JobRouterListJobsOptionalParams - ): PagedAsyncIterableIterator; - /** - * Retrieves existing workers. - * @param options The options parameters. - */ - listWorkers( - options?: JobRouterListWorkersOptionalParams - ): PagedAsyncIterableIterator; - /** - * Creates or updates a router job. - * @param id Id of the job. - * @param patch Model of job properties to be created or patched. See also: - * https://datatracker.ietf.org/doc/html/rfc7386. - * @param options The options parameters. - */ - upsertJob( - id: string, - patch: RouterJob, - options?: JobRouterUpsertJobOptionalParams - ): Promise; - /** - * Retrieves an existing job by Id - * @param id Id of the job to retrieve - * @param options The options parameters. - */ - getJob( - id: string, - options?: JobRouterGetJobOptionalParams - ): Promise; - /** - * Deletes a job and all of its traces. - * @param id Id of the job - * @param options The options parameters. - */ - deleteJob( - id: string, - options?: JobRouterDeleteJobOptionalParams - ): Promise; - /** - * Reclassify a job. - * @param id Id of the job - * @param options The options parameters. - */ - reclassifyJobAction( - id: string, - options?: JobRouterReclassifyJobActionOptionalParams - ): Promise; - /** - * Submits request to cancel an existing job by Id while supplying free-form cancellation reason. - * @param id Id of the job - * @param options The options parameters. - */ - cancelJobAction( - id: string, - options?: JobRouterCancelJobActionOptionalParams - ): Promise; - /** - * Completes an assigned job. - * @param id Id of the job - * @param assignmentId The assignment within the job to complete. - * @param options The options parameters. - */ - completeJobAction( - id: string, - assignmentId: string, - options?: JobRouterCompleteJobActionOptionalParams - ): Promise; - /** - * Closes a completed job. - * @param id Id of the job - * @param assignmentId The assignment within which the job is to be closed. - * @param options The options parameters. - */ - closeJobAction( - id: string, - assignmentId: string, - options?: JobRouterCloseJobActionOptionalParams - ): Promise; - /** - * Gets a job's position details. - * @param id Id of the job - * @param options The options parameters. - */ - getInQueuePosition( - id: string, - options?: JobRouterGetInQueuePositionOptionalParams - ): Promise; - /** - * Un-assign a job. - * @param id Id of the job to un-assign - * @param assignmentId Id of the assignment to un-assign - * @param options The options parameters. - */ - unassignJobAction( - id: string, - assignmentId: string, - options?: JobRouterUnassignJobActionOptionalParams - ): Promise; - /** - * Accepts an offer to work on a job and returns a 409/Conflict if another agent accepted the job - * already. - * @param workerId Id of the worker - * @param offerId Id of the offer - * @param options The options parameters. - */ - acceptJobAction( - workerId: string, - offerId: string, - options?: JobRouterAcceptJobActionOptionalParams - ): Promise; - /** - * Declines an offer to work on a job. - * @param workerId Id of the worker - * @param offerId Id of the offer - * @param options The options parameters. - */ - declineJobAction( - workerId: string, - offerId: string, - options?: JobRouterDeclineJobActionOptionalParams - ): Promise; - /** - * Retrieves a queue's statistics - * @param id Id of the queue to retrieve statistics - * @param options The options parameters. - */ - getQueueStatistics( - id: string, - options?: JobRouterGetQueueStatisticsOptionalParams - ): Promise; - /** - * Creates or updates a worker. - * @param workerId Id of the worker - * @param patch Model of worker properties to be created or patched. See also: - * https://datatracker.ietf.org/doc/html/rfc7386 - * @param options The options parameters. - */ - upsertWorker( - workerId: string, - patch: RouterWorker, - options?: JobRouterUpsertWorkerOptionalParams - ): Promise; - /** - * Retrieves an existing worker by Id - * @param workerId Id of the worker to retrieve - * @param options The options parameters. - */ - getWorker( - workerId: string, - options?: JobRouterGetWorkerOptionalParams - ): Promise; - /** - * Deletes a worker and all of its traces. - * @param workerId Id of the worker to delete - * @param options The options parameters. - */ - deleteWorker( - workerId: string, - options?: JobRouterDeleteWorkerOptionalParams - ): Promise; -} diff --git a/sdk/communication/communication-job-router/src/generated/src/operationsInterfaces/jobRouterAdministration.ts b/sdk/communication/communication-job-router/src/generated/src/operationsInterfaces/jobRouterAdministration.ts deleted file mode 100644 index 245644ad3c44..000000000000 --- a/sdk/communication/communication-job-router/src/generated/src/operationsInterfaces/jobRouterAdministration.ts +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PagedAsyncIterableIterator } from "@azure/core-paging"; -import { - ClassificationPolicyItem, - JobRouterAdministrationListClassificationPoliciesOptionalParams, - DistributionPolicyItem, - JobRouterAdministrationListDistributionPoliciesOptionalParams, - ExceptionPolicyItem, - JobRouterAdministrationListExceptionPoliciesOptionalParams, - RouterQueueItem, - JobRouterAdministrationListQueuesOptionalParams, - ClassificationPolicy, - JobRouterAdministrationUpsertClassificationPolicyOptionalParams, - JobRouterAdministrationUpsertClassificationPolicyResponse, - JobRouterAdministrationGetClassificationPolicyOptionalParams, - JobRouterAdministrationGetClassificationPolicyResponse, - JobRouterAdministrationDeleteClassificationPolicyOptionalParams, - DistributionPolicy, - JobRouterAdministrationUpsertDistributionPolicyOptionalParams, - JobRouterAdministrationUpsertDistributionPolicyResponse, - JobRouterAdministrationGetDistributionPolicyOptionalParams, - JobRouterAdministrationGetDistributionPolicyResponse, - JobRouterAdministrationDeleteDistributionPolicyOptionalParams, - ExceptionPolicy, - JobRouterAdministrationUpsertExceptionPolicyOptionalParams, - JobRouterAdministrationUpsertExceptionPolicyResponse, - JobRouterAdministrationGetExceptionPolicyOptionalParams, - JobRouterAdministrationGetExceptionPolicyResponse, - JobRouterAdministrationDeleteExceptionPolicyOptionalParams, - RouterQueue, - JobRouterAdministrationUpsertQueueOptionalParams, - JobRouterAdministrationUpsertQueueResponse, - JobRouterAdministrationGetQueueOptionalParams, - JobRouterAdministrationGetQueueResponse, - JobRouterAdministrationDeleteQueueOptionalParams -} from "../models"; - -/// -/** Interface representing a JobRouterAdministration. */ -export interface JobRouterAdministration { - /** - * Retrieves existing classification policies - * @param options The options parameters. - */ - listClassificationPolicies( - options?: JobRouterAdministrationListClassificationPoliciesOptionalParams - ): PagedAsyncIterableIterator; - /** - * Retrieves existing distribution policies - * @param options The options parameters. - */ - listDistributionPolicies( - options?: JobRouterAdministrationListDistributionPoliciesOptionalParams - ): PagedAsyncIterableIterator; - /** - * Retrieves existing exception policies - * @param options The options parameters. - */ - listExceptionPolicies( - options?: JobRouterAdministrationListExceptionPoliciesOptionalParams - ): PagedAsyncIterableIterator; - /** - * Retrieves existing queues - * @param options The options parameters. - */ - listQueues( - options?: JobRouterAdministrationListQueuesOptionalParams - ): PagedAsyncIterableIterator; - /** - * Creates or updates a classification policy. - * @param id Id of the classification policy - * @param patch Model of classification policy properties to be patched. See also: - * https://datatracker.ietf.org/doc/html/rfc7386 - * @param options The options parameters. - */ - upsertClassificationPolicy( - id: string, - patch: ClassificationPolicy, - options?: JobRouterAdministrationUpsertClassificationPolicyOptionalParams - ): Promise; - /** - * Retrieves an existing classification policy by Id - * @param id Id of the classification policy - * @param options The options parameters. - */ - getClassificationPolicy( - id: string, - options?: JobRouterAdministrationGetClassificationPolicyOptionalParams - ): Promise; - /** - * Delete a classification policy by Id - * @param id Id of the classification policy - * @param options The options parameters. - */ - deleteClassificationPolicy( - id: string, - options?: JobRouterAdministrationDeleteClassificationPolicyOptionalParams - ): Promise; - /** - * Creates or updates a distribution policy. - * @param id Id of the distribution policy - * @param patch Model of distribution policy properties to be patched. See also: - * https://datatracker.ietf.org/doc/html/rfc7386 - * @param options The options parameters. - */ - upsertDistributionPolicy( - id: string, - patch: DistributionPolicy, - options?: JobRouterAdministrationUpsertDistributionPolicyOptionalParams - ): Promise; - /** - * Retrieves an existing distribution policy by Id - * @param id Id of the distribution policy - * @param options The options parameters. - */ - getDistributionPolicy( - id: string, - options?: JobRouterAdministrationGetDistributionPolicyOptionalParams - ): Promise; - /** - * Delete a distribution policy by Id - * @param id Id of the distribution policy - * @param options The options parameters. - */ - deleteDistributionPolicy( - id: string, - options?: JobRouterAdministrationDeleteDistributionPolicyOptionalParams - ): Promise; - /** - * Creates or updates a exception policy. - * @param id Id of the exception policy - * @param patch Model of exception policy properties to be patched. See also: - * https://datatracker.ietf.org/doc/html/rfc7386 - * @param options The options parameters. - */ - upsertExceptionPolicy( - id: string, - patch: ExceptionPolicy, - options?: JobRouterAdministrationUpsertExceptionPolicyOptionalParams - ): Promise; - /** - * Retrieves an existing exception policy by Id - * @param id Id of the exception policy to retrieve - * @param options The options parameters. - */ - getExceptionPolicy( - id: string, - options?: JobRouterAdministrationGetExceptionPolicyOptionalParams - ): Promise; - /** - * Deletes a exception policy by Id - * @param id Id of the exception policy to delete - * @param options The options parameters. - */ - deleteExceptionPolicy( - id: string, - options?: JobRouterAdministrationDeleteExceptionPolicyOptionalParams - ): Promise; - /** - * Creates or updates a queue. - * @param id Id of the queue - * @param patch Model of queue properties to be patched. See also: - * https://datatracker.ietf.org/doc/html/rfc7386 - * @param options The options parameters. - */ - upsertQueue( - id: string, - patch: RouterQueue, - options?: JobRouterAdministrationUpsertQueueOptionalParams - ): Promise; - /** - * Retrieves an existing queue by Id - * @param id Id of the queue to retrieve - * @param options The options parameters. - */ - getQueue( - id: string, - options?: JobRouterAdministrationGetQueueOptionalParams - ): Promise; - /** - * Deletes a queue by Id - * @param id Id of the queue to delete - * @param options The options parameters. - */ - deleteQueue( - id: string, - options?: JobRouterAdministrationDeleteQueueOptionalParams - ): Promise; -} diff --git a/sdk/communication/communication-job-router/src/generated/src/pagingHelper.ts b/sdk/communication/communication-job-router/src/generated/src/pagingHelper.ts deleted file mode 100644 index 269a2b9814b5..000000000000 --- a/sdk/communication/communication-job-router/src/generated/src/pagingHelper.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export interface PageInfo { - continuationToken?: string; -} - -const pageMap = new WeakMap(); - -/** - * Given the last `.value` produced by the `byPage` iterator, - * returns a continuation token that can be used to begin paging from - * that point later. - * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator. - * @returns The continuation token that can be passed into byPage() during future calls. - */ -export function getContinuationToken(page: unknown): string | undefined { - if (typeof page !== "object" || page === null) { - return undefined; - } - return pageMap.get(page)?.continuationToken; -} - -export function setContinuationToken( - page: unknown, - continuationToken: string | undefined -): void { - if (typeof page !== "object" || page === null || !continuationToken) { - return; - } - const pageInfo = pageMap.get(page) ?? {}; - pageInfo.continuationToken = continuationToken; - pageMap.set(page, pageInfo); -} diff --git a/sdk/communication/communication-job-router/src/generated/src/tracing.ts b/sdk/communication/communication-job-router/src/generated/src/tracing.ts deleted file mode 100644 index 2ec424d449a7..000000000000 --- a/sdk/communication/communication-job-router/src/generated/src/tracing.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { createTracingClient } from "@azure/core-tracing"; - -export const tracingClient = createTracingClient({ - namespace: "Azure.Communication", - packageName: "@azure/communication-job-router", - packageVersion: "1.0.0-beta.1" -}); diff --git a/sdk/communication/communication-job-router/src/index.ts b/sdk/communication/communication-job-router/src/index.ts index f6ededc29ab0..cac5e0ed9b1d 100644 --- a/sdk/communication/communication-job-router/src/index.ts +++ b/sdk/communication/communication-job-router/src/index.ts @@ -1,14 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -/** - * @packageDocumentation - * JavaScript SDK for the Azure Communication Services Job Router Service. - */ +import AzureCommunicationRoutingServiceClient from "./azureCommunicationRoutingServiceClient"; -export * from "./models"; -export * from "./options"; +export * from "./azureCommunicationRoutingServiceClient"; +export * from "./parameters"; export * from "./responses"; -export * from "./clientUtils"; -export * from "./jobRouterClient"; -export * from "./jobRouterAdministrationClient"; +export * from "./clientDefinitions"; +export * from "./isUnexpected"; +export * from "./models"; +export * from "./outputModels"; +export * from "./paginateHelper"; + +export default AzureCommunicationRoutingServiceClient; diff --git a/sdk/communication/communication-job-router/src/isUnexpected.ts b/sdk/communication/communication-job-router/src/isUnexpected.ts new file mode 100644 index 000000000000..cb57c2000fa4 --- /dev/null +++ b/sdk/communication/communication-job-router/src/isUnexpected.ts @@ -0,0 +1,440 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { + UpsertClassificationPolicy200Response, + UpsertClassificationPolicy201Response, + UpsertClassificationPolicyDefaultResponse, + GetClassificationPolicy200Response, + GetClassificationPolicyDefaultResponse, + DeleteClassificationPolicy204Response, + DeleteClassificationPolicyDefaultResponse, + ListClassificationPolicies200Response, + ListClassificationPoliciesDefaultResponse, + UpsertDistributionPolicy200Response, + UpsertDistributionPolicy201Response, + UpsertDistributionPolicyDefaultResponse, + GetDistributionPolicy200Response, + GetDistributionPolicyDefaultResponse, + DeleteDistributionPolicy204Response, + DeleteDistributionPolicyDefaultResponse, + ListDistributionPolicies200Response, + ListDistributionPoliciesDefaultResponse, + UpsertExceptionPolicy200Response, + UpsertExceptionPolicy201Response, + UpsertExceptionPolicyDefaultResponse, + GetExceptionPolicy200Response, + GetExceptionPolicyDefaultResponse, + DeleteExceptionPolicy204Response, + DeleteExceptionPolicyDefaultResponse, + ListExceptionPolicies200Response, + ListExceptionPoliciesDefaultResponse, + UpsertQueue200Response, + UpsertQueue201Response, + UpsertQueueDefaultResponse, + GetQueue200Response, + GetQueueDefaultResponse, + DeleteQueue204Response, + DeleteQueueDefaultResponse, + ListQueues200Response, + ListQueuesDefaultResponse, + UpsertJob200Response, + UpsertJob201Response, + UpsertJobDefaultResponse, + GetJob200Response, + GetJobDefaultResponse, + DeleteJob204Response, + DeleteJobDefaultResponse, + Reclassify200Response, + ReclassifyDefaultResponse, + Cancel200Response, + CancelDefaultResponse, + Complete200Response, + CompleteDefaultResponse, + Close200Response, + CloseDefaultResponse, + ListJobs200Response, + ListJobsDefaultResponse, + GetInQueuePosition200Response, + GetInQueuePositionDefaultResponse, + Unassign200Response, + UnassignDefaultResponse, + Accept200Response, + AcceptDefaultResponse, + Decline200Response, + DeclineDefaultResponse, + GetQueueStatistics200Response, + GetQueueStatisticsDefaultResponse, + UpsertWorker200Response, + UpsertWorker201Response, + UpsertWorkerDefaultResponse, + GetWorker200Response, + GetWorkerDefaultResponse, + DeleteWorker204Response, + DeleteWorkerDefaultResponse, + ListWorkers200Response, + ListWorkersDefaultResponse, +} from "./responses"; + +const responseMap: Record = { + "PATCH /routing/classificationPolicies/{classificationPolicyId}": [ + "200", + "201", + ], + "GET /routing/classificationPolicies/{classificationPolicyId}": ["200"], + "DELETE /routing/classificationPolicies/{classificationPolicyId}": ["204"], + "GET /routing/classificationPolicies": ["200"], + "PATCH /routing/distributionPolicies/{distributionPolicyId}": ["200", "201"], + "GET /routing/distributionPolicies/{distributionPolicyId}": ["200"], + "DELETE /routing/distributionPolicies/{distributionPolicyId}": ["204"], + "GET /routing/distributionPolicies": ["200"], + "PATCH /routing/exceptionPolicies/{exceptionPolicyId}": ["200", "201"], + "GET /routing/exceptionPolicies/{exceptionPolicyId}": ["200"], + "DELETE /routing/exceptionPolicies/{exceptionPolicyId}": ["204"], + "GET /routing/exceptionPolicies": ["200"], + "PATCH /routing/queues/{queueId}": ["200", "201"], + "GET /routing/queues/{queueId}": ["200"], + "DELETE /routing/queues/{queueId}": ["204"], + "GET /routing/queues": ["200"], + "PATCH /routing/jobs/{jobId}": ["200", "201"], + "GET /routing/jobs/{jobId}": ["200"], + "DELETE /routing/jobs/{jobId}": ["204"], + "POST /routing/jobs/{jobId}:reclassify": ["200"], + "POST /routing/jobs/{jobId}:cancel": ["200"], + "POST /routing/jobs/{jobId}/assignments/{assignmentId}:complete": ["200"], + "POST /routing/jobs/{jobId}/assignments/{assignmentId}:close": ["200"], + "GET /routing/jobs": ["200"], + "GET /routing/jobs/{jobId}/position": ["200"], + "POST /routing/jobs/{jobId}/assignments/{assignmentId}:unassign": ["200"], + "POST /routing/workers/{workerId}/offers/{offerId}:accept": ["200"], + "POST /routing/workers/{workerId}/offers/{offerId}:decline": ["200"], + "GET /routing/queues/{queueId}/statistics": ["200"], + "PATCH /routing/workers/{workerId}": ["200", "201"], + "GET /routing/workers/{workerId}": ["200"], + "DELETE /routing/workers/{workerId}": ["204"], + "GET /routing/workers": ["200"], +}; + +export function isUnexpected( + response: + | UpsertClassificationPolicy200Response + | UpsertClassificationPolicy201Response + | UpsertClassificationPolicyDefaultResponse +): response is UpsertClassificationPolicyDefaultResponse; +export function isUnexpected( + response: + | GetClassificationPolicy200Response + | GetClassificationPolicyDefaultResponse +): response is GetClassificationPolicyDefaultResponse; +export function isUnexpected( + response: + | DeleteClassificationPolicy204Response + | DeleteClassificationPolicyDefaultResponse +): response is DeleteClassificationPolicyDefaultResponse; +export function isUnexpected( + response: + | ListClassificationPolicies200Response + | ListClassificationPoliciesDefaultResponse +): response is ListClassificationPoliciesDefaultResponse; +export function isUnexpected( + response: + | UpsertDistributionPolicy200Response + | UpsertDistributionPolicy201Response + | UpsertDistributionPolicyDefaultResponse +): response is UpsertDistributionPolicyDefaultResponse; +export function isUnexpected( + response: + | GetDistributionPolicy200Response + | GetDistributionPolicyDefaultResponse +): response is GetDistributionPolicyDefaultResponse; +export function isUnexpected( + response: + | DeleteDistributionPolicy204Response + | DeleteDistributionPolicyDefaultResponse +): response is DeleteDistributionPolicyDefaultResponse; +export function isUnexpected( + response: + | ListDistributionPolicies200Response + | ListDistributionPoliciesDefaultResponse +): response is ListDistributionPoliciesDefaultResponse; +export function isUnexpected( + response: + | UpsertExceptionPolicy200Response + | UpsertExceptionPolicy201Response + | UpsertExceptionPolicyDefaultResponse +): response is UpsertExceptionPolicyDefaultResponse; +export function isUnexpected( + response: GetExceptionPolicy200Response | GetExceptionPolicyDefaultResponse +): response is GetExceptionPolicyDefaultResponse; +export function isUnexpected( + response: + | DeleteExceptionPolicy204Response + | DeleteExceptionPolicyDefaultResponse +): response is DeleteExceptionPolicyDefaultResponse; +export function isUnexpected( + response: + | ListExceptionPolicies200Response + | ListExceptionPoliciesDefaultResponse +): response is ListExceptionPoliciesDefaultResponse; +export function isUnexpected( + response: + | UpsertQueue200Response + | UpsertQueue201Response + | UpsertQueueDefaultResponse +): response is UpsertQueueDefaultResponse; +export function isUnexpected( + response: GetQueue200Response | GetQueueDefaultResponse +): response is GetQueueDefaultResponse; +export function isUnexpected( + response: DeleteQueue204Response | DeleteQueueDefaultResponse +): response is DeleteQueueDefaultResponse; +export function isUnexpected( + response: ListQueues200Response | ListQueuesDefaultResponse +): response is ListQueuesDefaultResponse; +export function isUnexpected( + response: + | UpsertJob200Response + | UpsertJob201Response + | UpsertJobDefaultResponse +): response is UpsertJobDefaultResponse; +export function isUnexpected( + response: GetJob200Response | GetJobDefaultResponse +): response is GetJobDefaultResponse; +export function isUnexpected( + response: DeleteJob204Response | DeleteJobDefaultResponse +): response is DeleteJobDefaultResponse; +export function isUnexpected( + response: Reclassify200Response | ReclassifyDefaultResponse +): response is ReclassifyDefaultResponse; +export function isUnexpected( + response: Cancel200Response | CancelDefaultResponse +): response is CancelDefaultResponse; +export function isUnexpected( + response: Complete200Response | CompleteDefaultResponse +): response is CompleteDefaultResponse; +export function isUnexpected( + response: Close200Response | CloseDefaultResponse +): response is CloseDefaultResponse; +export function isUnexpected( + response: ListJobs200Response | ListJobsDefaultResponse +): response is ListJobsDefaultResponse; +export function isUnexpected( + response: GetInQueuePosition200Response | GetInQueuePositionDefaultResponse +): response is GetInQueuePositionDefaultResponse; +export function isUnexpected( + response: Unassign200Response | UnassignDefaultResponse +): response is UnassignDefaultResponse; +export function isUnexpected( + response: Accept200Response | AcceptDefaultResponse +): response is AcceptDefaultResponse; +export function isUnexpected( + response: Decline200Response | DeclineDefaultResponse +): response is DeclineDefaultResponse; +export function isUnexpected( + response: GetQueueStatistics200Response | GetQueueStatisticsDefaultResponse +): response is GetQueueStatisticsDefaultResponse; +export function isUnexpected( + response: + | UpsertWorker200Response + | UpsertWorker201Response + | UpsertWorkerDefaultResponse +): response is UpsertWorkerDefaultResponse; +export function isUnexpected( + response: GetWorker200Response | GetWorkerDefaultResponse +): response is GetWorkerDefaultResponse; +export function isUnexpected( + response: DeleteWorker204Response | DeleteWorkerDefaultResponse +): response is DeleteWorkerDefaultResponse; +export function isUnexpected( + response: ListWorkers200Response | ListWorkersDefaultResponse +): response is ListWorkersDefaultResponse; +export function isUnexpected( + response: + | UpsertClassificationPolicy200Response + | UpsertClassificationPolicy201Response + | UpsertClassificationPolicyDefaultResponse + | GetClassificationPolicy200Response + | GetClassificationPolicyDefaultResponse + | DeleteClassificationPolicy204Response + | DeleteClassificationPolicyDefaultResponse + | ListClassificationPolicies200Response + | ListClassificationPoliciesDefaultResponse + | UpsertDistributionPolicy200Response + | UpsertDistributionPolicy201Response + | UpsertDistributionPolicyDefaultResponse + | GetDistributionPolicy200Response + | GetDistributionPolicyDefaultResponse + | DeleteDistributionPolicy204Response + | DeleteDistributionPolicyDefaultResponse + | ListDistributionPolicies200Response + | ListDistributionPoliciesDefaultResponse + | UpsertExceptionPolicy200Response + | UpsertExceptionPolicy201Response + | UpsertExceptionPolicyDefaultResponse + | GetExceptionPolicy200Response + | GetExceptionPolicyDefaultResponse + | DeleteExceptionPolicy204Response + | DeleteExceptionPolicyDefaultResponse + | ListExceptionPolicies200Response + | ListExceptionPoliciesDefaultResponse + | UpsertQueue200Response + | UpsertQueue201Response + | UpsertQueueDefaultResponse + | GetQueue200Response + | GetQueueDefaultResponse + | DeleteQueue204Response + | DeleteQueueDefaultResponse + | ListQueues200Response + | ListQueuesDefaultResponse + | UpsertJob200Response + | UpsertJob201Response + | UpsertJobDefaultResponse + | GetJob200Response + | GetJobDefaultResponse + | DeleteJob204Response + | DeleteJobDefaultResponse + | Reclassify200Response + | ReclassifyDefaultResponse + | Cancel200Response + | CancelDefaultResponse + | Complete200Response + | CompleteDefaultResponse + | Close200Response + | CloseDefaultResponse + | ListJobs200Response + | ListJobsDefaultResponse + | GetInQueuePosition200Response + | GetInQueuePositionDefaultResponse + | Unassign200Response + | UnassignDefaultResponse + | Accept200Response + | AcceptDefaultResponse + | Decline200Response + | DeclineDefaultResponse + | GetQueueStatistics200Response + | GetQueueStatisticsDefaultResponse + | UpsertWorker200Response + | UpsertWorker201Response + | UpsertWorkerDefaultResponse + | GetWorker200Response + | GetWorkerDefaultResponse + | DeleteWorker204Response + | DeleteWorkerDefaultResponse + | ListWorkers200Response + | ListWorkersDefaultResponse +): response is + | UpsertClassificationPolicyDefaultResponse + | GetClassificationPolicyDefaultResponse + | DeleteClassificationPolicyDefaultResponse + | ListClassificationPoliciesDefaultResponse + | UpsertDistributionPolicyDefaultResponse + | GetDistributionPolicyDefaultResponse + | DeleteDistributionPolicyDefaultResponse + | ListDistributionPoliciesDefaultResponse + | UpsertExceptionPolicyDefaultResponse + | GetExceptionPolicyDefaultResponse + | DeleteExceptionPolicyDefaultResponse + | ListExceptionPoliciesDefaultResponse + | UpsertQueueDefaultResponse + | GetQueueDefaultResponse + | DeleteQueueDefaultResponse + | ListQueuesDefaultResponse + | UpsertJobDefaultResponse + | GetJobDefaultResponse + | DeleteJobDefaultResponse + | ReclassifyDefaultResponse + | CancelDefaultResponse + | CompleteDefaultResponse + | CloseDefaultResponse + | ListJobsDefaultResponse + | GetInQueuePositionDefaultResponse + | UnassignDefaultResponse + | AcceptDefaultResponse + | DeclineDefaultResponse + | GetQueueStatisticsDefaultResponse + | UpsertWorkerDefaultResponse + | GetWorkerDefaultResponse + | DeleteWorkerDefaultResponse + | ListWorkersDefaultResponse { + const lroOriginal = response.headers["x-ms-original-url"]; + const url = new URL(lroOriginal ?? response.request.url); + const method = response.request.method; + let pathDetails = responseMap[`${method} ${url.pathname}`]; + if (!pathDetails) { + pathDetails = getParametrizedPathSuccess(method, url.pathname); + } + return !pathDetails.includes(response.status); +} + +function getParametrizedPathSuccess(method: string, path: string): string[] { + const pathParts = path.split("/"); + + // Traverse list to match the longest candidate + // matchedLen: the length of candidate path + // matchedValue: the matched status code array + let matchedLen = -1, + matchedValue: string[] = []; + + // Iterate the responseMap to find a match + for (const [key, value] of Object.entries(responseMap)) { + // Extracting the path from the map key which is in format + // GET /path/foo + if (!key.startsWith(method)) { + continue; + } + const candidatePath = getPathFromMapKey(key); + // Get each part of the url path + const candidateParts = candidatePath.split("/"); + + // track if we have found a match to return the values found. + let found = true; + for ( + let i = candidateParts.length - 1, j = pathParts.length - 1; + i >= 1 && j >= 1; + i--, j-- + ) { + if ( + candidateParts[i]?.startsWith("{") && + candidateParts[i]?.indexOf("}") !== -1 + ) { + const start = candidateParts[i]!.indexOf("}") + 1, + end = candidateParts[i]?.length; + // If the current part of the candidate is a "template" part + // Try to use the suffix of pattern to match the path + // {guid} ==> $ + // {guid}:export ==> :export$ + const isMatched = new RegExp( + `${candidateParts[i]?.slice(start, end)}` + ).test(pathParts[j] || ""); + + if (!isMatched) { + found = false; + break; + } + continue; + } + + // If the candidate part is not a template and + // the parts don't match mark the candidate as not found + // to move on with the next candidate path. + if (candidateParts[i] !== pathParts[j]) { + found = false; + break; + } + } + + // We finished evaluating the current candidate parts + // Update the matched value if and only if we found the longer pattern + if (found && candidatePath.length > matchedLen) { + matchedLen = candidatePath.length; + matchedValue = value; + } + } + + return matchedValue; +} + +function getPathFromMapKey(mapKey: string): string { + const pathStart = mapKey.indexOf("/"); + return mapKey.slice(pathStart); +} diff --git a/sdk/communication/communication-job-router/src/jobRouterAdministrationClient.ts b/sdk/communication/communication-job-router/src/jobRouterAdministrationClient.ts deleted file mode 100644 index 5107ddaf9c8f..000000000000 --- a/sdk/communication/communication-job-router/src/jobRouterAdministrationClient.ts +++ /dev/null @@ -1,457 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -/// - -import { - CommunicationTokenCredential, - createCommunicationAuthPolicy, - isKeyCredential, - parseClientArguments, -} from "@azure/communication-common"; -import { KeyCredential, TokenCredential } from "@azure/core-auth"; -import { OperationOptions } from "@azure/core-client"; -import { InternalPipelineOptions } from "@azure/core-rest-pipeline"; -import { PagedAsyncIterableIterator } from "@azure/core-paging"; -import { - JobRouterAdministrationListClassificationPoliciesOptionalParams, - JobRouterAdministrationListDistributionPoliciesOptionalParams, - JobRouterAdministrationListExceptionPoliciesOptionalParams, - JobRouterAdministrationListQueuesOptionalParams, - JobRouterApiClient, -} from "./generated/src"; -import { - ClassificationPolicyItem, - DistributionPolicyItem, - ExceptionPolicyItem, - RouterQueueItem, - DistributionPolicy, - ExceptionPolicy, - RouterQueue, - ClassificationPolicy, -} from "./models"; -import { - CreateClassificationPolicyOptions, - CreateDistributionPolicyOptions, - CreateExceptionPolicyOptions, - CreateQueueOptions, - ListClassificationPoliciesOptions, - ListDistributionPoliciesOptions, - ListExceptionPoliciesOptions, - ListQueuesOptions, - JobRouterAdministrationClientOptions as JobRouterAdministrationClientOptions, - UpdateClassificationPolicyOptions, - UpdateDistributionPolicyOptions, - UpdateExceptionPolicyOptions, - UpdateQueueOptions, -} from "./options"; -import { - ClassificationPolicyResponse, - DistributionPolicyResponse, - ExceptionPolicyResponse, - RouterQueueResponse, -} from "./responses"; -import { SDK_VERSION } from "./constants"; -import { logger } from "./logger"; - -/** - * Checks whether a value is of type {@link JobRouterAdministrationClientOptions}. - * @param value - The value being checked. - */ -const isRouterAdministrationClientOptions = ( - value: any -): value is JobRouterAdministrationClientOptions => !!value && !isKeyCredential(value); - -/** - * The client to do administrative job router operations. - */ -export class JobRouterAdministrationClient { - private readonly client: JobRouterApiClient; - - /** - * Constructs an instance of {@link JobRouterAdministrationClient}. - * @param connectionString - The connection string of the Azure Communication Services resource. (ex: "endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret"). - * @param options - (Optional) Options to configure the HTTP pipeline. - */ - constructor(connectionString: string, options?: JobRouterAdministrationClientOptions); - - /** - * Constructs an instance of {@link JobRouterAdministrationClient} using an Azure KeyCredential. - * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net). - * @param credential - An object that is used to authenticate requests to the service. Use the Azure KeyCredential or `@azure/identity` or TokenCredential to create a credential. - * @param options - (Optional) Options to configure the HTTP pipeline. - */ - constructor( - endpoint: string, - credential: KeyCredential | TokenCredential, - options?: JobRouterAdministrationClientOptions - ); - - /** - * Constructs an instance of {@link JobRouterAdministrationClient} using a TokenCredential. - * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net). - * @param credential - CommunicationTokenCredential that is used to authenticate requests to the service. - * @param options - (Optional) Options to configure the HTTP pipeline. - */ - constructor( - endpoint: string, - credential: CommunicationTokenCredential, - options?: JobRouterAdministrationClientOptions - ); - - /** - * Constructs an instance of {@link JobRouterAdministrationClient} for a given resource and user. - * @param connectionStringOrUrl - The connection string or url of the Azure Communication Services resource. - * @param credentialOrOptions - The key or token credential or {@link RouterAdministrationClientOptions}. Use AzureCommunicationKeyCredential from \@azure/communication-common to create a credential. - * @param maybeOptions - Additional client options. - */ - constructor( - connectionStringOrUrl: string, - credentialOrOptions?: - | KeyCredential - | TokenCredential - | CommunicationTokenCredential - | JobRouterAdministrationClientOptions, - maybeOptions: JobRouterAdministrationClientOptions = {} - ) { - const { url, credential } = parseClientArguments(connectionStringOrUrl, credentialOrOptions); - const options = isRouterAdministrationClientOptions(credentialOrOptions) - ? credentialOrOptions - : maybeOptions; - - const libInfo = `azsdk-js-communication-job-router/${SDK_VERSION}`; - - if (!options.userAgentOptions) { - options.userAgentOptions = {}; - } - - const userAgentOptions = { ...options.userAgentOptions }; - if (options.userAgentOptions.userAgentPrefix) { - userAgentOptions.userAgentPrefix = `${options.userAgentOptions.userAgentPrefix} ${libInfo}`; - } else { - userAgentOptions.userAgentPrefix = libInfo; - } - - const internalPipelineOptions: InternalPipelineOptions = { - ...options, - userAgentOptions, - loggingOptions: { - logger: logger.info, - }, - }; - - const authPolicy = createCommunicationAuthPolicy(credential); - - this.client = new JobRouterApiClient(url, internalPipelineOptions); - this.client.pipeline.addPolicy(authPolicy); - } - - /** - * Creates a classification policy. - * @param classificationPolicyId - The id of the classification policy to create. - * @param options - Options for creating a classification policy. - * @returns - The created classification policy. - */ - public async createClassificationPolicy( - classificationPolicyId: string, - options: CreateClassificationPolicyOptions = {} - ): Promise { - const patch = options as ClassificationPolicy; - const response = await this.client.jobRouterAdministration.upsertClassificationPolicy( - classificationPolicyId, - patch, - options - ); - return response as ClassificationPolicyResponse; - } - - /** - * Updates a classification policy. - * @param classificationPolicyId - The id of the classification policy to update. - * @param options - Options for updating a classification policy. Uses merge-patch semantics: https://datatracker.ietf.org/doc/html/rfc7386. - * @returns - The updated classification policy. - */ - public async updateClassificationPolicy( - classificationPolicyId: string, - options: UpdateClassificationPolicyOptions = {} - ): Promise { - const patch = options as ClassificationPolicy; - const response = await this.client.jobRouterAdministration.upsertClassificationPolicy( - classificationPolicyId, - patch, - options - ); - return response as ClassificationPolicyResponse; - } - - /** - * Gets a list of classification policies. - * @param options - Options for listing classification policies. - * @returns - The list of classification policies. - */ - public listClassificationPolicies( - options: ListClassificationPoliciesOptions = {} - ): PagedAsyncIterableIterator { - const listOptions = options as JobRouterAdministrationListClassificationPoliciesOptionalParams; - listOptions.maxpagesize = options.maxPageSize; - return this.client.jobRouterAdministration.listClassificationPolicies(listOptions); - } - - /** - * Gets a classification policy. - * @param classificationPolicyId - The id of the classification policy to get. - * @param options - Options for getting a classification policy. - * @returns - The classification policy. - */ - public async getClassificationPolicy( - classificationPolicyId: string, - options: OperationOptions = {} - ): Promise { - const response = await this.client.jobRouterAdministration.getClassificationPolicy( - classificationPolicyId, - options - ); - return response as ClassificationPolicyResponse; - } - - /** - * Deletes a classification policy. - * @param classificationPolicyId - The id of the classification policy to delete. - * @param options - Options for deleting a classification policy. - */ - public async deleteClassificationPolicy( - classificationPolicyId: string, - options: OperationOptions = {} - ): Promise { - return this.client.jobRouterAdministration.deleteClassificationPolicy( - classificationPolicyId, - options - ); - } - - /** - * Creates a distribution policy. - * @param distributionPolicyId - The id of the distribution policy to create. - * @param options - Options for creating a distribution policy. - * @returns - The created distribution policy. - */ - public async createDistributionPolicy( - distributionPolicyId: string, - options: CreateDistributionPolicyOptions = {} - ): Promise { - const patch = options as DistributionPolicy; - const response = await this.client.jobRouterAdministration.upsertDistributionPolicy( - distributionPolicyId, - patch, - options - ); - return response as DistributionPolicyResponse; - } - - /** - * Updates a distribution policy. - * @param distributionPolicyId - The id of the distribution policy to update. - * @param options - Options for updating a distribution policy. Uses merge-patch semantics: https://datatracker.ietf.org/doc/html/rfc7386. - * @returns - The updated distribution policy. - */ - public async updateDistributionPolicy( - distributionPolicyId: string, - options: UpdateDistributionPolicyOptions = {} - ): Promise { - const patch = options as DistributionPolicy; - const response = await this.client.jobRouterAdministration.upsertDistributionPolicy( - distributionPolicyId, - patch, - options - ); - return response as DistributionPolicyResponse; - } - - /** - * Gets a list of distribution policies. - * @param options - Options for listing distribution policies. - * @returns - The list of distribution policies. - */ - public listDistributionPolicies( - options: ListDistributionPoliciesOptions = {} - ): PagedAsyncIterableIterator { - const listOptions = options as JobRouterAdministrationListDistributionPoliciesOptionalParams; - listOptions.maxpagesize = options.maxPageSize; - return this.client.jobRouterAdministration.listDistributionPolicies(listOptions); - } - - /** - * Gets a distribution policy. - * @param distributionPolicyId - The id of the distribution policy to get. - * @param options - Options for getting a distribution policy. - * @returns - The distribution policy. - */ - public async getDistributionPolicy( - distributionPolicyId: string, - options: OperationOptions = {} - ): Promise { - const response = await this.client.jobRouterAdministration.getDistributionPolicy( - distributionPolicyId, - options - ); - return response as DistributionPolicyResponse; - } - - /** - * Deletes a distribution policy. - * @param distributionPolicyId - The id of the distribution policy to delete. - * @param options - Options for deleting a distribution policy. - */ - public async deleteDistributionPolicy( - distributionPolicyId: string, - options: OperationOptions = {} - ): Promise { - return this.client.jobRouterAdministration.deleteDistributionPolicy( - distributionPolicyId, - options - ); - } - - /** - * Creates an exception policy. - * @param exceptionPolicyId - The id of the exception policy to create. - * @param options - Options for creating an exception policy. - * @returns - The created exception policy. - */ - public async createExceptionPolicy( - exceptionPolicyId: string, - options: CreateExceptionPolicyOptions = {} - ): Promise { - const patch = options as ExceptionPolicy; - const response = await this.client.jobRouterAdministration.upsertExceptionPolicy( - exceptionPolicyId, - patch, - options - ); - return response as ExceptionPolicyResponse; - } - - /** - * Updates an exception policy. - * @param exceptionPolicyId - The id of the exception policy to update. - * @param options - Options for updating an exception policy. Uses merge-patch semantics: https://datatracker.ietf.org/doc/html/rfc7386. - * @returns - The updated exception policy. - */ - public async updateExceptionPolicy( - exceptionPolicyId: string, - options: UpdateExceptionPolicyOptions = {} - ): Promise { - const patch = options as ExceptionPolicy; - const response = await this.client.jobRouterAdministration.upsertExceptionPolicy( - exceptionPolicyId, - patch, - options - ); - return response as ExceptionPolicyResponse; - } - - /** - * Gets a list of exception policies. - * @param options - Options for listing exception policies. - * @returns - The list of exception policies. - */ - public listExceptionPolicies( - options: ListExceptionPoliciesOptions = {} - ): PagedAsyncIterableIterator { - const listOptions = options; - listOptions.maxpagesize = options.maxPageSize; - return this.client.jobRouterAdministration.listExceptionPolicies(listOptions); - } - - /** - * Gets an exception policy. - * @param exceptionPolicyId - The id of the exception policy to get. - * @param options - Options for getting an exception policy. - * @returns - The exception policy. - */ - public async getExceptionPolicy( - exceptionPolicyId: string, - options: OperationOptions = {} - ): Promise { - const response = await this.client.jobRouterAdministration.getExceptionPolicy( - exceptionPolicyId, - options - ); - return response as ExceptionPolicyResponse; - } - - /** - * Deletes an exception policy. - * @param exceptionPolicyId - The id of the exception policy to delete. - * @param options - Options for deleting an exception policy. - */ - public async deleteExceptionPolicy( - exceptionPolicyId: string, - options: OperationOptions = {} - ): Promise { - return this.client.jobRouterAdministration.deleteExceptionPolicy(exceptionPolicyId, options); - } - - /** - * Creates a queue. - * @param queueId - The id of the queue to create. - * @param options - Options for creating a queue. - * @returns - The created queue. - */ - public async createQueue( - queueId: string, - options: CreateQueueOptions = {} - ): Promise { - const patch = options as RouterQueue; - const response = await this.client.jobRouterAdministration.upsertQueue(queueId, patch, options); - return response as RouterQueueResponse; - } - - /** - * Updates a queue. - * @param queueId - The id of the queue to update. - * @param options - Options for updating a queue. Uses merge-patch semantics: https://datatracker.ietf.org/doc/html/rfc7386. - * @returns - The updated queue. - */ - public async updateQueue( - queueId: string, - options: UpdateQueueOptions = {} - ): Promise { - const patch = options as RouterQueue; - const response = await this.client.jobRouterAdministration.upsertQueue(queueId, patch, options); - return response as RouterQueueResponse; - } - - /** - * Gets a list of queues. - * @param options - Options for listing queues. - * @returns - The list of queues. - */ - public listQueues(options: ListQueuesOptions = {}): PagedAsyncIterableIterator { - const listOptions = options as JobRouterAdministrationListQueuesOptionalParams; - listOptions.maxpagesize = options.maxPageSize || undefined; - return this.client.jobRouterAdministration.listQueues(listOptions); - } - - /** - * Gets a queue. - * @param queueId - The id of the queue to get. - * @param options - Options for a getting a queue. - * @returns - The queue. - */ - public async getQueue( - queueId: string, - options: OperationOptions = {} - ): Promise { - const response = await this.client.jobRouterAdministration.getQueue(queueId, options); - return response as RouterQueueResponse; - } - - /** - * Deletes a queue. - * @param queueId - The id of the queue to delete. - * @param options - Options for deleting a queue. - */ - public async deleteQueue(queueId: string, options: OperationOptions = {}): Promise { - return this.client.jobRouterAdministration.deleteQueue(queueId, options); - } -} diff --git a/sdk/communication/communication-job-router/src/jobRouterClient.ts b/sdk/communication/communication-job-router/src/jobRouterClient.ts deleted file mode 100644 index 7336699185bb..000000000000 --- a/sdk/communication/communication-job-router/src/jobRouterClient.ts +++ /dev/null @@ -1,522 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -/// - -import { - CommunicationTokenCredential, - createCommunicationAuthPolicy, - isKeyCredential, - parseClientArguments, -} from "@azure/communication-common"; -import { KeyCredential, TokenCredential } from "@azure/core-auth"; -import { OperationOptions } from "@azure/core-client"; -import { InternalPipelineOptions } from "@azure/core-rest-pipeline"; -import { SDK_VERSION } from "./constants"; -import { - JobRouterApiClient, - JobRouterListJobsOptionalParams, - JobRouterListWorkersOptionalParams, - RouterJobPositionDetails, - RouterQueueStatistics, - RouterJob as RouterJobGenerated, - RouterJobItem as RouterJobItemGenerated, - RouterWorkerItem as RouterWorkerItemGenerated, - KnownJobMatchModeType, - JobMatchingMode, -} from "./generated/src"; -import { logger } from "./logger"; -import { - RouterJobItem, - RouterWorkerItem, - RouterJobNote, - RouterJobStatus, - RouterWorkerSelector, - RouterJobMatchingMode, - RouterWorkerState, -} from "./models"; -import { - JobRouterClientOptions, - CreateJobOptions, - UpdateJobOptions, - CancelJobOptions, - CompleteJobOptions, - ReclassifyJobOptions, - CloseJobOptions, - UnassignJobOptions, - DeclineJobOfferOptions, - ListJobsOptions, - CreateWorkerOptions, - UpdateWorkerOptions, - ListWorkersOptions, -} from "./options"; -import { - RouterJobResponse, - CancelJobResponse, - CompleteJobResponse, - ReclassifyJobResponse, - CloseJobResponse, - UnassignJobResponse, - AcceptJobOfferResponse, - DeclineJobOfferResponse, - RouterWorkerResponse, -} from "./responses"; -import { TransformingPagedAsyncIterableIterator } from "./clientUtils"; - -/** - * Checks whether a value is of type {@link JobRouterClientOptions}. - * @param value - The value being checked. - * @returns - True or false. - */ -const isRouterClientOptions = (value: any): value is JobRouterClientOptions => - !!value && !isKeyCredential(value); - -/** - * Transforms an array of notes from their generated type to {@link RouterJobNote}. - * @param notes - An array of notes as their generated type. - * @returns - An array of notes as {@link RouterJobNote}. - */ -const transformNotesForSDK = ( - notes: { [propertyName: string]: string } | undefined -): RouterJobNote[] => { - if (notes === undefined) return []; - - return Object.keys(notes).map((key) => ({ addedAt: new Date(key), message: notes[key] })); -}; - -/** - * Transforms an array of notes from {@link RouterJobNote} to their generated type. - * @param notes - An array of notes as {@link RouterJobNote}. - * @returns - An array of notes as their generated type. - */ -const transformNotesForService = ( - notes: RouterJobNote[] | undefined | null -): { [propertyName: string]: string } | undefined => { - if (notes === undefined || notes === null || !Array.isArray(notes)) return {}; - - return notes.reduce( - (acc, { addedAt, message }) => ({ ...acc, [addedAt.toISOString()]: message }), - {} - ); -}; - -/** - * Transforms a job matching mode from {@link RouterJobMatchingMode} to {@link JobMatchingMode}. - * @param matchingMode - A job matching mode as {@link RouterJobMatchingMode}. - * @returns - The job matching mode as {@link JobMatchingMode}. - */ -const transformMatchingModeForService = ( - matchingMode: RouterJobMatchingMode | undefined | null -): JobMatchingMode | undefined => { - if (matchingMode === undefined || matchingMode === null) { - return null!; - } - - const tranformedMode = {} as RouterJobMatchingMode; - - if (matchingMode.scheduleAndSuspendMode) { - tranformedMode.modeType = KnownJobMatchModeType.ScheduleAndSuspendMode; - tranformedMode.scheduleAndSuspendMode = matchingMode.scheduleAndSuspendMode; - tranformedMode.queueAndMatchMode = null!; - tranformedMode.suspendMode = null!; - } else if (matchingMode.queueAndMatchMode) { - tranformedMode.modeType = KnownJobMatchModeType.QueueAndMatchMode; - tranformedMode.queueAndMatchMode = matchingMode.queueAndMatchMode; - tranformedMode.suspendMode = null!; - tranformedMode.scheduleAndSuspendMode = null!; - } else if (matchingMode.suspendMode) { - tranformedMode.modeType = KnownJobMatchModeType.SuspendMode; - tranformedMode.suspendMode = matchingMode.suspendMode; - tranformedMode.queueAndMatchMode = null!; - tranformedMode.scheduleAndSuspendMode = null!; - } else { - return null!; - } - - return tranformedMode; -}; - -/** - * Transforms a job item from {@link RouterJobItemGenerated} to {@link RouterJobItem}. - * @param item - A job item as {@link RouterJobItemGenerated}. - * @returns - The job item as {@link RouterJobItem}. - */ -const listJobsTransform = (item: RouterJobItemGenerated): RouterJobItem => ({ - ...item, - job: { - ...item.job, - notes: transformNotesForSDK(item.job!.notes), - status: item.job?.status as RouterJobStatus, - requestedWorkerSelectors: item.job?.requestedWorkerSelectors as RouterWorkerSelector[], - attachedWorkerSelectors: item.job?.attachedWorkerSelectors as RouterWorkerSelector[], - matchingMode: item.job?.matchingMode as RouterJobMatchingMode, - }, -}); - -/** - * Transforms a worker item from {@link RouterWorkerItemGenerated} to {@link RouterWorkerItem}. - * @param item - A job item as {@link RouterWorkerItemGenerated}. - * @returns - The job item as {@link RouterWorkerItem}. - */ -const listWorkersTransform = (item: RouterWorkerItemGenerated): RouterWorkerItem => ({ - ...item, - worker: { - ...item.worker, - state: item.worker?.state as RouterWorkerState, - }, -}); - -/** - * The client to do job router operations. - */ -export class JobRouterClient { - private readonly client: JobRouterApiClient; - - /** - * Constructs an instance of {@link JobRouterClient}. - * @param connectionString - Connection string to connect to an Azure Communication Service resource. (ex: "endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret"). - * @param options - (Optional) Options to configure the HTTP pipeline. - */ - constructor(connectionString: string, options?: JobRouterClientOptions); - - /** - * Constructs an instance of {@link JobRouterClient} using an Azure KeyCredential. - * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net). - * @param credential - An object that is used to authenticate requests to the service. Use the Azure KeyCredential or `@azure/identity` or TokenCredential to create a credential. - * @param options - (Optional) usingOptions to configure the HTTP pipeline. - */ - constructor( - endpoint: string, - credential: KeyCredential | TokenCredential, - options?: JobRouterClientOptions - ); - - /** - * Constructs an instance of {@link JobRouterClient} using a TokenCredential. - * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net). - * @param credential - CommunicationTokenCredential that is used to authenticate requests to the service. - * @param options - (Optional) Options to configure the HTTP pipeline. - */ - constructor( - endpoint: string, - credential: CommunicationTokenCredential, - options?: JobRouterClientOptions - ); - - /** - * Constructs an instance of {@link JobRouterClient} using a given resource and user. - * @param connectionStringOrUrl - The connectionString or url of the Communication Services resource. - * @param credentialOrOptions - The key or token credential or JobRouterClientOptions. Use AzureCommunicationKeyCredential from \@azure/communication-common to create a credential. - * @param maybeOptions - Additional client options. - */ - constructor( - connectionStringOrUrl: string, - credentialOrOptions?: - | KeyCredential - | TokenCredential - | CommunicationTokenCredential - | JobRouterClientOptions, - maybeOptions: JobRouterClientOptions = {} - ) { - const { url, credential } = parseClientArguments(connectionStringOrUrl, credentialOrOptions); - const options = isRouterClientOptions(credentialOrOptions) ? credentialOrOptions : maybeOptions; - - const libInfo = `azsdk-js-communication-job-router/${SDK_VERSION}`; - - if (!options.userAgentOptions) { - options.userAgentOptions = {}; - } - - const userAgentOptions = { ...options.userAgentOptions }; - if (options.userAgentOptions.userAgentPrefix) { - userAgentOptions.userAgentPrefix = `${options.userAgentOptions.userAgentPrefix} ${libInfo}`; - } else { - userAgentOptions.userAgentPrefix = libInfo; - } - - const internalPipelineOptions: InternalPipelineOptions = { - ...options, - userAgentOptions, - loggingOptions: { - logger: logger.info, - }, - }; - - const authPolicy = createCommunicationAuthPolicy(credential); - - this.client = new JobRouterApiClient(url, internalPipelineOptions); - this.client.pipeline.addPolicy(authPolicy); - } - - // TODO. Add tracing to both clients https://github.com/Azure/azure-sdk-for-js/issues/23008 - /** - * Creates a job. - * @param jobId - The id of the job to create. - * @param options - Options for creating a job. - * @returns - The created job. - */ - public async createJob( - jobId: string, - options: CreateJobOptions = {} - ): Promise { - const patch = options as RouterJobGenerated; - patch.notes = transformNotesForService(options.notes); - patch.matchingMode = transformMatchingModeForService(options?.matchingMode); - if (patch.matchingMode === undefined) { - delete patch.matchingMode; - } - - const response = await this.client.jobRouter.upsertJob(jobId, patch, options); - return response as RouterJobResponse; - } - - /** - * Updates a job. - * @param jobId - The id of the job to update. - * @param options - Options for updating a job. Uses merge-patch semantics: https://datatracker.ietf.org/doc/html/rfc7386. - * @returns - The updated job. - */ - public async updateJob( - jobId: string, - options: UpdateJobOptions = {} - ): Promise { - const patch = options as RouterJobGenerated; - patch.notes = transformNotesForService(options.notes); - patch.matchingMode = transformMatchingModeForService(options?.matchingMode); - if (patch.matchingMode === undefined) { - delete patch.matchingMode; - } - - const response = await this.client.jobRouter.upsertJob(jobId, patch, options); - return response as RouterJobResponse; - } - - /** - * Gets a job. - * @param jobId - The id of the job to get. - * @param options - Options for getting a job. - * @returns - The job. - */ - public async getJob(jobId: string, options: OperationOptions = {}): Promise { - const response = await this.client.jobRouter.getJob(jobId, options); - return response as RouterJobResponse; - } - - /** - * Gets a list of jobs. - * @param options - Options for listing jobs. - * @returns - The list of jobs. - */ - public listJobs( - options: ListJobsOptions = {} - ): TransformingPagedAsyncIterableIterator { - const listOptions = options; - listOptions.maxpagesize = options.maxPageSize; - listOptions.status = options.statusSelector; - - const transformingIterator = new TransformingPagedAsyncIterableIterator( - this.client.jobRouter.listJobs(listOptions), - listJobsTransform - ); - - return transformingIterator; - } - - /** - * Gets a job's queue position. - * @param jobId - The id of the job to get the queue position of. - * @param options - Options for getting a job's queue position. - * @returns - The job's queue position. - */ - public async getJobQueuePosition( - jobId: string, - options: OperationOptions = {} - ): Promise { - return this.client.jobRouter.getInQueuePosition(jobId, options); - } - - /** - * Cancels a job. - * @param jobId - The id of the job to cancel. - * @param options - Options for cancelling a job. - */ - public async cancelJob( - jobId: string, - options: CancelJobOptions = {} - ): Promise { - return this.client.jobRouter.cancelJobAction(jobId, options); - } - - /** - * Completes a job. - * @param jobId - The id of the job to complete. - * @param assignmentId - The id of the assignment to complete. - * @param options - Options for completing a job. - */ - public async completeJob( - jobId: string, - assignmentId: string, - options: CompleteJobOptions = {} - ): Promise { - return this.client.jobRouter.completeJobAction(jobId, assignmentId, options); - } - - /** - * Updates a job and forces it to be reclassified. - * @param jobId - The id of the job to reclassify. - * @param options - Options for reclassifying a job. - */ - public async reclassifyJob( - jobId: string, - options: ReclassifyJobOptions = {} - ): Promise { - return this.client.jobRouter.reclassifyJobAction(jobId, options); - } - - /** - * Closes a job. - * @param jobId - The id of the job to close. - * @param assignmentId - The assignment id corresponding to the job to be closed. - * @param options - Options for closing a job. - */ - public async closeJob( - jobId: string, - assignmentId: string, - options: CloseJobOptions = {} - ): Promise { - return this.client.jobRouter.closeJobAction(jobId, assignmentId, options); - } - - /** - * Unassigns a job. - * @param jobId - The id of the job to unassign. - * @param assignmentId - The assignment id corresponding to the job to be unassigned. - * @param options - Options for unassigning a job. - */ - public async unassignJob( - jobId: string, - assignmentId: string, - options: UnassignJobOptions = {} - ): Promise { - return this.client.jobRouter.unassignJobAction(jobId, assignmentId, options); - } - - /** - * Deletes a job. - * @param jobId - The id of the job to delete. - * @param options - Options for deleting a job. - */ - public async deleteJob(jobId: string, options: OperationOptions = {}): Promise { - return this.client.jobRouter.deleteJob(jobId, options); - } - - /** - * Accepts a job offer. - * @param workerId - The id of the worker that accepts the job. - * @param offerId - The id of the offer to accept. - * @param options - Options for accepting a job offer. - */ - public async acceptJobOffer( - workerId: string, - offerId: string, - options: OperationOptions = {} - ): Promise { - return this.client.jobRouter.acceptJobAction(workerId, offerId, options); - } - - /** - * Declines a job offer. - * @param workerId - The id of the worker holding the offer. - * @param offerId - The id of the offer to decline. - * @param options - Options for declining a job offer. - */ - public async declineJobOffer( - workerId: string, - offerId: string, - options: DeclineJobOfferOptions = {} - ): Promise { - return this.client.jobRouter.declineJobAction(workerId, offerId, options); - } - - /** - * Creates a worker. - * @param workerId - The id of the worker to create. - * @param options - Options for creating a worker. - * @returns - The created worker. - */ - public async createWorker( - workerId: string, - options: CreateWorkerOptions = {} - ): Promise { - const response = await this.client.jobRouter.upsertWorker(workerId, options, options); - return response as RouterWorkerResponse; - } - - /** - * Updates a worker. - * @param workerId - The id of the worker to update. - * @param options - Options for updating a worker. Uses merge-patch semantics: https://datatracker.ietf.org/doc/html/rfc7386. - * @returns - The updated worker. - */ - public async updateWorker( - workerId: string, - options: UpdateWorkerOptions = {} - ): Promise { - const response = await this.client.jobRouter.upsertWorker(workerId, options, options); - return response as RouterWorkerResponse; - } - - /** - * Gets a worker. - * @param workerId - The id of the worker to get. - * @param options - Options for getting a worker. - * @returns - The worker. - */ - public async getWorker( - workerId: string, - options: OperationOptions = {} - ): Promise { - const response = await this.client.jobRouter.getWorker(workerId, options); - return response as RouterWorkerResponse; - } - - /** - * Gets a list of workers. - * @param options - Options for listing workers. - * @returns - The list of workers. - */ - public listWorkers( - options: ListWorkersOptions = {} - ): TransformingPagedAsyncIterableIterator { - const listOptions = options; - listOptions.maxpagesize = options.maxPageSize; - - const transformingIterator = new TransformingPagedAsyncIterableIterator( - this.client.jobRouter.listWorkers(listOptions), - listWorkersTransform - ); - - return transformingIterator; - } - - /** - * Deletes a worker. - * @param workerId - The id of the worker to delete. - * @param options - Options for deleting a worker. - */ - public async deleteWorker(workerId: string, options: OperationOptions = {}): Promise { - return this.client.jobRouter.deleteWorker(workerId, options); - } - - /** - * Gets a queue's statistics. - * @param queueId - The id of the queue to get statistics of. - * @param options - Options for getting a queue's statistics. - * @returns - The queue's statistics. - */ - public async getQueueStatistics( - queueId: string, - options: OperationOptions = {} - ): Promise { - return this.client.jobRouter.getQueueStatistics(queueId, options); - } -} diff --git a/sdk/communication/communication-job-router/src/logger.ts b/sdk/communication/communication-job-router/src/logger.ts index 258dae041e0a..9c41962553ee 100644 --- a/sdk/communication/communication-job-router/src/logger.ts +++ b/sdk/communication/communication-job-router/src/logger.ts @@ -2,5 +2,4 @@ // Licensed under the MIT license. import { createClientLogger } from "@azure/logger"; - export const logger = createClientLogger("communication-job-router"); diff --git a/sdk/communication/communication-job-router/src/models.ts b/sdk/communication/communication-job-router/src/models.ts index 331e6ce9a76a..7dce014e57b8 100644 --- a/sdk/communication/communication-job-router/src/models.ts +++ b/sdk/communication/communication-job-router/src/models.ts @@ -1,640 +1,625 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { - ScoringRuleParameterSelector, - ExpressionRouterRuleLanguage, - RouterWorkerSelectorStatus, - JobMatchModeType, - RouterWorkerState, - RouterJobStatus, - LabelOperator, - RouterRule, - DirectMapRouterRule, - FunctionRouterRule, - WebhookRouterRule, - ScheduleAndSuspendMode, - ChannelConfiguration, - RouterJobOffer, - RouterWorkerAssignment, - RouterJobAssignment, - ExceptionAction, - CancelExceptionAction, - ExceptionTriggerUnion, - DistributionMode, - QueueSelectorAttachment, - WorkerSelectorAttachment, - LongestIdleMode, - RoundRobinMode, -} from "./generated/src"; - -/** Safe type instead of 'any'. */ -export type JSONValue = boolean | number | string | JSONArray | JSONObject; - -/** Safe type for objects. */ -export interface JSONObject { - [key: string]: JSONValue; -} - -/** Safe type for arrays. */ -export interface JSONArray extends ArrayLike {} +/** A container for the rules that govern how jobs are classified. */ +export interface ClassificationPolicy { + /** Friendly name of this policy. */ + name?: string; + /** The fallback queue to select if the queue selector doesn't find a match. */ + fallbackQueueId?: string; + /** The queue selector attachments used to resolve a queue for a given job. */ + queueSelectorAttachments?: Array; + /** The rule to determine a priority score for a given job. */ + prioritizationRule?: RouterRule; + /** The worker selector attachments used to attach worker selectors to a given job. */ + workerSelectorAttachments?: Array; +} -/** - * Note with timestamp for a router job. - */ -export interface RouterJobNote { - /** Timestamp in UTC of when the note was recorded. */ - addedAt: Date; - /** The content of the note. */ - message: string; +/** An attachment of queue selectors to resolve a queue to a job from a classification policy */ +export interface QueueSelectorAttachmentParent { + kind: string; } -/** Queue and match job matching mode type. */ -export interface QueueAndMatchMode {} +/** Describes a set of queue selectors that will be attached if the given condition resolves to true */ +export interface ConditionalQueueSelectorAttachment + extends QueueSelectorAttachmentParent { + /** The condition that must be true for the queue selectors to be attached */ + condition: RouterRule; + /** The queue selectors to attach */ + queueSelectors: Array; + /** The type discriminator describing the type of queue selector attachment */ + kind: "conditional"; +} -/** Suspend job matching mode type. */ -export interface SuspendMode {} +/** + * A rule of one of the following types: + * StaticRule: A rule providing static rules that always return the same result, regardless of input. + * DirectMapRule: A rule that return the same labels as the input labels. + * ExpressionRule: A rule providing inline expression rules. + * FunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. + * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. + */ +export interface RouterRuleParent { + kind: string; +} -/** Queue and match job matching mode. */ -export interface RouterJobMatchingMode { - /** Type of matching mode. */ - modeType?: JobMatchModeType; - /** (Optional) Options for when match mode is queue and match. */ - queueAndMatchMode?: QueueAndMatchMode; - /** (Optional) Options for when match mode is schedule and suspend. */ - scheduleAndSuspendMode?: ScheduleAndSuspendMode; - /** (Optional) Options for when match mode is suspend. */ - suspendMode?: SuspendMode; +/** A rule that return the same labels as the input labels. */ +export interface DirectMapRouterRule extends RouterRuleParent { + /** The type discriminator describing a sub-type of Rule */ + kind: "directMap"; } -/** A unit of work to be routed. */ -export interface RouterJob { - /** - * The id of the job. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly id?: string; - /** Reference to an external parent context, eg. call id. */ - channelReference?: string; - /** - * The status of the Job. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly status?: RouterJobStatus; - /** - * The time a job was queued in UTC. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly enqueuedAt?: Date; - /** The channel identifier. eg. voice, chat, etc. */ - channelId?: string; - /** The Id of the Classification policy used for classifying a job. */ - classificationPolicyId?: string; - /** The Id of the Queue that this job is queued to. */ - queueId?: string; - /** The priority of this job. */ - priority?: number; - /** Reason code for cancelled or closed jobs. */ - dispositionCode?: string; - /** A collection of manually specified label selectors, which a worker must satisfy in order to process this job. */ - requestedWorkerSelectors?: RouterWorkerSelector[]; - /** - * A collection of label selectors attached by a classification policy, which a worker must satisfy in order to process this job. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly attachedWorkerSelectors?: RouterWorkerSelector[]; - /** A set of key/value pairs that are identifying attributes used by the rules engines to make decisions. */ - labels?: JSONObject; - /** - * A collection of the assignments of the job. - * Key is AssignmentId. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly assignments?: { [propertyName: string]: RouterJobAssignment }; - /** A set of non-identifying attributes attached to this job */ - tags?: JSONObject; - /** Notes attached to a job, sorted by timestamp */ - notes?: RouterJobNote[]; +/** A rule providing inline expression rules. */ +export interface ExpressionRouterRule extends RouterRuleParent { /** - * If set, job will be scheduled to be enqueued at a given time - * NOTE: This property will not be serialized. It can only be populated by the server. + * The expression language to compile to and execute + * + * Possible values: powerFx */ - readonly scheduledAt?: Date; - /** The mode the job is matched as. */ - matchingMode?: RouterJobMatchingMode; + language?: string; + /** The string containing the expression to evaluate. Should contain return statement with calculated values. */ + expression: string; + /** The type discriminator describing a sub-type of Rule */ + kind: "expression"; } -/** An entity for jobs to be routed to. */ -export interface RouterWorker { - /** NOTE: This property will not be serialized. It can only be populated by the server. */ - readonly id?: string; - /** - * The current state of the worker. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly state?: RouterWorkerState; - /** The queue(s) that this worker can receive work from. */ - 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?: JSONObject; - /** A set of non-identifying attributes attached to this worker. */ - tags?: JSONObject; - /** The channel(s) this worker can handle and their impact on the workers capacity. */ - channelConfigurations?: { [propertyName: string]: ChannelConfiguration }; - /** - * A list of active offers issued to this worker. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly offers?: RouterJobOffer[]; - /** - * A list of assigned jobs attached to this worker. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly assignedJobs?: RouterWorkerAssignment[]; - /** - * A value indicating the workers capacity. A value of '1' means all capacity is consumed. A value of '0' means no capacity is currently consumed. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly loadRatio?: number; - /** A flag indicating this worker is open to receive offers or not. */ - availableForOffers?: boolean; +/** A rule providing a binding to an HTTP Triggered Azure Function. */ +export interface FunctionRouterRule extends RouterRuleParent { + /** URL for Azure Function */ + functionUri: string; + /** Credentials used to access Azure function rule */ + credential?: FunctionRouterRuleCredential; + /** The type discriminator describing a sub-type of Rule */ + kind: "function"; } -/** Describes a condition that must be met against a set of labels for worker selection. */ -export interface RouterWorkerSelector { +/** Credentials used to access Azure function rule */ +export interface FunctionRouterRuleCredential { + /** Access key scoped to a particular function */ + functionKey?: string; + /** Access key scoped to a Azure Function app. This key grants access to all functions under the app. */ + appKey?: string; + /** Client id, when AppKey is provided In context of Azure function, this is usually the name of the key */ + clientId?: string; +} + +/** A rule providing static rules that always return the same result, regardless of input. */ +export interface StaticRouterRule extends RouterRuleParent { + /** The static value this rule always returns. Values must be primitive values - number, string, boolean. */ + value?: unknown; + /** The type discriminator describing a sub-type of Rule */ + kind: "static"; +} + +/** A rule providing a binding to an external web server. */ +export interface WebhookRouterRule extends RouterRuleParent { + /** Uri for Authorization Server. */ + authorizationServerUri?: string; + /** OAuth2.0 Credentials used to Contoso's Authorization server. Reference: https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/ */ + clientCredential?: OAuth2WebhookClientCredential; + /** Uri for Contoso's Web Server. */ + webhookUri?: string; + /** The type discriminator describing a sub-type of Rule */ + kind: "webhook"; +} + +/** OAuth2.0 Credentials used to Contoso's Authorization server. Reference: https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/ */ +export interface OAuth2WebhookClientCredential { + /** ClientId for Contoso Authorization server. */ + clientId?: string; + /** Client secret for Contoso Authorization server. */ + clientSecret?: string; +} + +/** Describes a condition that must be met against a set of labels for queue selection */ +export interface RouterQueueSelector { /** The label key to query against */ key: string; - /** Describes how the value of the label is compared to the value defined on the label selector */ - labelOperator: LabelOperator; - /** The value to compare against the actual label value with the given operator */ - value?: JSONValue; - /** Describes how long this label selector is valid in seconds. */ - expiresAfterSeconds?: number; - /** Pushes the job to the front of the queue as long as this selector is active. */ - expedite?: boolean; - /** - * The status of the worker selector. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly status?: RouterWorkerSelectorStatus; /** - * The time at which this worker selector expires in UTC - * NOTE: This property will not be serialized. It can only be populated by the server. + * Describes how the value of the label is compared to the value defined on the label selector + * + * Possible values: equal, notEqual, lessThan, lessThanOrEqual, greaterThan, greaterThanOrEqual */ - readonly expiresAt?: Date; + labelOperator: string; + /** The value to compare against the actual label value with the given operator. Values must be primitive values - number, string, boolean. */ + value?: unknown; } -/** A queue that can contain jobs to be routed. */ -export interface RouterQueue { +/** Attaches a queue selector where the value is passed through from the job label with the same key */ +export interface PassThroughQueueSelectorAttachment + extends QueueSelectorAttachmentParent { + /** The label key to query against */ + key: string; /** - * The Id of this queue - * NOTE: This property will not be serialized. It can only be populated by the server. + * Describes how the value of the label is compared to the value pass through + * + * Possible values: equal, notEqual, lessThan, lessThanOrEqual, greaterThan, greaterThanOrEqual */ - readonly id?: string; - /** The name of this queue. */ - name?: string; - /** 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?: JSONObject; - /** (Optional) The id of the exception policy that determines various job escalation rules. */ - exceptionPolicyId?: string; + labelOperator: string; + /** The type discriminator describing the type of queue selector attachment */ + kind: "passThrough"; } -/** Paged instance of RouterJob */ -export interface RouterJobItem { - /** A unit of work to be routed */ - job?: RouterJob; - /** (Optional) The Concurrency Token. */ - etag?: string; +/** Attaches queue selectors to a job when the RouterRule is resolved */ +export interface RuleEngineQueueSelectorAttachment + extends QueueSelectorAttachmentParent { + /** A RouterRule that resolves a collection of queue selectors to attach */ + rule: RouterRule; + /** The type discriminator describing the type of queue selector attachment */ + kind: "ruleEngine"; } -/** Paged instance of RouterWorker */ -export interface RouterWorkerItem { - /** An entity for jobs to be routed to */ - worker?: RouterWorker; - /** (Optional) The Concurrency Token. */ - etag?: string; +/** Describes a queue selector that will be attached to the job */ +export interface StaticQueueSelectorAttachment + extends QueueSelectorAttachmentParent { + /** The queue selector to attach. */ + queueSelector: RouterQueueSelector; + /** The type discriminator describing the type of queue selector attachment */ + kind: "static"; } -/** Paged instance of RouterQueue */ -export interface RouterQueueItem { - /** A queue that can contain jobs to be routed. */ - queue?: RouterQueue; - /** (Optional) The Concurrency Token. */ - etag?: string; +/** Describes multiple sets of queue selectors, of which one will be selected and attached according to a weighting */ +export interface WeightedAllocationQueueSelectorAttachment + extends QueueSelectorAttachmentParent { + /** A collection of percentage based weighted allocations. */ + allocations: Array; + /** The type discriminator describing the type of queue selector attachment */ + kind: "weightedAllocation"; } -/** Describes a condition that must be met against a set of labels for queue selection. */ -export interface RouterQueueSelector { - /** The label key to query against. */ - key: string; - /** Describes how the value of the label is compared to the value defined on the label selector. */ - labelOperator: LabelOperator; - /** The value to compare against the actual label value with the given operator. */ - value?: JSONValue; +/** Contains the weight percentage and queue selectors to be applied if selected for weighted distributions. */ +export interface QueueWeightedAllocation { + /** The percentage of this weight, expressed as a fraction of 1. */ + weight: number; + /** A collection of queue selectors that will be applied if this allocation is selected. */ + queueSelectors: Array; } -/** A rule providing static rules that always return the same result, regardless of input. */ -export interface StaticRouterRule extends RouterRule { - /** Polymorphic discriminator, which specifies the different types this object can be. */ - kind: "static-rule"; - /** The static value this rule always returns. */ - value?: JSONValue; +/** An attachment which attaches worker selectors to a job */ +export interface WorkerSelectorAttachmentParent { + kind: string; } -/** An action that modifies labels on a job and then reclassifies it */ -export interface ReclassifyExceptionAction extends ExceptionAction { - /** Polymorphic discriminator, which specifies the different types this object can be. */ - kind: "reclassify"; - /** (optional) The new classification policy that will determine queue, priority and worker selectors. */ - classificationPolicyId?: string; - /** (optional) Dictionary containing the labels to update (or add if not existing) in key-value pairs. */ - labelsToUpsert?: JSONObject; +/** Describes a set of worker selectors that will be attached if the given condition resolves to true */ +export interface ConditionalWorkerSelectorAttachment + extends WorkerSelectorAttachmentParent { + /** The condition that must be true for the worker selectors to be attached */ + condition: RouterRule; + /** The worker selectors to attach */ + workerSelectors: Array; + /** The type discriminator describing the type of worker selector attachment */ + kind: "conditional"; } -/** A rule that defines actions to execute upon a specific trigger. */ -export interface ExceptionRule { - /** The trigger for this exception rule */ - trigger: ExceptionTriggerUnion; - /** A dictionary collection of actions to perform once the exception is triggered. Key is the Id of each exception action. */ - actions: { [propertyName: string]: ExceptionActionUnion }; +/** Describes a condition that must be met against a set of labels for worker selection */ +export interface RouterWorkerSelector { + /** The label key to query against */ + key: string; + /** + * Describes how the value of the label is compared to the value defined on the label selector + * + * Possible values: equal, notEqual, lessThan, lessThanOrEqual, greaterThan, greaterThanOrEqual + */ + labelOperator: string; + /** The value to compare against the actual label value with the given operator. Values must be primitive values - number, string, boolean. */ + value?: unknown; + /** Describes how long this label selector is valid in seconds. */ + expiresAfterSeconds?: number; + /** Pushes the job to the front of the queue as long as this selector is active. */ + expedite?: boolean; } -/** A policy that defines actions to execute when exception are triggered. */ -export interface ExceptionPolicy { +/** Attaches a worker selector where the value is passed through from the job label with the same key */ +export interface PassThroughWorkerSelectorAttachment + extends WorkerSelectorAttachmentParent { + /** The label key to query against */ + key: string; /** - * The Id of the exception policy - * NOTE: This property will not be serialized. It can only be populated by the server. + * Describes how the value of the label is compared to the value pass through + * + * Possible values: equal, notEqual, lessThan, lessThanOrEqual, greaterThan, greaterThanOrEqual */ - readonly id?: string; - /** (Optional) The name of the exception policy. */ - name?: string; - /** (Optional) A dictionary collection of exception rules on the exception policy. Key is the Id of each exception rule. */ - exceptionRules?: { [propertyName: string]: ExceptionRule }; + labelOperator: string; + /** Describes how long the attached label selector is valid in seconds. */ + expiresAfterSeconds?: number; + /** The type discriminator describing the type of worker selector attachment */ + kind: "passThrough"; } -/** Paged instance of ExceptionPolicy */ -export interface ExceptionPolicyItem { - /** A policy that defines actions to execute when exception are triggered. */ - exceptionPolicy?: ExceptionPolicy; - /** (Optional) The Concurrency Token. */ - etag?: string; +/** Attaches worker selectors to a job when a RouterRule is resolved */ +export interface RuleEngineWorkerSelectorAttachment + extends WorkerSelectorAttachmentParent { + /** A RouterRule that resolves a collection of worker selectors to attach */ + rule: RouterRule; + /** The type discriminator describing the type of worker selector attachment */ + kind: "ruleEngine"; } -/** A container for the rules that govern how jobs are classified. */ -export interface ClassificationPolicy { - /** - * Unique identifier of this policy. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly id?: string; - /** Friendly name of this policy. */ - name?: string; - /** The fallback queue to select if the queue selector doesn't find a match. */ - fallbackQueueId?: string; - /** The queue selectors to resolve a queue for a given job. */ - queueSelectors?: QueueSelectorAttachmentUnion[]; - /** - * A rule of one of the following types: - * - * StaticRule: A rule providing static rules that always return the same result, regardless of input. - * DirectMapRule: A rule that return the same labels as the input labels. - * ExpressionRule: A rule providing inline expression rules. - * AzureFunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. - * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. - */ - prioritizationRule?: RouterRuleUnion; - /** The worker label selectors to attach to a given job. */ - workerSelectors?: WorkerSelectorAttachmentUnion[]; +/** Describes a worker selector that will be attached to the job */ +export interface StaticWorkerSelectorAttachment + extends WorkerSelectorAttachmentParent { + /** The worker selector to attach. */ + workerSelector: RouterWorkerSelector; + /** The type discriminator describing the type of worker selector attachment */ + kind: "static"; +} + +/** Describes multiple sets of worker selectors, of which one will be selected and attached according to a weighting */ +export interface WeightedAllocationWorkerSelectorAttachment + extends WorkerSelectorAttachmentParent { + /** A collection of percentage based weighted allocations. */ + allocations: Array; + /** The type discriminator describing the type of worker selector attachment */ + kind: "weightedAllocation"; } -/** Paged instance of ClassificationPolicy */ -export interface ClassificationPolicyItem { - /** A container for the rules that govern how jobs are classified. */ - classificationPolicy?: ClassificationPolicy; - /** (Optional) The Concurrency Token. */ - etag?: string; +/** Contains the weight percentage and worker selectors to be applied if selected for weighted distributions. */ +export interface WorkerWeightedAllocation { + /** The percentage of this weight, expressed as a fraction of 1. */ + weight: number; + /** A collection of worker selectors that will be applied if this allocation is selected. */ + workerSelectors: Array; } /** Policy governing how jobs are distributed to workers */ export interface DistributionPolicy { - /** - * The unique identifier of the policy. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly id?: string; /** The human readable name of the policy. */ name?: string; /** The number of seconds after which any offers created under this policy will be expired. */ offerExpiresAfterSeconds?: number; /** Abstract base class for defining a distribution mode */ - mode?: DistributionModeUnion; + mode?: DistributionMode; } -/** Paged instance of DistributionPolicy */ -export interface DistributionPolicyItem { - /** Policy governing how jobs are distributed to workers */ - distributionPolicy?: DistributionPolicy; - /** (Optional) The Concurrency Token. */ - etag?: string; -} - -/** 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. */ - continuationToken?: string; +/** Abstract base class for defining a distribution mode */ +export interface DistributionModeParent { + /** Governs the minimum desired number of active concurrent offers a job can have. */ + minConcurrentOffers?: number; + /** Governs the maximum number of active concurrent offers a job can have. */ + maxConcurrentOffers?: number; + /** If set to true, then router will match workers to jobs even if they don't match label selectors. Warning: You may get workers that are not qualified for the job they are matched with if you set this variable to true. This flag is intended more for temporary usage. By default, set to false. */ + bypassSelectors?: boolean; + kind: string; } /** Jobs are distributed to the worker with the strongest abilities available. */ -export interface BestWorkerMode extends DistributionMode { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "best-worker"; - /** - * A rule of one of the following types: - * - * StaticRule: A rule providing static rules that always return the same result, regardless of input. - * DirectMapRule: A rule that return the same labels as the input labels. - * ExpressionRule: A rule providing inline expression rules. - * AzureFunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. - * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. - */ - scoringRule?: RouterRuleUnion; - /** Encapsulates all options that can be passed as parameters for scoring rule with BestWorkerMode */ +export interface BestWorkerMode extends DistributionModeParent { + /** Define a scoring rule to use, when calculating a score to determine the best worker. If not set, will use a default scoring formula that uses the number of job labels that the worker labels match, as well as the number of label selectors the worker labels match and/or exceed using a logistic function (https://en.wikipedia.org/wiki/Logistic_function). */ + scoringRule?: RouterRule; + /** Options to configure 'scoringRule'. If not set, default values are used. */ scoringRuleOptions?: ScoringRuleOptions; + /** The type discriminator describing a sub-type of Mode */ + kind: "bestWorker"; } -/** Describes a set of queue selectors that will be attached if the given condition resolves to true */ -export interface ConditionalQueueSelectorAttachment extends QueueSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "conditional"; - /** - * A rule of one of the following types: - * - * StaticRule: A rule providing static rules that always return the same result, regardless of input. - * DirectMapRule: A rule that return the same labels as the input labels. - * ExpressionRule: A rule providing inline expression rules. - * AzureFunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. - * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. - */ - condition: RouterRuleUnion; - /** The queue selectors to attach */ - queueSelectors: RouterQueueSelector[]; +/** Encapsulates all options that can be passed as parameters for scoring rule with BestWorkerMode */ +export interface ScoringRuleOptions { + /** Set batch size when 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. */ + batchSize?: number; + /** List of extra parameters from the job that will be sent as part of the payload to scoring rule. If not set, the job's labels (sent in the payload as `job`) and the job's worker selectors (sent in the payload as `selectors`) are added to the payload of the scoring rule by default. Note: Worker labels are always sent with scoring payload. */ + scoringParameters?: string[]; + /** If set to true, will score workers in batches, and the parameter name of the worker labels will be sent as `workers`. By default, set to false and the parameter name for the worker labels will be sent as `worker`. Note: If enabled, use 'batchSize' to set batch size. */ + isBatchScoringEnabled?: boolean; + /** If false, will sort scores by ascending order. By default, set to true. */ + descendingOrder?: boolean; } -/** Describes a set of worker selectors that will be attached if the given condition resolves to true */ -export interface ConditionalWorkerSelectorAttachment extends WorkerSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "conditional"; - /** - * A rule of one of the following types: - * - * StaticRule: A rule providing static rules that always return the same result, regardless of input. - * DirectMapRule: A rule that return the same labels as the input labels. - * ExpressionRule: A rule providing inline expression rules. - * AzureFunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. - * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. - */ - condition: RouterRuleUnion; - /** The worker selectors to attach */ - workerSelectors: RouterWorkerSelector[]; +/** Jobs are directed to the worker who has been idle longest. */ +export interface LongestIdleMode extends DistributionModeParent { + /** The type discriminator describing a sub-type of Mode */ + kind: "longestIdle"; } -/** Attaches queue selectors to a job when the RouterRule is resolved */ -export interface RuleEngineQueueSelectorAttachment extends QueueSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "rule-engine"; - /** - * A rule of one of the following types: - * - * StaticRule: A rule providing static rules that always return the same result, regardless of input. - * DirectMapRule: A rule that return the same labels as the input labels. - * ExpressionRule: A rule providing inline expression rules. - * AzureFunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. - * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. - */ - rule: RouterRuleUnion; +/** Jobs are distributed in order to workers, starting with the worker that is after the last worker to receive a job. */ +export interface RoundRobinMode extends DistributionModeParent { + /** The type discriminator describing a sub-type of Mode */ + kind: "roundRobin"; } -/** A rule providing inline expression rules. */ -export interface ExpressionRouterRule extends RouterRule { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "expression-rule"; - /** The expression language to compile to and execute */ - language?: ExpressionRouterRuleLanguage; - /** The string containing the expression to evaluate. Should contain return statement with calculated values. */ - expression: string; +/** A policy that defines actions to execute when exception are triggered. */ +export interface ExceptionPolicy { + /** The name of the exception policy. */ + name?: string; + /** A collection of exception rules on the exception policy. */ + exceptionRules?: Array; } -/** Contains the weight percentage and queue selectors to be applied if selected for weighted distributions. */ -export interface QueueWeightedAllocation { - /** The percentage of this weight, expressed as a fraction of 1. */ - weight: number; - /** A collection of queue selectors that will be applied if this allocation is selected. */ - queueSelectors: RouterQueueSelector[]; +/** A rule that defines actions to execute upon a specific trigger. */ +export interface ExceptionRule { + /** Id of the exception rule. */ + id: string; + /** The trigger for this exception rule */ + trigger: ExceptionTrigger; + /** A collection of actions to perform once the exception is triggered. */ + actions: Array; } -/** Attaches queue selectors to a job when the RouterRule is resolved */ -export interface RuleEngineQueueSelectorAttachment extends QueueSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "rule-engine"; - /** - * A rule of one of the following types: - * - * StaticRule: A rule providing static rules that always return the same result, regardless of input. - * DirectMapRule: A rule that return the same labels as the input labels. - * ExpressionRule: A rule providing inline expression rules. - * AzureFunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. - * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. - */ - rule: RouterRuleUnion; +/** The trigger for this exception rule */ +export interface ExceptionTriggerParent { + kind: string; +} + +/** Trigger for an exception action on exceeding queue length */ +export interface QueueLengthExceptionTrigger extends ExceptionTriggerParent { + /** Threshold of number of jobs ahead in the queue to for this trigger to fire. */ + threshold: number; + /** The type discriminator describing a sub-type of ExceptionTrigger */ + kind: "queueLength"; +} + +/** Trigger for an exception action on exceeding wait time */ +export interface WaitTimeExceptionTrigger extends ExceptionTriggerParent { + /** Threshold for wait time for this trigger. */ + thresholdSeconds: number; + /** The type discriminator describing a sub-type of ExceptionTrigger */ + kind: "waitTime"; +} + +/** The action to take when the exception is triggered */ +export interface ExceptionActionParent { + /** Unique Id of the exception action */ + id?: string; + kind: string; +} + +/** An action that marks a job as cancelled */ +export interface CancelExceptionAction extends ExceptionActionParent { + /** A note that will be appended to the jobs' Notes collection with the current timestamp. */ + note?: string; + /** Indicates the outcome of the job, populate this field with your own custom values. */ + dispositionCode?: string; + /** The type discriminator describing a sub-type of ExceptionAction */ + kind: "cancel"; } /** An action that manually reclassifies a job by providing the queue, priority and worker selectors. */ -export interface ManualReclassifyExceptionAction extends ExceptionAction { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "manual-reclassify"; +export interface ManualReclassifyExceptionAction extends ExceptionActionParent { /** Updated QueueId. */ queueId?: string; /** Updated Priority. */ priority?: number; /** Updated WorkerSelectors. */ - workerSelectors?: RouterWorkerSelector[]; + workerSelectors?: Array; + /** The type discriminator describing a sub-type of ExceptionAction */ + kind: "manualReclassify"; } -/** Attaches worker selectors to a job when a RouterRule is resolved */ -export interface RuleEngineWorkerSelectorAttachment extends WorkerSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "rule-engine"; - /** - * A rule of one of the following types: - * - * StaticRule: A rule providing static rules that always return the same result, regardless of input. - * DirectMapRule: A rule that return the same labels as the input labels. - * ExpressionRule: A rule providing inline expression rules. - * AzureFunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. - * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. - */ - rule: RouterRuleUnion; +/** An action that modifies labels on a job and then reclassifies it */ +export interface ReclassifyExceptionAction extends ExceptionActionParent { + /** The new classification policy that will determine queue, priority and worker selectors. */ + classificationPolicyId?: string; + /** Dictionary containing the labels to update (or add if not existing) in key-value pairs. Values must be primitive values - number, string, boolean. */ + labelsToUpsert?: Record; + /** The type discriminator describing a sub-type of ExceptionAction */ + kind: "reclassify"; } -/** Describes a queue selector that will be attached to the job */ -export interface StaticQueueSelectorAttachment extends QueueSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "static"; - /** Describes a condition that must be met against a set of labels for queue selection */ - queueSelector: RouterQueueSelector; +/** A queue that can contain jobs to be routed. */ +export interface RouterQueue { + /** The name of this queue. */ + name?: string; + /** 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. Values must be primitive values - number, string, boolean. */ + labels?: Record; + /** The ID of the exception policy that determines various job escalation rules. */ + exceptionPolicyId?: string; } -/** Describes multiple sets of queue selectors, of which one will be selected and attached according to a weighting */ -export interface WeightedAllocationQueueSelectorAttachment extends QueueSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "weighted-allocation-queue-selector"; - /** A collection of percentage based weighted allocations. */ - allocations: QueueWeightedAllocation[]; +/** A unit of work to be routed */ +export interface RouterJob { + /** Reference to an external parent context, eg. call ID. */ + channelReference?: string; + /** The channel identifier. eg. voice, chat, etc. */ + channelId?: string; + /** The Id of the Classification policy used for classifying a job. */ + classificationPolicyId?: string; + /** The Id of the Queue that this job is queued to. */ + queueId?: string; + /** The priority of this job. */ + priority?: number; + /** Reason code for cancelled or closed jobs. */ + dispositionCode?: string; + /** A collection of manually specified label selectors, which a worker must satisfy in order to process this job. */ + requestedWorkerSelectors?: Array; + /** A set of key/value pairs that are identifying attributes used by the rules engines to make decisions. Values must be primitive values - number, string, boolean. */ + labels?: Record; + /** A set of non-identifying attributes attached to this job. Values must be primitive values - number, string, boolean. */ + tags?: Record; + /** Notes attached to a job, sorted by timestamp */ + notes?: Array; + /** If provided, will determine how job matching will be carried out. Default mode: QueueAndMatchMode. */ + matchingMode?: JobMatchingMode; } -/** Describes a worker selector that will be attached to the job */ -export interface StaticWorkerSelectorAttachment extends WorkerSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "static"; - /** Describes a condition that must be met against a set of labels for worker selection */ - workerSelector: RouterWorkerSelector; +/** Assignment details of a job to a worker */ +export interface RouterJobAssignment { + /** The Id of the Worker assigned to the job. */ + workerId?: string; + /** The assignment time of the job in UTC. */ + assignedAt: Date | string; + /** The time the job was marked as completed after being assigned in UTC. */ + completedAt?: Date | string; + /** The time the job was marked as closed after being completed in UTC. */ + closedAt?: Date | string; } -/** Attaches a worker selector where the value is passed through from the job label with the same key */ -export interface PassThroughWorkerSelectorAttachment extends WorkerSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "pass-through"; - /** The label key to query against */ - key: string; - /** Describes how the value of the label is compared to the value pass through */ - labelOperator: LabelOperator; - /** Describes how long the attached label selector is valid in seconds. */ - expiresAfterSeconds?: number; +/** A note attached to a job. */ +export interface RouterJobNote { + /** The message contained in the note. */ + message: string; + /** The time at which the note was added in UTC. If not provided, will default to the current time. */ + addedAt?: Date | string; } -/** Describes multiple sets of worker selectors, of which one will be selected and attached according to a weighting */ -export interface WeightedAllocationWorkerSelectorAttachment extends WorkerSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "weighted-allocation-worker-selector"; - /** A collection of percentage based weighted allocations. */ - allocations: WorkerWeightedAllocation[]; +/** + * A matching mode of one of the following types: + * QueueAndMatchMode: Used when matching worker to a job is required to be done right after job is queued. + * ScheduleAndSuspendMode: Used for scheduling jobs to be queued at a future time. At specified time, matching of a worker to the job will not start automatically. + * SuspendMode: Used when matching workers to a job needs to be suspended. + */ +export interface JobMatchingModeParent { + kind: string; } -/** Attaches a queue selector where the value is passed through from the job label with the same key */ -export interface PassThroughQueueSelectorAttachment extends QueueSelectorAttachment { - /** Polymorphic discriminator, which specifies the different types this object can be */ - kind: "pass-through"; - /** The label key to query against */ - key: string; - /** Describes how the value of the label is compared to the value pass through */ - labelOperator: LabelOperator; +/** Describes a matching mode used for scheduling jobs to be queued at a future time. At the specified time, matching worker to a job will not start automatically. */ +export interface ScheduleAndSuspendMode extends JobMatchingModeParent { + /** Scheduled time. */ + scheduleAt: Date | string; + /** The type discriminator describing ScheduleAndSuspendMode */ + kind: "scheduleAndSuspend"; } -/** Contains the weight percentage and worker selectors to be applied if selected for weighted distributions. */ -export interface WorkerWeightedAllocation { - /** The percentage of this weight, expressed as a fraction of 1. */ - weight: number; - /** A collection of worker selectors that will be applied if this allocation is selected. */ - workerSelectors: RouterWorkerSelector[]; +/** Describes a matching mode where matching worker to a job is automatically started after job is queued successfully. */ +export interface QueueAndMatchMode extends JobMatchingModeParent { + /** The type discriminator describing QueueAndMatchMode */ + kind: "queueAndMatch"; } -/** Encapsulates all options that can be passed as parameters for scoring rule with BestWorkerMode */ -export interface ScoringRuleOptions { - /** (Optional) Set batch size when AllowScoringBatchOfWorkers is set to true. Defaults to 20 if not configured. */ - batchSize?: number; - /** - * (Optional) List of extra parameters from the job that will be sent as part of the payload to scoring rule. - * If not set, the job's labels (sent in the payload as `job`) and the job's worker selectors (sent in the payload as `selectors`) - * are added to the payload of the scoring rule by default. - * Note: Worker labels are always sent with scoring payload. - */ - scoringParameters?: ScoringRuleParameterSelector[]; - /** - * (Optional) - * If set to true, will score workers in batches, and the parameter name of the worker labels will be sent as `workers`. - * By default, set to false and the parameter name for the worker labels will be sent as `worker`. - * Note: If enabled, use BatchSize to set batch size. - */ - allowScoringBatchOfWorkers?: boolean; - /** - * (Optional) - * If false, will sort scores by ascending order. By default, set to true. - */ - descendingOrder?: boolean; +/** Describes a matching mode where matching worker to a job is suspended. */ +export interface SuspendMode extends JobMatchingModeParent { + /** The type discriminator describing SuspendMode */ + kind: "suspend"; +} + +/** Request payload for reclassifying jobs */ +export interface ReclassifyJobOptions {} + +/** Request payload for deleting a job */ +export interface CancelJobOptions { + /** A note that will be appended to the jobs' Notes collection with the current timestamp. */ + note?: string; + /** Indicates the outcome of the job, populate this field with your own custom values. If not provided, default value of "Cancelled" is set. */ + dispositionCode?: string; } -export type RouterRuleUnion = - | RouterRule +/** Request payload for completing jobs */ +export interface CompleteJobOptions { + /** A note that will be appended to the jobs' Notes collection with the current timestamp. */ + note?: string; +} + +/** Request payload for closing jobs */ +export interface CloseJobOptions { + /** Indicates the outcome of the job, populate this field with your own custom values. */ + dispositionCode?: string; + /** If not provided, worker capacity is released immediately along with a JobClosedEvent notification. If provided, worker capacity is released along with a JobClosedEvent notification at a future time in UTC. */ + closeAt?: Date | string; + /** A note that will be appended to the jobs' Notes collection with the current timestamp. */ + note?: string; +} + +/** Request payload for unassigning a job. */ +export interface UnassignJobOptions { + /** If SuspendMatching is true, then the job is not queued for re-matching with a worker. */ + suspendMatching?: boolean; +} + +/** Request payload for declining offers */ +export interface DeclineJobOfferOptions { + /** If the RetryOfferAt is not provided, then this job will not be offered again to the worker who declined this job unless the worker is de-registered and re-registered. If a RetryOfferAt time is provided, then the job will be re-matched to eligible workers at the retry time in UTC. The worker that declined the job will also be eligible for the job at that time. */ + retryOfferAt?: Date | string; +} + +/** An entity for jobs to be routed to */ +export interface RouterWorker { + /** The queue(s) that this worker can receive work from. */ + queues?: string[]; + /** The total capacity score this worker has to manage multiple concurrent jobs. */ + capacity?: number; + /** A set of key/value pairs that are identifying attributes used by the rules engines to make decisions. Values must be primitive values - number, string, boolean. */ + labels?: Record; + /** A set of non-identifying attributes attached to this worker. Values must be primitive values - number, string, boolean. */ + tags?: Record; + /** The channel(s) this worker can handle and their impact on the workers capacity. */ + channels?: Array; + /** A flag indicating this worker is open to receive offers or not. */ + availableForOffers?: boolean; +} + +/** Represents the capacity a job in this channel will consume from a worker */ +export interface RouterChannel { + /** Id of the channel. */ + channelId: string; + /** The amount of capacity that an instance of a job of this channel will consume of the total worker capacity. */ + capacityCostPerJob: number; + /** The maximum number of jobs that can be supported concurrently for this channel. */ + maxNumberOfJobs?: number; +} + +/** An offer of a job to a worker */ +export interface RouterJobOffer { + /** The Id of the job. */ + jobId: string; + /** The capacity cost consumed by the job offer. */ + capacityCost: number; + /** The time the offer was created in UTC. */ + offeredAt?: Date | string; + /** The time that the offer will expire in UTC. */ + expiresAt?: Date | string; +} + +/** The assignment for a worker to a job */ +export interface RouterWorkerAssignment { + /** The Id of the assignment. */ + assignmentId: string; + /** The Id of the Job assigned. */ + jobId: string; + /** The amount of capacity this assignment has consumed on the worker. */ + capacityCost: number; + /** The assignment time of the job in UTC. */ + assignedAt: Date | string; +} + +/** An attachment of queue selectors to resolve a queue to a job from a classification policy */ +export type QueueSelectorAttachment = + | ConditionalQueueSelectorAttachment + | PassThroughQueueSelectorAttachment + | RuleEngineQueueSelectorAttachment + | StaticQueueSelectorAttachment + | WeightedAllocationQueueSelectorAttachment; +/** + * A rule of one of the following types: + * StaticRule: A rule providing static rules that always return the same result, regardless of input. + * DirectMapRule: A rule that return the same labels as the input labels. + * ExpressionRule: A rule providing inline expression rules. + * FunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. + * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. + */ +export type RouterRule = | DirectMapRouterRule | ExpressionRouterRule | FunctionRouterRule - | WebhookRouterRule - | StaticRouterRule; - -export type ExceptionActionUnion = - | ExceptionAction - | CancelExceptionAction - | ManualReclassifyExceptionAction - | ReclassifyExceptionAction; - -export type WorkerSelectorAttachmentUnion = - | WorkerSelectorAttachment + | StaticRouterRule + | WebhookRouterRule; +/** An attachment which attaches worker selectors to a job */ +export type WorkerSelectorAttachment = | ConditionalWorkerSelectorAttachment | PassThroughWorkerSelectorAttachment | RuleEngineWorkerSelectorAttachment | StaticWorkerSelectorAttachment | WeightedAllocationWorkerSelectorAttachment; - -export type DistributionModeUnion = - | DistributionMode +/** Abstract base class for defining a distribution mode */ +export type DistributionMode = | BestWorkerMode | LongestIdleMode | RoundRobinMode; - -export type QueueSelectorAttachmentUnion = - | QueueSelectorAttachment - | ConditionalQueueSelectorAttachment - | PassThroughQueueSelectorAttachment - | RuleEngineQueueSelectorAttachment - | StaticQueueSelectorAttachment - | WeightedAllocationQueueSelectorAttachment; - -export { - Oauth2ClientCredential, - ChannelConfiguration, - RouterQueueStatistics, - RouterJobOffer, - RouterJobPositionDetails, - RouterJobAssignment, - RouterWorkerAssignment, - ScheduleAndSuspendMode, - DistributionMode, - LongestIdleMode, - RoundRobinMode, - QueueLengthExceptionTrigger, - WaitTimeExceptionTrigger, - ExceptionTrigger, - CancelExceptionAction, - ExceptionAction, - FunctionRouterRuleCredential, - DirectMapRouterRule, - FunctionRouterRule, - WebhookRouterRule, - RouterRule, - ExceptionTriggerUnion, - WorkerSelectorAttachment, - QueueSelectorAttachment, - ExpressionRouterRuleLanguage, - ScoringRuleParameterSelector, - RouterWorkerSelectorStatus, - RouterWorkerStateSelector, - RouterJobStatusSelector, - JobMatchModeType, - RouterWorkerState, - RouterJobStatus, - LabelOperator, -} from "./generated/src"; +/** The trigger for this exception rule */ +export type ExceptionTrigger = + | QueueLengthExceptionTrigger + | WaitTimeExceptionTrigger; +/** The action to take when the exception is triggered */ +export type ExceptionAction = + | CancelExceptionAction + | ManualReclassifyExceptionAction + | ReclassifyExceptionAction; +/** + * A matching mode of one of the following types: + * QueueAndMatchMode: Used when matching worker to a job is required to be done right after job is queued. + * ScheduleAndSuspendMode: Used for scheduling jobs to be queued at a future time. At specified time, matching of a worker to the job will not start automatically. + * SuspendMode: Used when matching workers to a job needs to be suspended. + */ +export type JobMatchingMode = + | ScheduleAndSuspendMode + | QueueAndMatchMode + | SuspendMode; diff --git a/sdk/communication/communication-job-router/src/options.ts b/sdk/communication/communication-job-router/src/options.ts deleted file mode 100644 index e28a9201a0c5..000000000000 --- a/sdk/communication/communication-job-router/src/options.ts +++ /dev/null @@ -1,394 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - JobRouterAdministrationUpsertClassificationPolicyOptionalParams, - JobRouterAdministrationUpsertDistributionPolicyOptionalParams, - JobRouterAdministrationUpsertExceptionPolicyOptionalParams, - JobRouterAdministrationUpsertQueueOptionalParams, - JobRouterCloseJobActionOptionalParams, - JobRouterDeclineJobActionOptionalParams, - JobRouterReclassifyJobActionOptionalParams, - JobRouterUpsertJobOptionalParams, - JobRouterUpsertWorkerOptionalParams, - JobRouterUnassignJobActionOptionalParams, - ChannelConfiguration, -} from "./generated/src"; -import { CommonClientOptions, OperationOptions } from "@azure/core-client"; -import { - JSONObject, - RouterJobMatchingMode, - RouterJobNote, - RouterRuleUnion, - WorkerSelectorAttachmentUnion, - RouterWorkerSelector, - DistributionModeUnion, - QueueSelectorAttachmentUnion, - ExceptionRule, - RouterJobStatusSelector, - RouterWorkerStateSelector, -} from "./models"; - -/** - * Options to create a job router administration client. - */ -export interface JobRouterAdministrationClientOptions extends CommonClientOptions {} - -/** - * Options to create a job router client. - */ -export interface JobRouterClientOptions extends CommonClientOptions { - /** The headers to be set on requests **/ - headers?: JSONObject; -} - -/** - * Options to create a classification policy. - */ -export interface CreateClassificationPolicyOptions - extends JobRouterAdministrationUpsertClassificationPolicyOptionalParams { - /** Friendly name of this policy. */ - name?: string; - /** The fallback queue to select if the queue selector doesn't find a match. */ - fallbackQueueId?: string; - /** The queue selectors to resolve a queue for a given job. */ - queueSelectors?: QueueSelectorAttachmentUnion[]; - /** The worker selectors to determine workers that are eligible for a given job. */ - workerSelectors?: WorkerSelectorAttachmentUnion[]; - /** Prioritization rule to determine the priority for a given job. */ - prioritizationRule?: RouterRuleUnion; -} - -/** - * Options to update a classification policy. - */ -export interface UpdateClassificationPolicyOptions - extends JobRouterAdministrationUpsertClassificationPolicyOptionalParams { - /** Friendly name of this policy. */ - name?: string; - /** The fallback queue to select if the queue selector doesn't find a match. */ - fallbackQueueId?: string; - /** The queue selectors to resolve a queue for a given job. */ - queueSelectors?: QueueSelectorAttachmentUnion[]; - /** The worker selectors to determine workers that are eligible for a given job. */ - workerSelectors?: WorkerSelectorAttachmentUnion[]; - /** Prioritization rule to determine the priority for a given job. */ - prioritizationRule?: RouterRuleUnion; -} - -/** - * Options to list classification policies. - */ -export interface ListClassificationPoliciesOptions extends OperationOptions { - /** Maximum page size */ - maxPageSize?: number; -} - -/** - * Options to create a distribution policy. - */ -export interface CreateDistributionPolicyOptions - extends JobRouterAdministrationUpsertDistributionPolicyOptionalParams { - /** The human readable name of the policy. */ - name?: string; - /** The expiry time of any offers created under this policy will be governed by the offer time to live. */ - offerExpiresAfterSeconds?: number; - /** The distribution mode used to distribute offers to workers on this queue. */ - mode?: DistributionModeUnion; -} - -/** - * Options to update a distribution policy. - */ -export interface UpdateDistributionPolicyOptions - extends JobRouterAdministrationUpsertDistributionPolicyOptionalParams { - /** The human readable name of the policy. */ - name?: string; - /** The expiry time of any offers created under this policy will be governed by the offer time to live. */ - offerExpiresAfterSeconds?: number; - /** The distribution mode used to distribute offers to workers on this queue. */ - mode?: DistributionModeUnion; -} - -/** - * Options to list distribution policies. - */ -export interface ListDistributionPoliciesOptions extends OperationOptions { - /** Maximum page size */ - maxPageSize?: number; -} - -/** - * Options to create an exception policy. - */ -export interface CreateExceptionPolicyOptions - extends JobRouterAdministrationUpsertExceptionPolicyOptionalParams { - /** (Optional) The name of the exception policy. */ - name?: string; - /** (Optional) A dictionary collection of exception rules on the exception policy. Key is the Id of each exception rule. */ - exceptionRules?: { [propertyName: string]: ExceptionRule }; -} - -/** - * Options to update an exception policy. - */ -export interface UpdateExceptionPolicyOptions - extends JobRouterAdministrationUpsertExceptionPolicyOptionalParams { - /** (Optional) The name of the exception policy. */ - name?: string; - /** (Optional) A dictionary collection of exception rules on the exception policy. Key is the Id of each exception rule. */ - exceptionRules?: { [propertyName: string]: ExceptionRule }; -} - -/** - * Options to list exception policies. - */ -export interface ListExceptionPoliciesOptions extends OperationOptions { - /** Number of objects to return per page */ - maxPageSize?: number; -} - -/** - * Options to create a queue. - */ -export interface CreateQueueOptions extends JobRouterAdministrationUpsertQueueOptionalParams { - /** The name of this queue. */ - name?: string; - /** 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?: JSONObject; - /** (Optional) The ID of the exception policy that determines various job escalation rules. */ - exceptionPolicyId?: string; -} - -/** - * Options to update a queue. - */ -export interface UpdateQueueOptions extends JobRouterAdministrationUpsertQueueOptionalParams { - /** The name of this queue. */ - name?: string; - /** 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?: JSONObject; - /** (Optional) The ID of the exception policy that determines various job escalation rules. */ - exceptionPolicyId?: string; -} - -/** - * Options to list queues. - */ -export interface ListQueuesOptions extends OperationOptions { - /** Number of objects to return per page */ - maxPageSize?: number; -} - -/** - * Options to create a job. - */ -export interface CreateJobOptions extends JobRouterUpsertJobOptionalParams { - /** Reference to an external parent context, eg. call ID. */ - channelReference?: string; - /** The channel identifier. eg. voice, chat, etc. */ - channelId?: string; - /** The Id of the Classification policy used for classifying a job. */ - classificationPolicyId?: string; - /** The Id of the Queue that this job is queued to. */ - queueId?: string; - /** The priority of this job. */ - priority?: number; - /** Reason code for cancelled or closed jobs. */ - dispositionCode?: string; - /** A collection of manually specified label selectors, which a worker must satisfy in order to process this job. */ - requestedWorkerSelectors?: RouterWorkerSelector[]; - /** 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; - /** Notes attached to a job, sorted by timestamp */ - notes?: RouterJobNote[]; - /** The mode the job is matched as. */ - matchingMode?: RouterJobMatchingMode; -} - -/** - * Options to update a job. - */ -export interface UpdateJobOptions extends JobRouterUpsertJobOptionalParams { - /** Reference to an external parent context, eg. call ID. */ - channelReference?: string; - /** The channel identifier. eg. voice, chat, etc. */ - channelId?: string; - /** The Id of the Classification policy used for classifying a job. */ - classificationPolicyId?: string; - /** The Id of the Queue that this job is queued to. */ - queueId?: string; - /** The priority of this job. */ - priority?: number; - /** Reason code for cancelled or closed jobs. */ - dispositionCode?: string; - /** A collection of manually specified label selectors, which a worker must satisfy in order to process this job. */ - requestedWorkerSelectors?: RouterWorkerSelector[]; - /** 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; - /** Notes attached to a job, sorted by timestamp */ - notes?: RouterJobNote[]; - /** The mode the job is matched as. */ - matchingMode?: RouterJobMatchingMode; -} - -/** - * Options to get router jobs. - */ -export interface ListJobsOptions extends OperationOptions { - /** Number of objects to return per page */ - maxPageSize?: number; - /** (Optional) If specified, filter jobs by status. */ - statusSelector?: RouterJobStatusSelector; - /** (Optional) If specified, filter jobs by queue. */ - queueId?: string; - /** (Optional) If specified, filter jobs by channel. */ - channelId?: string; - /** (Optional) If specified, filter jobs by classificationPolicy. */ - classificationPolicyId?: string; - /** (Optional) If specified, filter on jobs that was scheduled before or at given timestamp. Range: (-Inf, scheduledBefore] */ - scheduledBefore?: Date; - /** (Optional) If specified, filter on jobs that was scheduled at or after given value. Range: [scheduledAfter, +Inf). */ - scheduledAfter?: Date; -} - -/** - * Options to reclassify a job. - */ -export interface ReclassifyJobOptions extends JobRouterReclassifyJobActionOptionalParams { - /** Request object for reclassifying a job. */ - reclassifyJobRequest?: JSONObject; -} - -/** - * Options to cancel a job. - */ -export interface CancelJobOptions extends OperationOptions { - /** (Optional) A note that will be appended to the jobs' Notes collection with the current timestamp. */ - note?: string; - /** - * Indicates the outcome of the job, populate this field with your own custom values. - * If not provided, default value of "Cancelled" is set. - */ - dispositionCode?: string; -} - -/** - * Options to complete a job. - */ -export interface CompleteJobOptions extends OperationOptions { - /** (Optional) A note that will be appended to the jobs' Notes collection with the current timestamp. */ - note?: string; -} - -/** - * Options to close a job. - */ -export interface CloseJobOptions extends JobRouterCloseJobActionOptionalParams { - /** Indicates the outcome of the job, populate this field with your own custom values. */ - dispositionCode?: string; - /** - * If not provided, worker capacity is released immediately along with a JobClosedEvent notification. - * If provided, worker capacity is released along with a JobClosedEvent notification at a future time in UTC. - */ - closeAt?: Date; - /** (Optional) A note that will be appended to the jobs' Notes collection with the current timestamp. */ - note?: string; -} - -/** - * Options to unassign a job. - */ -export interface UnassignJobOptions extends JobRouterUnassignJobActionOptionalParams { - /** If WaitForActivation is true, then the job is not queued for re-matching with a worker. */ - suspendMatching?: boolean; -} - -/** - * Options to decline a job. - */ -export interface DeclineJobOfferOptions extends JobRouterDeclineJobActionOptionalParams { - /** - * If the reoffer time is not provided, then this job will not be re-offered to the worker who declined this job unless - * the worker is de-registered and re-registered. If a reoffer time is provided, then the job will be re-matched to - * eligible workers after the reoffer time. The worker that declined the job will also be eligible for the job at that time. - */ - retryOfferAt?: Date; -} - -/** - * Options to create a worker. - */ -export interface CreateWorkerOptions extends JobRouterUpsertWorkerOptionalParams { - /** The queue(s) that this worker can receive work from. */ - 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?: JSONObject; - /** A set of non-identifying attributes attached to this worker. */ - 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. */ - availableForOffers?: boolean; -} - -/** - * Options to update a worker. - */ -export interface UpdateWorkerOptions extends JobRouterUpsertWorkerOptionalParams { - /** The queue(s) that this worker can receive work from. */ - 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?: JSONObject; - /** A set of non-identifying attributes attached to this worker. */ - 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. */ - availableForOffers?: boolean; -} - -/** - * Options to list workers. - */ -export interface ListWorkersOptions extends OperationOptions { - /** Number of objects to return per page */ - maxPageSize?: number; - /** (Optional) If specified, select workers who are assigned to this queue */ - queueId?: string; - /** (Optional) If specified, select workers who have a channel configuration with this channel */ - channelId?: string; - /** (Optional) If specified, select workers by worker status. */ - status?: RouterWorkerStateSelector; - /** (Optional) If true, select workers who have capacity for the channel specified by `channelId` (any channel if `channelId` not specified). If false, does not effect list behavior. Defaults to false. */ - hasCapacity?: boolean; -} - -export { - JobRouterAdministrationUpsertClassificationPolicyOptionalParams, - JobRouterAdministrationUpsertDistributionPolicyOptionalParams, - JobRouterAdministrationUpsertExceptionPolicyOptionalParams, - JobRouterAdministrationUpsertQueueOptionalParams, - JobRouterReclassifyJobActionOptionalParams, - JobRouterUnassignJobActionOptionalParams, - JobRouterCompleteJobActionOptionalParams, - JobRouterCancelJobActionOptionalParams, - JobRouterCloseJobActionOptionalParams, - JobRouterDeclineJobActionOptionalParams, - JobRouterUpsertJobOptionalParams, - JobRouterUpsertWorkerOptionalParams, - DeclineJobOfferRequest, - UnassignJobRequest, -} from "./generated/src"; diff --git a/sdk/communication/communication-job-router/src/outputModels.ts b/sdk/communication/communication-job-router/src/outputModels.ts new file mode 100644 index 000000000000..4c21e42fb9ad --- /dev/null +++ b/sdk/communication/communication-job-router/src/outputModels.ts @@ -0,0 +1,730 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { Paged } from "@azure/core-paging"; + +/** A container for the rules that govern how jobs are classified. */ +export interface ClassificationPolicyOutput { + /** The entity tag for this resource. */ + readonly etag: string; + /** Unique identifier of this policy. */ + readonly id: string; + /** Friendly name of this policy. */ + name?: string; + /** The fallback queue to select if the queue selector doesn't find a match. */ + fallbackQueueId?: string; + /** The queue selector attachments used to resolve a queue for a given job. */ + queueSelectorAttachments?: Array; + /** The rule to determine a priority score for a given job. */ + prioritizationRule?: RouterRuleOutput; + /** The worker selector attachments used to attach worker selectors to a given job. */ + workerSelectorAttachments?: Array; +} + +/** An attachment of queue selectors to resolve a queue to a job from a classification policy */ +export interface QueueSelectorAttachmentOutputParent { + kind: string; +} + +/** Describes a set of queue selectors that will be attached if the given condition resolves to true */ +export interface ConditionalQueueSelectorAttachmentOutput + extends QueueSelectorAttachmentOutputParent { + /** The condition that must be true for the queue selectors to be attached */ + condition: RouterRuleOutput; + /** The queue selectors to attach */ + queueSelectors: Array; + /** The type discriminator describing the type of queue selector attachment */ + kind: "conditional"; +} + +/** + * A rule of one of the following types: + * StaticRule: A rule providing static rules that always return the same result, regardless of input. + * DirectMapRule: A rule that return the same labels as the input labels. + * ExpressionRule: A rule providing inline expression rules. + * FunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. + * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. + */ +export interface RouterRuleOutputParent { + kind: string; +} + +/** A rule that return the same labels as the input labels. */ +export interface DirectMapRouterRuleOutput extends RouterRuleOutputParent { + /** The type discriminator describing a sub-type of Rule */ + kind: "directMap"; +} + +/** A rule providing inline expression rules. */ +export interface ExpressionRouterRuleOutput extends RouterRuleOutputParent { + /** + * The expression language to compile to and execute + * + * Possible values: powerFx + */ + language?: string; + /** The string containing the expression to evaluate. Should contain return statement with calculated values. */ + expression: string; + /** The type discriminator describing a sub-type of Rule */ + kind: "expression"; +} + +/** A rule providing a binding to an HTTP Triggered Azure Function. */ +export interface FunctionRouterRuleOutput extends RouterRuleOutputParent { + /** URL for Azure Function */ + functionUri: string; + /** Credentials used to access Azure function rule */ + credential?: FunctionRouterRuleCredentialOutput; + /** The type discriminator describing a sub-type of Rule */ + kind: "function"; +} + +/** Credentials used to access Azure function rule */ +export interface FunctionRouterRuleCredentialOutput { + /** Access key scoped to a particular function */ + functionKey?: string; + /** Access key scoped to a Azure Function app. This key grants access to all functions under the app. */ + appKey?: string; + /** Client id, when AppKey is provided In context of Azure function, this is usually the name of the key */ + clientId?: string; +} + +/** A rule providing static rules that always return the same result, regardless of input. */ +export interface StaticRouterRuleOutput extends RouterRuleOutputParent { + /** The static value this rule always returns. Values must be primitive values - number, string, boolean. */ + value?: any; + /** The type discriminator describing a sub-type of Rule */ + kind: "static"; +} + +/** A rule providing a binding to an external web server. */ +export interface WebhookRouterRuleOutput extends RouterRuleOutputParent { + /** Uri for Authorization Server. */ + authorizationServerUri?: string; + /** OAuth2.0 Credentials used to Contoso's Authorization server. Reference: https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/ */ + clientCredential?: OAuth2WebhookClientCredentialOutput; + /** Uri for Contoso's Web Server. */ + webhookUri?: string; + /** The type discriminator describing a sub-type of Rule */ + kind: "webhook"; +} + +/** OAuth2.0 Credentials used to Contoso's Authorization server. Reference: https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/ */ +export interface OAuth2WebhookClientCredentialOutput { + /** ClientId for Contoso Authorization server. */ + clientId?: string; + /** Client secret for Contoso Authorization server. */ + clientSecret?: string; +} + +/** Describes a condition that must be met against a set of labels for queue selection */ +export interface RouterQueueSelectorOutput { + /** The label key to query against */ + key: string; + /** + * Describes how the value of the label is compared to the value defined on the label selector + * + * Possible values: equal, notEqual, lessThan, lessThanOrEqual, greaterThan, greaterThanOrEqual + */ + labelOperator: string; + /** The value to compare against the actual label value with the given operator. Values must be primitive values - number, string, boolean. */ + value?: any; +} + +/** Attaches a queue selector where the value is passed through from the job label with the same key */ +export interface PassThroughQueueSelectorAttachmentOutput + extends QueueSelectorAttachmentOutputParent { + /** The label key to query against */ + key: string; + /** + * Describes how the value of the label is compared to the value pass through + * + * Possible values: equal, notEqual, lessThan, lessThanOrEqual, greaterThan, greaterThanOrEqual + */ + labelOperator: string; + /** The type discriminator describing the type of queue selector attachment */ + kind: "passThrough"; +} + +/** Attaches queue selectors to a job when the RouterRule is resolved */ +export interface RuleEngineQueueSelectorAttachmentOutput + extends QueueSelectorAttachmentOutputParent { + /** A RouterRule that resolves a collection of queue selectors to attach */ + rule: RouterRuleOutput; + /** The type discriminator describing the type of queue selector attachment */ + kind: "ruleEngine"; +} + +/** Describes a queue selector that will be attached to the job */ +export interface StaticQueueSelectorAttachmentOutput + extends QueueSelectorAttachmentOutputParent { + /** The queue selector to attach. */ + queueSelector: RouterQueueSelectorOutput; + /** The type discriminator describing the type of queue selector attachment */ + kind: "static"; +} + +/** Describes multiple sets of queue selectors, of which one will be selected and attached according to a weighting */ +export interface WeightedAllocationQueueSelectorAttachmentOutput + extends QueueSelectorAttachmentOutputParent { + /** A collection of percentage based weighted allocations. */ + allocations: Array; + /** The type discriminator describing the type of queue selector attachment */ + kind: "weightedAllocation"; +} + +/** Contains the weight percentage and queue selectors to be applied if selected for weighted distributions. */ +export interface QueueWeightedAllocationOutput { + /** The percentage of this weight, expressed as a fraction of 1. */ + weight: number; + /** A collection of queue selectors that will be applied if this allocation is selected. */ + queueSelectors: Array; +} + +/** An attachment which attaches worker selectors to a job */ +export interface WorkerSelectorAttachmentOutputParent { + kind: string; +} + +/** Describes a set of worker selectors that will be attached if the given condition resolves to true */ +export interface ConditionalWorkerSelectorAttachmentOutput + extends WorkerSelectorAttachmentOutputParent { + /** The condition that must be true for the worker selectors to be attached */ + condition: RouterRuleOutput; + /** The worker selectors to attach */ + workerSelectors: Array; + /** The type discriminator describing the type of worker selector attachment */ + kind: "conditional"; +} + +/** Describes a condition that must be met against a set of labels for worker selection */ +export interface RouterWorkerSelectorOutput { + /** The label key to query against */ + key: string; + /** + * Describes how the value of the label is compared to the value defined on the label selector + * + * Possible values: equal, notEqual, lessThan, lessThanOrEqual, greaterThan, greaterThanOrEqual + */ + labelOperator: string; + /** The value to compare against the actual label value with the given operator. Values must be primitive values - number, string, boolean. */ + value?: any; + /** Describes how long this label selector is valid in seconds. */ + expiresAfterSeconds?: number; + /** Pushes the job to the front of the queue as long as this selector is active. */ + expedite?: boolean; + /** + * The status of the worker selector. + * + * Possible values: active, expired + */ + readonly status?: string; + /** The time at which this worker selector expires in UTC */ + readonly expiresAt?: string; +} + +/** Attaches a worker selector where the value is passed through from the job label with the same key */ +export interface PassThroughWorkerSelectorAttachmentOutput + extends WorkerSelectorAttachmentOutputParent { + /** The label key to query against */ + key: string; + /** + * Describes how the value of the label is compared to the value pass through + * + * Possible values: equal, notEqual, lessThan, lessThanOrEqual, greaterThan, greaterThanOrEqual + */ + labelOperator: string; + /** Describes how long the attached label selector is valid in seconds. */ + expiresAfterSeconds?: number; + /** The type discriminator describing the type of worker selector attachment */ + kind: "passThrough"; +} + +/** Attaches worker selectors to a job when a RouterRule is resolved */ +export interface RuleEngineWorkerSelectorAttachmentOutput + extends WorkerSelectorAttachmentOutputParent { + /** A RouterRule that resolves a collection of worker selectors to attach */ + rule: RouterRuleOutput; + /** The type discriminator describing the type of worker selector attachment */ + kind: "ruleEngine"; +} + +/** Describes a worker selector that will be attached to the job */ +export interface StaticWorkerSelectorAttachmentOutput + extends WorkerSelectorAttachmentOutputParent { + /** The worker selector to attach. */ + workerSelector: RouterWorkerSelectorOutput; + /** The type discriminator describing the type of worker selector attachment */ + kind: "static"; +} + +/** Describes multiple sets of worker selectors, of which one will be selected and attached according to a weighting */ +export interface WeightedAllocationWorkerSelectorAttachmentOutput + extends WorkerSelectorAttachmentOutputParent { + /** A collection of percentage based weighted allocations. */ + allocations: Array; + /** The type discriminator describing the type of worker selector attachment */ + kind: "weightedAllocation"; +} + +/** Contains the weight percentage and worker selectors to be applied if selected for weighted distributions. */ +export interface WorkerWeightedAllocationOutput { + /** The percentage of this weight, expressed as a fraction of 1. */ + weight: number; + /** A collection of worker selectors that will be applied if this allocation is selected. */ + workerSelectors: Array; +} + +/** Provides the 'If-*' headers to enable conditional (cached) responses for JobRouter. */ +export interface RouterConditionalRequestHeadersOutput {} + +/** Policy governing how jobs are distributed to workers */ +export interface DistributionPolicyOutput { + /** The entity tag for this resource. */ + readonly etag: string; + /** The unique identifier of the policy. */ + readonly id: string; + /** The human readable name of the policy. */ + name?: string; + /** The number of seconds after which any offers created under this policy will be expired. */ + offerExpiresAfterSeconds?: number; + /** Abstract base class for defining a distribution mode */ + mode?: DistributionModeOutput; +} + +/** Abstract base class for defining a distribution mode */ +export interface DistributionModeOutputParent { + /** Governs the minimum desired number of active concurrent offers a job can have. */ + minConcurrentOffers?: number; + /** Governs the maximum number of active concurrent offers a job can have. */ + maxConcurrentOffers?: number; + /** If set to true, then router will match workers to jobs even if they don't match label selectors. Warning: You may get workers that are not qualified for the job they are matched with if you set this variable to true. This flag is intended more for temporary usage. By default, set to false. */ + bypassSelectors?: boolean; + kind: string; +} + +/** Jobs are distributed to the worker with the strongest abilities available. */ +export interface BestWorkerModeOutput extends DistributionModeOutputParent { + /** Define a scoring rule to use, when calculating a score to determine the best worker. If not set, will use a default scoring formula that uses the number of job labels that the worker labels match, as well as the number of label selectors the worker labels match and/or exceed using a logistic function (https://en.wikipedia.org/wiki/Logistic_function). */ + scoringRule?: RouterRuleOutput; + /** Options to configure 'scoringRule'. If not set, default values are used. */ + scoringRuleOptions?: ScoringRuleOptionsOutput; + /** The type discriminator describing a sub-type of Mode */ + kind: "bestWorker"; +} + +/** Encapsulates all options that can be passed as parameters for scoring rule with BestWorkerMode */ +export interface ScoringRuleOptionsOutput { + /** Set batch size when 'isBatchScoringEnabled' is set to true. Defaults to 20 if not configured. */ + batchSize?: number; + /** List of extra parameters from the job that will be sent as part of the payload to scoring rule. If not set, the job's labels (sent in the payload as `job`) and the job's worker selectors (sent in the payload as `selectors`) are added to the payload of the scoring rule by default. Note: Worker labels are always sent with scoring payload. */ + scoringParameters?: string[]; + /** If set to true, will score workers in batches, and the parameter name of the worker labels will be sent as `workers`. By default, set to false and the parameter name for the worker labels will be sent as `worker`. Note: If enabled, use 'batchSize' to set batch size. */ + isBatchScoringEnabled?: boolean; + /** If false, will sort scores by ascending order. By default, set to true. */ + descendingOrder?: boolean; +} + +/** Jobs are directed to the worker who has been idle longest. */ +export interface LongestIdleModeOutput extends DistributionModeOutputParent { + /** The type discriminator describing a sub-type of Mode */ + kind: "longestIdle"; +} + +/** Jobs are distributed in order to workers, starting with the worker that is after the last worker to receive a job. */ +export interface RoundRobinModeOutput extends DistributionModeOutputParent { + /** The type discriminator describing a sub-type of Mode */ + kind: "roundRobin"; +} + +/** A policy that defines actions to execute when exception are triggered. */ +export interface ExceptionPolicyOutput { + /** The entity tag for this resource. */ + readonly etag: string; + /** The Id of the exception policy */ + readonly id: string; + /** The name of the exception policy. */ + name?: string; + /** A collection of exception rules on the exception policy. */ + exceptionRules?: Array; +} + +/** A rule that defines actions to execute upon a specific trigger. */ +export interface ExceptionRuleOutput { + /** Id of the exception rule. */ + id: string; + /** The trigger for this exception rule */ + trigger: ExceptionTriggerOutput; + /** A collection of actions to perform once the exception is triggered. */ + actions: Array; +} + +/** The trigger for this exception rule */ +export interface ExceptionTriggerOutputParent { + kind: string; +} + +/** Trigger for an exception action on exceeding queue length */ +export interface QueueLengthExceptionTriggerOutput + extends ExceptionTriggerOutputParent { + /** Threshold of number of jobs ahead in the queue to for this trigger to fire. */ + threshold: number; + /** The type discriminator describing a sub-type of ExceptionTrigger */ + kind: "queueLength"; +} + +/** Trigger for an exception action on exceeding wait time */ +export interface WaitTimeExceptionTriggerOutput + extends ExceptionTriggerOutputParent { + /** Threshold for wait time for this trigger. */ + thresholdSeconds: number; + /** The type discriminator describing a sub-type of ExceptionTrigger */ + kind: "waitTime"; +} + +/** The action to take when the exception is triggered */ +export interface ExceptionActionOutputParent { + /** Unique Id of the exception action */ + id?: string; + kind: string; +} + +/** An action that marks a job as cancelled */ +export interface CancelExceptionActionOutput + extends ExceptionActionOutputParent { + /** A note that will be appended to the jobs' Notes collection with the current timestamp. */ + note?: string; + /** Indicates the outcome of the job, populate this field with your own custom values. */ + dispositionCode?: string; + /** The type discriminator describing a sub-type of ExceptionAction */ + kind: "cancel"; +} + +/** An action that manually reclassifies a job by providing the queue, priority and worker selectors. */ +export interface ManualReclassifyExceptionActionOutput + extends ExceptionActionOutputParent { + /** Updated QueueId. */ + queueId?: string; + /** Updated Priority. */ + priority?: number; + /** Updated WorkerSelectors. */ + workerSelectors?: Array; + /** The type discriminator describing a sub-type of ExceptionAction */ + kind: "manualReclassify"; +} + +/** An action that modifies labels on a job and then reclassifies it */ +export interface ReclassifyExceptionActionOutput + extends ExceptionActionOutputParent { + /** The new classification policy that will determine queue, priority and worker selectors. */ + classificationPolicyId?: string; + /** Dictionary containing the labels to update (or add if not existing) in key-value pairs. Values must be primitive values - number, string, boolean. */ + labelsToUpsert?: Record; + /** The type discriminator describing a sub-type of ExceptionAction */ + kind: "reclassify"; +} + +/** A queue that can contain jobs to be routed. */ +export interface RouterQueueOutput { + /** The entity tag for this resource. */ + readonly etag: string; + /** The Id of this queue */ + readonly id: string; + /** The name of this queue. */ + name?: string; + /** 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. Values must be primitive values - number, string, boolean. */ + labels?: Record; + /** The ID of the exception policy that determines various job escalation rules. */ + exceptionPolicyId?: string; +} + +/** A unit of work to be routed */ +export interface RouterJobOutput { + /** The entity tag for this resource. */ + readonly etag: string; + /** The id of the job. */ + readonly id: string; + /** Reference to an external parent context, eg. call ID. */ + channelReference?: string; + /** + * The status of the Job. + * + * Possible values: pendingClassification, queued, assigned, completed, closed, cancelled, classificationFailed, created, pendingSchedule, scheduled, scheduleFailed, waitingForActivation + */ + readonly status?: string; + /** The time a job was queued in UTC. */ + readonly enqueuedAt?: string; + /** The channel identifier. eg. voice, chat, etc. */ + channelId?: string; + /** The Id of the Classification policy used for classifying a job. */ + classificationPolicyId?: string; + /** The Id of the Queue that this job is queued to. */ + queueId?: string; + /** The priority of this job. */ + priority?: number; + /** Reason code for cancelled or closed jobs. */ + dispositionCode?: string; + /** A collection of manually specified label selectors, which a worker must satisfy in order to process this job. */ + requestedWorkerSelectors?: Array; + /** A collection of label selectors attached by a classification policy, which a worker must satisfy in order to process this job. */ + readonly attachedWorkerSelectors?: Array; + /** A set of key/value pairs that are identifying attributes used by the rules engines to make decisions. Values must be primitive values - number, string, boolean. */ + labels?: Record; + /** A collection of the assignments of the job. Key is AssignmentId. */ + readonly assignments?: Record; + /** A set of non-identifying attributes attached to this job. Values must be primitive values - number, string, boolean. */ + tags?: Record; + /** Notes attached to a job, sorted by timestamp */ + notes?: Array; + /** If set, job will be scheduled to be enqueued at a given time */ + readonly scheduledAt?: string; + /** If provided, will determine how job matching will be carried out. Default mode: QueueAndMatchMode. */ + matchingMode?: JobMatchingModeOutput; +} + +/** Assignment details of a job to a worker */ +export interface RouterJobAssignmentOutput { + /** The Id of the job assignment. */ + readonly assignmentId: string; + /** The Id of the Worker assigned to the job. */ + workerId?: string; + /** The assignment time of the job in UTC. */ + assignedAt: string; + /** The time the job was marked as completed after being assigned in UTC. */ + completedAt?: string; + /** The time the job was marked as closed after being completed in UTC. */ + closedAt?: string; +} + +/** A note attached to a job. */ +export interface RouterJobNoteOutput { + /** The message contained in the note. */ + message: string; + /** The time at which the note was added in UTC. If not provided, will default to the current time. */ + addedAt?: string; +} + +/** + * A matching mode of one of the following types: + * QueueAndMatchMode: Used when matching worker to a job is required to be done right after job is queued. + * ScheduleAndSuspendMode: Used for scheduling jobs to be queued at a future time. At specified time, matching of a worker to the job will not start automatically. + * SuspendMode: Used when matching workers to a job needs to be suspended. + */ +export interface JobMatchingModeOutputParent { + kind: string; +} + +/** Describes a matching mode used for scheduling jobs to be queued at a future time. At the specified time, matching worker to a job will not start automatically. */ +export interface ScheduleAndSuspendModeOutput + extends JobMatchingModeOutputParent { + /** Scheduled time. */ + scheduleAt: string; + /** The type discriminator describing ScheduleAndSuspendMode */ + kind: "scheduleAndSuspend"; +} + +/** Describes a matching mode where matching worker to a job is automatically started after job is queued successfully. */ +export interface QueueAndMatchModeOutput extends JobMatchingModeOutputParent { + /** The type discriminator describing QueueAndMatchMode */ + kind: "queueAndMatch"; +} + +/** Describes a matching mode where matching worker to a job is suspended. */ +export interface SuspendModeOutput extends JobMatchingModeOutputParent { + /** The type discriminator describing SuspendMode */ + kind: "suspend"; +} + +/** Response payload from reclassifying a job */ +export interface ReclassifyJobResultOutput {} + +/** Response payload from cancelling a job */ +export interface CancelJobResultOutput {} + +/** Response payload from completing a job */ +export interface CompleteJobResultOutput {} + +/** Response payload from closing a job */ +export interface CloseJobResultOutput {} + +/** Position and estimated wait time for a job. */ +export interface RouterJobPositionDetailsOutput { + /** Id of the job these details are about. */ + jobId: string; + /** Position of the job in question within that queue. */ + position: number; + /** Id of the queue this job is enqueued in. */ + queueId: string; + /** Length of the queue: total number of enqueued jobs. */ + queueLength: number; + /** Estimated wait time of the job rounded up to the nearest minute */ + estimatedWaitTimeMinutes: number; +} + +/** Response payload after a job has been successfully unassigned. */ +export interface UnassignJobResultOutput { + /** The Id of the job unassigned. */ + jobId: string; + /** The number of times a job is unassigned. At a maximum 3. */ + unassignmentCount: number; +} + +/** Response containing Id's for the worker, job, and assignment from an accepted offer */ +export interface AcceptJobOfferResultOutput { + /** The assignment Id that assigns a worker that has accepted an offer to a job. */ + assignmentId: string; + /** The Id of the job assigned. */ + jobId: string; + /** The Id of the worker that has been assigned this job. */ + workerId: string; +} + +/** Response payload from declining a job */ +export interface DeclineJobOfferResultOutput {} + +/** Statistics for the queue */ +export interface RouterQueueStatisticsOutput { + /** Id of the queue these details are about. */ + queueId: string; + /** Length of the queue: total number of enqueued jobs. */ + length: number; + /** The estimated wait time of this queue rounded up to the nearest minute, grouped by job priority */ + estimatedWaitTimeMinutes?: Record; + /** The wait time of the job that has been enqueued in this queue for the longest. */ + longestJobWaitTimeMinutes?: number; +} + +/** An entity for jobs to be routed to */ +export interface RouterWorkerOutput { + /** The entity tag for this resource. */ + readonly etag: string; + /** Id of the worker. */ + readonly id: string; + /** + * The current state of the worker. + * + * Possible values: active, draining, inactive + */ + readonly state?: string; + /** The queue(s) that this worker can receive work from. */ + queues?: string[]; + /** The total capacity score this worker has to manage multiple concurrent jobs. */ + capacity?: number; + /** A set of key/value pairs that are identifying attributes used by the rules engines to make decisions. Values must be primitive values - number, string, boolean. */ + labels?: Record; + /** A set of non-identifying attributes attached to this worker. Values must be primitive values - number, string, boolean. */ + tags?: Record; + /** The channel(s) this worker can handle and their impact on the workers capacity. */ + channels?: Array; + /** A list of active offers issued to this worker. */ + readonly offers?: Array; + /** A list of assigned jobs attached to this worker. */ + readonly assignedJobs?: Array; + /** A value indicating the workers capacity. A value of '1' means all capacity is consumed. A value of '0' means no capacity is currently consumed. */ + readonly loadRatio?: number; + /** A flag indicating this worker is open to receive offers or not. */ + availableForOffers?: boolean; +} + +/** Represents the capacity a job in this channel will consume from a worker */ +export interface RouterChannelOutput { + /** Id of the channel. */ + channelId: string; + /** The amount of capacity that an instance of a job of this channel will consume of the total worker capacity. */ + capacityCostPerJob: number; + /** The maximum number of jobs that can be supported concurrently for this channel. */ + maxNumberOfJobs?: number; +} + +/** An offer of a job to a worker */ +export interface RouterJobOfferOutput { + /** The Id of the offer. */ + readonly offerId: string; + /** The Id of the job. */ + jobId: string; + /** The capacity cost consumed by the job offer. */ + capacityCost: number; + /** The time the offer was created in UTC. */ + offeredAt?: string; + /** The time that the offer will expire in UTC. */ + expiresAt?: string; +} + +/** The assignment for a worker to a job */ +export interface RouterWorkerAssignmentOutput { + /** The Id of the assignment. */ + assignmentId: string; + /** The Id of the Job assigned. */ + jobId: string; + /** The amount of capacity this assignment has consumed on the worker. */ + capacityCost: number; + /** The assignment time of the job in UTC. */ + assignedAt: string; +} + +/** An attachment of queue selectors to resolve a queue to a job from a classification policy */ +export type QueueSelectorAttachmentOutput = + | ConditionalQueueSelectorAttachmentOutput + | PassThroughQueueSelectorAttachmentOutput + | RuleEngineQueueSelectorAttachmentOutput + | StaticQueueSelectorAttachmentOutput + | WeightedAllocationQueueSelectorAttachmentOutput; +/** + * A rule of one of the following types: + * StaticRule: A rule providing static rules that always return the same result, regardless of input. + * DirectMapRule: A rule that return the same labels as the input labels. + * ExpressionRule: A rule providing inline expression rules. + * FunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. + * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. + */ +export type RouterRuleOutput = + | DirectMapRouterRuleOutput + | ExpressionRouterRuleOutput + | FunctionRouterRuleOutput + | StaticRouterRuleOutput + | WebhookRouterRuleOutput; +/** An attachment which attaches worker selectors to a job */ +export type WorkerSelectorAttachmentOutput = + | ConditionalWorkerSelectorAttachmentOutput + | PassThroughWorkerSelectorAttachmentOutput + | RuleEngineWorkerSelectorAttachmentOutput + | StaticWorkerSelectorAttachmentOutput + | WeightedAllocationWorkerSelectorAttachmentOutput; +/** Abstract base class for defining a distribution mode */ +export type DistributionModeOutput = + | BestWorkerModeOutput + | LongestIdleModeOutput + | RoundRobinModeOutput; +/** The trigger for this exception rule */ +export type ExceptionTriggerOutput = + | QueueLengthExceptionTriggerOutput + | WaitTimeExceptionTriggerOutput; +/** The action to take when the exception is triggered */ +export type ExceptionActionOutput = + | CancelExceptionActionOutput + | ManualReclassifyExceptionActionOutput + | ReclassifyExceptionActionOutput; +/** + * A matching mode of one of the following types: + * QueueAndMatchMode: Used when matching worker to a job is required to be done right after job is queued. + * ScheduleAndSuspendMode: Used for scheduling jobs to be queued at a future time. At specified time, matching of a worker to the job will not start automatically. + * SuspendMode: Used when matching workers to a job needs to be suspended. + */ +export type JobMatchingModeOutput = + | ScheduleAndSuspendModeOutput + | QueueAndMatchModeOutput + | SuspendModeOutput; +/** Paged collection of ClassificationPolicy items */ +export type PagedClassificationPolicyOutput = Paged; +/** Paged collection of DistributionPolicy items */ +export type PagedDistributionPolicyOutput = Paged; +/** Paged collection of ExceptionPolicy items */ +export type PagedExceptionPolicyOutput = Paged; +/** Paged collection of RouterQueue items */ +export type PagedRouterQueueOutput = Paged; +/** Paged collection of RouterJob items */ +export type PagedRouterJobOutput = Paged; +/** Paged collection of RouterWorker items */ +export type PagedRouterWorkerOutput = Paged; diff --git a/sdk/communication/communication-job-router/src/paginateHelper.ts b/sdk/communication/communication-job-router/src/paginateHelper.ts new file mode 100644 index 000000000000..1c9af35b1efd --- /dev/null +++ b/sdk/communication/communication-job-router/src/paginateHelper.ts @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { + getPagedAsyncIterator, + PagedAsyncIterableIterator, + PagedResult, +} from "@azure/core-paging"; +import { + Client, + createRestError, + PathUncheckedResponse, +} from "@azure-rest/core-client"; + +/** + * Helper type to extract the type of an array + */ +export type GetArrayType = T extends Array ? TData : never; + +/** + * The type of a custom function that defines how to get a page and a link to the next one if any. + */ +export type GetPage = ( + pageLink: string, + maxPageSize?: number +) => Promise<{ + page: TPage; + nextPageLink?: string; +}>; + +/** + * Options for the paging helper + */ +export interface PagingOptions { + /** + * Custom function to extract pagination details for crating the PagedAsyncIterableIterator + */ + customGetPage?: GetPage[]>; +} + +/** + * Helper type to infer the Type of the paged elements from the response type + * This type is generated based on the swagger information for x-ms-pageable + * specifically on the itemName property which indicates the property of the response + * where the page items are found. The default value is `value`. + * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter + */ +export type PaginateReturn = TResult extends { + body: { value?: infer TPage }; +} + ? GetArrayType + : Array; + +/** + * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension + * @param client - Client to use for sending the next page requests + * @param initialResponse - Initial response containing the nextLink and current page of elements + * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results + * @returns - PagedAsyncIterableIterator to iterate the elements + */ +export function paginate( + client: Client, + initialResponse: TResponse, + options: PagingOptions = {} +): PagedAsyncIterableIterator> { + // Extract element type from initial response + type TElement = PaginateReturn; + let firstRun = true; + const itemName = "value"; + const nextLinkName = "nextLink"; + const { customGetPage } = options; + const pagedResult: PagedResult = { + firstPageLink: "", + getPage: + typeof customGetPage === "function" + ? customGetPage + : async (pageLink: string) => { + const result = firstRun + ? initialResponse + : await client.pathUnchecked(pageLink).get(); + firstRun = false; + checkPagingRequest(result); + const nextLink = getNextLink(result.body, nextLinkName); + const values = getElements(result.body, itemName); + return { + page: values, + nextPageLink: nextLink, + }; + }, + }; + + return getPagedAsyncIterator(pagedResult); +} + +/** + * Gets for the value of nextLink in the body + */ +function getNextLink(body: unknown, nextLinkName?: string): string | undefined { + if (!nextLinkName) { + return undefined; + } + + const nextLink = (body as Record)[nextLinkName]; + + if (typeof nextLink !== "string" && typeof nextLink !== "undefined") { + throw new Error( + `Body Property ${nextLinkName} should be a string or undefined` + ); + } + + return nextLink; +} + +/** + * Gets the elements of the current request in the body. + */ +function getElements(body: unknown, itemName: string): T[] { + const value = (body as Record)[itemName] as T[]; + + // value has to be an array according to the x-ms-pageable extension. + // The fact that this must be an array is used above to calculate the + // type of elements in the page in PaginateReturn + if (!Array.isArray(value)) { + throw new Error( + `Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}` + ); + } + + return value ?? []; +} + +/** + * Checks if a request failed + */ +function checkPagingRequest(response: PathUncheckedResponse): void { + const Http2xxStatusCodes = [ + "200", + "201", + "202", + "203", + "204", + "205", + "206", + "207", + "208", + "226", + ]; + if (!Http2xxStatusCodes.includes(response.status)) { + throw createRestError( + `Pagination failed with unexpected statusCode ${response.status}`, + response + ); + } +} diff --git a/sdk/communication/communication-job-router/src/parameters.ts b/sdk/communication/communication-job-router/src/parameters.ts new file mode 100644 index 000000000000..bfe9cf135261 --- /dev/null +++ b/sdk/communication/communication-job-router/src/parameters.ts @@ -0,0 +1,351 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { RawHttpHeadersInput } from "@azure/core-rest-pipeline"; +import { RequestParameters } from "@azure-rest/core-client"; +import { + ClassificationPolicy, + DistributionPolicy, + ExceptionPolicy, + RouterQueue, + RouterJob, + ReclassifyJobOptions, + CancelJobOptions, + CompleteJobOptions, + CloseJobOptions, + UnassignJobOptions, + DeclineJobOfferOptions, + RouterWorker, +} from "./models"; + +export interface UpsertClassificationPolicyHeaders { + /** The request should only proceed if an entity matches this string. */ + "If-Match"?: string; + /** The request should only proceed if the entity was not modified after this time. */ + "If-Unmodified-Since"?: string; +} + +/** The resource instance. */ +export type ClassificationPolicyResourceMergeAndPatch = + Partial; + +export interface UpsertClassificationPolicyBodyParam { + /** The resource instance. */ + body: ClassificationPolicyResourceMergeAndPatch; +} + +export interface UpsertClassificationPolicyHeaderParam { + headers?: RawHttpHeadersInput & UpsertClassificationPolicyHeaders; +} + +export interface UpsertClassificationPolicyMediaTypesParam { + /** This request has a JSON Merge Patch body. */ + contentType: "application/merge-patch+json"; +} + +export type UpsertClassificationPolicyParameters = + UpsertClassificationPolicyHeaderParam & + UpsertClassificationPolicyMediaTypesParam & + UpsertClassificationPolicyBodyParam & + RequestParameters; +export type GetClassificationPolicyParameters = RequestParameters; +export type DeleteClassificationPolicyParameters = RequestParameters; + +export interface ListClassificationPoliciesQueryParamProperties { + /** Number of objects to return per page. */ + maxpagesize?: number; +} + +export interface ListClassificationPoliciesQueryParam { + queryParameters?: ListClassificationPoliciesQueryParamProperties; +} + +export type ListClassificationPoliciesParameters = + ListClassificationPoliciesQueryParam & RequestParameters; + +export interface UpsertDistributionPolicyHeaders { + /** The request should only proceed if an entity matches this string. */ + "If-Match"?: string; + /** The request should only proceed if the entity was not modified after this time. */ + "If-Unmodified-Since"?: string; +} + +/** The resource instance. */ +export type DistributionPolicyResourceMergeAndPatch = + Partial; + +export interface UpsertDistributionPolicyBodyParam { + /** The resource instance. */ + body: DistributionPolicyResourceMergeAndPatch; +} + +export interface UpsertDistributionPolicyHeaderParam { + headers?: RawHttpHeadersInput & UpsertDistributionPolicyHeaders; +} + +export interface UpsertDistributionPolicyMediaTypesParam { + /** This request has a JSON Merge Patch body. */ + contentType: "application/merge-patch+json"; +} + +export type UpsertDistributionPolicyParameters = + UpsertDistributionPolicyHeaderParam & + UpsertDistributionPolicyMediaTypesParam & + UpsertDistributionPolicyBodyParam & + RequestParameters; +export type GetDistributionPolicyParameters = RequestParameters; +export type DeleteDistributionPolicyParameters = RequestParameters; + +export interface ListDistributionPoliciesQueryParamProperties { + /** Number of objects to return per page. */ + maxpagesize?: number; +} + +export interface ListDistributionPoliciesQueryParam { + queryParameters?: ListDistributionPoliciesQueryParamProperties; +} + +export type ListDistributionPoliciesParameters = + ListDistributionPoliciesQueryParam & RequestParameters; + +export interface UpsertExceptionPolicyHeaders { + /** The request should only proceed if an entity matches this string. */ + "If-Match"?: string; + /** The request should only proceed if the entity was not modified after this time. */ + "If-Unmodified-Since"?: string; +} + +/** The resource instance. */ +export type ExceptionPolicyResourceMergeAndPatch = Partial; + +export interface UpsertExceptionPolicyBodyParam { + /** The resource instance. */ + body: ExceptionPolicyResourceMergeAndPatch; +} + +export interface UpsertExceptionPolicyHeaderParam { + headers?: RawHttpHeadersInput & UpsertExceptionPolicyHeaders; +} + +export interface UpsertExceptionPolicyMediaTypesParam { + /** This request has a JSON Merge Patch body. */ + contentType: "application/merge-patch+json"; +} + +export type UpsertExceptionPolicyParameters = UpsertExceptionPolicyHeaderParam & + UpsertExceptionPolicyMediaTypesParam & + UpsertExceptionPolicyBodyParam & + RequestParameters; +export type GetExceptionPolicyParameters = RequestParameters; +export type DeleteExceptionPolicyParameters = RequestParameters; + +export interface ListExceptionPoliciesQueryParamProperties { + /** Number of objects to return per page. */ + maxpagesize?: number; +} + +export interface ListExceptionPoliciesQueryParam { + queryParameters?: ListExceptionPoliciesQueryParamProperties; +} + +export type ListExceptionPoliciesParameters = ListExceptionPoliciesQueryParam & + RequestParameters; + +export interface UpsertQueueHeaders { + /** The request should only proceed if an entity matches this string. */ + "If-Match"?: string; + /** The request should only proceed if the entity was not modified after this time. */ + "If-Unmodified-Since"?: string; +} + +/** The resource instance. */ +export type RouterQueueResourceMergeAndPatch = Partial; + +export interface UpsertQueueBodyParam { + /** The resource instance. */ + body: RouterQueueResourceMergeAndPatch; +} + +export interface UpsertQueueHeaderParam { + headers?: RawHttpHeadersInput & UpsertQueueHeaders; +} + +export interface UpsertQueueMediaTypesParam { + /** This request has a JSON Merge Patch body. */ + contentType: "application/merge-patch+json"; +} + +export type UpsertQueueParameters = UpsertQueueHeaderParam & + UpsertQueueMediaTypesParam & + UpsertQueueBodyParam & + RequestParameters; +export type GetQueueParameters = RequestParameters; +export type DeleteQueueParameters = RequestParameters; + +export interface ListQueuesQueryParamProperties { + /** Number of objects to return per page. */ + maxpagesize?: number; +} + +export interface ListQueuesQueryParam { + queryParameters?: ListQueuesQueryParamProperties; +} + +export type ListQueuesParameters = ListQueuesQueryParam & RequestParameters; + +export interface UpsertJobHeaders { + /** The request should only proceed if an entity matches this string. */ + "If-Match"?: string; + /** The request should only proceed if the entity was not modified after this time. */ + "If-Unmodified-Since"?: string; +} + +/** The resource instance. */ +export type RouterJobResourceMergeAndPatch = Partial; + +export interface UpsertJobBodyParam { + /** The resource instance. */ + body: RouterJobResourceMergeAndPatch; +} + +export interface UpsertJobHeaderParam { + headers?: RawHttpHeadersInput & UpsertJobHeaders; +} + +export interface UpsertJobMediaTypesParam { + /** This request has a JSON Merge Patch body. */ + contentType: "application/merge-patch+json"; +} + +export type UpsertJobParameters = UpsertJobHeaderParam & + UpsertJobMediaTypesParam & + UpsertJobBodyParam & + RequestParameters; +export type GetJobParameters = RequestParameters; +export type DeleteJobParameters = RequestParameters; + +export interface ReclassifyBodyParam { + /** Request object for reclassifying a job. */ + body?: ReclassifyJobOptions; +} + +export type ReclassifyParameters = ReclassifyBodyParam & RequestParameters; + +export interface CancelBodyParam { + /** Request model for cancelling job. */ + body?: CancelJobOptions; +} + +export type CancelParameters = CancelBodyParam & RequestParameters; + +export interface CompleteBodyParam { + /** Request model for completing job. */ + body?: CompleteJobOptions; +} + +export type CompleteParameters = CompleteBodyParam & RequestParameters; + +export interface CloseBodyParam { + /** Request model for closing job. */ + body?: CloseJobOptions; +} + +export type CloseParameters = CloseBodyParam & RequestParameters; + +export interface ListJobsQueryParamProperties { + /** Number of objects to return per page. */ + maxpagesize?: number; + /** + * If specified, filter jobs by status. + * + * Possible values: all, pendingClassification, queued, assigned, completed, closed, cancelled, classificationFailed, created, pendingSchedule, scheduled, scheduleFailed, waitingForActivation, active + */ + status?: string; + /** If specified, filter jobs by queue. */ + queueId?: string; + /** If specified, filter jobs by channel. */ + channelId?: string; + /** If specified, filter jobs by classificationPolicy. */ + classificationPolicyId?: string; + /** If specified, filter on jobs that was scheduled before or at given timestamp. Range: (-Inf, scheduledBefore]. */ + scheduledBefore?: Date | string; + /** If specified, filter on jobs that was scheduled at or after given value. Range: [scheduledAfter, +Inf). */ + scheduledAfter?: Date | string; +} + +export interface ListJobsQueryParam { + queryParameters?: ListJobsQueryParamProperties; +} + +export type ListJobsParameters = ListJobsQueryParam & RequestParameters; +export type GetInQueuePositionParameters = RequestParameters; + +export interface UnassignBodyParam { + /** Request body for unassign route. */ + body?: UnassignJobOptions; +} + +export type UnassignParameters = UnassignBodyParam & RequestParameters; +export type AcceptParameters = RequestParameters; + +export interface DeclineBodyParam { + /** Request model for declining offer. */ + body?: DeclineJobOfferOptions; +} + +export type DeclineParameters = DeclineBodyParam & RequestParameters; +export type GetQueueStatisticsParameters = RequestParameters; + +export interface UpsertWorkerHeaders { + /** The request should only proceed if an entity matches this string. */ + "If-Match"?: string; + /** The request should only proceed if the entity was not modified after this time. */ + "If-Unmodified-Since"?: string; +} + +/** The resource instance. */ +export type RouterWorkerResourceMergeAndPatch = Partial; + +export interface UpsertWorkerBodyParam { + /** The resource instance. */ + body: RouterWorkerResourceMergeAndPatch; +} + +export interface UpsertWorkerHeaderParam { + headers?: RawHttpHeadersInput & UpsertWorkerHeaders; +} + +export interface UpsertWorkerMediaTypesParam { + /** This request has a JSON Merge Patch body. */ + contentType: "application/merge-patch+json"; +} + +export type UpsertWorkerParameters = UpsertWorkerHeaderParam & + UpsertWorkerMediaTypesParam & + UpsertWorkerBodyParam & + RequestParameters; +export type GetWorkerParameters = RequestParameters; +export type DeleteWorkerParameters = RequestParameters; + +export interface ListWorkersQueryParamProperties { + /** Number of objects to return per page. */ + maxpagesize?: number; + /** + * If specified, select workers by worker state. + * + * Possible values: active, draining, inactive, all + */ + state?: string; + /** If specified, select workers who have a channel configuration with this channel. */ + channelId?: string; + /** If specified, select workers who are assigned to this queue. */ + queueId?: string; + /** If set to true, select only workers who have capacity for the channel specified by `channelId` or for any channel if `channelId` not specified. If set to false, then will return all workers including workers without any capacity for jobs. Defaults to false. */ + hasCapacity?: boolean; +} + +export interface ListWorkersQueryParam { + queryParameters?: ListWorkersQueryParamProperties; +} + +export type ListWorkersParameters = ListWorkersQueryParam & RequestParameters; diff --git a/sdk/communication/communication-job-router/src/responses.ts b/sdk/communication/communication-job-router/src/responses.ts index 3ad98373188c..8ccef12cd469 100644 --- a/sdk/communication/communication-job-router/src/responses.ts +++ b/sdk/communication/communication-job-router/src/responses.ts @@ -1,71 +1,766 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { RawHttpHeaders } from "@azure/core-rest-pipeline"; +import { HttpResponse, ErrorResponse } from "@azure-rest/core-client"; import { - ClassificationPolicy, - ExceptionPolicy, - DistributionPolicy, - RouterQueue, - RouterJob, - RouterWorker, - JSONValue, -} from "./models"; + ClassificationPolicyOutput, + PagedClassificationPolicyOutput, + DistributionPolicyOutput, + PagedDistributionPolicyOutput, + ExceptionPolicyOutput, + PagedExceptionPolicyOutput, + RouterQueueOutput, + PagedRouterQueueOutput, + RouterJobOutput, + ReclassifyJobResultOutput, + CancelJobResultOutput, + CompleteJobResultOutput, + CloseJobResultOutput, + PagedRouterJobOutput, + RouterJobPositionDetailsOutput, + UnassignJobResultOutput, + AcceptJobOfferResultOutput, + DeclineJobOfferResultOutput, + RouterQueueStatisticsOutput, + RouterWorkerOutput, + PagedRouterWorkerOutput, +} from "./outputModels"; -export interface RouterJobResponse extends RouterJob { - readonly id: string; +export interface UpsertClassificationPolicy200Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; } -export interface RouterWorkerResponse extends RouterWorker { - readonly id: string; +/** The request has succeeded. */ +export interface UpsertClassificationPolicy200Response extends HttpResponse { + status: "200"; + body: ClassificationPolicyOutput; + headers: RawHttpHeaders & UpsertClassificationPolicy200Headers; } -export interface RouterQueueResponse extends RouterQueue { - readonly id: string; +export interface UpsertClassificationPolicy201Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; } -export interface ClassificationPolicyResponse extends ClassificationPolicy { - readonly id: string; +/** The request has succeeded and a new resource has been created as a result. */ +export interface UpsertClassificationPolicy201Response extends HttpResponse { + status: "201"; + body: ClassificationPolicyOutput; + headers: RawHttpHeaders & UpsertClassificationPolicy201Headers; } -export interface DistributionPolicyResponse extends DistributionPolicy { - readonly id: string; +export interface UpsertClassificationPolicyDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; } -export interface ExceptionPolicyResponse extends ExceptionPolicy { - readonly id: string; +export interface UpsertClassificationPolicyDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & UpsertClassificationPolicyDefaultHeaders; } -/** Contains response data for the reclassify job operation. */ -export type ReclassifyJobResponse = { - /** The parsed response body. */ - body: JSONValue; -}; +export interface GetClassificationPolicy200Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; +} + +/** The request has succeeded. */ +export interface GetClassificationPolicy200Response extends HttpResponse { + status: "200"; + body: ClassificationPolicyOutput; + headers: RawHttpHeaders & GetClassificationPolicy200Headers; +} + +export interface GetClassificationPolicyDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface GetClassificationPolicyDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & GetClassificationPolicyDefaultHeaders; +} + +/** There is no content to send for this request, but the headers may be useful. */ +export interface DeleteClassificationPolicy204Response extends HttpResponse { + status: "204"; +} + +export interface DeleteClassificationPolicyDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DeleteClassificationPolicyDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DeleteClassificationPolicyDefaultHeaders; +} + +/** The request has succeeded. */ +export interface ListClassificationPolicies200Response extends HttpResponse { + status: "200"; + body: PagedClassificationPolicyOutput; +} + +export interface ListClassificationPoliciesDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ListClassificationPoliciesDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ListClassificationPoliciesDefaultHeaders; +} + +export interface UpsertDistributionPolicy200Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; +} + +/** The request has succeeded. */ +export interface UpsertDistributionPolicy200Response extends HttpResponse { + status: "200"; + body: DistributionPolicyOutput; + headers: RawHttpHeaders & UpsertDistributionPolicy200Headers; +} + +export interface UpsertDistributionPolicy201Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; +} + +/** The request has succeeded and a new resource has been created as a result. */ +export interface UpsertDistributionPolicy201Response extends HttpResponse { + status: "201"; + body: DistributionPolicyOutput; + headers: RawHttpHeaders & UpsertDistributionPolicy201Headers; +} + +export interface UpsertDistributionPolicyDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface UpsertDistributionPolicyDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & UpsertDistributionPolicyDefaultHeaders; +} + +export interface GetDistributionPolicy200Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; +} + +/** The request has succeeded. */ +export interface GetDistributionPolicy200Response extends HttpResponse { + status: "200"; + body: DistributionPolicyOutput; + headers: RawHttpHeaders & GetDistributionPolicy200Headers; +} + +export interface GetDistributionPolicyDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface GetDistributionPolicyDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & GetDistributionPolicyDefaultHeaders; +} + +/** There is no content to send for this request, but the headers may be useful. */ +export interface DeleteDistributionPolicy204Response extends HttpResponse { + status: "204"; +} + +export interface DeleteDistributionPolicyDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DeleteDistributionPolicyDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DeleteDistributionPolicyDefaultHeaders; +} + +/** The request has succeeded. */ +export interface ListDistributionPolicies200Response extends HttpResponse { + status: "200"; + body: PagedDistributionPolicyOutput; +} + +export interface ListDistributionPoliciesDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ListDistributionPoliciesDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ListDistributionPoliciesDefaultHeaders; +} + +export interface UpsertExceptionPolicy200Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; +} + +/** The request has succeeded. */ +export interface UpsertExceptionPolicy200Response extends HttpResponse { + status: "200"; + body: ExceptionPolicyOutput; + headers: RawHttpHeaders & UpsertExceptionPolicy200Headers; +} + +export interface UpsertExceptionPolicy201Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; +} + +/** The request has succeeded and a new resource has been created as a result. */ +export interface UpsertExceptionPolicy201Response extends HttpResponse { + status: "201"; + body: ExceptionPolicyOutput; + headers: RawHttpHeaders & UpsertExceptionPolicy201Headers; +} + +export interface UpsertExceptionPolicyDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface UpsertExceptionPolicyDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & UpsertExceptionPolicyDefaultHeaders; +} + +export interface GetExceptionPolicy200Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; +} + +/** The request has succeeded. */ +export interface GetExceptionPolicy200Response extends HttpResponse { + status: "200"; + body: ExceptionPolicyOutput; + headers: RawHttpHeaders & GetExceptionPolicy200Headers; +} + +export interface GetExceptionPolicyDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface GetExceptionPolicyDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & GetExceptionPolicyDefaultHeaders; +} + +/** There is no content to send for this request, but the headers may be useful. */ +export interface DeleteExceptionPolicy204Response extends HttpResponse { + status: "204"; +} + +export interface DeleteExceptionPolicyDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DeleteExceptionPolicyDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DeleteExceptionPolicyDefaultHeaders; +} + +/** The request has succeeded. */ +export interface ListExceptionPolicies200Response extends HttpResponse { + status: "200"; + body: PagedExceptionPolicyOutput; +} + +export interface ListExceptionPoliciesDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ListExceptionPoliciesDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ListExceptionPoliciesDefaultHeaders; +} + +export interface UpsertQueue200Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; +} + +/** The request has succeeded. */ +export interface UpsertQueue200Response extends HttpResponse { + status: "200"; + body: RouterQueueOutput; + headers: RawHttpHeaders & UpsertQueue200Headers; +} + +export interface UpsertQueue201Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; +} + +/** The request has succeeded and a new resource has been created as a result. */ +export interface UpsertQueue201Response extends HttpResponse { + status: "201"; + body: RouterQueueOutput; + headers: RawHttpHeaders & UpsertQueue201Headers; +} + +export interface UpsertQueueDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface UpsertQueueDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & UpsertQueueDefaultHeaders; +} + +export interface GetQueue200Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; +} + +/** The request has succeeded. */ +export interface GetQueue200Response extends HttpResponse { + status: "200"; + body: RouterQueueOutput; + headers: RawHttpHeaders & GetQueue200Headers; +} + +export interface GetQueueDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface GetQueueDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & GetQueueDefaultHeaders; +} + +/** There is no content to send for this request, but the headers may be useful. */ +export interface DeleteQueue204Response extends HttpResponse { + status: "204"; +} + +export interface DeleteQueueDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DeleteQueueDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DeleteQueueDefaultHeaders; +} + +/** The request has succeeded. */ +export interface ListQueues200Response extends HttpResponse { + status: "200"; + body: PagedRouterQueueOutput; +} + +export interface ListQueuesDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ListQueuesDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ListQueuesDefaultHeaders; +} + +export interface UpsertJob200Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; +} + +/** The request has succeeded. */ +export interface UpsertJob200Response extends HttpResponse { + status: "200"; + body: RouterJobOutput; + headers: RawHttpHeaders & UpsertJob200Headers; +} + +export interface UpsertJob201Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; +} + +/** The request has succeeded and a new resource has been created as a result. */ +export interface UpsertJob201Response extends HttpResponse { + status: "201"; + body: RouterJobOutput; + headers: RawHttpHeaders & UpsertJob201Headers; +} + +export interface UpsertJobDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface UpsertJobDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & UpsertJobDefaultHeaders; +} + +export interface GetJob200Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; +} + +/** The request has succeeded. */ +export interface GetJob200Response extends HttpResponse { + status: "200"; + body: RouterJobOutput; + headers: RawHttpHeaders & GetJob200Headers; +} + +export interface GetJobDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface GetJobDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & GetJobDefaultHeaders; +} + +/** There is no content to send for this request, but the headers may be useful. */ +export interface DeleteJob204Response extends HttpResponse { + status: "204"; +} + +export interface DeleteJobDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DeleteJobDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DeleteJobDefaultHeaders; +} + +/** The request has succeeded. */ +export interface Reclassify200Response extends HttpResponse { + status: "200"; + body: ReclassifyJobResultOutput; +} + +export interface ReclassifyDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ReclassifyDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ReclassifyDefaultHeaders; +} + +/** The request has succeeded. */ +export interface Cancel200Response extends HttpResponse { + status: "200"; + body: CancelJobResultOutput; +} + +export interface CancelDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface CancelDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & CancelDefaultHeaders; +} + +/** The request has succeeded. */ +export interface Complete200Response extends HttpResponse { + status: "200"; + body: CompleteJobResultOutput; +} + +export interface CompleteDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface CompleteDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & CompleteDefaultHeaders; +} + +/** The request has succeeded. */ +export interface Close200Response extends HttpResponse { + status: "200"; + body: CloseJobResultOutput; +} + +export interface CloseDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface CloseDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & CloseDefaultHeaders; +} + +/** The request has succeeded. */ +export interface ListJobs200Response extends HttpResponse { + status: "200"; + body: PagedRouterJobOutput; +} + +export interface ListJobsDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ListJobsDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ListJobsDefaultHeaders; +} -/** Contains response data for the cancel job operation. */ -export type CancelJobResponse = { - /** The parsed response body. */ - body: JSONValue; -}; +/** The request has succeeded. */ +export interface GetInQueuePosition200Response extends HttpResponse { + status: "200"; + body: RouterJobPositionDetailsOutput; +} + +export interface GetInQueuePositionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface GetInQueuePositionDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & GetInQueuePositionDefaultHeaders; +} -/** Contains response data for the complete job operation. */ -export type CompleteJobResponse = { - /** The parsed response body. */ - body: JSONValue; -}; +/** The request has succeeded. */ +export interface Unassign200Response extends HttpResponse { + status: "200"; + body: UnassignJobResultOutput; +} -/** Contains response data for the close job operation. */ -export type CloseJobResponse = { - /** The parsed response body. */ - body: JSONValue; -}; +export interface UnassignDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} -/** Contains response data for the decline job operation. */ -export type DeclineJobOfferResponse = { - /** The parsed response body. */ - body: JSONValue; -}; +export interface UnassignDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & UnassignDefaultHeaders; +} -export { - AcceptJobOfferResult as AcceptJobOfferResponse, - UnassignJobResult as UnassignJobResponse, -} from "./generated/src"; +/** The request has succeeded. */ +export interface Accept200Response extends HttpResponse { + status: "200"; + body: AcceptJobOfferResultOutput; +} + +export interface AcceptDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface AcceptDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & AcceptDefaultHeaders; +} + +/** The request has succeeded. */ +export interface Decline200Response extends HttpResponse { + status: "200"; + body: DeclineJobOfferResultOutput; +} + +export interface DeclineDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DeclineDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DeclineDefaultHeaders; +} + +/** The request has succeeded. */ +export interface GetQueueStatistics200Response extends HttpResponse { + status: "200"; + body: RouterQueueStatisticsOutput; +} + +export interface GetQueueStatisticsDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface GetQueueStatisticsDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & GetQueueStatisticsDefaultHeaders; +} + +export interface UpsertWorker200Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; +} + +/** The request has succeeded. */ +export interface UpsertWorker200Response extends HttpResponse { + status: "200"; + body: RouterWorkerOutput; + headers: RawHttpHeaders & UpsertWorker200Headers; +} + +export interface UpsertWorker201Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; +} + +/** The request has succeeded and a new resource has been created as a result. */ +export interface UpsertWorker201Response extends HttpResponse { + status: "201"; + body: RouterWorkerOutput; + headers: RawHttpHeaders & UpsertWorker201Headers; +} + +export interface UpsertWorkerDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface UpsertWorkerDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & UpsertWorkerDefaultHeaders; +} + +export interface GetWorker200Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; +} + +/** The request has succeeded. */ +export interface GetWorker200Response extends HttpResponse { + status: "200"; + body: RouterWorkerOutput; + headers: RawHttpHeaders & GetWorker200Headers; +} + +export interface GetWorkerDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface GetWorkerDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & GetWorkerDefaultHeaders; +} + +/** There is no content to send for this request, but the headers may be useful. */ +export interface DeleteWorker204Response extends HttpResponse { + status: "204"; +} + +export interface DeleteWorkerDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DeleteWorkerDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DeleteWorkerDefaultHeaders; +} + +/** The request has succeeded. */ +export interface ListWorkers200Response extends HttpResponse { + status: "200"; + body: PagedRouterWorkerOutput; +} + +export interface ListWorkersDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ListWorkersDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ListWorkersDefaultHeaders; +} diff --git a/sdk/communication/communication-job-router/tsconfig.json b/sdk/communication/communication-job-router/tsconfig.json index 4484b45a0367..f250fbc16d24 100644 --- a/sdk/communication/communication-job-router/tsconfig.json +++ b/sdk/communication/communication-job-router/tsconfig.json @@ -4,9 +4,23 @@ "outDir": "./dist-esm", "declarationDir": "./types", "paths": { - "@azure/communication-job-router": ["./src/index"] + "@azure/communication-job-router": [ + "./src/index" + ] } }, - "exclude": ["node_modules", "types", "temp", "browser", "dist", "dist-esm", "./samples/**/*.ts"], - "include": ["src/**/*.ts", "test/**/*.ts", "samples-dev/**/*.ts"] -} + "exclude": [ + "node_modules", + "types", + "temp", + "browser", + "dist", + "dist-esm", + "./samples/**/*.ts" + ], + "include": [ + "src/**/*.ts", + "test/**/*.ts", + "samples-dev/**/*.ts" + ] +} \ No newline at end of file diff --git a/sdk/communication/communication-job-router/tsp-location.yaml b/sdk/communication/communication-job-router/tsp-location.yaml new file mode 100644 index 000000000000..67011c1892e4 --- /dev/null +++ b/sdk/communication/communication-job-router/tsp-location.yaml @@ -0,0 +1,5 @@ +commit: a54a86884fe1dd97b81f4f65d18e201baea2ee9b +directory: specification/communication/Communication.JobRouter +repo: Azure/azure-rest-api-specs +additionalDirectories: [] +