diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index e29ea4a82c83..bde321a58542 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -734,6 +734,9 @@ dependencies: '@rush-temp/communication-job-router': specifier: file:./projects/communication-job-router.tgz version: file:projects/communication-job-router.tgz + '@rush-temp/communication-job-router-1': + specifier: file:./projects/communication-job-router-1.tgz + version: file:projects/communication-job-router-1.tgz '@rush-temp/communication-network-traversal': specifier: file:./projects/communication-network-traversal.tgz version: file:projects/communication-network-traversal.tgz @@ -2543,7 +2546,7 @@ packages: resolution: {integrity: sha512-oyl4jvAfTGX9Bt6Or4H9ni1Z447/tQuxnZsytsCaExKlmJiU8sFgnIBRzJUpKwB5eWn9HuBYlUlVA74q/yN0eQ==} dependencies: '@types/connect': 3.4.36 - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/chai-as-promised@7.1.6: @@ -2565,7 +2568,7 @@ packages: /@types/connect@3.4.36: resolution: {integrity: sha512-P63Zd/JUGq+PdrM1lv0Wv5SBYeA2+CORvbrXbngriYY0jzLUWfQMQQxOhjONEz/wlHOAxOdY7CY65rgQdTjq2w==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/cookie@0.4.1: @@ -2575,7 +2578,7 @@ packages: /@types/cors@2.8.14: resolution: {integrity: sha512-RXHUvNWYICtbP6s18PnOCaqToK8y14DnLd75c6HfyKf228dxy7pHNOQkxPtvXKp/hINFMDjbYzsj63nnpPMSRQ==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/debug@4.1.9: @@ -2587,7 +2590,7 @@ packages: /@types/decompress@4.2.5: resolution: {integrity: sha512-LdL+kbcKGs9TzvB/K+OBGzPfDoP6gwwTsykYjodlzUJUUYp/43c1p1jE5YTtz3z4Ml90iruvBXbJ6+kDvb3WSQ==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/eslint@8.44.3: @@ -2608,7 +2611,7 @@ packages: /@types/express-serve-static-core@4.17.37: resolution: {integrity: sha512-ZohaCYTgGFcOP7u6aJOhY9uIZQgZ2vxC2yWoArY+FeDXlqeH66ZVBjgvg+RLVAS/DWNq4Ap9ZXu1+SUQiiWYMg==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 '@types/qs': 6.9.8 '@types/range-parser': 1.2.5 '@types/send': 0.17.2 @@ -2626,13 +2629,13 @@ packages: /@types/fs-extra@8.1.3: resolution: {integrity: sha512-7IdV01N0u/CaVO0fuY1YmEg14HQN3+EW8mpNgg6NEfxEl/lzCa5OxlBu3iFsCAdamnYOcTQ7oEi43Xc/67Rgzw==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/fs-extra@9.0.13: resolution: {integrity: sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/http-errors@2.0.2: @@ -2649,7 +2652,7 @@ packages: /@types/is-buffer@2.0.0: resolution: {integrity: sha512-0f7N/e3BAz32qDYvgB4d2cqv1DqUwvGxHkXsrucICn8la1Vb6Yl6Eg8mPScGwUiqHJeE7diXlzaK+QMA9m4Gxw==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/json-schema@7.0.13: @@ -2663,13 +2666,13 @@ packages: /@types/jsonwebtoken@9.0.3: resolution: {integrity: sha512-b0jGiOgHtZ2jqdPgPnP6WLCXZk1T8p06A/vPGzUvxpFGgKMbjXJDjC5m52ErqBnIuWZFgGoIJyRdeG5AyreJjA==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/jws@3.2.6: resolution: {integrity: sha512-SVbs88FPvGVMj19JYVOV+NpWu3HO5LUjz0+z6ks/rdRbrWlxs6fBz6Qxb/PKalZaweJisPyfikeoPu8VlpljQQ==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/linkify-it@3.0.3: @@ -2709,6 +2712,10 @@ packages: resolution: {integrity: sha512-NaHL0+0lLNhX6d9rs+NSt97WH/gIlRHmszXbQ/8/MV/eVcFNdeJ/GYhrFuUc8K7WuPhRhTSdMkCp8VMzhUq85w==} dev: false + /@types/mocha@7.0.2: + resolution: {integrity: sha512-ZvO2tAcjmMi8V/5Z3JsyofMe3hasRcaw88cto5etSVMwVQfeivGAlEYmaQgceUSVYFofVjT+ioHsATjdWcFt1w==} + dev: false + /@types/ms@0.7.32: resolution: {integrity: sha512-xPSg0jm4mqgEkNhowKgZFBNtwoEwF6gJ4Dhww+GFpm3IgtNseHQZ5IqdNwnquZEoANxyDAKDRAdVo4Z72VvD/g==} dev: false @@ -2720,13 +2727,13 @@ packages: /@types/mysql@2.15.21: resolution: {integrity: sha512-NPotx5CVful7yB+qZbWtXL2fA4e7aEHkihHLjklc6ID8aq7bhguHgeIoC1EmSNTAuCgI6ZXrjt2ZSaXnYX0EUg==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/node-fetch@2.6.6: resolution: {integrity: sha512-95X8guJYhfqiuVVhRFxVQcf4hW/2bCuoPwDasMf/531STFoNoWTT7YDnWdXHEZKqAGUigmpG31r2FE70LwnzJw==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 form-data: 4.0.0 dev: false @@ -2751,7 +2758,7 @@ packages: /@types/pg@8.6.1: resolution: {integrity: sha512-1Kc4oAGzAl7uqUStZCDvaLFqZrW9qWSjXOmBfdgyBP5La7Us6Mg4GBvRlSoaZMhQF/zSj1C8CtKMBkoiT8eL8w==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 pg-protocol: 1.6.0 pg-types: 2.2.0 dev: false @@ -2779,7 +2786,7 @@ packages: /@types/resolve@1.17.1: resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/resolve@1.20.2: @@ -2802,7 +2809,7 @@ packages: resolution: {integrity: sha512-aAG6yRf6r0wQ29bkS+x97BIs64ZLxeE/ARwyS6wrldMm3C1MdKwCcnnEwMC1slI8wuxJOpiUH9MioC0A0i+GJw==} dependencies: '@types/mime': 1.3.3 - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/serve-static@1.15.3: @@ -2810,7 +2817,7 @@ packages: dependencies: '@types/http-errors': 2.0.2 '@types/mime': 3.0.2 - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/shimmer@1.0.3: @@ -2830,13 +2837,13 @@ packages: /@types/stoppable@1.1.1: resolution: {integrity: sha512-b8N+fCADRIYYrGZOcmOR8ZNBOqhktWTB/bMUl5LvGtT201QKJZOOH5UsFyI3qtteM6ZAJbJqZoBcLqqxKIwjhw==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/through@0.0.31: resolution: {integrity: sha512-LpKpmb7FGevYgXnBXYs6HWnmiFyVG07Pt1cnbgM1IhEacITTiUaBXXvOR3Y50ksaJWGSfhbEvQFivQEFGCC55w==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/tough-cookie@4.0.3: @@ -2850,7 +2857,7 @@ packages: /@types/tunnel@0.0.3: resolution: {integrity: sha512-sOUTGn6h1SfQ+gbgqC364jLFBw2lnFqkgF3q0WovEHRLMrVD1sd5aufqi/aJObLekJO+Aq5z646U4Oxy6shXMA==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/underscore@1.11.9: @@ -2868,19 +2875,19 @@ packages: /@types/ws@7.4.7: resolution: {integrity: sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/ws@8.5.6: resolution: {integrity: sha512-8B5EO9jLVCy+B58PLHvLDuOD8DRVMgQzq8d55SjLCOn9kqGyqOvy27exVaTio1q1nX5zLu8/6N0n2ThSxOM6tg==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/xml2js@0.4.12: resolution: {integrity: sha512-CZPpQKBZ8db66EP5hCjwvYrLThgZvnyZrPXK2W+UI1oOaWezGt34iOaUCX4Jah2X8+rQqjvl9VKEIT8TR1I0rA==} dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false /@types/yargs-parser@21.0.1: @@ -2897,7 +2904,7 @@ packages: resolution: {integrity: sha512-CHzgNU3qYBnp/O4S3yv2tXPlvMTq0YWSTVg2/JYLqWZGHwwgJGAwd00poay/11asPq8wLFwHzubyInqHIFmmiw==} requiresBuild: true dependencies: - '@types/node': 14.18.63 + '@types/node': 16.18.55 dev: false optional: true @@ -4207,7 +4214,7 @@ packages: dependencies: semver: 7.5.4 shelljs: 0.8.5 - typescript: 5.3.0-dev.20231002 + typescript: 5.3.0-dev.20231005 dev: false /eastasianwidth@0.2.0: @@ -4266,7 +4273,7 @@ packages: dependencies: '@types/cookie': 0.4.1 '@types/cors': 2.8.14 - '@types/node': 14.18.63 + '@types/node': 16.18.55 accepts: 1.3.8 base64id: 2.0.0 cookie: 0.4.2 @@ -5215,7 +5222,7 @@ packages: fs.realpath: 1.0.0 inflight: 1.0.6 inherits: 2.0.4 - minimatch: 3.0.4 + minimatch: 3.1.2 once: 1.4.0 path-is-absolute: 1.0.1 dev: false @@ -6229,6 +6236,12 @@ packages: graceful-fs: 4.2.11 dev: false + /karma-sourcemap-loader@0.4.0: + resolution: {integrity: sha512-xCRL3/pmhAYF3I6qOrcn0uhbQevitc2DERMPH82FMnG+4WReoGcGFZb1pURf2a5apyrOHRdvD+O6K7NljqKHyA==} + dependencies: + graceful-fs: 4.2.11 + dev: false + /karma@6.4.2(debug@4.3.4): resolution: {integrity: sha512-C6SU/53LB31BEgRg+omznBEMY4SjHU3ricV6zBcAe1EeILKkeScr+fZXtaI5WyDbkVowJxxAI6h73NcFPmXolQ==} engines: {node: '>= 10'} @@ -6772,6 +6785,19 @@ packages: xml: 1.0.1 dev: false + /mocha-junit-reporter@1.23.3(mocha@7.2.0): + resolution: {integrity: sha512-ed8LqbRj1RxZfjt/oC9t12sfrWsjZ3gNnbhV1nuj9R/Jb5/P3Xb4duv2eCfCDMYH+fEu0mqca7m4wsiVjsxsvA==} + peerDependencies: + mocha: '>=2.2.5' + dependencies: + debug: 2.6.9 + md5: 2.3.0 + mkdirp: 0.5.6 + mocha: 7.2.0 + strip-ansi: 4.0.0 + xml: 1.0.1 + dev: false + /mocha-junit-reporter@2.2.1(mocha@10.2.0): resolution: {integrity: sha512-iDn2tlKHn8Vh8o4nCzcUVW4q7iXp7cC4EB78N0cDHIobLymyHNwe0XG8HEHHjc3hJlXm0Vy6zcrxaIhnI2fWmw==} peerDependencies: @@ -7631,7 +7657,7 @@ packages: '@protobufjs/path': 1.1.2 '@protobufjs/pool': 1.1.0 '@protobufjs/utf8': 1.1.0 - '@types/node': 14.18.63 + '@types/node': 16.18.55 long: 5.2.3 dev: false @@ -8937,8 +8963,8 @@ packages: hasBin: true dev: false - /typescript@5.3.0-dev.20231002: - resolution: {integrity: sha512-TQXM13rrDgID8W4Ok4KDQAqwLUjLcAXL+NKv0zJiIEQfa0bOM0yoRiSgvcjaCJ4lZT4bScrq3vHspVM2x8rkOQ==} + /typescript@5.3.0-dev.20231005: + resolution: {integrity: sha512-Twm3wBauTO94CSWbjXFMpsHsbaOUVssreq6pUo4wr8YsaIp0jim8EeCa9LfawFetQ+P4PODMmiM+uBhhWRVX0Q==} engines: {node: '>=14.17'} hasBin: true dev: false @@ -16887,9 +16913,9 @@ packages: - utf-8-validate dev: false - file:projects/communication-job-router.tgz: - resolution: {integrity: sha512-9BbMN+FtfocjeQX8XkbZsNoFN4+mhBrtUB8LwWiBIzyhtwEeut+LG1OWVi4d/Ix/lMcWRQJNRHtP7/L5gJ0crw==, tarball: file:projects/communication-job-router.tgz} - name: '@rush-temp/communication-job-router' + file:projects/communication-job-router-1.tgz: + resolution: {integrity: sha512-x0+PfvLx12jjcnMZVlCD2v3hQyQsRPUxiqBL710XGpH6AaP9AL2oLLKHDU/KplBoAfJP/Xq7lmzh9Ltk0DRW6g==, tarball: file:projects/communication-job-router-1.tgz} + name: '@rush-temp/communication-job-router-1' version: 0.0.0 dependencies: '@microsoft/api-extractor': 7.38.0(@types/node@14.18.63) @@ -16936,6 +16962,60 @@ packages: - utf-8-validate dev: false + file:projects/communication-job-router.tgz: + resolution: {integrity: sha512-vQcHXvrr9KBZogoCzJfcgOW/wrhZAwMrbNjF4z1phPOPBgS06Bmg2lkGAjGAq6R0svNQEgxixBjWbNbepWkzFA==, tarball: file:projects/communication-job-router.tgz} + name: '@rush-temp/communication-job-router' + version: 0.0.0 + dependencies: + '@azure/identity': 2.1.0 + '@microsoft/api-extractor': 7.38.0(@types/node@14.18.63) + '@types/chai': 4.3.6 + '@types/mocha': 7.0.2 + '@types/node': 14.18.63 + '@types/sinon': 10.0.17 + '@types/uuid': 8.3.4 + autorest: 3.6.3 + chai: 4.3.10 + cross-env: 7.0.3 + dotenv: 16.3.1 + eslint: 8.50.0 + esm: 3.2.25 + events: 3.3.0 + inherits: 2.0.4 + karma: 6.4.2(debug@4.3.4) + karma-chrome-launcher: 3.2.0 + karma-coverage: 2.2.1 + karma-env-preprocessor: 0.1.1 + karma-firefox-launcher: 2.1.2 + karma-json-preprocessor: 0.3.3(karma@6.4.2) + karma-json-to-file-reporter: 1.0.1 + karma-junit-reporter: 2.0.1(karma@6.4.2) + karma-mocha: 2.0.1 + karma-mocha-reporter: 2.2.5(karma@6.4.2) + karma-source-map-support: 1.4.0 + karma-sourcemap-loader: 0.4.0 + mkdirp: 2.1.6 + mocha: 7.2.0 + mocha-junit-reporter: 1.23.3(mocha@7.2.0) + nyc: 15.1.0 + prettier: 2.8.8 + rimraf: 5.0.5 + sinon: 15.2.0 + source-map-support: 0.5.21 + ts-node: 10.9.1(@types/node@14.18.63)(typescript@5.0.4) + tslib: 2.6.2 + typescript: 5.0.4 + util: 0.12.5 + uuid: 8.3.2 + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - bufferutil + - debug + - supports-color + - utf-8-validate + dev: false + file:projects/communication-network-traversal.tgz: resolution: {integrity: sha512-Y5ZoqerV2ZOpZ1qIruFqQVRHOQUMqTroFctSAvHt+RUn5+v4hAD6KQsAWDtceg6gMWil0fSH4z1nqHQEypjhAQ==, tarball: file:projects/communication-network-traversal.tgz} name: '@rush-temp/communication-network-traversal' diff --git a/rush.json b/rush.json index 5ceebf4a77f3..787ddaf6e361 100644 --- a/rush.json +++ b/rush.json @@ -485,6 +485,11 @@ "projectFolder": "sdk/communication/communication-job-router", "versionPolicyName": "client" }, + { + "packageName": "@azure-rest/communication-job-router", + "projectFolder": "sdk/communication/communication-job-router-rest", + "versionPolicyName": "client" + }, { "packageName": "@azure/container-registry", "projectFolder": "sdk/containerregistry/container-registry", diff --git a/sdk/communication/communication-job-router-rest/.eslintrc.json b/sdk/communication/communication-job-router-rest/.eslintrc.json new file mode 100644 index 000000000000..619797ac39b6 --- /dev/null +++ b/sdk/communication/communication-job-router-rest/.eslintrc.json @@ -0,0 +1,11 @@ +{ + "plugins": ["@azure/azure-sdk"], + "extends": ["plugin:@azure/azure-sdk/azure-sdk-base"], + "rules": { + "@azure/azure-sdk/ts-modules-only-named": "warn", + "@azure/azure-sdk/ts-apiextractor-json-types": "warn", + "@azure/azure-sdk/ts-package-json-types": "warn", + "@azure/azure-sdk/ts-package-json-engine-is-present": "warn", + "tsdoc/syntax": "warn" + } +} diff --git a/sdk/communication/communication-job-router-rest/README.md b/sdk/communication/communication-job-router-rest/README.md new file mode 100644 index 000000000000..09bb58d0ef4b --- /dev/null +++ b/sdk/communication/communication-job-router-rest/README.md @@ -0,0 +1,57 @@ +# AzureCommunicationRoutingService REST client library for JavaScript + +Azure Communication Routing Service + +**Please rely heavily on our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library** + +Key links: + +- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-job-router-rest) +- [Package (NPM)](https://www.npmjs.com/package/@azure-rest/communication-job-router) + +## Getting started + +### Currently supported environments + +- LTS versions of Node.js + +### Prerequisites + +- You must have an [Azure subscription](https://azure.microsoft.com/free/) to use this package. + +### Install the `@azure-rest/communication-job-router` package + +Install the AzureCommunicationRoutingService REST client REST client library for JavaScript with `npm`: + +```bash +npm install @azure-rest/communication-job-router +``` + +### Create and authenticate a `AzureCommunicationRoutingServiceClient` + +To use an [Azure Active Directory (AAD) token credential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token), +provide an instance of the desired credential type obtained from the +[@azure/identity](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) library. + +To authenticate with AAD, you must first `npm` install [`@azure/identity`](https://www.npmjs.com/package/@azure/identity) + +After setup, you can choose which type of [credential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) from `@azure/identity` to use. +As an example, [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential) +can be used to authenticate the client. + +Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: +AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET + +## Troubleshooting + +### Logging + +Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`: + +```javascript +const { setLogLevel } = require("@azure/logger"); + +setLogLevel("info"); +``` + +For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). diff --git a/sdk/communication/communication-job-router-rest/api-extractor.json b/sdk/communication/communication-job-router-rest/api-extractor.json new file mode 100644 index 000000000000..5ff7f4621cde --- /dev/null +++ b/sdk/communication/communication-job-router-rest/api-extractor.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "mainEntryPointFilePath": "./types/src/index.d.ts", + "docModel": { "enabled": true }, + "apiReport": { "enabled": true, "reportFolder": "./review" }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "./types/communication-job-router.d.ts" + }, + "messages": { + "tsdocMessageReporting": { "default": { "logLevel": "none" } }, + "extractorMessageReporting": { + "ae-missing-release-tag": { "logLevel": "none" }, + "ae-unresolved-link": { "logLevel": "none" } + } + } +} diff --git a/sdk/communication/communication-job-router-rest/karma.conf.js b/sdk/communication/communication-job-router-rest/karma.conf.js new file mode 100644 index 000000000000..a9d5f1b5fc59 --- /dev/null +++ b/sdk/communication/communication-job-router-rest/karma.conf.js @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +// https://github.com/karma-runner/karma-chrome-launcher +process.env.CHROME_BIN = require("puppeteer").executablePath(); +require("dotenv").config(); +const { relativeRecordingsPath } = require("@azure-tools/test-recorder"); +process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath(); + +module.exports = function (config) { + config.set({ + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: "./", + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ["source-map-support", "mocha"], + + plugins: [ + "karma-mocha", + "karma-mocha-reporter", + "karma-chrome-launcher", + "karma-firefox-launcher", + "karma-env-preprocessor", + "karma-coverage", + "karma-sourcemap-loader", + "karma-junit-reporter", + "karma-source-map-support", + ], + + // list of files / patterns to load in the browser + files: [ + "dist-test/index.browser.js", + { + pattern: "dist-test/index.browser.js.map", + type: "html", + included: false, + served: true, + }, + ], + + // list of files / patterns to exclude + exclude: [], + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + "**/*.js": ["sourcemap", "env"], + // IMPORTANT: COMMENT following line if you want to debug in your browsers!! + // Preprocess source file to calculate code coverage, however this will make source file unreadable + // "dist-test/index.js": ["coverage"] + }, + + envPreprocessor: [ + "TEST_MODE", + "ENDPOINT", + "AZURE_CLIENT_SECRET", + "AZURE_CLIENT_ID", + "AZURE_TENANT_ID", + "SUBSCRIPTION_ID", + "RECORDINGS_RELATIVE_PATH", + ], + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ["mocha", "coverage", "junit"], + + coverageReporter: { + // specify a common output directory + dir: "coverage-browser/", + reporters: [ + { type: "json", subdir: ".", file: "coverage.json" }, + { type: "lcovonly", subdir: ".", file: "lcov.info" }, + { type: "html", subdir: "html" }, + { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }, + ], + }, + + junitReporter: { + outputDir: "", // results will be saved as $outputDir/$browserName.xml + outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile + suite: "", // suite will become the package name attribute in xml testsuite element + useBrowserName: false, // add browser name to report and classes names + nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element + classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element + properties: {}, // key value pair of properties to add to the section of the report + }, + + // web server port + port: 9876, + + // enable / disable colors in the output (reporters and logs) + colors: true, + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: false, + + // --no-sandbox allows our tests to run in Linux without having to change the system. + // --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex. + browsers: ["ChromeHeadlessNoSandbox"], + customLaunchers: { + ChromeHeadlessNoSandbox: { + base: "ChromeHeadless", + flags: ["--no-sandbox", "--disable-web-security"], + }, + }, + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: 1, + + browserNoActivityTimeout: 60000000, + browserDisconnectTimeout: 10000, + browserDisconnectTolerance: 3, + + client: { + mocha: { + // change Karma's debug.html to the mocha web reporter + reporter: "html", + timeout: "600000", + }, + }, + }); +}; diff --git a/sdk/communication/communication-job-router-rest/package.json b/sdk/communication/communication-job-router-rest/package.json new file mode 100644 index 000000000000..dc6e1ae78741 --- /dev/null +++ b/sdk/communication/communication-job-router-rest/package.json @@ -0,0 +1,107 @@ +{ + "name": "@azure-rest/communication-job-router", + "sdk-type": "client", + "author": "Microsoft Corporation", + "version": "1.0.0-beta.1", + "description": "Azure client library for Azure Communication Job Router services", + "keywords": ["node", "azure", "cloud", "typescript", "browser", "isomorphic"], + "license": "MIT", + "main": "dist/index.js", + "module": "./dist-esm/src/index.js", + "types": "./types/communication-job-router.d.ts", + "repository": "github:Azure/azure-sdk-for-js", + "bugs": { "url": "https://github.com/Azure/azure-sdk-for-js/issues" }, + "files": [ + "dist/", + "dist-esm/src/", + "types/communication-job-router.d.ts", + "README.md", + "LICENSE", + "review/*" + ], + "engines": { "node": ">=14.0.0" }, + "scripts": { + "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", + "build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1", + "build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1", + "build:samples": "echo skipped.", + "build:test": "tsc -p . && dev-tool run bundle", + "build:debug": "tsc -p . && dev-tool run bundle && api-extractor run --local", + "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"test/**/*.ts\"", + "clean": "rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", + "execute:samples": "echo skipped", + "extract-api": "rimraf review && mkdirp ./review && api-extractor run --local", + "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"test/**/*.ts\"", + "generate:client": "echo skipped", + "integration-test:browser": "dev-tool run test:browser", + "integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]", + "lint": "eslint package.json api-extractor.json src test --ext .ts", + "pack": "npm pack 2>&1", + "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser", + "test:node": "npm run clean && npm run build:test && npm run unit-test:node", + "test": "npm run clean && npm run build:test && npm run unit-test", + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'", + "unit-test:browser": "dev-tool run test:browser", + "build": "npm run clean && tsc -p . && dev-tool run bundle && mkdirp ./review && api-extractor run --local" + }, + "sideEffects": false, + "autoPublish": false, + "dependencies": { + "@azure/core-auth": "^1.3.0", + "@azure-rest/core-client": "^1.1.4", + "@azure/core-rest-pipeline": "^1.12.0", + "@azure/logger": "^1.0.0", + "tslib": "^2.2.0", + "@azure/core-paging": "^1.5.0" + }, + "devDependencies": { + "@microsoft/api-extractor": "^7.31.1", + "autorest": "latest", + "@types/node": "^14.0.0", + "dotenv": "^16.0.0", + "eslint": "^8.0.0", + "mkdirp": "^2.1.2", + "prettier": "^2.5.1", + "rimraf": "^5.0.0", + "source-map-support": "^0.5.9", + "typescript": "~5.0.0", + "@azure/dev-tool": "^1.0.0", + "@azure/eslint-plugin-azure-sdk": "^3.0.0", + "@azure-tools/test-credential": "^1.0.0", + "@azure/identity": "^2.0.1", + "@azure-tools/test-recorder": "^3.0.0", + "mocha": "^7.1.1", + "@types/mocha": "^7.0.2", + "mocha-junit-reporter": "^1.18.0", + "cross-env": "^7.0.2", + "@types/chai": "^4.2.8", + "chai": "^4.2.0", + "karma-chrome-launcher": "^3.0.0", + "karma-coverage": "^2.0.0", + "karma-env-preprocessor": "^0.1.1", + "karma-firefox-launcher": "^2.1.2", + "karma-junit-reporter": "^2.0.1", + "karma-mocha-reporter": "^2.2.5", + "karma-mocha": "^2.0.1", + "karma-source-map-support": "~1.4.0", + "karma-sourcemap-loader": "^0.4.0", + "karma": "^6.2.0", + "nyc": "^15.0.0", + "ts-node": "^10.0.0" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-job-router-rest/README.md", + "//metadata": { + "constantPaths": [ + { + "path": "src/azureCommunicationRoutingServiceClient.ts", + "prefix": "userAgentInfo" + } + ] + }, + "browser": { + "./dist-esm/test/public/utils/env.js": "./dist-esm/test/public/utils/env.browser.js" + } +} diff --git a/sdk/communication/communication-job-router-rest/review/communication-job-router.api.md b/sdk/communication/communication-job-router-rest/review/communication-job-router.api.md new file mode 100644 index 000000000000..2b7852483fc9 --- /dev/null +++ b/sdk/communication/communication-job-router-rest/review/communication-job-router.api.md @@ -0,0 +1,2466 @@ +## API Report File for "@azure-rest/communication-job-router" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import { Client } from '@azure-rest/core-client'; +import { ClientOptions } from '@azure-rest/core-client'; +import { ErrorResponse } from '@azure-rest/core-client'; +import { HttpResponse } from '@azure-rest/core-client'; +import { Paged } from '@azure/core-paging'; +import { PagedAsyncIterableIterator } from '@azure/core-paging'; +import { PathUncheckedResponse } from '@azure-rest/core-client'; +import { RawHttpHeaders } from '@azure/core-rest-pipeline'; +import { RawHttpHeadersInput } from '@azure/core-rest-pipeline'; +import { RequestParameters } from '@azure-rest/core-client'; +import { StreamableMethod } from '@azure-rest/core-client'; + +// @public (undocumented) +export interface AcceptJobAction { + post(options?: AcceptJobActionParameters): StreamableMethod; +} + +// @public +export interface AcceptJobAction200Response extends HttpResponse { + // (undocumented) + body: AcceptJobOfferResultOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface AcceptJobActionDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface AcceptJobActionDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & AcceptJobActionDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type AcceptJobActionParameters = RequestParameters; + +// @public +export interface AcceptJobOfferResultOutput { + assignmentId: string; + jobId: string; + workerId: string; +} + +// @public (undocumented) +export type AzureCommunicationRoutingServiceClient = Client & { + path: Routes; +}; + +// @public +export interface BestWorkerMode extends DistributionModeParent { + kind: "best-worker"; + scoringRule?: RouterRule; + scoringRuleOptions?: ScoringRuleOptions; +} + +// @public +export interface BestWorkerModeOutput extends DistributionModeOutputParent { + kind: "best-worker"; + scoringRule?: RouterRuleOutput; + scoringRuleOptions?: ScoringRuleOptionsOutput; +} + +// @public +export interface CancelExceptionAction extends ExceptionActionParent { + dispositionCode?: string; + kind: "cancel"; + note?: string; +} + +// @public +export interface CancelExceptionActionOutput extends ExceptionActionOutputParent { + dispositionCode?: string; + kind: "cancel"; + note?: string; +} + +// @public (undocumented) +export interface CancelJobAction { + post(options?: CancelJobActionParameters): StreamableMethod; +} + +// @public +export interface CancelJobAction200Response extends HttpResponse { + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface CancelJobActionBodyParam { + body?: CancelJobRequest; +} + +// @public (undocumented) +export interface CancelJobActionDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface CancelJobActionDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & CancelJobActionDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type CancelJobActionParameters = CancelJobActionBodyParam & RequestParameters; + +// @public +export interface CancelJobRequest { + dispositionCode?: string; + note?: string; +} + +// @public +export interface ChannelConfiguration { + capacityCostPerJob: number; + maxNumberOfJobs?: number; +} + +// @public +export interface ChannelConfigurationOutput { + capacityCostPerJob: number; + maxNumberOfJobs?: number; +} + +// @public +export interface ClassificationPolicy { + fallbackQueueId?: string; + name?: string; + prioritizationRule?: RouterRule; + queueSelectors?: Array; + workerSelectors?: Array; +} + +// @public +export interface ClassificationPolicyItemOutput { + classificationPolicy: ClassificationPolicyOutput; + etag: string; +} + +// @public +export interface ClassificationPolicyOutput { + fallbackQueueId?: string; + readonly id: string; + name?: string; + prioritizationRule?: RouterRuleOutput; + queueSelectors?: Array; + workerSelectors?: Array; +} + +// @public +export type ClassificationPolicyResourceMergeAndPatch = Partial; + +// @public (undocumented) +export interface CloseJobAction { + post(options: CloseJobActionParameters): StreamableMethod; +} + +// @public +export interface CloseJobAction200Response extends HttpResponse { + // (undocumented) + status: "200"; +} + +// @public +export interface CloseJobAction202Response extends HttpResponse { + // (undocumented) + status: "202"; +} + +// @public (undocumented) +export interface CloseJobActionBodyParam { + body: CloseJobRequest; +} + +// @public (undocumented) +export interface CloseJobActionDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface CloseJobActionDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & CloseJobActionDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type CloseJobActionParameters = CloseJobActionBodyParam & RequestParameters; + +// @public +export interface CloseJobRequest { + assignmentId: string; + closeAt?: Date | string; + dispositionCode?: string; + note?: string; +} + +// @public (undocumented) +export interface CompleteJobAction { + post(options: CompleteJobActionParameters): StreamableMethod; +} + +// @public +export interface CompleteJobAction200Response extends HttpResponse { + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface CompleteJobActionBodyParam { + body: CompleteJobRequest; +} + +// @public (undocumented) +export interface CompleteJobActionDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface CompleteJobActionDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & CompleteJobActionDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type CompleteJobActionParameters = CompleteJobActionBodyParam & RequestParameters; + +// @public +export interface CompleteJobRequest { + assignmentId: string; + note?: string; +} + +// @public +export interface ConditionalQueueSelectorAttachment extends QueueSelectorAttachmentParent { + condition: RouterRule; + kind: "conditional"; + queueSelectors: Array; +} + +// @public +export interface ConditionalQueueSelectorAttachmentOutput extends QueueSelectorAttachmentOutputParent { + condition: RouterRuleOutput; + kind: "conditional"; + queueSelectors: Array; +} + +// @public +export interface ConditionalWorkerSelectorAttachment extends WorkerSelectorAttachmentParent { + condition: RouterRule; + kind: "conditional"; + workerSelectors: Array; +} + +// @public +export interface ConditionalWorkerSelectorAttachmentOutput extends WorkerSelectorAttachmentOutputParent { + condition: RouterRuleOutput; + kind: "conditional"; + workerSelectors: Array; +} + +// @public +function createClient(endpoint: string, options?: ClientOptions): AzureCommunicationRoutingServiceClient; +export default createClient; + +// @public (undocumented) +export interface DeclineJobAction { + post(options?: DeclineJobActionParameters): StreamableMethod; +} + +// @public +export interface DeclineJobAction200Response extends HttpResponse { + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface DeclineJobActionBodyParam { + body?: DeclineJobOfferRequest; +} + +// @public (undocumented) +export interface DeclineJobActionDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface DeclineJobActionDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & DeclineJobActionDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type DeclineJobActionParameters = DeclineJobActionBodyParam & RequestParameters; + +// @public +export interface DeclineJobOfferRequest { + retryOfferAt?: Date | string; +} + +// @public +export interface DeleteClassificationPolicy204Response extends HttpResponse { + // (undocumented) + status: "204"; +} + +// @public (undocumented) +export interface DeleteClassificationPolicyDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface DeleteClassificationPolicyDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & DeleteClassificationPolicyDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type DeleteClassificationPolicyParameters = RequestParameters; + +// @public +export interface DeleteDistributionPolicy204Response extends HttpResponse { + // (undocumented) + status: "204"; +} + +// @public (undocumented) +export interface DeleteDistributionPolicyDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface DeleteDistributionPolicyDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & DeleteDistributionPolicyDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type DeleteDistributionPolicyParameters = RequestParameters; + +// @public +export interface DeleteExceptionPolicy204Response extends HttpResponse { + // (undocumented) + status: "204"; +} + +// @public (undocumented) +export interface DeleteExceptionPolicyDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface DeleteExceptionPolicyDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & DeleteExceptionPolicyDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type DeleteExceptionPolicyParameters = RequestParameters; + +// @public +export interface DeleteJob204Response extends HttpResponse { + // (undocumented) + status: "204"; +} + +// @public (undocumented) +export interface DeleteJobDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface DeleteJobDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & DeleteJobDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type DeleteJobParameters = RequestParameters; + +// @public +export interface DeleteQueue204Response extends HttpResponse { + // (undocumented) + status: "204"; +} + +// @public (undocumented) +export interface DeleteQueueDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface DeleteQueueDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & DeleteQueueDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type DeleteQueueParameters = RequestParameters; + +// @public +export interface DeleteWorker204Response extends HttpResponse { + // (undocumented) + status: "204"; +} + +// @public (undocumented) +export interface DeleteWorkerDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface DeleteWorkerDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & DeleteWorkerDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type DeleteWorkerParameters = RequestParameters; + +// @public +export interface DirectMapRouterRule extends RouterRuleParent { + kind: "direct-map-rule"; +} + +// @public +export interface DirectMapRouterRuleOutput extends RouterRuleOutputParent { + kind: "direct-map-rule"; +} + +// @public +export type DistributionMode = BestWorkerMode | LongestIdleMode | RoundRobinMode; + +// @public +export type DistributionModeOutput = BestWorkerModeOutput | LongestIdleModeOutput | RoundRobinModeOutput; + +// @public +export interface DistributionModeOutputParent { + bypassSelectors?: boolean; + // (undocumented) + kind: string; + maxConcurrentOffers?: number; + minConcurrentOffers?: number; +} + +// @public +export interface DistributionModeParent { + bypassSelectors?: boolean; + // (undocumented) + kind: string; + maxConcurrentOffers?: number; + minConcurrentOffers?: number; +} + +// @public +export interface DistributionPolicy { + mode?: DistributionMode; + name?: string; + offerExpiresAfterSeconds?: number; +} + +// @public +export interface DistributionPolicyItemOutput { + distributionPolicy: DistributionPolicyOutput; + etag: string; +} + +// @public +export interface DistributionPolicyOutput { + readonly id: string; + mode?: DistributionModeOutput; + name?: string; + offerExpiresAfterSeconds?: number; +} + +// @public +export type DistributionPolicyResourceMergeAndPatch = Partial; + +// @public +export type ExceptionAction = CancelExceptionAction | ManualReclassifyExceptionAction | ReclassifyExceptionAction; + +// @public +export type ExceptionActionOutput = CancelExceptionActionOutput | ManualReclassifyExceptionActionOutput | ReclassifyExceptionActionOutput; + +// @public +export interface ExceptionActionOutputParent { + // (undocumented) + kind: string; +} + +// @public +export interface ExceptionActionParent { + // (undocumented) + kind: string; +} + +// @public +export interface ExceptionPolicy { + exceptionRules?: Record; + name?: string; +} + +// @public +export interface ExceptionPolicyItemOutput { + etag: string; + exceptionPolicy: ExceptionPolicyOutput; +} + +// @public +export interface ExceptionPolicyOutput { + exceptionRules?: Record; + readonly id: string; + name?: string; +} + +// @public +export type ExceptionPolicyResourceMergeAndPatch = Partial; + +// @public +export interface ExceptionRule { + actions: Record; + trigger: ExceptionTrigger; +} + +// @public +export interface ExceptionRuleOutput { + actions: Record; + trigger: ExceptionTriggerOutput; +} + +// @public +export type ExceptionTrigger = QueueLengthExceptionTrigger | WaitTimeExceptionTrigger; + +// @public +export type ExceptionTriggerOutput = QueueLengthExceptionTriggerOutput | WaitTimeExceptionTriggerOutput; + +// @public +export interface ExceptionTriggerOutputParent { + // (undocumented) + kind: string; +} + +// @public +export interface ExceptionTriggerParent { + // (undocumented) + kind: string; +} + +// @public +export interface ExpressionRouterRule extends RouterRuleParent { + expression: string; + kind: "expression-rule"; + language?: string; +} + +// @public +export interface ExpressionRouterRuleOutput extends RouterRuleOutputParent { + expression: string; + kind: "expression-rule"; + language?: string; +} + +// @public +export interface FunctionRouterRule extends RouterRuleParent { + credential?: FunctionRouterRuleCredential; + functionUri: string; + kind: "azure-function-rule"; +} + +// @public +export interface FunctionRouterRuleCredential { + appKey?: string; + clientId?: string; + functionKey?: string; +} + +// @public +export interface FunctionRouterRuleCredentialOutput { + appKey?: string; + clientId?: string; + functionKey?: string; +} + +// @public +export interface FunctionRouterRuleOutput extends RouterRuleOutputParent { + credential?: FunctionRouterRuleCredentialOutput; + functionUri: string; + kind: "azure-function-rule"; +} + +// @public +export type GetArrayType = T extends Array ? TData : never; + +// @public (undocumented) +export interface GetClassificationPolicy200Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface GetClassificationPolicy200Response extends HttpResponse { + // (undocumented) + body: ClassificationPolicyOutput; + // (undocumented) + headers: RawHttpHeaders & GetClassificationPolicy200Headers; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface GetClassificationPolicyDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface GetClassificationPolicyDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & GetClassificationPolicyDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type GetClassificationPolicyParameters = RequestParameters; + +// @public (undocumented) +export interface GetDistributionPolicy200Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface GetDistributionPolicy200Response extends HttpResponse { + // (undocumented) + body: DistributionPolicyOutput; + // (undocumented) + headers: RawHttpHeaders & GetDistributionPolicy200Headers; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface GetDistributionPolicyDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface GetDistributionPolicyDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & GetDistributionPolicyDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type GetDistributionPolicyParameters = RequestParameters; + +// @public (undocumented) +export interface GetExceptionPolicy200Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface GetExceptionPolicy200Response extends HttpResponse { + // (undocumented) + body: ExceptionPolicyOutput; + // (undocumented) + headers: RawHttpHeaders & GetExceptionPolicy200Headers; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface GetExceptionPolicyDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface GetExceptionPolicyDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & GetExceptionPolicyDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type GetExceptionPolicyParameters = RequestParameters; + +// @public (undocumented) +export interface GetInQueuePosition { + get(options?: GetInQueuePositionParameters): StreamableMethod; +} + +// @public +export interface GetInQueuePosition200Response extends HttpResponse { + // (undocumented) + body: RouterJobPositionDetailsOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface GetInQueuePositionDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface GetInQueuePositionDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & GetInQueuePositionDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type GetInQueuePositionParameters = RequestParameters; + +// @public (undocumented) +export interface GetJob200Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface GetJob200Response extends HttpResponse { + // (undocumented) + body: RouterJobOutput; + // (undocumented) + headers: RawHttpHeaders & GetJob200Headers; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface GetJobDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface GetJobDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & GetJobDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type GetJobParameters = RequestParameters; + +// @public +export type GetPage = (pageLink: string, maxPageSize?: number) => Promise<{ + page: TPage; + nextPageLink?: string; +}>; + +// @public (undocumented) +export interface GetQueue200Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface GetQueue200Response extends HttpResponse { + // (undocumented) + body: RouterQueueOutput; + // (undocumented) + headers: RawHttpHeaders & GetQueue200Headers; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface GetQueueDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface GetQueueDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & GetQueueDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type GetQueueParameters = RequestParameters; + +// @public (undocumented) +export interface GetQueueStatistics { + get(options?: GetQueueStatisticsParameters): StreamableMethod; +} + +// @public +export interface GetQueueStatistics200Response extends HttpResponse { + // (undocumented) + body: RouterQueueStatisticsOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface GetQueueStatisticsDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface GetQueueStatisticsDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & GetQueueStatisticsDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type GetQueueStatisticsParameters = RequestParameters; + +// @public (undocumented) +export interface GetWorker200Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface GetWorker200Response extends HttpResponse { + // (undocumented) + body: RouterWorkerOutput; + // (undocumented) + headers: RawHttpHeaders & GetWorker200Headers; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface GetWorkerDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface GetWorkerDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & GetWorkerDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type GetWorkerParameters = RequestParameters; + +// @public (undocumented) +export function isUnexpected(response: UpsertClassificationPolicy200Response | UpsertClassificationPolicy201Response | UpsertClassificationPolicyDefaultResponse): response is UpsertClassificationPolicyDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: GetClassificationPolicy200Response | GetClassificationPolicyDefaultResponse): response is GetClassificationPolicyDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: DeleteClassificationPolicy204Response | DeleteClassificationPolicyDefaultResponse): response is DeleteClassificationPolicyDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: ListClassificationPolicies200Response | ListClassificationPoliciesDefaultResponse): response is ListClassificationPoliciesDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: UpsertDistributionPolicy200Response | UpsertDistributionPolicy201Response | UpsertDistributionPolicyDefaultResponse): response is UpsertDistributionPolicyDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: GetDistributionPolicy200Response | GetDistributionPolicyDefaultResponse): response is GetDistributionPolicyDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: DeleteDistributionPolicy204Response | DeleteDistributionPolicyDefaultResponse): response is DeleteDistributionPolicyDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: ListDistributionPolicies200Response | ListDistributionPoliciesDefaultResponse): response is ListDistributionPoliciesDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: UpsertExceptionPolicy200Response | UpsertExceptionPolicy201Response | UpsertExceptionPolicyDefaultResponse): response is UpsertExceptionPolicyDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: GetExceptionPolicy200Response | GetExceptionPolicyDefaultResponse): response is GetExceptionPolicyDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: DeleteExceptionPolicy204Response | DeleteExceptionPolicyDefaultResponse): response is DeleteExceptionPolicyDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: ListExceptionPolicies200Response | ListExceptionPoliciesDefaultResponse): response is ListExceptionPoliciesDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: UpsertQueue200Response | UpsertQueue201Response | UpsertQueueDefaultResponse): response is UpsertQueueDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: GetQueue200Response | GetQueueDefaultResponse): response is GetQueueDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: DeleteQueue204Response | DeleteQueueDefaultResponse): response is DeleteQueueDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: ListQueues200Response | ListQueuesDefaultResponse): response is ListQueuesDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: UpsertJob200Response | UpsertJob201Response | UpsertJobDefaultResponse): response is UpsertJobDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: GetJob200Response | GetJobDefaultResponse): response is GetJobDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: DeleteJob204Response | DeleteJobDefaultResponse): response is DeleteJobDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: ReclassifyJobAction200Response | ReclassifyJobActionDefaultResponse): response is ReclassifyJobActionDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: CancelJobAction200Response | CancelJobActionDefaultResponse): response is CancelJobActionDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: CompleteJobAction200Response | CompleteJobActionDefaultResponse): response is CompleteJobActionDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: CloseJobAction200Response | CloseJobAction202Response | CloseJobActionDefaultResponse): response is CloseJobActionDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: ListJobs200Response | ListJobsDefaultResponse): response is ListJobsDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: GetInQueuePosition200Response | GetInQueuePositionDefaultResponse): response is GetInQueuePositionDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: UnassignJobAction200Response | UnassignJobActionDefaultResponse): response is UnassignJobActionDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: AcceptJobAction200Response | AcceptJobActionDefaultResponse): response is AcceptJobActionDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: DeclineJobAction200Response | DeclineJobActionDefaultResponse): response is DeclineJobActionDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: GetQueueStatistics200Response | GetQueueStatisticsDefaultResponse): response is GetQueueStatisticsDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: UpsertWorker200Response | UpsertWorker201Response | UpsertWorkerDefaultResponse): response is UpsertWorkerDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: GetWorker200Response | GetWorkerDefaultResponse): response is GetWorkerDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: DeleteWorker204Response | DeleteWorkerDefaultResponse): response is DeleteWorkerDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: ListWorkers200Response | ListWorkersDefaultResponse): response is ListWorkersDefaultResponse; + +// @public +export interface JobMatchingMode { + modeType?: string; + queueAndMatchMode?: QueueAndMatchMode; + scheduleAndSuspendMode?: ScheduleAndSuspendMode; + suspendMode?: SuspendMode; +} + +// @public +export interface JobMatchingModeOutput { + modeType?: string; + queueAndMatchMode?: QueueAndMatchModeOutput; + scheduleAndSuspendMode?: ScheduleAndSuspendModeOutput; + suspendMode?: SuspendModeOutput; +} + +// @public (undocumented) +export interface ListClassificationPolicies { + get(options?: ListClassificationPoliciesParameters): StreamableMethod; +} + +// @public +export interface ListClassificationPolicies200Response extends HttpResponse { + // (undocumented) + body: PagedClassificationPolicyItemOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface ListClassificationPoliciesDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ListClassificationPoliciesDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ListClassificationPoliciesDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type ListClassificationPoliciesParameters = ListClassificationPoliciesQueryParam & RequestParameters; + +// @public (undocumented) +export interface ListClassificationPoliciesQueryParam { + // (undocumented) + queryParameters?: ListClassificationPoliciesQueryParamProperties; +} + +// @public (undocumented) +export interface ListClassificationPoliciesQueryParamProperties { + maxpagesize?: number; +} + +// @public (undocumented) +export interface ListDistributionPolicies { + get(options?: ListDistributionPoliciesParameters): StreamableMethod; +} + +// @public +export interface ListDistributionPolicies200Response extends HttpResponse { + // (undocumented) + body: PagedDistributionPolicyItemOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface ListDistributionPoliciesDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ListDistributionPoliciesDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ListDistributionPoliciesDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type ListDistributionPoliciesParameters = ListDistributionPoliciesQueryParam & RequestParameters; + +// @public (undocumented) +export interface ListDistributionPoliciesQueryParam { + // (undocumented) + queryParameters?: ListDistributionPoliciesQueryParamProperties; +} + +// @public (undocumented) +export interface ListDistributionPoliciesQueryParamProperties { + maxpagesize?: number; +} + +// @public (undocumented) +export interface ListExceptionPolicies { + get(options?: ListExceptionPoliciesParameters): StreamableMethod; +} + +// @public +export interface ListExceptionPolicies200Response extends HttpResponse { + // (undocumented) + body: PagedExceptionPolicyItemOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface ListExceptionPoliciesDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ListExceptionPoliciesDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ListExceptionPoliciesDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type ListExceptionPoliciesParameters = ListExceptionPoliciesQueryParam & RequestParameters; + +// @public (undocumented) +export interface ListExceptionPoliciesQueryParam { + // (undocumented) + queryParameters?: ListExceptionPoliciesQueryParamProperties; +} + +// @public (undocumented) +export interface ListExceptionPoliciesQueryParamProperties { + maxpagesize?: number; +} + +// @public (undocumented) +export interface ListJobs { + get(options?: ListJobsParameters): StreamableMethod; +} + +// @public +export interface ListJobs200Response extends HttpResponse { + // (undocumented) + body: PagedRouterJobItemOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface ListJobsDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ListJobsDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ListJobsDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type ListJobsParameters = ListJobsQueryParam & RequestParameters; + +// @public (undocumented) +export interface ListJobsQueryParam { + // (undocumented) + queryParameters?: ListJobsQueryParamProperties; +} + +// @public (undocumented) +export interface ListJobsQueryParamProperties { + channelId?: string; + classificationPolicyId?: string; + maxpagesize?: number; + queueId?: string; + scheduledAfter?: Date | string; + scheduledBefore?: Date | string; + status?: string; +} + +// @public (undocumented) +export interface ListQueues { + get(options?: ListQueuesParameters): StreamableMethod; +} + +// @public +export interface ListQueues200Response extends HttpResponse { + // (undocumented) + body: PagedRouterQueueItemOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface ListQueuesDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ListQueuesDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ListQueuesDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type ListQueuesParameters = ListQueuesQueryParam & RequestParameters; + +// @public (undocumented) +export interface ListQueuesQueryParam { + // (undocumented) + queryParameters?: ListQueuesQueryParamProperties; +} + +// @public (undocumented) +export interface ListQueuesQueryParamProperties { + maxpagesize?: number; +} + +// @public (undocumented) +export interface ListWorkers { + get(options?: ListWorkersParameters): StreamableMethod; +} + +// @public +export interface ListWorkers200Response extends HttpResponse { + // (undocumented) + body: PagedRouterWorkerItemOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface ListWorkersDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ListWorkersDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ListWorkersDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type ListWorkersParameters = ListWorkersQueryParam & RequestParameters; + +// @public (undocumented) +export interface ListWorkersQueryParam { + // (undocumented) + queryParameters?: ListWorkersQueryParamProperties; +} + +// @public (undocumented) +export interface ListWorkersQueryParamProperties { + channelId?: string; + hasCapacity?: boolean; + maxpagesize?: number; + queueId?: string; + state?: string; +} + +// @public +export interface LongestIdleMode extends DistributionModeParent { + kind: "longest-idle"; +} + +// @public +export interface LongestIdleModeOutput extends DistributionModeOutputParent { + kind: "longest-idle"; +} + +// @public +export interface ManualReclassifyExceptionAction extends ExceptionActionParent { + kind: "manual-reclassify"; + priority?: number; + queueId?: string; + workerSelectors?: Array; +} + +// @public +export interface ManualReclassifyExceptionActionOutput extends ExceptionActionOutputParent { + kind: "manual-reclassify"; + priority?: number; + queueId?: string; + workerSelectors?: Array; +} + +// @public +export interface Oauth2ClientCredential { + clientId?: string; + clientSecret?: string; +} + +// @public +export interface Oauth2ClientCredentialOutput { + clientId?: string; + clientSecret?: string; +} + +// @public +export type PagedClassificationPolicyItemOutput = Paged; + +// @public +export type PagedDistributionPolicyItemOutput = Paged; + +// @public +export type PagedExceptionPolicyItemOutput = Paged; + +// @public +export type PagedRouterJobItemOutput = Paged; + +// @public +export type PagedRouterQueueItemOutput = Paged; + +// @public +export type PagedRouterWorkerItemOutput = Paged; + +// @public +export function paginate(client: Client, initialResponse: TResponse, options?: PagingOptions): PagedAsyncIterableIterator>; + +// @public +export type PaginateReturn = TResult extends { + body: { + value?: infer TPage; + }; +} ? GetArrayType : Array; + +// @public +export interface PagingOptions { + customGetPage?: GetPage[]>; +} + +// @public +export interface PassThroughQueueSelectorAttachment extends QueueSelectorAttachmentParent { + key: string; + kind: "pass-through"; + labelOperator: string; +} + +// @public +export interface PassThroughQueueSelectorAttachmentOutput extends QueueSelectorAttachmentOutputParent { + key: string; + kind: "pass-through"; + labelOperator: string; +} + +// @public +export interface PassThroughWorkerSelectorAttachment extends WorkerSelectorAttachmentParent { + expiresAfterSeconds?: number; + key: string; + kind: "pass-through"; + labelOperator: string; +} + +// @public +export interface PassThroughWorkerSelectorAttachmentOutput extends WorkerSelectorAttachmentOutputParent { + expiresAfterSeconds?: number; + key: string; + kind: "pass-through"; + labelOperator: string; +} + +// @public +export interface QueueAndMatchMode { +} + +// @public +export interface QueueAndMatchModeOutput { +} + +// @public +export interface QueueLengthExceptionTrigger extends ExceptionTriggerParent { + kind: "queue-length"; + threshold: number; +} + +// @public +export interface QueueLengthExceptionTriggerOutput extends ExceptionTriggerOutputParent { + kind: "queue-length"; + threshold: number; +} + +// @public +export type QueueSelectorAttachment = ConditionalQueueSelectorAttachment | PassThroughQueueSelectorAttachment | RuleEngineQueueSelectorAttachment | StaticQueueSelectorAttachment | WeightedAllocationQueueSelectorAttachment; + +// @public +export type QueueSelectorAttachmentOutput = ConditionalQueueSelectorAttachmentOutput | PassThroughQueueSelectorAttachmentOutput | RuleEngineQueueSelectorAttachmentOutput | StaticQueueSelectorAttachmentOutput | WeightedAllocationQueueSelectorAttachmentOutput; + +// @public +export interface QueueSelectorAttachmentOutputParent { + // (undocumented) + kind: string; +} + +// @public +export interface QueueSelectorAttachmentParent { + // (undocumented) + kind: string; +} + +// @public +export interface QueueWeightedAllocation { + queueSelectors: Array; + weight: number; +} + +// @public +export interface QueueWeightedAllocationOutput { + queueSelectors: Array; + weight: number; +} + +// @public +export interface ReclassifyExceptionAction extends ExceptionActionParent { + classificationPolicyId?: string; + kind: "reclassify"; + labelsToUpsert?: Record; +} + +// @public +export interface ReclassifyExceptionActionOutput extends ExceptionActionOutputParent { + classificationPolicyId?: string; + kind: "reclassify"; + labelsToUpsert?: Record; +} + +// @public (undocumented) +export interface ReclassifyJobAction { + post(options?: ReclassifyJobActionParameters): StreamableMethod; +} + +// @public +export interface ReclassifyJobAction200Response extends HttpResponse { + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface ReclassifyJobActionBodyParam { + body?: Record; +} + +// @public (undocumented) +export interface ReclassifyJobActionDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ReclassifyJobActionDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ReclassifyJobActionDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type ReclassifyJobActionParameters = ReclassifyJobActionBodyParam & RequestParameters; + +// @public +export interface RoundRobinMode extends DistributionModeParent { + kind: "round-robin"; +} + +// @public +export interface RoundRobinModeOutput extends DistributionModeOutputParent { + kind: "round-robin"; +} + +// @public +export interface RouterConditionalRequestHeadersOutput { +} + +// @public +export interface RouterJob { + channelId?: string; + channelReference?: string; + classificationPolicyId?: string; + dispositionCode?: string; + labels?: Record; + matchingMode?: JobMatchingMode; + notes?: Record; + priority?: number; + queueId?: string; + requestedWorkerSelectors?: Array; + tags?: Record; +} + +// @public +export interface RouterJobAssignment { + assignedAt: Date | string; + assignmentId: string; + closedAt?: Date | string; + completedAt?: Date | string; + workerId?: string; +} + +// @public +export interface RouterJobAssignmentOutput { + assignedAt: string; + assignmentId: string; + closedAt?: string; + completedAt?: string; + workerId?: string; +} + +// @public +export interface RouterJobItemOutput { + etag: string; + job: RouterJobOutput; +} + +// @public +export interface RouterJobOffer { + capacityCost: number; + expiresAt?: Date | string; + jobId: string; + offeredAt?: Date | string; + offerId: string; +} + +// @public +export interface RouterJobOfferOutput { + capacityCost: number; + expiresAt?: string; + jobId: string; + offeredAt?: string; + offerId: string; +} + +// @public +export interface RouterJobOutput { + readonly assignments?: Record; + readonly attachedWorkerSelectors?: Array; + channelId?: string; + channelReference?: string; + classificationPolicyId?: string; + dispositionCode?: string; + readonly enqueuedAt?: string; + readonly id: string; + labels?: Record; + matchingMode?: JobMatchingModeOutput; + notes?: Record; + priority?: number; + queueId?: string; + requestedWorkerSelectors?: Array; + readonly scheduledAt?: string; + readonly status?: string; + tags?: Record; +} + +// @public +export interface RouterJobPositionDetailsOutput { + estimatedWaitTimeMinutes: number; + jobId: string; + position: number; + queueId: string; + queueLength: number; +} + +// @public +export type RouterJobResourceMergeAndPatch = Partial; + +// @public +export interface RouterQueue { + distributionPolicyId?: string; + exceptionPolicyId?: string; + labels?: Record; + name?: string; +} + +// @public +export interface RouterQueueAssignment { +} + +// @public +export interface RouterQueueAssignmentOutput { +} + +// @public +export interface RouterQueueItemOutput { + etag: string; + queue: RouterQueueOutput; +} + +// @public +export interface RouterQueueOutput { + distributionPolicyId?: string; + exceptionPolicyId?: string; + readonly id: string; + labels?: Record; + name?: string; +} + +// @public +export type RouterQueueResourceMergeAndPatch = Partial; + +// @public +export interface RouterQueueSelector { + key: string; + labelOperator: string; + value?: unknown; +} + +// @public +export interface RouterQueueSelectorOutput { + key: string; + labelOperator: string; + value?: any; +} + +// @public +export interface RouterQueueStatisticsOutput { + estimatedWaitTimeMinutes?: Record; + length: number; + longestJobWaitTimeMinutes?: number; + queueId: string; +} + +// @public +export type RouterRule = DirectMapRouterRule | ExpressionRouterRule | FunctionRouterRule | StaticRouterRule | WebhookRouterRule; + +// @public +export type RouterRuleOutput = DirectMapRouterRuleOutput | ExpressionRouterRuleOutput | FunctionRouterRuleOutput | StaticRouterRuleOutput | WebhookRouterRuleOutput; + +// @public +export interface RouterRuleOutputParent { + // (undocumented) + kind: string; +} + +// @public +export interface RouterRuleParent { + // (undocumented) + kind: string; +} + +// @public +export interface RouterWorker { + availableForOffers?: boolean; + channelConfigurations?: Record; + labels?: Record; + queueAssignments?: Record; + tags?: Record; + totalCapacity?: number; +} + +// @public +export interface RouterWorkerAssignment { + assignedAt: Date | string; + assignmentId: string; + capacityCost: number; + jobId: string; +} + +// @public +export interface RouterWorkerAssignmentOutput { + assignedAt: string; + assignmentId: string; + capacityCost: number; + jobId: string; +} + +// @public +export interface RouterWorkerItemOutput { + etag: string; + worker: RouterWorkerOutput; +} + +// @public +export interface RouterWorkerOutput { + readonly assignedJobs?: Array; + availableForOffers?: boolean; + channelConfigurations?: Record; + readonly id: string; + labels?: Record; + readonly loadRatio?: number; + readonly offers?: Array; + queueAssignments?: Record; + readonly state?: string; + tags?: Record; + totalCapacity?: number; +} + +// @public +export type RouterWorkerResourceMergeAndPatch = Partial; + +// @public +export interface RouterWorkerSelector { + expedite?: boolean; + expiresAfterSeconds?: number; + key: string; + labelOperator: string; + value?: unknown; +} + +// @public +export interface RouterWorkerSelectorOutput { + expedite?: boolean; + expiresAfterSeconds?: number; + readonly expiresAt?: string; + key: string; + labelOperator: string; + readonly status?: string; + value?: any; +} + +// @public (undocumented) +export interface Routes { + (path: "/routing/classificationPolicies/{id}", id: string): UpsertClassificationPolicy; + (path: "/routing/classificationPolicies"): ListClassificationPolicies; + (path: "/routing/distributionPolicies/{id}", id: string): UpsertDistributionPolicy; + (path: "/routing/distributionPolicies"): ListDistributionPolicies; + (path: "/routing/exceptionPolicies/{id}", id: string): UpsertExceptionPolicy; + (path: "/routing/exceptionPolicies"): ListExceptionPolicies; + (path: "/routing/queues/{id}", id: string): UpsertQueue; + (path: "/routing/queues"): ListQueues; + (path: "/routing/jobs/{id}", id: string): UpsertJob; + (path: "/routing/jobs/{id}:reclassify", id: string): ReclassifyJobAction; + (path: "/routing/jobs/{id}:cancel", id: string): CancelJobAction; + (path: "/routing/jobs/{id}:complete", id: string): CompleteJobAction; + (path: "/routing/jobs/{id}:close", id: string): CloseJobAction; + (path: "/routing/jobs"): ListJobs; + (path: "/routing/jobs/{id}/position", id: string): GetInQueuePosition; + (path: "/routing/jobs/{id}/assignments/{assignmentId}:unassign", id: string, assignmentId: string): UnassignJobAction; + (path: "/routing/workers/{workerId}/offers/{offerId}:accept", workerId: string, offerId: string): AcceptJobAction; + (path: "/routing/workers/{workerId}/offers/{offerId}:decline", workerId: string, offerId: string): DeclineJobAction; + (path: "/routing/queues/{id}/statistics", id: string): GetQueueStatistics; + (path: "/routing/workers/{workerId}", workerId: string): UpsertWorker; + (path: "/routing/workers"): ListWorkers; +} + +// @public +export interface RuleEngineQueueSelectorAttachment extends QueueSelectorAttachmentParent { + kind: "rule-engine"; + rule: RouterRule; +} + +// @public +export interface RuleEngineQueueSelectorAttachmentOutput extends QueueSelectorAttachmentOutputParent { + kind: "rule-engine"; + rule: RouterRuleOutput; +} + +// @public +export interface RuleEngineWorkerSelectorAttachment extends WorkerSelectorAttachmentParent { + kind: "rule-engine"; + rule: RouterRule; +} + +// @public +export interface RuleEngineWorkerSelectorAttachmentOutput extends WorkerSelectorAttachmentOutputParent { + kind: "rule-engine"; + rule: RouterRuleOutput; +} + +// @public +export interface ScheduleAndSuspendMode { + scheduleAt: Date | string; +} + +// @public +export interface ScheduleAndSuspendModeOutput { + scheduleAt: string; +} + +// @public +export interface ScoringRuleOptions { + allowScoringBatchOfWorkers?: boolean; + batchSize?: number; + descendingOrder?: boolean; + scoringParameters?: string[]; +} + +// @public +export interface ScoringRuleOptionsOutput { + allowScoringBatchOfWorkers?: boolean; + batchSize?: number; + descendingOrder?: boolean; + scoringParameters?: string[]; +} + +// @public +export interface StaticQueueSelectorAttachment extends QueueSelectorAttachmentParent { + kind: "static"; + queueSelector: RouterQueueSelector; +} + +// @public +export interface StaticQueueSelectorAttachmentOutput extends QueueSelectorAttachmentOutputParent { + kind: "static"; + queueSelector: RouterQueueSelectorOutput; +} + +// @public +export interface StaticRouterRule extends RouterRuleParent { + kind: "static-rule"; + value?: unknown; +} + +// @public +export interface StaticRouterRuleOutput extends RouterRuleOutputParent { + kind: "static-rule"; + value?: any; +} + +// @public +export interface StaticWorkerSelectorAttachment extends WorkerSelectorAttachmentParent { + kind: "static"; + workerSelector: RouterWorkerSelector; +} + +// @public +export interface StaticWorkerSelectorAttachmentOutput extends WorkerSelectorAttachmentOutputParent { + kind: "static"; + workerSelector: RouterWorkerSelectorOutput; +} + +// @public +export interface SuspendMode { +} + +// @public +export interface SuspendModeOutput { +} + +// @public (undocumented) +export interface UnassignJobAction { + post(options?: UnassignJobActionParameters): StreamableMethod; +} + +// @public +export interface UnassignJobAction200Response extends HttpResponse { + // (undocumented) + body: UnassignJobResultOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface UnassignJobActionBodyParam { + body?: UnassignJobRequest; +} + +// @public (undocumented) +export interface UnassignJobActionDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface UnassignJobActionDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & UnassignJobActionDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type UnassignJobActionParameters = UnassignJobActionBodyParam & RequestParameters; + +// @public +export interface UnassignJobRequest { + suspendMatching?: boolean; +} + +// @public +export interface UnassignJobResultOutput { + jobId: string; + unassignmentCount: number; +} + +// @public (undocumented) +export interface UpsertClassificationPolicy { + delete(options?: DeleteClassificationPolicyParameters): StreamableMethod; + get(options?: GetClassificationPolicyParameters): StreamableMethod; + patch(options: UpsertClassificationPolicyParameters): StreamableMethod; +} + +// @public (undocumented) +export interface UpsertClassificationPolicy200Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface UpsertClassificationPolicy200Response extends HttpResponse { + // (undocumented) + body: ClassificationPolicyOutput; + // (undocumented) + headers: RawHttpHeaders & UpsertClassificationPolicy200Headers; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface UpsertClassificationPolicy201Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface UpsertClassificationPolicy201Response extends HttpResponse { + // (undocumented) + body: ClassificationPolicyOutput; + // (undocumented) + headers: RawHttpHeaders & UpsertClassificationPolicy201Headers; + // (undocumented) + status: "201"; +} + +// @public (undocumented) +export interface UpsertClassificationPolicyBodyParam { + body: ClassificationPolicyResourceMergeAndPatch; +} + +// @public (undocumented) +export interface UpsertClassificationPolicyDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface UpsertClassificationPolicyDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & UpsertClassificationPolicyDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export interface UpsertClassificationPolicyHeaderParam { + // (undocumented) + headers?: RawHttpHeadersInput & UpsertClassificationPolicyHeaders; +} + +// @public (undocumented) +export interface UpsertClassificationPolicyHeaders { + "If-Match"?: string; + "If-Unmodified-Since"?: string; +} + +// @public (undocumented) +export interface UpsertClassificationPolicyMediaTypesParam { + contentType: "application/merge-patch+json"; +} + +// @public (undocumented) +export type UpsertClassificationPolicyParameters = UpsertClassificationPolicyHeaderParam & UpsertClassificationPolicyMediaTypesParam & UpsertClassificationPolicyBodyParam & RequestParameters; + +// @public (undocumented) +export interface UpsertDistributionPolicy { + delete(options?: DeleteDistributionPolicyParameters): StreamableMethod; + get(options?: GetDistributionPolicyParameters): StreamableMethod; + patch(options: UpsertDistributionPolicyParameters): StreamableMethod; +} + +// @public (undocumented) +export interface UpsertDistributionPolicy200Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface UpsertDistributionPolicy200Response extends HttpResponse { + // (undocumented) + body: DistributionPolicyOutput; + // (undocumented) + headers: RawHttpHeaders & UpsertDistributionPolicy200Headers; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface UpsertDistributionPolicy201Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface UpsertDistributionPolicy201Response extends HttpResponse { + // (undocumented) + body: DistributionPolicyOutput; + // (undocumented) + headers: RawHttpHeaders & UpsertDistributionPolicy201Headers; + // (undocumented) + status: "201"; +} + +// @public (undocumented) +export interface UpsertDistributionPolicyBodyParam { + body: DistributionPolicyResourceMergeAndPatch; +} + +// @public (undocumented) +export interface UpsertDistributionPolicyDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface UpsertDistributionPolicyDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & UpsertDistributionPolicyDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export interface UpsertDistributionPolicyHeaderParam { + // (undocumented) + headers?: RawHttpHeadersInput & UpsertDistributionPolicyHeaders; +} + +// @public (undocumented) +export interface UpsertDistributionPolicyHeaders { + "If-Match"?: string; + "If-Unmodified-Since"?: string; +} + +// @public (undocumented) +export interface UpsertDistributionPolicyMediaTypesParam { + contentType: "application/merge-patch+json"; +} + +// @public (undocumented) +export type UpsertDistributionPolicyParameters = UpsertDistributionPolicyHeaderParam & UpsertDistributionPolicyMediaTypesParam & UpsertDistributionPolicyBodyParam & RequestParameters; + +// @public (undocumented) +export interface UpsertExceptionPolicy { + delete(options?: DeleteExceptionPolicyParameters): StreamableMethod; + get(options?: GetExceptionPolicyParameters): StreamableMethod; + patch(options: UpsertExceptionPolicyParameters): StreamableMethod; +} + +// @public (undocumented) +export interface UpsertExceptionPolicy200Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface UpsertExceptionPolicy200Response extends HttpResponse { + // (undocumented) + body: ExceptionPolicyOutput; + // (undocumented) + headers: RawHttpHeaders & UpsertExceptionPolicy200Headers; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface UpsertExceptionPolicy201Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface UpsertExceptionPolicy201Response extends HttpResponse { + // (undocumented) + body: ExceptionPolicyOutput; + // (undocumented) + headers: RawHttpHeaders & UpsertExceptionPolicy201Headers; + // (undocumented) + status: "201"; +} + +// @public (undocumented) +export interface UpsertExceptionPolicyBodyParam { + body: ExceptionPolicyResourceMergeAndPatch; +} + +// @public (undocumented) +export interface UpsertExceptionPolicyDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface UpsertExceptionPolicyDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & UpsertExceptionPolicyDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export interface UpsertExceptionPolicyHeaderParam { + // (undocumented) + headers?: RawHttpHeadersInput & UpsertExceptionPolicyHeaders; +} + +// @public (undocumented) +export interface UpsertExceptionPolicyHeaders { + "If-Match"?: string; + "If-Unmodified-Since"?: string; +} + +// @public (undocumented) +export interface UpsertExceptionPolicyMediaTypesParam { + contentType: "application/merge-patch+json"; +} + +// @public (undocumented) +export type UpsertExceptionPolicyParameters = UpsertExceptionPolicyHeaderParam & UpsertExceptionPolicyMediaTypesParam & UpsertExceptionPolicyBodyParam & RequestParameters; + +// @public (undocumented) +export interface UpsertJob { + delete(options?: DeleteJobParameters): StreamableMethod; + get(options?: GetJobParameters): StreamableMethod; + patch(options: UpsertJobParameters): StreamableMethod; +} + +// @public (undocumented) +export interface UpsertJob200Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface UpsertJob200Response extends HttpResponse { + // (undocumented) + body: RouterJobOutput; + // (undocumented) + headers: RawHttpHeaders & UpsertJob200Headers; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface UpsertJob201Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface UpsertJob201Response extends HttpResponse { + // (undocumented) + body: RouterJobOutput; + // (undocumented) + headers: RawHttpHeaders & UpsertJob201Headers; + // (undocumented) + status: "201"; +} + +// @public (undocumented) +export interface UpsertJobBodyParam { + body: RouterJobResourceMergeAndPatch; +} + +// @public (undocumented) +export interface UpsertJobDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface UpsertJobDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & UpsertJobDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export interface UpsertJobHeaderParam { + // (undocumented) + headers?: RawHttpHeadersInput & UpsertJobHeaders; +} + +// @public (undocumented) +export interface UpsertJobHeaders { + "If-Match"?: string; + "If-Unmodified-Since"?: string; +} + +// @public (undocumented) +export interface UpsertJobMediaTypesParam { + contentType: "application/merge-patch+json"; +} + +// @public (undocumented) +export type UpsertJobParameters = UpsertJobHeaderParam & UpsertJobMediaTypesParam & UpsertJobBodyParam & RequestParameters; + +// @public (undocumented) +export interface UpsertQueue { + delete(options?: DeleteQueueParameters): StreamableMethod; + get(options?: GetQueueParameters): StreamableMethod; + patch(options: UpsertQueueParameters): StreamableMethod; +} + +// @public (undocumented) +export interface UpsertQueue200Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface UpsertQueue200Response extends HttpResponse { + // (undocumented) + body: RouterQueueOutput; + // (undocumented) + headers: RawHttpHeaders & UpsertQueue200Headers; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface UpsertQueue201Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface UpsertQueue201Response extends HttpResponse { + // (undocumented) + body: RouterQueueOutput; + // (undocumented) + headers: RawHttpHeaders & UpsertQueue201Headers; + // (undocumented) + status: "201"; +} + +// @public (undocumented) +export interface UpsertQueueBodyParam { + body: RouterQueueResourceMergeAndPatch; +} + +// @public (undocumented) +export interface UpsertQueueDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface UpsertQueueDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & UpsertQueueDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export interface UpsertQueueHeaderParam { + // (undocumented) + headers?: RawHttpHeadersInput & UpsertQueueHeaders; +} + +// @public (undocumented) +export interface UpsertQueueHeaders { + "If-Match"?: string; + "If-Unmodified-Since"?: string; +} + +// @public (undocumented) +export interface UpsertQueueMediaTypesParam { + contentType: "application/merge-patch+json"; +} + +// @public (undocumented) +export type UpsertQueueParameters = UpsertQueueHeaderParam & UpsertQueueMediaTypesParam & UpsertQueueBodyParam & RequestParameters; + +// @public (undocumented) +export interface UpsertWorker { + delete(options?: DeleteWorkerParameters): StreamableMethod; + get(options?: GetWorkerParameters): StreamableMethod; + patch(options: UpsertWorkerParameters): StreamableMethod; +} + +// @public (undocumented) +export interface UpsertWorker200Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface UpsertWorker200Response extends HttpResponse { + // (undocumented) + body: RouterWorkerOutput; + // (undocumented) + headers: RawHttpHeaders & UpsertWorker200Headers; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface UpsertWorker201Headers { + "last-modified"?: string; + etag?: string; +} + +// @public +export interface UpsertWorker201Response extends HttpResponse { + // (undocumented) + body: RouterWorkerOutput; + // (undocumented) + headers: RawHttpHeaders & UpsertWorker201Headers; + // (undocumented) + status: "201"; +} + +// @public (undocumented) +export interface UpsertWorkerBodyParam { + body: RouterWorkerResourceMergeAndPatch; +} + +// @public (undocumented) +export interface UpsertWorkerDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface UpsertWorkerDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & UpsertWorkerDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export interface UpsertWorkerHeaderParam { + // (undocumented) + headers?: RawHttpHeadersInput & UpsertWorkerHeaders; +} + +// @public (undocumented) +export interface UpsertWorkerHeaders { + "If-Match"?: string; + "If-Unmodified-Since"?: string; +} + +// @public (undocumented) +export interface UpsertWorkerMediaTypesParam { + contentType: "application/merge-patch+json"; +} + +// @public (undocumented) +export type UpsertWorkerParameters = UpsertWorkerHeaderParam & UpsertWorkerMediaTypesParam & UpsertWorkerBodyParam & RequestParameters; + +// @public +export interface WaitTimeExceptionTrigger extends ExceptionTriggerParent { + kind: "wait-time"; + thresholdSeconds: number; +} + +// @public +export interface WaitTimeExceptionTriggerOutput extends ExceptionTriggerOutputParent { + kind: "wait-time"; + thresholdSeconds: number; +} + +// @public +export interface WebhookRouterRule extends RouterRuleParent { + authorizationServerUri?: string; + clientCredential?: Oauth2ClientCredential; + kind: "webhook-rule"; + webhookUri?: string; +} + +// @public +export interface WebhookRouterRuleOutput extends RouterRuleOutputParent { + authorizationServerUri?: string; + clientCredential?: Oauth2ClientCredentialOutput; + kind: "webhook-rule"; + webhookUri?: string; +} + +// @public +export interface WeightedAllocationQueueSelectorAttachment extends QueueSelectorAttachmentParent { + allocations: Array; + kind: "weighted-allocation-queue-selector"; +} + +// @public +export interface WeightedAllocationQueueSelectorAttachmentOutput extends QueueSelectorAttachmentOutputParent { + allocations: Array; + kind: "weighted-allocation-queue-selector"; +} + +// @public +export interface WeightedAllocationWorkerSelectorAttachment extends WorkerSelectorAttachmentParent { + allocations: Array; + kind: "weighted-allocation-worker-selector"; +} + +// @public +export interface WeightedAllocationWorkerSelectorAttachmentOutput extends WorkerSelectorAttachmentOutputParent { + allocations: Array; + kind: "weighted-allocation-worker-selector"; +} + +// @public +export type WorkerSelectorAttachment = ConditionalWorkerSelectorAttachment | PassThroughWorkerSelectorAttachment | RuleEngineWorkerSelectorAttachment | StaticWorkerSelectorAttachment | WeightedAllocationWorkerSelectorAttachment; + +// @public +export type WorkerSelectorAttachmentOutput = ConditionalWorkerSelectorAttachmentOutput | PassThroughWorkerSelectorAttachmentOutput | RuleEngineWorkerSelectorAttachmentOutput | StaticWorkerSelectorAttachmentOutput | WeightedAllocationWorkerSelectorAttachmentOutput; + +// @public +export interface WorkerSelectorAttachmentOutputParent { + // (undocumented) + kind: string; +} + +// @public +export interface WorkerSelectorAttachmentParent { + // (undocumented) + kind: string; +} + +// @public +export interface WorkerWeightedAllocation { + weight: number; + workerSelectors: Array; +} + +// @public +export interface WorkerWeightedAllocationOutput { + weight: number; + workerSelectors: Array; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/communication/communication-job-router-rest/src/azureCommunicationRoutingServiceClient.ts b/sdk/communication/communication-job-router-rest/src/azureCommunicationRoutingServiceClient.ts new file mode 100644 index 000000000000..eecffe22e5c0 --- /dev/null +++ b/sdk/communication/communication-job-router-rest/src/azureCommunicationRoutingServiceClient.ts @@ -0,0 +1,41 @@ +// 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-rest/src/clientDefinitions.ts b/sdk/communication/communication-job-router-rest/src/clientDefinitions.ts new file mode 100644 index 000000000000..61fb183d8434 --- /dev/null +++ b/sdk/communication/communication-job-router-rest/src/clientDefinitions.ts @@ -0,0 +1,444 @@ +// 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, + ReclassifyJobActionParameters, + CancelJobActionParameters, + CompleteJobActionParameters, + CloseJobActionParameters, + ListJobsParameters, + GetInQueuePositionParameters, + UnassignJobActionParameters, + AcceptJobActionParameters, + DeclineJobActionParameters, + 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, + ReclassifyJobAction200Response, + ReclassifyJobActionDefaultResponse, + CancelJobAction200Response, + CancelJobActionDefaultResponse, + CompleteJobAction200Response, + CompleteJobActionDefaultResponse, + CloseJobAction200Response, + CloseJobAction202Response, + CloseJobActionDefaultResponse, + ListJobs200Response, + ListJobsDefaultResponse, + GetInQueuePosition200Response, + GetInQueuePositionDefaultResponse, + UnassignJobAction200Response, + UnassignJobActionDefaultResponse, + AcceptJobAction200Response, + AcceptJobActionDefaultResponse, + DeclineJobAction200Response, + DeclineJobActionDefaultResponse, + 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 ReclassifyJobAction { + /** Reclassify a job. */ + post( + options?: ReclassifyJobActionParameters + ): StreamableMethod< + ReclassifyJobAction200Response | ReclassifyJobActionDefaultResponse + >; +} + +export interface CancelJobAction { + /** + * Submits request to cancel an existing job by Id while supplying free-form + * cancellation reason. + */ + post( + options?: CancelJobActionParameters + ): StreamableMethod< + CancelJobAction200Response | CancelJobActionDefaultResponse + >; +} + +export interface CompleteJobAction { + /** Completes an assigned job. */ + post( + options: CompleteJobActionParameters + ): StreamableMethod< + CompleteJobAction200Response | CompleteJobActionDefaultResponse + >; +} + +export interface CloseJobAction { + /** Closes a completed job. */ + post( + options: CloseJobActionParameters + ): StreamableMethod< + | CloseJobAction200Response + | CloseJobAction202Response + | CloseJobActionDefaultResponse + >; +} + +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 UnassignJobAction { + /** Un-assign a job. */ + post( + options?: UnassignJobActionParameters + ): StreamableMethod< + UnassignJobAction200Response | UnassignJobActionDefaultResponse + >; +} + +export interface AcceptJobAction { + /** + * Accepts an offer to work on a job and returns a 409/Conflict if another agent + * accepted the job already. + */ + post( + options?: AcceptJobActionParameters + ): StreamableMethod< + AcceptJobAction200Response | AcceptJobActionDefaultResponse + >; +} + +export interface DeclineJobAction { + /** Declines an offer to work on a job. */ + post( + options?: DeclineJobActionParameters + ): StreamableMethod< + DeclineJobAction200Response | DeclineJobActionDefaultResponse + >; +} + +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/\{id\}' has methods for the following verbs: patch, get, delete */ + ( + path: "/routing/classificationPolicies/{id}", + id: string + ): UpsertClassificationPolicy; + /** Resource for '/routing/classificationPolicies' has methods for the following verbs: get */ + (path: "/routing/classificationPolicies"): ListClassificationPolicies; + /** Resource for '/routing/distributionPolicies/\{id\}' has methods for the following verbs: patch, get, delete */ + ( + path: "/routing/distributionPolicies/{id}", + id: string + ): UpsertDistributionPolicy; + /** Resource for '/routing/distributionPolicies' has methods for the following verbs: get */ + (path: "/routing/distributionPolicies"): ListDistributionPolicies; + /** Resource for '/routing/exceptionPolicies/\{id\}' has methods for the following verbs: patch, get, delete */ + (path: "/routing/exceptionPolicies/{id}", id: string): UpsertExceptionPolicy; + /** Resource for '/routing/exceptionPolicies' has methods for the following verbs: get */ + (path: "/routing/exceptionPolicies"): ListExceptionPolicies; + /** Resource for '/routing/queues/\{id\}' has methods for the following verbs: patch, get, delete */ + (path: "/routing/queues/{id}", id: string): UpsertQueue; + /** Resource for '/routing/queues' has methods for the following verbs: get */ + (path: "/routing/queues"): ListQueues; + /** Resource for '/routing/jobs/\{id\}' has methods for the following verbs: patch, get, delete */ + (path: "/routing/jobs/{id}", id: string): UpsertJob; + /** Resource for '/routing/jobs/\{id\}:reclassify' has methods for the following verbs: post */ + (path: "/routing/jobs/{id}:reclassify", id: string): ReclassifyJobAction; + /** Resource for '/routing/jobs/\{id\}:cancel' has methods for the following verbs: post */ + (path: "/routing/jobs/{id}:cancel", id: string): CancelJobAction; + /** Resource for '/routing/jobs/\{id\}:complete' has methods for the following verbs: post */ + (path: "/routing/jobs/{id}:complete", id: string): CompleteJobAction; + /** Resource for '/routing/jobs/\{id\}:close' has methods for the following verbs: post */ + (path: "/routing/jobs/{id}:close", id: string): CloseJobAction; + /** Resource for '/routing/jobs' has methods for the following verbs: get */ + (path: "/routing/jobs"): ListJobs; + /** Resource for '/routing/jobs/\{id\}/position' has methods for the following verbs: get */ + (path: "/routing/jobs/{id}/position", id: string): GetInQueuePosition; + /** Resource for '/routing/jobs/\{id\}/assignments/\{assignmentId\}:unassign' has methods for the following verbs: post */ + ( + path: "/routing/jobs/{id}/assignments/{assignmentId}:unassign", + id: string, + assignmentId: string + ): UnassignJobAction; + /** 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 + ): AcceptJobAction; + /** 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 + ): DeclineJobAction; + /** Resource for '/routing/queues/\{id\}/statistics' has methods for the following verbs: get */ + (path: "/routing/queues/{id}/statistics", id: 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-rest/src/index.ts b/sdk/communication/communication-job-router-rest/src/index.ts new file mode 100644 index 000000000000..cac5e0ed9b1d --- /dev/null +++ b/sdk/communication/communication-job-router-rest/src/index.ts @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import AzureCommunicationRoutingServiceClient from "./azureCommunicationRoutingServiceClient"; + +export * from "./azureCommunicationRoutingServiceClient"; +export * from "./parameters"; +export * from "./responses"; +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-rest/src/isUnexpected.ts b/sdk/communication/communication-job-router-rest/src/isUnexpected.ts new file mode 100644 index 000000000000..b7fb50a338f0 --- /dev/null +++ b/sdk/communication/communication-job-router-rest/src/isUnexpected.ts @@ -0,0 +1,442 @@ +// 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, + ReclassifyJobAction200Response, + ReclassifyJobActionDefaultResponse, + CancelJobAction200Response, + CancelJobActionDefaultResponse, + CompleteJobAction200Response, + CompleteJobActionDefaultResponse, + CloseJobAction200Response, + CloseJobAction202Response, + CloseJobActionDefaultResponse, + ListJobs200Response, + ListJobsDefaultResponse, + GetInQueuePosition200Response, + GetInQueuePositionDefaultResponse, + UnassignJobAction200Response, + UnassignJobActionDefaultResponse, + AcceptJobAction200Response, + AcceptJobActionDefaultResponse, + DeclineJobAction200Response, + DeclineJobActionDefaultResponse, + GetQueueStatistics200Response, + GetQueueStatisticsDefaultResponse, + UpsertWorker200Response, + UpsertWorker201Response, + UpsertWorkerDefaultResponse, + GetWorker200Response, + GetWorkerDefaultResponse, + DeleteWorker204Response, + DeleteWorkerDefaultResponse, + ListWorkers200Response, + ListWorkersDefaultResponse, +} from "./responses"; + +const responseMap: Record = { + "PATCH /routing/classificationPolicies/{id}": ["200", "201"], + "GET /routing/classificationPolicies/{id}": ["200"], + "DELETE /routing/classificationPolicies/{id}": ["204"], + "GET /routing/classificationPolicies": ["200"], + "PATCH /routing/distributionPolicies/{id}": ["200", "201"], + "GET /routing/distributionPolicies/{id}": ["200"], + "DELETE /routing/distributionPolicies/{id}": ["204"], + "GET /routing/distributionPolicies": ["200"], + "PATCH /routing/exceptionPolicies/{id}": ["200", "201"], + "GET /routing/exceptionPolicies/{id}": ["200"], + "DELETE /routing/exceptionPolicies/{id}": ["204"], + "GET /routing/exceptionPolicies": ["200"], + "PATCH /routing/queues/{id}": ["200", "201"], + "GET /routing/queues/{id}": ["200"], + "DELETE /routing/queues/{id}": ["204"], + "GET /routing/queues": ["200"], + "PATCH /routing/jobs/{id}": ["200", "201"], + "GET /routing/jobs/{id}": ["200"], + "DELETE /routing/jobs/{id}": ["204"], + "POST /routing/jobs/{id}:reclassify": ["200"], + "POST /routing/jobs/{id}:cancel": ["200"], + "POST /routing/jobs/{id}:complete": ["200"], + "POST /routing/jobs/{id}:close": ["200", "202"], + "GET /routing/jobs": ["200"], + "GET /routing/jobs/{id}/position": ["200"], + "POST /routing/jobs/{id}/assignments/{assignmentId}:unassign": ["200"], + "POST /routing/workers/{workerId}/offers/{offerId}:accept": ["200"], + "POST /routing/workers/{workerId}/offers/{offerId}:decline": ["200"], + "GET /routing/queues/{id}/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: ReclassifyJobAction200Response | ReclassifyJobActionDefaultResponse +): response is ReclassifyJobActionDefaultResponse; +export function isUnexpected( + response: CancelJobAction200Response | CancelJobActionDefaultResponse +): response is CancelJobActionDefaultResponse; +export function isUnexpected( + response: CompleteJobAction200Response | CompleteJobActionDefaultResponse +): response is CompleteJobActionDefaultResponse; +export function isUnexpected( + response: + | CloseJobAction200Response + | CloseJobAction202Response + | CloseJobActionDefaultResponse +): response is CloseJobActionDefaultResponse; +export function isUnexpected( + response: ListJobs200Response | ListJobsDefaultResponse +): response is ListJobsDefaultResponse; +export function isUnexpected( + response: GetInQueuePosition200Response | GetInQueuePositionDefaultResponse +): response is GetInQueuePositionDefaultResponse; +export function isUnexpected( + response: UnassignJobAction200Response | UnassignJobActionDefaultResponse +): response is UnassignJobActionDefaultResponse; +export function isUnexpected( + response: AcceptJobAction200Response | AcceptJobActionDefaultResponse +): response is AcceptJobActionDefaultResponse; +export function isUnexpected( + response: DeclineJobAction200Response | DeclineJobActionDefaultResponse +): response is DeclineJobActionDefaultResponse; +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 + | ReclassifyJobAction200Response + | ReclassifyJobActionDefaultResponse + | CancelJobAction200Response + | CancelJobActionDefaultResponse + | CompleteJobAction200Response + | CompleteJobActionDefaultResponse + | CloseJobAction200Response + | CloseJobAction202Response + | CloseJobActionDefaultResponse + | ListJobs200Response + | ListJobsDefaultResponse + | GetInQueuePosition200Response + | GetInQueuePositionDefaultResponse + | UnassignJobAction200Response + | UnassignJobActionDefaultResponse + | AcceptJobAction200Response + | AcceptJobActionDefaultResponse + | DeclineJobAction200Response + | DeclineJobActionDefaultResponse + | 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 + | ReclassifyJobActionDefaultResponse + | CancelJobActionDefaultResponse + | CompleteJobActionDefaultResponse + | CloseJobActionDefaultResponse + | ListJobsDefaultResponse + | GetInQueuePositionDefaultResponse + | UnassignJobActionDefaultResponse + | AcceptJobActionDefaultResponse + | DeclineJobActionDefaultResponse + | 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-rest/src/logger.ts b/sdk/communication/communication-job-router-rest/src/logger.ts new file mode 100644 index 000000000000..9c41962553ee --- /dev/null +++ b/sdk/communication/communication-job-router-rest/src/logger.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// 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-rest/src/models.ts b/sdk/communication/communication-job-router-rest/src/models.ts new file mode 100644 index 000000000000..25bad4d1c9df --- /dev/null +++ b/sdk/communication/communication-job-router-rest/src/models.ts @@ -0,0 +1,935 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** 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 selectors to resolve a queue for a given job. */ + queueSelectors?: Array; + /** + * 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. + */ + prioritizationRule?: RouterRule; + /** The worker label selectors to attach to a given job. */ + workerSelectors?: Array; +} + +/** + * An attachment of queue selectors to resolve a queue to a job from a + * classification policy + */ +export interface QueueSelectorAttachmentParent { + kind: string; +} + +/** + * Describes a set of queue selectors that will be attached if the given condition + * resolves to true + */ +export interface ConditionalQueueSelectorAttachment + extends QueueSelectorAttachmentParent { + /** + * 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. + */ + condition: RouterRule; + /** 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 RouterRuleParent { + kind: string; +} + +/** 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: "direct-map-rule"; +} + +/** A rule providing inline expression rules. */ +export interface ExpressionRouterRule extends RouterRuleParent { + /** + * 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-rule"; +} + +/** 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: "azure-function-rule"; +} + +/** 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; +} + +/** + * 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. */ + value?: unknown; + /** The type discriminator describing a sub-type of Rule */ + kind: "static-rule"; +} + +/** 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?: Oauth2ClientCredential; + /** Uri for Contoso's Web Server. */ + webhookUri?: string; + /** The type discriminator describing a sub-type of Rule */ + kind: "webhook-rule"; +} + +/** + * 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; +} + +/** + * 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 + * + * Possible values: equal, notEqual, lessThan, lessThanEqual, greaterThan, greaterThanEqual + */ + labelOperator: string; + /** The value to compare against the actual label value with the given operator */ + value?: unknown; +} + +/** + * 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; + /** + * Describes how the value of the label is compared to the value pass through + * + * Possible values: equal, notEqual, lessThan, lessThanEqual, greaterThan, greaterThanEqual + */ + labelOperator: string; + /** The type discriminator describing the type of queue selector attachment */ + kind: "pass-through"; +} + +/** Attaches queue selectors to a job when the RouterRule is resolved */ +export interface RuleEngineQueueSelectorAttachment + extends QueueSelectorAttachmentParent { + /** + * 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. + */ + rule: RouterRule; + /** The type discriminator describing the type of queue selector attachment */ + kind: "rule-engine"; +} + +/** Describes a queue selector that will be attached to the job */ +export interface StaticQueueSelectorAttachment + extends QueueSelectorAttachmentParent { + /** + * Describes a condition that must be met against a set of labels for queue + * selection + */ + queueSelector: RouterQueueSelector; + /** 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 WeightedAllocationQueueSelectorAttachment + extends QueueSelectorAttachmentParent { + /** A collection of percentage based weighted allocations. */ + allocations: Array; + /** The type discriminator describing the type of queue selector attachment */ + kind: "weighted-allocation-queue-selector"; +} + +/** + * 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; +} + +/** An attachment which attaches worker selectors to a job */ +export interface WorkerSelectorAttachmentParent { + kind: string; +} + +/** + * Describes a set of worker selectors that will be attached if the given + * condition resolves to true + */ +export interface ConditionalWorkerSelectorAttachment + extends WorkerSelectorAttachmentParent { + /** + * 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. + */ + condition: RouterRule; + /** 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 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, lessThanEqual, greaterThan, greaterThanEqual + */ + labelOperator: string; + /** The value to compare against the actual label value with the given operator */ + 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; +} + +/** + * 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; + /** + * Describes how the value of the label is compared to the value pass through + * + * Possible values: equal, notEqual, lessThan, lessThanEqual, greaterThan, greaterThanEqual + */ + 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: "pass-through"; +} + +/** Attaches worker selectors to a job when a RouterRule is resolved */ +export interface RuleEngineWorkerSelectorAttachment + extends WorkerSelectorAttachmentParent { + /** + * 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. + */ + rule: RouterRule; + /** The type discriminator describing the type of worker selector attachment */ + kind: "rule-engine"; +} + +/** Describes a worker selector that will be attached to the job */ +export interface StaticWorkerSelectorAttachment + extends WorkerSelectorAttachmentParent { + /** + * Describes a condition that must be met against a set of labels for worker + * selection + */ + 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: "weighted-allocation-worker-selector"; +} + +/** + * 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 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?: DistributionMode; +} + +/** 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; + /** + * (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; + kind: string; +} + +/** Jobs are distributed to the worker with the strongest abilities available. */ +export interface BestWorkerMode extends DistributionModeParent { + /** + * 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. + */ + scoringRule?: RouterRule; + /** + * Encapsulates all options that can be passed as parameters for scoring rule with + * BestWorkerMode + */ + scoringRuleOptions?: ScoringRuleOptions; + /** The type discriminator describing a sub-type of Mode */ + kind: "best-worker"; +} + +/** + * 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?: string[]; + /** + * (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; +} + +/** 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: "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 DistributionModeParent { + /** The type discriminator describing a sub-type of Mode */ + kind: "round-robin"; +} + +/** A policy that defines actions to execute when exception are triggered. */ +export interface ExceptionPolicy { + /** (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?: Record; +} + +/** A rule that defines actions to execute upon a specific trigger. */ +export interface ExceptionRule { + /** The trigger for this exception rule */ + trigger: ExceptionTrigger; + /** + * A dictionary collection of actions to perform once the exception is triggered. + * Key is the Id of each exception action. + */ + actions: Record; +} + +/** 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: "queue-length"; +} + +/** 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: "wait-time"; +} + +/** The action to take when the exception is triggered */ +export interface ExceptionActionParent { + kind: string; +} + +/** An action that marks a job as cancelled */ +export interface CancelExceptionAction extends ExceptionActionParent { + /** + * (Optional) A note that will be appended to the jobs' Notes collection with the + * current timestamp. + */ + note?: string; + /** + * (Optional) 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 ExceptionActionParent { + /** Updated QueueId. */ + queueId?: string; + /** Updated Priority. */ + priority?: number; + /** Updated WorkerSelectors. */ + workerSelectors?: Array; + /** The type discriminator describing a sub-type of ExceptionAction */ + kind: "manual-reclassify"; +} + +/** An action that modifies labels on a job and then reclassifies it */ +export interface ReclassifyExceptionAction extends ExceptionActionParent { + /** + * (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?: Record; + /** The type discriminator describing a sub-type of ExceptionAction */ + kind: "reclassify"; +} + +/** 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. + */ + labels?: Record; + /** + * (Optional) The ID of the exception policy that determines various job + * escalation rules. + */ + exceptionPolicyId?: string; +} + +/** 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. + */ + labels?: Record; + /** A set of non-identifying attributes attached to this job */ + tags?: Record; + /** Notes attached to a job, sorted by timestamp */ + notes?: Record; + /** + * The matching mode to be applied to this job. + * + * Supported 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. + */ + matchingMode?: JobMatchingMode; +} + +/** 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 | 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; +} + +/** + * The matching mode to be applied to this job. + * + * Supported 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 JobMatchingMode { + /** + * Discriminator value used to differentiate between supported matching mode types. + * + * Possible values: queueAndMatchMode, scheduleAndSuspendMode, suspendMode + */ + modeType?: string; + /** + * Describes a matching mode where matching worker to a job is automatically + * started after job is queued successfully. + */ + queueAndMatchMode?: QueueAndMatchMode; + /** + * 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. + */ + scheduleAndSuspendMode?: ScheduleAndSuspendMode; + /** Describes a matching mode where matching worker to a job is suspended. */ + suspendMode?: SuspendMode; +} + +/** Describes a matching mode where matching worker to a job is automatically started after job is queued successfully. */ +export interface QueueAndMatchMode {} + +/** + * 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 { + /** Scheduled time. */ + scheduleAt: Date | string; +} + +/** Describes a matching mode where matching worker to a job is suspended. */ +export interface SuspendMode {} + +/** 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 | string; + /** + * (Optional) 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 UnassignJobRequest { + /** + * 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 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 | string; +} + +/** An entity for jobs to be routed to */ +export interface RouterWorker { + /** The queue(s) that this worker can receive work from. */ + queueAssignments?: Record; + /** 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?: Record; + /** A set of non-identifying attributes attached to this worker. */ + tags?: Record; + /** The channel(s) this worker can handle and their impact on the workers capacity. */ + channelConfigurations?: Record; + /** A flag indicating this worker is open to receive offers or not. */ + availableForOffers?: boolean; +} + +/** An assignment of a worker to a queue */ +export interface RouterQueueAssignment {} + +/** 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 | 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 + | StaticRouterRule + | WebhookRouterRule; +/** An attachment which attaches worker selectors to a job */ +export type WorkerSelectorAttachment = + | ConditionalWorkerSelectorAttachment + | PassThroughWorkerSelectorAttachment + | RuleEngineWorkerSelectorAttachment + | StaticWorkerSelectorAttachment + | WeightedAllocationWorkerSelectorAttachment; +/** Abstract base class for defining a distribution mode */ +export type DistributionMode = + | BestWorkerMode + | LongestIdleMode + | RoundRobinMode; +/** 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; diff --git a/sdk/communication/communication-job-router-rest/src/outputModels.ts b/sdk/communication/communication-job-router-rest/src/outputModels.ts new file mode 100644 index 000000000000..5fa31bf4bb0b --- /dev/null +++ b/sdk/communication/communication-job-router-rest/src/outputModels.ts @@ -0,0 +1,1040 @@ +// 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 { + /** 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 selectors to resolve a queue for a given job. */ + queueSelectors?: Array; + /** + * 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. + */ + prioritizationRule?: RouterRuleOutput; + /** The worker label selectors to attach to a given job. */ + workerSelectors?: 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 { + /** + * 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. + */ + 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: "direct-map-rule"; +} + +/** 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-rule"; +} + +/** 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: "azure-function-rule"; +} + +/** Credentials used to access Azure function rule */ +export interface FunctionRouterRuleCredentialOutput { + /** (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; +} + +/** + * 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. */ + value?: any; + /** The type discriminator describing a sub-type of Rule */ + kind: "static-rule"; +} + +/** 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?: Oauth2ClientCredentialOutput; + /** Uri for Contoso's Web Server. */ + webhookUri?: string; + /** The type discriminator describing a sub-type of Rule */ + kind: "webhook-rule"; +} + +/** + * OAuth2.0 Credentials used to Contoso's Authorization server. + * Reference: + * https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/ + */ +export interface Oauth2ClientCredentialOutput { + /** 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, lessThanEqual, greaterThan, greaterThanEqual + */ + labelOperator: string; + /** The value to compare against the actual label value with the given operator */ + 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, lessThanEqual, greaterThan, greaterThanEqual + */ + labelOperator: string; + /** The type discriminator describing the type of queue selector attachment */ + kind: "pass-through"; +} + +/** Attaches queue selectors to a job when the RouterRule is resolved */ +export interface RuleEngineQueueSelectorAttachmentOutput + extends QueueSelectorAttachmentOutputParent { + /** + * 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. + */ + rule: RouterRuleOutput; + /** The type discriminator describing the type of queue selector attachment */ + kind: "rule-engine"; +} + +/** Describes a queue selector that will be attached to the job */ +export interface StaticQueueSelectorAttachmentOutput + extends QueueSelectorAttachmentOutputParent { + /** + * Describes a condition that must be met against a set of labels for queue + * selection + */ + 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: "weighted-allocation-queue-selector"; +} + +/** + * 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 { + /** + * 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. + */ + 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, lessThanEqual, greaterThan, greaterThanEqual + */ + labelOperator: string; + /** 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. + * + * 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, lessThanEqual, greaterThan, greaterThanEqual + */ + 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: "pass-through"; +} + +/** Attaches worker selectors to a job when a RouterRule is resolved */ +export interface RuleEngineWorkerSelectorAttachmentOutput + extends WorkerSelectorAttachmentOutputParent { + /** + * 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. + */ + rule: RouterRuleOutput; + /** The type discriminator describing the type of worker selector attachment */ + kind: "rule-engine"; +} + +/** Describes a worker selector that will be attached to the job */ +export interface StaticWorkerSelectorAttachmentOutput + extends WorkerSelectorAttachmentOutputParent { + /** + * Describes a condition that must be met against a set of labels for worker + * selection + */ + 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: "weighted-allocation-worker-selector"; +} + +/** + * 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 {} + +/** Paged instance of ClassificationPolicy */ +export interface ClassificationPolicyItemOutput { + /** A container for the rules that govern how jobs are classified. */ + classificationPolicy: ClassificationPolicyOutput; + /** (Optional) The Concurrency Token. */ + etag: string; +} + +/** Policy governing how jobs are distributed to workers */ +export interface DistributionPolicyOutput { + /** 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; + /** + * (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; + kind: string; +} + +/** Jobs are distributed to the worker with the strongest abilities available. */ +export interface BestWorkerModeOutput extends DistributionModeOutputParent { + /** + * 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. + */ + scoringRule?: RouterRuleOutput; + /** + * Encapsulates all options that can be passed as parameters for scoring rule with + * BestWorkerMode + */ + scoringRuleOptions?: ScoringRuleOptionsOutput; + /** The type discriminator describing a sub-type of Mode */ + kind: "best-worker"; +} + +/** + * Encapsulates all options that can be passed as parameters for scoring rule with + * BestWorkerMode + */ +export interface ScoringRuleOptionsOutput { + /** + * (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?: string[]; + /** + * (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; +} + +/** 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: "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 RoundRobinModeOutput extends DistributionModeOutputParent { + /** The type discriminator describing a sub-type of Mode */ + kind: "round-robin"; +} + +/** Paged instance of DistributionPolicy */ +export interface DistributionPolicyItemOutput { + /** Policy governing how jobs are distributed to workers */ + distributionPolicy: DistributionPolicyOutput; + /** (Optional) The Concurrency Token. */ + etag: string; +} + +/** A policy that defines actions to execute when exception are triggered. */ +export interface ExceptionPolicyOutput { + /** The Id of the exception policy */ + 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?: Record; +} + +/** A rule that defines actions to execute upon a specific trigger. */ +export interface ExceptionRuleOutput { + /** The trigger for this exception rule */ + trigger: ExceptionTriggerOutput; + /** + * A dictionary collection of actions to perform once the exception is triggered. + * Key is the Id of each exception action. + */ + actions: Record; +} + +/** 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: "queue-length"; +} + +/** 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: "wait-time"; +} + +/** The action to take when the exception is triggered */ +export interface ExceptionActionOutputParent { + kind: string; +} + +/** An action that marks a job as cancelled */ +export interface CancelExceptionActionOutput + extends ExceptionActionOutputParent { + /** + * (Optional) A note that will be appended to the jobs' Notes collection with the + * current timestamp. + */ + note?: string; + /** + * (Optional) 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: "manual-reclassify"; +} + +/** An action that modifies labels on a job and then reclassifies it */ +export interface ReclassifyExceptionActionOutput + extends ExceptionActionOutputParent { + /** + * (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?: Record; + /** The type discriminator describing a sub-type of ExceptionAction */ + kind: "reclassify"; +} + +/** Paged instance of ExceptionPolicy */ +export interface ExceptionPolicyItemOutput { + /** A policy that defines actions to execute when exception are triggered. */ + exceptionPolicy: ExceptionPolicyOutput; + /** (Optional) The Concurrency Token. */ + etag: string; +} + +/** A queue that can contain jobs to be routed. */ +export interface RouterQueueOutput { + /** 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. + */ + labels?: Record; + /** + * (Optional) The ID of the exception policy that determines various job + * escalation rules. + */ + exceptionPolicyId?: string; +} + +/** Paged instance of RouterQueue */ +export interface RouterQueueItemOutput { + /** A queue that can contain jobs to be routed. */ + queue: RouterQueueOutput; + /** (Optional) The Concurrency Token. */ + etag: string; +} + +/** A unit of work to be routed */ +export interface RouterJobOutput { + /** 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. + */ + 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 */ + tags?: Record; + /** Notes attached to a job, sorted by timestamp */ + notes?: Record; + /** If set, job will be scheduled to be enqueued at a given time */ + readonly scheduledAt?: string; + /** + * The matching mode to be applied to this job. + * + * Supported 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. + */ + matchingMode?: JobMatchingModeOutput; +} + +/** Assignment details of a job to a worker */ +export interface RouterJobAssignmentOutput { + /** 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: 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; +} + +/** + * The matching mode to be applied to this job. + * + * Supported 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 JobMatchingModeOutput { + /** + * Discriminator value used to differentiate between supported matching mode types. + * + * Possible values: queueAndMatchMode, scheduleAndSuspendMode, suspendMode + */ + modeType?: string; + /** + * Describes a matching mode where matching worker to a job is automatically + * started after job is queued successfully. + */ + queueAndMatchMode?: QueueAndMatchModeOutput; + /** + * 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. + */ + scheduleAndSuspendMode?: ScheduleAndSuspendModeOutput; + /** Describes a matching mode where matching worker to a job is suspended. */ + suspendMode?: SuspendModeOutput; +} + +/** Describes a matching mode where matching worker to a job is automatically started after job is queued successfully. */ +export interface QueueAndMatchModeOutput {} + +/** + * 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 { + /** Scheduled time. */ + scheduleAt: string; +} + +/** Describes a matching mode where matching worker to a job is suspended. */ +export interface SuspendModeOutput {} + +/** Paged instance of RouterJob */ +export interface RouterJobItemOutput { + /** A unit of work to be routed */ + job: RouterJobOutput; + /** (Optional) The Concurrency Token. */ + etag: string; +} + +/** 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; +} + +/** 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 { + /** 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. */ + queueAssignments?: Record; + /** 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?: Record; + /** A set of non-identifying attributes attached to this worker. */ + tags?: Record; + /** The channel(s) this worker can handle and their impact on the workers capacity. */ + channelConfigurations?: Record; + /** 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; +} + +/** An assignment of a worker to a queue */ +export interface RouterQueueAssignmentOutput {} + +/** Represents the capacity a job in this channel will consume from a worker */ +export interface ChannelConfigurationOutput { + /** + * 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. */ + 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; +} + +/** Paged instance of RouterWorker */ +export interface RouterWorkerItemOutput { + /** An entity for jobs to be routed to */ + worker: RouterWorkerOutput; + /** (Optional) The Concurrency Token. */ + etag: 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 paged collection of classification policies. */ +export type PagedClassificationPolicyItemOutput = + Paged; +/** A paged collection of distribution policies. */ +export type PagedDistributionPolicyItemOutput = + Paged; +/** A paged collection of exception policies. */ +export type PagedExceptionPolicyItemOutput = Paged; +/** A paged collection of queues. */ +export type PagedRouterQueueItemOutput = Paged; +/** A paged collection of jobs. */ +export type PagedRouterJobItemOutput = Paged; +/** A paged collection of workers. */ +export type PagedRouterWorkerItemOutput = Paged; diff --git a/sdk/communication/communication-job-router-rest/src/paginateHelper.ts b/sdk/communication/communication-job-router-rest/src/paginateHelper.ts new file mode 100644 index 000000000000..1c9af35b1efd --- /dev/null +++ b/sdk/communication/communication-job-router-rest/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-rest/src/parameters.ts b/sdk/communication/communication-job-router-rest/src/parameters.ts new file mode 100644 index 000000000000..8ec63aa1c569 --- /dev/null +++ b/sdk/communication/communication-job-router-rest/src/parameters.ts @@ -0,0 +1,367 @@ +// 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, + CancelJobRequest, + CompleteJobRequest, + CloseJobRequest, + UnassignJobRequest, + DeclineJobOfferRequest, + 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 ReclassifyJobActionBodyParam { + /** Request object for reclassifying a job. */ + body?: Record; +} + +export type ReclassifyJobActionParameters = ReclassifyJobActionBodyParam & + RequestParameters; + +export interface CancelJobActionBodyParam { + /** Request model for cancelling job. */ + body?: CancelJobRequest; +} + +export type CancelJobActionParameters = CancelJobActionBodyParam & + RequestParameters; + +export interface CompleteJobActionBodyParam { + /** Request model for completing job. */ + body: CompleteJobRequest; +} + +export type CompleteJobActionParameters = CompleteJobActionBodyParam & + RequestParameters; + +export interface CloseJobActionBodyParam { + /** Request model for closing job. */ + body: CloseJobRequest; +} + +export type CloseJobActionParameters = CloseJobActionBodyParam & + 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 UnassignJobActionBodyParam { + /** Request body for unassign route. */ + body?: UnassignJobRequest; +} + +export type UnassignJobActionParameters = UnassignJobActionBodyParam & + RequestParameters; +export type AcceptJobActionParameters = RequestParameters; + +export interface DeclineJobActionBodyParam { + /** Request model for declining offer. */ + body?: DeclineJobOfferRequest; +} + +export type DeclineJobActionParameters = DeclineJobActionBodyParam & + 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-rest/src/responses.ts b/sdk/communication/communication-job-router-rest/src/responses.ts new file mode 100644 index 000000000000..23a55d1a1855 --- /dev/null +++ b/sdk/communication/communication-job-router-rest/src/responses.ts @@ -0,0 +1,761 @@ +// 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 { + ClassificationPolicyOutput, + PagedClassificationPolicyItemOutput, + DistributionPolicyOutput, + PagedDistributionPolicyItemOutput, + ExceptionPolicyOutput, + PagedExceptionPolicyItemOutput, + RouterQueueOutput, + PagedRouterQueueItemOutput, + RouterJobOutput, + PagedRouterJobItemOutput, + RouterJobPositionDetailsOutput, + UnassignJobResultOutput, + AcceptJobOfferResultOutput, + RouterQueueStatisticsOutput, + RouterWorkerOutput, + PagedRouterWorkerItemOutput, +} from "./outputModels"; + +export interface UpsertClassificationPolicy200Headers { + /** The entity tag for the response. */ + etag?: string; + /** The last modified timestamp. */ + "last-modified"?: string; +} + +/** The request has succeeded. */ +export interface UpsertClassificationPolicy200Response extends HttpResponse { + status: "200"; + body: ClassificationPolicyOutput; + headers: RawHttpHeaders & UpsertClassificationPolicy200Headers; +} + +export interface UpsertClassificationPolicy201Headers { + /** 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 UpsertClassificationPolicy201Response extends HttpResponse { + status: "201"; + body: ClassificationPolicyOutput; + headers: RawHttpHeaders & UpsertClassificationPolicy201Headers; +} + +export interface UpsertClassificationPolicyDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface UpsertClassificationPolicyDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & UpsertClassificationPolicyDefaultHeaders; +} + +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: PagedClassificationPolicyItemOutput; +} + +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: PagedDistributionPolicyItemOutput; +} + +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: PagedExceptionPolicyItemOutput; +} + +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: PagedRouterQueueItemOutput; +} + +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 ReclassifyJobAction200Response extends HttpResponse { + status: "200"; +} + +export interface ReclassifyJobActionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ReclassifyJobActionDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ReclassifyJobActionDefaultHeaders; +} + +/** The request has succeeded. */ +export interface CancelJobAction200Response extends HttpResponse { + status: "200"; +} + +export interface CancelJobActionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface CancelJobActionDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & CancelJobActionDefaultHeaders; +} + +/** The request has succeeded. */ +export interface CompleteJobAction200Response extends HttpResponse { + status: "200"; +} + +export interface CompleteJobActionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface CompleteJobActionDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & CompleteJobActionDefaultHeaders; +} + +/** The request has succeeded. */ +export interface CloseJobAction200Response extends HttpResponse { + status: "200"; +} + +/** The request has been accepted for processing, but processing has not yet completed. */ +export interface CloseJobAction202Response extends HttpResponse { + status: "202"; +} + +export interface CloseJobActionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface CloseJobActionDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & CloseJobActionDefaultHeaders; +} + +/** The request has succeeded. */ +export interface ListJobs200Response extends HttpResponse { + status: "200"; + body: PagedRouterJobItemOutput; +} + +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; +} + +/** 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; +} + +/** The request has succeeded. */ +export interface UnassignJobAction200Response extends HttpResponse { + status: "200"; + body: UnassignJobResultOutput; +} + +export interface UnassignJobActionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface UnassignJobActionDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & UnassignJobActionDefaultHeaders; +} + +/** The request has succeeded. */ +export interface AcceptJobAction200Response extends HttpResponse { + status: "200"; + body: AcceptJobOfferResultOutput; +} + +export interface AcceptJobActionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface AcceptJobActionDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & AcceptJobActionDefaultHeaders; +} + +/** The request has succeeded. */ +export interface DeclineJobAction200Response extends HttpResponse { + status: "200"; +} + +export interface DeclineJobActionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DeclineJobActionDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DeclineJobActionDefaultHeaders; +} + +/** 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: PagedRouterWorkerItemOutput; +} + +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-rest/test/public/sampleTest.spec.ts b/sdk/communication/communication-job-router-rest/test/public/sampleTest.spec.ts new file mode 100644 index 000000000000..bce68e428645 --- /dev/null +++ b/sdk/communication/communication-job-router-rest/test/public/sampleTest.spec.ts @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { Recorder } from "@azure-tools/test-recorder"; +import { assert } from "chai"; +import { createRecorder } from "./utils/recordedClient"; +import { Context } from "mocha"; + +describe("My test", () => { + let recorder: Recorder; + + beforeEach(async function (this: Context) { + recorder = await createRecorder(this); + }); + + afterEach(async function () { + await recorder.stop(); + }); + + it("sample test", async function () { + assert.equal(1, 1); + }); +}); diff --git a/sdk/communication/communication-job-router-rest/test/public/utils/env.browser.ts b/sdk/communication/communication-job-router-rest/test/public/utils/env.browser.ts new file mode 100644 index 000000000000..fd2aca680c7b --- /dev/null +++ b/sdk/communication/communication-job-router-rest/test/public/utils/env.browser.ts @@ -0,0 +1,2 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. diff --git a/sdk/communication/communication-job-router-rest/test/public/utils/env.ts b/sdk/communication/communication-job-router-rest/test/public/utils/env.ts new file mode 100644 index 000000000000..0e06855b73ae --- /dev/null +++ b/sdk/communication/communication-job-router-rest/test/public/utils/env.ts @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import * as dotenv from "dotenv"; + +dotenv.config(); diff --git a/sdk/communication/communication-job-router-rest/test/public/utils/recordedClient.ts b/sdk/communication/communication-job-router-rest/test/public/utils/recordedClient.ts new file mode 100644 index 000000000000..6cc58bc15e11 --- /dev/null +++ b/sdk/communication/communication-job-router-rest/test/public/utils/recordedClient.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { Context } from "mocha"; +import { Recorder, RecorderStartOptions } from "@azure-tools/test-recorder"; +import "./env"; + +const envSetupForPlayback: Record = { + ENDPOINT: "https://endpoint", + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id", +}; + +const recorderEnvSetup: RecorderStartOptions = { + envSetupForPlayback, +}; + +/** + * creates the recorder and reads the environment variables from the `.env` file. + * Should be called first in the test suite to make sure environment variables are + * read before they are being used. + */ +export async function createRecorder(context: Context): Promise { + const recorder = new Recorder(context.currentTest); + await recorder.start(recorderEnvSetup); + return recorder; +} diff --git a/sdk/communication/communication-job-router-rest/tsconfig.json b/sdk/communication/communication-job-router-rest/tsconfig.json new file mode 100644 index 000000000000..064a66156b54 --- /dev/null +++ b/sdk/communication/communication-job-router-rest/tsconfig.json @@ -0,0 +1,5 @@ +{ + "extends": "../../../tsconfig.package", + "compilerOptions": { "outDir": "./dist-esm", "declarationDir": "./types" }, + "include": ["src/**/*.ts", "./test/**/*.ts"] +}