From 8b3eb9500d54f7c535368cd44ebfd8726cfd8adc Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 18 Nov 2024 21:57:26 +0000 Subject: [PATCH] CodeGen from PR 31593 in Azure/azure-rest-api-specs Merge 4c48183528b82ef007cbaa6420d7381773b57c23 into 4ae412cf228fb0320ced6fd6020435296752bf68 --- common/config/rush/pnpm-lock.yaml | 107 ++- rush.json | 9 +- .../azure-apicenter-rest/CHANGELOG.md | 7 + sdk/apicenter/azure-apicenter-rest/LICENSE | 21 + sdk/apicenter/azure-apicenter-rest/README.md | 57 ++ .../azure-apicenter-rest/api-extractor.json | 31 + .../azure-apicenter-rest/eslint.config.mjs | 17 + .../azure-apicenter-rest/package.json | 131 +++ .../review/azure-apicenter-rest.api.md | 906 ++++++++++++++++++ sdk/apicenter/azure-apicenter-rest/sample.env | 1 + .../src/clientDefinitions.ts | 264 +++++ .../azure-apicenter-rest/src/dataApiClient.ts | 71 ++ .../azure-apicenter-rest/src/index.ts | 15 + .../azure-apicenter-rest/src/isUnexpected.ts | 248 +++++ .../azure-apicenter-rest/src/logger.ts | 5 + .../azure-apicenter-rest/src/outputModels.ts | 269 ++++++ .../src/paginateHelper.ts | 297 ++++++ .../azure-apicenter-rest/src/parameters.ts | 122 +++ .../azure-apicenter-rest/src/pollingHelper.ts | 221 +++++ .../azure-apicenter-rest/src/responses.ts | 316 ++++++ .../test/public/sampleTest.spec.ts | 21 + .../test/public/utils/recordedClient.ts | 29 + .../tsconfig.browser.config.json | 10 + .../azure-apicenter-rest/tsconfig.json | 16 + .../azure-apicenter-rest/tsp-location.yaml | 4 + .../vitest.browser.config.ts | 38 + .../azure-apicenter-rest/vitest.config.ts | 34 + sdk/apicenter/ci.yml | 39 + 28 files changed, 3265 insertions(+), 41 deletions(-) create mode 100644 sdk/apicenter/azure-apicenter-rest/CHANGELOG.md create mode 100644 sdk/apicenter/azure-apicenter-rest/LICENSE create mode 100644 sdk/apicenter/azure-apicenter-rest/README.md create mode 100644 sdk/apicenter/azure-apicenter-rest/api-extractor.json create mode 100644 sdk/apicenter/azure-apicenter-rest/eslint.config.mjs create mode 100644 sdk/apicenter/azure-apicenter-rest/package.json create mode 100644 sdk/apicenter/azure-apicenter-rest/review/azure-apicenter-rest.api.md create mode 100644 sdk/apicenter/azure-apicenter-rest/sample.env create mode 100644 sdk/apicenter/azure-apicenter-rest/src/clientDefinitions.ts create mode 100644 sdk/apicenter/azure-apicenter-rest/src/dataApiClient.ts create mode 100644 sdk/apicenter/azure-apicenter-rest/src/index.ts create mode 100644 sdk/apicenter/azure-apicenter-rest/src/isUnexpected.ts create mode 100644 sdk/apicenter/azure-apicenter-rest/src/logger.ts create mode 100644 sdk/apicenter/azure-apicenter-rest/src/outputModels.ts create mode 100644 sdk/apicenter/azure-apicenter-rest/src/paginateHelper.ts create mode 100644 sdk/apicenter/azure-apicenter-rest/src/parameters.ts create mode 100644 sdk/apicenter/azure-apicenter-rest/src/pollingHelper.ts create mode 100644 sdk/apicenter/azure-apicenter-rest/src/responses.ts create mode 100644 sdk/apicenter/azure-apicenter-rest/test/public/sampleTest.spec.ts create mode 100644 sdk/apicenter/azure-apicenter-rest/test/public/utils/recordedClient.ts create mode 100644 sdk/apicenter/azure-apicenter-rest/tsconfig.browser.config.json create mode 100644 sdk/apicenter/azure-apicenter-rest/tsconfig.json create mode 100644 sdk/apicenter/azure-apicenter-rest/tsp-location.yaml create mode 100644 sdk/apicenter/azure-apicenter-rest/vitest.browser.config.ts create mode 100644 sdk/apicenter/azure-apicenter-rest/vitest.config.ts create mode 100644 sdk/apicenter/ci.yml diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 83d3be1d5dda..99e66d2dcda2 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -806,6 +806,9 @@ dependencies: '@rush-temp/attestation': specifier: file:./projects/attestation.tgz version: file:projects/attestation.tgz + '@rush-temp/azure-apicenter-rest': + specifier: file:./projects/azure-apicenter-rest.tgz + version: file:projects/azure-apicenter-rest.tgz '@rush-temp/batch': specifier: file:./projects/batch.tgz version: file:projects/batch.tgz @@ -1970,12 +1973,6 @@ packages: '@babel/helper-validator-identifier': 7.25.9 dev: false - /@bundled-es-modules/cookie@2.0.0: - resolution: {integrity: sha512-Or6YHg/kamKHpxULAdSqhGqnWFneIXu1NKvvfBBzKGwpVsYuFIQ5aBPHDnnoR3ghW1nvSkALd+EF9iMtY7Vjxw==} - dependencies: - cookie: 0.5.0 - dev: false - /@bundled-es-modules/cookie@2.0.1: resolution: {integrity: sha512-8o+5fRPLNbjbdGRRmJj3h6Hh1AQJf2dk3qQ/5ZFb+PXkRNiSoMGGUKlsgLfrxneb72axVJyIYji64E2+nNfYyw==} dependencies: @@ -3822,13 +3819,13 @@ packages: resolution: {integrity: sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==} dependencies: '@types/connect': 3.4.38 - '@types/node': 18.19.64 + '@types/node': 20.17.6 dev: false /@types/bunyan@1.8.9: resolution: {integrity: sha512-ZqS9JGpBxVOvsawzmVt30sP++gSQMTejCkIAQ3VdadOcRE8izTyW66hufvwLeH+YEGP6Js2AW7Gz+RMyvrEbmw==} dependencies: - '@types/node': 18.19.64 + '@types/node': 20.17.6 dev: false /@types/chai-as-promised@7.1.8: @@ -3856,7 +3853,7 @@ packages: /@types/connect@3.4.38: resolution: {integrity: sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==} dependencies: - '@types/node': 18.19.64 + '@types/node': 20.17.6 dev: false /@types/cookie@0.4.1: @@ -3870,7 +3867,7 @@ packages: /@types/cors@2.8.17: resolution: {integrity: sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==} dependencies: - '@types/node': 18.19.64 + '@types/node': 20.17.6 dev: false /@types/debug@4.1.12: @@ -3959,7 +3956,7 @@ packages: /@types/jsonfile@6.1.4: resolution: {integrity: sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==} dependencies: - '@types/node': 18.19.64 + '@types/node': 20.17.6 dev: false /@types/jsonwebtoken@9.0.7: @@ -4018,13 +4015,13 @@ packages: /@types/mysql@2.15.26: resolution: {integrity: sha512-DSLCOXhkvfS5WNNPbfn2KdICAmk8lLc+/PNvnPnF7gOdMZCxopXduqv0OQ13y/yA/zXTSikZZqVgybUxOEg6YQ==} dependencies: - '@types/node': 18.19.64 + '@types/node': 20.17.6 dev: false /@types/node-fetch@2.6.11: resolution: {integrity: sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g==} dependencies: - '@types/node': 18.19.64 + '@types/node': 20.17.6 form-data: 4.0.1 dev: false @@ -4063,7 +4060,7 @@ packages: /@types/pg@8.6.1: resolution: {integrity: sha512-1Kc4oAGzAl7uqUStZCDvaLFqZrW9qWSjXOmBfdgyBP5La7Us6Mg4GBvRlSoaZMhQF/zSj1C8CtKMBkoiT8eL8w==} dependencies: - '@types/node': 18.19.64 + '@types/node': 20.17.6 pg-protocol: 1.7.0 pg-types: 2.2.0 dev: false @@ -4090,7 +4087,7 @@ packages: /@types/readdir-glob@1.1.5: resolution: {integrity: sha512-raiuEPUYqXu+nvtY2Pe8s8FEmZ3x5yAH4VkLdihcPdalvsHltomrRC9BzuStrJ9yk06470hS0Crw0f1pXqD+Hg==} dependencies: - '@types/node': 18.19.64 + '@types/node': 20.17.6 dev: false /@types/resolve@1.20.2: @@ -4109,14 +4106,14 @@ packages: resolution: {integrity: sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==} dependencies: '@types/mime': 1.3.5 - '@types/node': 18.19.64 + '@types/node': 20.17.6 dev: false /@types/serve-static@1.15.7: resolution: {integrity: sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==} dependencies: '@types/http-errors': 2.0.4 - '@types/node': 18.19.64 + '@types/node': 20.17.6 '@types/send': 0.17.4 dev: false @@ -4147,7 +4144,7 @@ packages: /@types/through@0.0.33: resolution: {integrity: sha512-HsJ+z3QuETzP3cswwtzt2vEIiHBk/dCcHGhbmG5X3ecnwFD/lPrMpliGXxSCg03L9AhrdwA4Oz/qfspkDW+xGQ==} dependencies: - '@types/node': 18.19.64 + '@types/node': 20.17.6 dev: false /@types/tough-cookie@4.0.5: @@ -4200,7 +4197,7 @@ packages: resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==} requiresBuild: true dependencies: - '@types/node': 18.19.64 + '@types/node': 20.17.6 dev: false optional: true @@ -5670,11 +5667,6 @@ packages: resolution: {integrity: sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==} dev: false - /cookie@0.5.0: - resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==} - engines: {node: '>= 0.6'} - dev: false - /cookie@0.7.1: resolution: {integrity: sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==} engines: {node: '>= 0.6'} @@ -6132,7 +6124,7 @@ packages: dependencies: '@types/cookie': 0.4.1 '@types/cors': 2.8.17 - '@types/node': 18.19.64 + '@types/node': 20.17.6 accepts: 1.3.8 base64id: 2.0.0 cookie: 0.7.2 @@ -8702,7 +8694,7 @@ packages: typescript: optional: true dependencies: - '@bundled-es-modules/cookie': 2.0.0 + '@bundled-es-modules/cookie': 2.0.1 '@bundled-es-modules/statuses': 1.0.1 '@bundled-es-modules/tough-cookie': 0.1.6 '@inquirer/confirm': 5.0.1(@types/node@18.19.64) @@ -12348,7 +12340,7 @@ packages: dev: false file:projects/ai-language-text.tgz: - resolution: {integrity: sha512-PqM9ui81lmdhXEtP8GIAjLVcVvlupuMDmN23SvaEKLDAwj7x83KNuxMXUC03nuAu7GGw7f6duJQPj59nEyUXig==, tarball: file:projects/ai-language-text.tgz} + resolution: {integrity: sha512-6C3jjNxEgVBUU20JjosTiobhkOlbsaBeUq+OJ0mXgqnm/Y3L5EhJz6zvG8MgM9Mj2yQPfX9VWCy4+Pn9Nkhslw==, tarball: file:projects/ai-language-text.tgz} name: '@rush-temp/ai-language-text' version: 0.0.0 dependencies: @@ -12506,7 +12498,7 @@ packages: dev: false file:projects/ai-translation-document.tgz: - resolution: {integrity: sha512-tczwZFFKsT8A5tYnAH8FLQ1cpw9B0tFIiAVb5wPaI40o9Rx3gBKBxZ7mGU9lPdXwAy03uyqtXOAwr1JzaNTj4A==, tarball: file:projects/ai-translation-document.tgz} + resolution: {integrity: sha512-Ab59rauKcO/H7u7fQJ0DmNlyMycKybpGa1Wsaw9GNLpNJxh+ibmPDS44TaOAcFwxOLIadyxaj7vsrmXXkM5Ocg==, tarball: file:projects/ai-translation-document.tgz} name: '@rush-temp/ai-translation-document' version: 0.0.0 dependencies: @@ -12710,7 +12702,7 @@ packages: dev: false file:projects/api-management-custom-widgets-tools.tgz: - resolution: {integrity: sha512-+ezPIFcLbT94W1qUmvCf/8ZmRXgcIp4ZPWPvZChsGG05CeBCDrZecSEeO58F3vnVQDhYQAwOUwmqhgYJanVg0g==, tarball: file:projects/api-management-custom-widgets-tools.tgz} + resolution: {integrity: sha512-dMAIacqzLU3uGgVdn+A8r+/Vv7vC4Emr0Z0T3lCVhq7JoQmL3I7yyUueYdP6tPVYSGzko9MdRYXA11RvB9GHPA==, tarball: file:projects/api-management-custom-widgets-tools.tgz} name: '@rush-temp/api-management-custom-widgets-tools' version: 0.0.0 dependencies: @@ -18839,6 +18831,43 @@ packages: - webdriverio dev: false + file:projects/azure-apicenter-rest.tgz: + resolution: {integrity: sha512-7hr3o5WJwiis38t7OQMjDwMpqJ4RybTg0Sbebag+VUiOqliz8e9UF6u6ylU3vd8Klra/1NAgngz9vzCtapNmNA==, tarball: file:projects/azure-apicenter-rest.tgz} + name: '@rush-temp/azure-apicenter-rest' + version: 0.0.0 + dependencies: + '@microsoft/api-extractor': 7.47.11(@types/node@18.19.64) + '@types/node': 18.19.64 + '@vitest/browser': 2.1.5(@types/node@18.19.64)(playwright@1.48.2)(typescript@5.6.3)(vitest@2.1.5) + '@vitest/coverage-istanbul': 2.1.5(vitest@2.1.5) + dotenv: 16.4.5 + eslint: 8.57.1 + playwright: 1.48.2 + tshy: 2.0.1 + tslib: 2.8.1 + typescript: 5.6.3 + vitest: 2.1.5(@types/node@18.19.64)(@vitest/browser@2.1.5) + transitivePeerDependencies: + - '@edge-runtime/vm' + - '@vitest/ui' + - bufferutil + - happy-dom + - jsdom + - less + - lightningcss + - msw + - safaridriver + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + - utf-8-validate + - vite + - webdriverio + dev: false + file:projects/batch.tgz: resolution: {integrity: sha512-5aWGICBLDXaS8dyz90IUuG+KysKDtOr7RkVjdYzfxCimiWRMgPYdRmvP+k7Dkm5xkp16VRTIG8kTnJFVUBSMHw==, tarball: file:projects/batch.tgz} name: '@rush-temp/batch' @@ -20800,7 +20829,7 @@ packages: dev: false file:projects/eventhubs-checkpointstore-blob.tgz(chai@4.3.10): - resolution: {integrity: sha512-d0r9Tcp+PR88ElbvXVtloMca/5o3x7baoqzfzU6erNYp3+qDb28vnauB7wgtSr/JCNFXUUEwCRdCDkqnj2SjIg==, tarball: file:projects/eventhubs-checkpointstore-blob.tgz} + resolution: {integrity: sha512-QIMCv2kTVX8O/o5j/9cm9cj3M1Yu68nIK2z4ubzIx+w0ZJ4Sby3hc2F+UFe5oj59UyA29uZLX6sfITm7+SuKgQ==, tarball: file:projects/eventhubs-checkpointstore-blob.tgz} id: file:projects/eventhubs-checkpointstore-blob.tgz name: '@rush-temp/eventhubs-checkpointstore-blob' version: 0.0.0 @@ -21833,7 +21862,7 @@ packages: dev: false file:projects/microsoft-playwright-testing.tgz: - resolution: {integrity: sha512-5ZtQtASg+gjAwV0BZ3pqTl2taVn2mW46wnhVjYnUhjn08xDzhaRqPvupmTT6S4Nfc1TcP+J/dQWhqEqwD22HGw==, tarball: file:projects/microsoft-playwright-testing.tgz} + resolution: {integrity: sha512-LOfcpsGhkCQlf/ONHLHqjTVgWCasb0ImH6OcRwRpzkO4ybQbiAi4eQvnD2CVwpoa3crRHI9hebbLeSvBsBKAVA==, tarball: file:projects/microsoft-playwright-testing.tgz} name: '@rush-temp/microsoft-playwright-testing' version: 0.0.0 dependencies: @@ -22661,7 +22690,7 @@ packages: dev: false file:projects/perf-storage-blob.tgz: - resolution: {integrity: sha512-bP40paE6XWSxK1NI6IqTFa3TnZ/KV+oOwXvHOlWlnpDa6vHxzuVaSLO22jn2HKpusBkvMhL2znxbrnglHkXp7Q==, tarball: file:projects/perf-storage-blob.tgz} + resolution: {integrity: sha512-gC/6yI3RAsLz8yW4HuwmY/hZJdfQ4WpTasQrnaGM2o0ADvshX7BbTMziACBVC1IJ+SZS0f25nzWdMrf1cKEPUA==, tarball: file:projects/perf-storage-blob.tgz} name: '@rush-temp/perf-storage-blob' version: 0.0.0 dependencies: @@ -22680,7 +22709,7 @@ packages: dev: false file:projects/perf-storage-file-datalake.tgz: - resolution: {integrity: sha512-lOYRq0haEkX/2PuDMltoOo+lVVv6qQ6vg9V9bTtsf49Dw0Cl+6GBEzEdY5zzfK/QJj8GqH0BDKJe9SH0dFtnuw==, tarball: file:projects/perf-storage-file-datalake.tgz} + resolution: {integrity: sha512-/Ci5NG7Th6jCRFjxNQnQIN066A0l8K8hkuTPVCvaChixw0hduEm6MN1HeVT+Qmwkko8uVFlLNu1s7HgLwy8rLw==, tarball: file:projects/perf-storage-file-datalake.tgz} name: '@rush-temp/perf-storage-file-datalake' version: 0.0.0 dependencies: @@ -22699,7 +22728,7 @@ packages: dev: false file:projects/perf-storage-file-share.tgz: - resolution: {integrity: sha512-2xwPxzCMbVfYgHjYiUFtyHhpNoU3rDDiz8voS+JIJni80uABgbEZbbTqb/sGDiMkix0lky1xHLBgplcoq50p8g==, tarball: file:projects/perf-storage-file-share.tgz} + resolution: {integrity: sha512-PA4GNlP5egvK17bRRWDzOrPQgQ87ZxFP+UzUQxy/Wa1NwuHJdBlcsa8P3do4HTkD0UpSzTyeNQ5P7X2etFM+8A==, tarball: file:projects/perf-storage-file-share.tgz} name: '@rush-temp/perf-storage-file-share' version: 0.0.0 dependencies: @@ -22983,7 +23012,7 @@ packages: dev: false file:projects/quantum-jobs.tgz: - resolution: {integrity: sha512-LcPcq+CQlLRl1qN04ARwMlUE2OQi7Bef8aO8uqXIxhejiYFVDLUvtES/oJPoqRTAcYiNs0+6dW7DV/tlyyncdQ==, tarball: file:projects/quantum-jobs.tgz} + resolution: {integrity: sha512-7t0BJaiAPuiDKNgRvOYijVm/Nd8OdjCrk2UhxSYDCVAaJkxRcbNExsrj1RLHv7LrmDbg3AcKymMM+dP9KPBAeA==, tarball: file:projects/quantum-jobs.tgz} name: '@rush-temp/quantum-jobs' version: 0.0.0 dependencies: @@ -23251,7 +23280,7 @@ packages: dev: false file:projects/storage-blob-changefeed.tgz: - resolution: {integrity: sha512-g3z0U7sH8A+7aPtYY/h7NmhPoYx4N12mE1GyVw0EENN4iO6jFRVFh4r8y1qcfPXCUewloCiPfF2DxwZR8KmyXg==, tarball: file:projects/storage-blob-changefeed.tgz} + resolution: {integrity: sha512-ulb7cStYuBYLz5klWzekE1UG2EGSPjv5VqYpaBmA73FZHcjYXumEFAsnGOdUxJFL2/mJAUHJ2nutM3jWLwoH/g==, tarball: file:projects/storage-blob-changefeed.tgz} name: '@rush-temp/storage-blob-changefeed' version: 0.0.0 dependencies: @@ -23343,7 +23372,7 @@ packages: dev: false file:projects/storage-file-datalake.tgz: - resolution: {integrity: sha512-0S+88/SFOzE4eUYtKCMMikxfTh8NzfL5hEGTleZyl+URlPSpUBt/SJE35R9OlVOI+ihfc9RE66XdsYktjy5SBQ==, tarball: file:projects/storage-file-datalake.tgz} + resolution: {integrity: sha512-FVV+PJzMPt7z/pAYIE+3/XbfTv9nR1icrxKEnPtNjNiu1SIFzxoqsSfyzWEhM3OaDxw7cGkn5CVEb1dGo0yoRA==, tarball: file:projects/storage-file-datalake.tgz} name: '@rush-temp/storage-file-datalake' version: 0.0.0 dependencies: @@ -23390,7 +23419,7 @@ packages: dev: false file:projects/storage-file-share.tgz: - resolution: {integrity: sha512-YwK1nFzjoDaHcHuGiKSexyTzZmiRARdZ6VeWkvXMmmOckWkIzYfcUkwEnIhU60ban96FVT/6BrczNFgvHMOCUg==, tarball: file:projects/storage-file-share.tgz} + resolution: {integrity: sha512-UIGe6OIq8WYfDcVyTGSBN+NoU0a62Gp8CPRLfLLdhyewy7MtMfQeQeqsJA0UheHGE7KiVMdEJ1Y7CqVnVBT4+A==, tarball: file:projects/storage-file-share.tgz} name: '@rush-temp/storage-file-share' version: 0.0.0 dependencies: @@ -23476,7 +23505,7 @@ packages: dev: false file:projects/storage-queue.tgz: - resolution: {integrity: sha512-7PfyEm0o178jiAjKrXJJ/BGBF09A1GzA3dTgPIPNQ6Y4XJitrpDIm4jliYFQYvoiJgBDG2zvzjNP2Z4HCa2sCw==, tarball: file:projects/storage-queue.tgz} + resolution: {integrity: sha512-5eSIt9TpDfdl5IHCDEjtBqAe+1Ipe/bEju6w4pdLRo7/j/dcOrewCOj+c96FLKsU334aj4qhvZ0/5TQqyxizpw==, tarball: file:projects/storage-queue.tgz} name: '@rush-temp/storage-queue' version: 0.0.0 dependencies: diff --git a/rush.json b/rush.json index b6f3ab160e70..77bc82c97aa4 100644 --- a/rush.json +++ b/rush.json @@ -1,7 +1,7 @@ /** * This is the main configuration file for Rush. * For full documentation, please see https://rushjs.io - */ { + */{ "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush.schema.json", /** * (Required) This specifies the version of the Rush engine to be used in this repo. @@ -2306,6 +2306,11 @@ "packageName": "@azure/arm-containerorchestratorruntime", "projectFolder": "sdk/kubernetesruntime/arm-containerorchestratorruntime", "versionPolicyName": "management" + }, + { + "packageName": "@azure-rest/azure-apicenter-rest", + "projectFolder": "sdk/apicenter/azure-apicenter-rest", + "versionPolicyName": "client" } ] -} +} \ No newline at end of file diff --git a/sdk/apicenter/azure-apicenter-rest/CHANGELOG.md b/sdk/apicenter/azure-apicenter-rest/CHANGELOG.md new file mode 100644 index 000000000000..a19c69455d10 --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 1.0.0-beta.1 (2024-11-18) + +### Features Added + +The package of @azure-rest/azure-apicenter-rest is using our next generation design principles. To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/js/mgmt/quickstart). diff --git a/sdk/apicenter/azure-apicenter-rest/LICENSE b/sdk/apicenter/azure-apicenter-rest/LICENSE new file mode 100644 index 000000000000..7d5934740965 --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2024 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/apicenter/azure-apicenter-rest/README.md b/sdk/apicenter/azure-apicenter-rest/README.md new file mode 100644 index 000000000000..0fae99daca3c --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/README.md @@ -0,0 +1,57 @@ +# Azure DataApi REST client library for JavaScript + +Data API introduces endpoints to manage your API Center resources. + +**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: + +- [Package (NPM)](https://www.npmjs.com/package/@azure-rest/azure-apicenter-rest) +- [API reference documentation](https://docs.microsoft.com/javascript/api/@azure-rest/azure-apicenter-rest?view=azure-node-preview) + +## 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/azure-apicenter-rest` package + +Install the Azure DataApi REST client REST client library for JavaScript with `npm`: + +```bash +npm install @azure-rest/azure-apicenter-rest +``` + +### Create and authenticate a `DataApiClient` + +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/apicenter/azure-apicenter-rest/api-extractor.json b/sdk/apicenter/azure-apicenter-rest/api-extractor.json new file mode 100644 index 000000000000..953c2cc3555e --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/api-extractor.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "mainEntryPointFilePath": "./dist/esm/index.d.ts", + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "./types/azure-apicenter-rest.d.ts" + }, + "messages": { + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, + "extractorMessageReporting": { + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } + } + } +} \ No newline at end of file diff --git a/sdk/apicenter/azure-apicenter-rest/eslint.config.mjs b/sdk/apicenter/azure-apicenter-rest/eslint.config.mjs new file mode 100644 index 000000000000..113bdc3eaf5f --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/eslint.config.mjs @@ -0,0 +1,17 @@ +import azsdkEslint from "@azure/eslint-plugin-azure-sdk"; + +export default [ + ...azsdkEslint.configs.recommended, + { + 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", + "@azure/azure-sdk/ts-package-json-module": "off", + "@azure/azure-sdk/ts-package-json-files-required": "off", + "@azure/azure-sdk/ts-package-json-main-is-cjs": "off", + "tsdoc/syntax": "warn" + } + } +]; diff --git a/sdk/apicenter/azure-apicenter-rest/package.json b/sdk/apicenter/azure-apicenter-rest/package.json new file mode 100644 index 000000000000..dab8d1699d75 --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/package.json @@ -0,0 +1,131 @@ +{ + "name": "@azure-rest/azure-apicenter-rest", + "version": "1.0.0-beta.1", + "description": "azure.ApiCenter Service", + "engines": { + "node": ">=18.0.0" + }, + "sideEffects": false, + "autoPublish": false, + "tshy": { + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts" + }, + "dialects": [ + "esm", + "commonjs" + ], + "esmDialects": [ + "browser", + "react-native" + ], + "selfLink": false + }, + "type": "module", + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "files": [ + "dist", + "README.md", + "LICENSE", + "review/*", + "CHANGELOG.md" + ], + "sdk-type": "client", + "repository": "github:Azure/azure-sdk-for-js", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", + "//metadata": { + "constantPaths": [ + { + "path": "src/dataApiClient.ts", + "prefix": "userAgentInfo" + } + ] + }, + "dependencies": { + "@azure-rest/core-client": "^2.3.1", + "@azure/core-auth": "^1.6.0", + "@azure/core-rest-pipeline": "^1.5.0", + "@azure/logger": "^1.0.0", + "tslib": "^2.6.2", + "@azure/core-lro": "^3.1.0", + "@azure/abort-controller": "^2.1.2" + }, + "devDependencies": { + "dotenv": "^16.0.0", + "@microsoft/api-extractor": "^7.40.3", + "@types/node": "^18.0.0", + "eslint": "^8.55.0", + "typescript": "~5.6.2", + "tshy": "^2.0.0", + "@azure/identity": "^4.2.1", + "@vitest/browser": "^2.0.5", + "@vitest/coverage-istanbul": "^2.0.5", + "playwright": "^1.41.2", + "vitest": "^2.0.5", + "@azure-tools/test-credential": "^2.0.0", + "@azure-tools/test-recorder": "^4.0.0", + "@azure/dev-tool": "^1.0.0", + "@azure/eslint-plugin-azure-sdk": "^3.0.0" + }, + "scripts": { + "clean": "dev-tool run vendored rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", + "extract-api": "dev-tool run vendored rimraf review && dev-tool run vendored mkdirp ./review && dev-tool run extract-api", + "pack": "npm pack 2>&1", + "lint": "eslint package.json api-extractor.json src test", + "lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]", + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "unit-test:browser": "npm run build:test && dev-tool run test:vitest --browser", + "unit-test:node": "dev-tool run test:vitest", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "integration-test:browser": "echo skipped", + "integration-test:node": "echo skipped", + "build:samples": "echo skipped", + "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" ", + "execute:samples": "echo skipped", + "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" ", + "generate:client": "echo skipped", + "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser", + "minify": "dev-tool run vendored uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", + "build:test": "npm run clean && dev-tool run build-package && dev-tool run build-test", + "build": "npm run clean && dev-tool run build-package && dev-tool run vendored mkdirp ./review && dev-tool run extract-api", + "test:node": "npm run clean && dev-tool run build-package && npm run unit-test:node && npm run integration-test:node", + "test": "npm run clean && dev-tool run build-package && npm run unit-test:node && dev-tool run bundle && npm run unit-test:browser && npm run integration-test", + "update-snippets": "echo skipped" + }, + "exports": { + "./package.json": "./package.json", + ".": { + "browser": { + "types": "./dist/browser/index.d.ts", + "default": "./dist/browser/index.js" + }, + "react-native": { + "types": "./dist/react-native/index.d.ts", + "default": "./dist/react-native/index.js" + }, + "import": { + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" + }, + "require": { + "types": "./dist/commonjs/index.d.ts", + "default": "./dist/commonjs/index.js" + } + } + }, + "main": "./dist/commonjs/index.js", + "types": "./dist/commonjs/index.d.ts" +} \ No newline at end of file diff --git a/sdk/apicenter/azure-apicenter-rest/review/azure-apicenter-rest.api.md b/sdk/apicenter/azure-apicenter-rest/review/azure-apicenter-rest.api.md new file mode 100644 index 000000000000..10f77b12843f --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/review/azure-apicenter-rest.api.md @@ -0,0 +1,906 @@ +## API Report File for "@azure-rest/azure-apicenter-rest" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import { AbortSignalLike } from '@azure/abort-controller'; +import { CancelOnProgress } from '@azure/core-lro'; +import { Client } from '@azure-rest/core-client'; +import { ClientOptions } from '@azure-rest/core-client'; +import { CreateHttpPollerOptions } from '@azure/core-lro'; +import { ErrorModel } from '@azure-rest/core-client'; +import { ErrorResponse } from '@azure-rest/core-client'; +import { HttpResponse } from '@azure-rest/core-client'; +import { OperationState } from '@azure/core-lro'; +import { PathUncheckedResponse } from '@azure-rest/core-client'; +import { RawHttpHeaders } from '@azure/core-rest-pipeline'; +import { RequestParameters } from '@azure-rest/core-client'; +import { StreamableMethod } from '@azure-rest/core-client'; +import { TokenCredential } from '@azure/core-auth'; + +// @public +export interface ApiDefinitionOutput { + description?: string; + name: string; + specification?: ApiSpecificationOutput; + title: string; +} + +// @public (undocumented) +export interface ApiDefinitionsExportSpecification { + post(options?: ApiDefinitionsExportSpecificationParameters): StreamableMethod; +} + +// @public (undocumented) +export interface ApiDefinitionsExportSpecification202Headers { + "operation-location": string; +} + +// @public +export interface ApiDefinitionsExportSpecification202Response extends HttpResponse { + // (undocumented) + body: ResourceOperationStatusOutput; + // (undocumented) + headers: RawHttpHeaders & ApiDefinitionsExportSpecification202Headers; + // (undocumented) + status: "202"; +} + +// @public (undocumented) +export interface ApiDefinitionsExportSpecificationDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ApiDefinitionsExportSpecificationDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ApiDefinitionsExportSpecificationDefaultHeaders; + // (undocumented) + status: string; +} + +// @public +export interface ApiDefinitionsExportSpecificationLogicalResponse extends HttpResponse { + // (undocumented) + body: ResourceOperationStatusOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export type ApiDefinitionsExportSpecificationParameters = RequestParameters; + +// @public (undocumented) +export interface ApiDefinitionsGetDefinition { + get(options?: ApiDefinitionsGetDefinitionParameters): StreamableMethod; +} + +// @public +export interface ApiDefinitionsGetDefinition200Response extends HttpResponse { + // (undocumented) + body: { + title: string; + description?: string; + specification?: ApiSpecificationOutput; + }; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface ApiDefinitionsGetDefinitionDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ApiDefinitionsGetDefinitionDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ApiDefinitionsGetDefinitionDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type ApiDefinitionsGetDefinitionParameters = RequestParameters; + +// @public (undocumented) +export interface ApiDefinitionsGetExportSpecificationOperationStatus { + get(options?: ApiDefinitionsGetExportSpecificationOperationStatusParameters): StreamableMethod; +} + +// @public +export interface ApiDefinitionsGetExportSpecificationOperationStatus200Response extends HttpResponse { + // (undocumented) + body: ResourceOperationStatusOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface ApiDefinitionsGetExportSpecificationOperationStatusDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ApiDefinitionsGetExportSpecificationOperationStatusDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ApiDefinitionsGetExportSpecificationOperationStatusDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type ApiDefinitionsGetExportSpecificationOperationStatusParameters = RequestParameters; + +// @public (undocumented) +export interface ApiDefinitionsListDefinitions { + get(options?: ApiDefinitionsListDefinitionsParameters): StreamableMethod; +} + +// @public +export interface ApiDefinitionsListDefinitions200Response extends HttpResponse { + // (undocumented) + body: PagedApiDefinitionOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface ApiDefinitionsListDefinitionsDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ApiDefinitionsListDefinitionsDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ApiDefinitionsListDefinitionsDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type ApiDefinitionsListDefinitionsParameters = ApiDefinitionsListDefinitionsQueryParam & RequestParameters; + +// @public (undocumented) +export interface ApiDefinitionsListDefinitionsQueryParam { + // (undocumented) + queryParameters?: ApiDefinitionsListDefinitionsQueryParamProperties; +} + +// @public (undocumented) +export interface ApiDefinitionsListDefinitionsQueryParamProperties { + maxpagesize?: number; + skip?: number; + top?: number; +} + +// @public +export interface ApiDeploymentOutput { + customProperties?: Record; + description?: string; + environment: string; + name: string; + recommended?: boolean; + server: ApiDeploymentServerOutput; + title: string; +} + +// @public +export interface ApiDeploymentServerOutput { + runtimeUris: string[]; +} + +// @public (undocumented) +export interface ApiDeploymentsGetDeployment { + get(options?: ApiDeploymentsGetDeploymentParameters): StreamableMethod; +} + +// @public +export interface ApiDeploymentsGetDeployment200Response extends HttpResponse { + // (undocumented) + body: { + title: string; + description?: string; + environment: string; + server: ApiDeploymentServerOutput; + customProperties?: Record; + recommended?: boolean; + }; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface ApiDeploymentsGetDeploymentDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ApiDeploymentsGetDeploymentDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ApiDeploymentsGetDeploymentDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type ApiDeploymentsGetDeploymentParameters = RequestParameters; + +// @public (undocumented) +export interface ApiDeploymentsListDeployments { + get(options?: ApiDeploymentsListDeploymentsParameters): StreamableMethod; +} + +// @public +export interface ApiDeploymentsListDeployments200Response extends HttpResponse { + // (undocumented) + body: PagedApiDeploymentOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface ApiDeploymentsListDeploymentsDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ApiDeploymentsListDeploymentsDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ApiDeploymentsListDeploymentsDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type ApiDeploymentsListDeploymentsParameters = ApiDeploymentsListDeploymentsQueryParam & RequestParameters; + +// @public (undocumented) +export interface ApiDeploymentsListDeploymentsQueryParam { + // (undocumented) + queryParameters?: ApiDeploymentsListDeploymentsQueryParamProperties; +} + +// @public (undocumented) +export interface ApiDeploymentsListDeploymentsQueryParamProperties { + maxpagesize?: number; + skip?: number; + top?: number; +} + +// @public +export type ApiKindOutput = string; + +// @public +export interface ApiOutput { + contacts?: Array; + customProperties?: Record; + description?: string; + externalDocumentation?: Array; + kind: ApiKindOutput; + readonly lastUpdated?: string; + license?: LicenseOutput; + readonly lifecycleStage?: LifecycleStageOutput; + name: string; + summary?: string; + termsOfService?: TermsOfServiceOutput; + title: string; +} + +// @public (undocumented) +export interface ApisGet { + get(options?: ApisGetParameters): StreamableMethod; +} + +// @public +export interface ApisGet200Response extends HttpResponse { + // (undocumented) + body: { + title: string; + summary?: string; + description?: string; + kind: ApiKindOutput; + lifecycleStage?: LifecycleStageOutput; + termsOfService?: TermsOfServiceOutput; + license?: LicenseOutput; + externalDocumentation?: Array; + contacts?: Array; + customProperties?: Record; + lastUpdated?: string; + }; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface ApisGetDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ApisGetDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ApisGetDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type ApisGetParameters = RequestParameters; + +// @public (undocumented) +export interface ApisList { + get(options?: ApisListParameters): StreamableMethod; +} + +// @public +export interface ApisList200Response extends HttpResponse { + // (undocumented) + body: PagedApiOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface ApisListAll { + get(options?: ApisListAllParameters): StreamableMethod; +} + +// @public +export interface ApisListAll200Response extends HttpResponse { + // (undocumented) + body: PagedApiAllOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface ApisListAllDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ApisListAllDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ApisListAllDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type ApisListAllParameters = ApisListAllQueryParam & RequestParameters; + +// @public (undocumented) +export interface ApisListAllQueryParam { + // (undocumented) + queryParameters?: ApisListAllQueryParamProperties; +} + +// @public (undocumented) +export interface ApisListAllQueryParamProperties { + maxpagesize?: number; + skip?: number; + top?: number; +} + +// @public (undocumented) +export interface ApisListDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ApisListDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ApisListDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type ApisListParameters = ApisListQueryParam & RequestParameters; + +// @public (undocumented) +export interface ApisListQueryParam { + // (undocumented) + queryParameters?: ApisListQueryParamProperties; +} + +// @public (undocumented) +export interface ApisListQueryParamProperties { + maxpagesize?: number; + skip?: number; + top?: number; +} + +// @public +export type ApiSpecExportResultFormatOutput = string; + +// @public +export interface ApiSpecExportResultOutput { + definitionName: string; + format: ApiSpecExportResultFormatOutput; + value: string; +} + +// @public +export interface ApiSpecificationOutput { + name: string; + version: string; +} + +// @public +export interface ApiVersionOutput { + lifecycleStage: LifecycleStageOutput; + name: string; + title: string; +} + +// @public (undocumented) +export interface ApiVersionsGetVersion { + get(options?: ApiVersionsGetVersionParameters): StreamableMethod; +} + +// @public +export interface ApiVersionsGetVersion200Response extends HttpResponse { + // (undocumented) + body: { + title: string; + lifecycleStage: LifecycleStageOutput; + }; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface ApiVersionsGetVersionDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ApiVersionsGetVersionDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ApiVersionsGetVersionDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type ApiVersionsGetVersionParameters = RequestParameters; + +// @public (undocumented) +export interface ApiVersionsListVersions { + get(options?: ApiVersionsListVersionsParameters): StreamableMethod; +} + +// @public +export interface ApiVersionsListVersions200Response extends HttpResponse { + // (undocumented) + body: PagedApiVersionOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface ApiVersionsListVersionsDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface ApiVersionsListVersionsDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & ApiVersionsListVersionsDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type ApiVersionsListVersionsParameters = ApiVersionsListVersionsQueryParam & RequestParameters; + +// @public (undocumented) +export interface ApiVersionsListVersionsQueryParam { + // (undocumented) + queryParameters?: ApiVersionsListVersionsQueryParamProperties; +} + +// @public (undocumented) +export interface ApiVersionsListVersionsQueryParamProperties { + maxpagesize?: number; + skip?: number; + top?: number; +} + +// @public +export interface ContactOutput { + email?: string; + name: string; + url?: string; +} + +// @public +function createClient(serviceName: string, region: string, credentials: TokenCredential, { apiVersion, ...options }?: DataApiClientOptions): DataApiClient; +export default createClient; + +// @public (undocumented) +export type DataApiClient = Client & { + path: Routes; +}; + +// @public +export interface DataApiClientOptions extends ClientOptions { + apiVersion?: string; +} + +// @public +export type EnvironmentKindOutput = string; + +// @public +export interface EnvironmentOnboardingModelOutput { + developerPortalUris: string[]; + instructions: string; +} + +// @public +export interface EnvironmentOutput { + customProperties?: Record; + description?: string; + kind: EnvironmentKindOutput; + name: string; + onboarding?: EnvironmentOnboardingModelOutput; + server?: EnvironmentServerOutput; + title: string; +} + +// @public +export interface EnvironmentServerOutput { + managementPortalUris: string[]; + type: string; +} + +// @public (undocumented) +export interface EnvironmentsGet { + get(options?: EnvironmentsGetParameters): StreamableMethod; +} + +// @public +export interface EnvironmentsGet200Response extends HttpResponse { + // (undocumented) + body: { + title: string; + kind: EnvironmentKindOutput; + description?: string; + server?: EnvironmentServerOutput; + onboarding?: EnvironmentOnboardingModelOutput; + customProperties?: Record; + }; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface EnvironmentsGetDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface EnvironmentsGetDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & EnvironmentsGetDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type EnvironmentsGetParameters = RequestParameters; + +// @public (undocumented) +export interface EnvironmentsList { + get(options?: EnvironmentsListParameters): StreamableMethod; +} + +// @public +export interface EnvironmentsList200Response extends HttpResponse { + // (undocumented) + body: PagedEnvironmentOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface EnvironmentsListAll { + get(options?: EnvironmentsListAllParameters): StreamableMethod; +} + +// @public +export interface EnvironmentsListAll200Response extends HttpResponse { + // (undocumented) + body: PagedEnvironmentAllOutput; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +export interface EnvironmentsListAllDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface EnvironmentsListAllDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & EnvironmentsListAllDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type EnvironmentsListAllParameters = EnvironmentsListAllQueryParam & RequestParameters; + +// @public (undocumented) +export interface EnvironmentsListAllQueryParam { + // (undocumented) + queryParameters?: EnvironmentsListAllQueryParamProperties; +} + +// @public (undocumented) +export interface EnvironmentsListAllQueryParamProperties { + maxpagesize?: number; + skip?: number; + top?: number; +} + +// @public (undocumented) +export interface EnvironmentsListDefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public (undocumented) +export interface EnvironmentsListDefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponse; + // (undocumented) + headers: RawHttpHeaders & EnvironmentsListDefaultHeaders; + // (undocumented) + status: string; +} + +// @public (undocumented) +export type EnvironmentsListParameters = EnvironmentsListQueryParam & RequestParameters; + +// @public (undocumented) +export interface EnvironmentsListQueryParam { + // (undocumented) + queryParameters?: EnvironmentsListQueryParamProperties; +} + +// @public (undocumented) +export interface EnvironmentsListQueryParamProperties { + maxpagesize?: number; + skip?: number; + top?: number; +} + +// @public +export interface ExternalDocumentationOutput { + description: string; + title: string; + url: string; +} + +// @public +export type GetArrayType = T extends Array ? TData : never; + +// @public +export function getLongRunningPoller(client: Client, initialResponse: ApiDefinitionsExportSpecification202Response | ApiDefinitionsExportSpecificationDefaultResponse, options?: CreateHttpPollerOptions>): Promise, TResult>>; + +// @public +export type GetPage = (pageLink: string) => Promise<{ + page: TPage; + nextPageLink?: string; +}>; + +// @public (undocumented) +export function isUnexpected(response: ApisList200Response | ApisListDefaultResponse): response is ApisListDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: ApisListAll200Response | ApisListAllDefaultResponse): response is ApisListAllDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: ApisGet200Response | ApisGetDefaultResponse): response is ApisGetDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: ApiDefinitionsListDefinitions200Response | ApiDefinitionsListDefinitionsDefaultResponse): response is ApiDefinitionsListDefinitionsDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: ApiDefinitionsGetDefinition200Response | ApiDefinitionsGetDefinitionDefaultResponse): response is ApiDefinitionsGetDefinitionDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: ApiDefinitionsGetExportSpecificationOperationStatus200Response | ApiDefinitionsGetExportSpecificationOperationStatusDefaultResponse): response is ApiDefinitionsGetExportSpecificationOperationStatusDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: ApiDefinitionsExportSpecification202Response | ApiDefinitionsExportSpecificationLogicalResponse | ApiDefinitionsExportSpecificationDefaultResponse): response is ApiDefinitionsExportSpecificationDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: ApiDeploymentsListDeployments200Response | ApiDeploymentsListDeploymentsDefaultResponse): response is ApiDeploymentsListDeploymentsDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: ApiDeploymentsGetDeployment200Response | ApiDeploymentsGetDeploymentDefaultResponse): response is ApiDeploymentsGetDeploymentDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: EnvironmentsList200Response | EnvironmentsListDefaultResponse): response is EnvironmentsListDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: EnvironmentsListAll200Response | EnvironmentsListAllDefaultResponse): response is EnvironmentsListAllDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: EnvironmentsGet200Response | EnvironmentsGetDefaultResponse): response is EnvironmentsGetDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: ApiVersionsListVersions200Response | ApiVersionsListVersionsDefaultResponse): response is ApiVersionsListVersionsDefaultResponse; + +// @public (undocumented) +export function isUnexpected(response: ApiVersionsGetVersion200Response | ApiVersionsGetVersionDefaultResponse): response is ApiVersionsGetVersionDefaultResponse; + +// @public +export interface LicenseOutput { + identifier?: string; + name: string; + url?: string; +} + +// @public +export type LifecycleStageOutput = string; + +// @public +export type OperationStateOutput = string; + +// @public +export interface PagedApiAllOutput { + nextLink?: string; + value: Array; +} + +// @public +export interface PagedApiDefinitionOutput { + nextLink?: string; + value: Array; +} + +// @public +export interface PagedApiDeploymentOutput { + nextLink?: string; + value: Array; +} + +// @public +export interface PagedApiOutput { + nextLink?: string; + value: Array; +} + +// @public +export interface PagedApiVersionOutput { + nextLink?: string; + value: Array; +} + +// @public +export interface PagedAsyncIterableIterator { + [Symbol.asyncIterator](): PagedAsyncIterableIterator; + byPage: (settings?: TPageSettings) => AsyncIterableIterator; + next(): Promise>; +} + +// @public +export interface PagedEnvironmentAllOutput { + nextLink?: string; + value: Array; +} + +// @public +export interface PagedEnvironmentOutput { + nextLink?: string; + value: Array; +} + +// @public +export interface PageSettings { + continuationToken?: string; +} + +// @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 ResourceOperationStatusOutput { + error?: ErrorModel; + id: string; + result?: ApiSpecExportResultOutput; + status: OperationStateOutput; +} + +// @public (undocumented) +export interface Routes { + (path: "/workspaces/{workspaceName}/apis", workspaceName: string): ApisList; + (path: "/apis"): ApisListAll; + (path: "/workspaces/{workspaceName}/apis/{apiName}", workspaceName: string, apiName: string): ApisGet; + (path: "/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions", workspaceName: string, apiName: string, versionName: string): ApiDefinitionsListDefinitions; + (path: "/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}", workspaceName: string, apiName: string, versionName: string, definitionName: string): ApiDefinitionsGetDefinition; + (path: "/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/operations/{operationId}", workspaceName: string, apiName: string, versionName: string, definitionName: string, operationId: string): ApiDefinitionsGetExportSpecificationOperationStatus; + (path: "/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}:exportSpecification", workspaceName: string, apiName: string, versionName: string, definitionName: string): ApiDefinitionsExportSpecification; + (path: "/workspaces/{workspaceName}/apis/{apiName}/deployments", workspaceName: string, apiName: string): ApiDeploymentsListDeployments; + (path: "/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}", workspaceName: string, apiName: string, deploymentName: string): ApiDeploymentsGetDeployment; + (path: "/workspaces/{workspaceName}/environments", workspaceName: string): EnvironmentsList; + (path: "/environments"): EnvironmentsListAll; + (path: "/workspaces/{workspaceName}/environments/{environmentName}", workspaceName: string, environmentName: string): EnvironmentsGet; + (path: "/workspaces/{workspaceName}/apis/{apiName}/versions", workspaceName: string, apiName: string): ApiVersionsListVersions; + (path: "/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}", workspaceName: string, apiName: string, versionName: string): ApiVersionsGetVersion; +} + +// @public +export interface SimplePollerLike, TResult> { + getOperationState(): TState; + getResult(): TResult | undefined; + isDone(): boolean; + // @deprecated + isStopped(): boolean; + onProgress(callback: (state: TState) => void): CancelOnProgress; + poll(options?: { + abortSignal?: AbortSignalLike; + }): Promise; + pollUntilDone(pollOptions?: { + abortSignal?: AbortSignalLike; + }): Promise; + serialize(): Promise; + // @deprecated + stopPolling(): void; + submitted(): Promise; + // @deprecated + toString(): string; +} + +// @public +export interface TermsOfServiceOutput { + url: string; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/apicenter/azure-apicenter-rest/sample.env b/sdk/apicenter/azure-apicenter-rest/sample.env new file mode 100644 index 000000000000..508439fc7d62 --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/sample.env @@ -0,0 +1 @@ +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/apicenter/azure-apicenter-rest/src/clientDefinitions.ts b/sdk/apicenter/azure-apicenter-rest/src/clientDefinitions.ts new file mode 100644 index 000000000000..2321d9968c70 --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/src/clientDefinitions.ts @@ -0,0 +1,264 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + ApisListParameters, + ApisListAllParameters, + ApisGetParameters, + ApiDefinitionsListDefinitionsParameters, + ApiDefinitionsGetDefinitionParameters, + ApiDefinitionsGetExportSpecificationOperationStatusParameters, + ApiDefinitionsExportSpecificationParameters, + ApiDeploymentsListDeploymentsParameters, + ApiDeploymentsGetDeploymentParameters, + EnvironmentsListParameters, + EnvironmentsListAllParameters, + EnvironmentsGetParameters, + ApiVersionsListVersionsParameters, + ApiVersionsGetVersionParameters, +} from "./parameters.js"; +import { + ApisList200Response, + ApisListDefaultResponse, + ApisListAll200Response, + ApisListAllDefaultResponse, + ApisGet200Response, + ApisGetDefaultResponse, + ApiDefinitionsListDefinitions200Response, + ApiDefinitionsListDefinitionsDefaultResponse, + ApiDefinitionsGetDefinition200Response, + ApiDefinitionsGetDefinitionDefaultResponse, + ApiDefinitionsGetExportSpecificationOperationStatus200Response, + ApiDefinitionsGetExportSpecificationOperationStatusDefaultResponse, + ApiDefinitionsExportSpecification202Response, + ApiDefinitionsExportSpecificationDefaultResponse, + ApiDeploymentsListDeployments200Response, + ApiDeploymentsListDeploymentsDefaultResponse, + ApiDeploymentsGetDeployment200Response, + ApiDeploymentsGetDeploymentDefaultResponse, + EnvironmentsList200Response, + EnvironmentsListDefaultResponse, + EnvironmentsListAll200Response, + EnvironmentsListAllDefaultResponse, + EnvironmentsGet200Response, + EnvironmentsGetDefaultResponse, + ApiVersionsListVersions200Response, + ApiVersionsListVersionsDefaultResponse, + ApiVersionsGetVersion200Response, + ApiVersionsGetVersionDefaultResponse, +} from "./responses.js"; +import { Client, StreamableMethod } from "@azure-rest/core-client"; + +export interface ApisList { + /** List a collection of APIs. */ + get( + options?: ApisListParameters, + ): StreamableMethod; +} + +export interface ApisListAll { + /** List a collection of APIs across workspaces. */ + get( + options?: ApisListAllParameters, + ): StreamableMethod; +} + +export interface ApisGet { + /** Get an API. */ + get( + options?: ApisGetParameters, + ): StreamableMethod; +} + +export interface ApiDefinitionsListDefinitions { + /** List a collection of API definitions. */ + get( + options?: ApiDefinitionsListDefinitionsParameters, + ): StreamableMethod< + | ApiDefinitionsListDefinitions200Response + | ApiDefinitionsListDefinitionsDefaultResponse + >; +} + +export interface ApiDefinitionsGetDefinition { + /** Get an API definition. */ + get( + options?: ApiDefinitionsGetDefinitionParameters, + ): StreamableMethod< + | ApiDefinitionsGetDefinition200Response + | ApiDefinitionsGetDefinitionDefaultResponse + >; +} + +export interface ApiDefinitionsGetExportSpecificationOperationStatus { + /** Gets status of a an API specification export operation. */ + get( + options?: ApiDefinitionsGetExportSpecificationOperationStatusParameters, + ): StreamableMethod< + | ApiDefinitionsGetExportSpecificationOperationStatus200Response + | ApiDefinitionsGetExportSpecificationOperationStatusDefaultResponse + >; +} + +export interface ApiDefinitionsExportSpecification { + /** Export an API specification asynchronously. */ + post( + options?: ApiDefinitionsExportSpecificationParameters, + ): StreamableMethod< + | ApiDefinitionsExportSpecification202Response + | ApiDefinitionsExportSpecificationDefaultResponse + >; +} + +export interface ApiDeploymentsListDeployments { + /** List a collection of API deployments. */ + get( + options?: ApiDeploymentsListDeploymentsParameters, + ): StreamableMethod< + | ApiDeploymentsListDeployments200Response + | ApiDeploymentsListDeploymentsDefaultResponse + >; +} + +export interface ApiDeploymentsGetDeployment { + /** Get an API deployment. */ + get( + options?: ApiDeploymentsGetDeploymentParameters, + ): StreamableMethod< + | ApiDeploymentsGetDeployment200Response + | ApiDeploymentsGetDeploymentDefaultResponse + >; +} + +export interface EnvironmentsList { + /** List a collection of environments. */ + get( + options?: EnvironmentsListParameters, + ): StreamableMethod< + EnvironmentsList200Response | EnvironmentsListDefaultResponse + >; +} + +export interface EnvironmentsListAll { + /** List a collection of environments across workspaces. */ + get( + options?: EnvironmentsListAllParameters, + ): StreamableMethod< + EnvironmentsListAll200Response | EnvironmentsListAllDefaultResponse + >; +} + +export interface EnvironmentsGet { + /** Get an environment. */ + get( + options?: EnvironmentsGetParameters, + ): StreamableMethod< + EnvironmentsGet200Response | EnvironmentsGetDefaultResponse + >; +} + +export interface ApiVersionsListVersions { + /** List a collection of API versions. */ + get( + options?: ApiVersionsListVersionsParameters, + ): StreamableMethod< + ApiVersionsListVersions200Response | ApiVersionsListVersionsDefaultResponse + >; +} + +export interface ApiVersionsGetVersion { + /** Get an API version. */ + get( + options?: ApiVersionsGetVersionParameters, + ): StreamableMethod< + ApiVersionsGetVersion200Response | ApiVersionsGetVersionDefaultResponse + >; +} + +export interface Routes { + /** Resource for '/workspaces/\{workspaceName\}/apis' has methods for the following verbs: get */ + (path: "/workspaces/{workspaceName}/apis", workspaceName: string): ApisList; + /** Resource for '/apis' has methods for the following verbs: get */ + (path: "/apis"): ApisListAll; + /** Resource for '/workspaces/\{workspaceName\}/apis/\{apiName\}' has methods for the following verbs: get */ + ( + path: "/workspaces/{workspaceName}/apis/{apiName}", + workspaceName: string, + apiName: string, + ): ApisGet; + /** Resource for '/workspaces/\{workspaceName\}/apis/\{apiName\}/versions/\{versionName\}/definitions' has methods for the following verbs: get */ + ( + path: "/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions", + workspaceName: string, + apiName: string, + versionName: string, + ): ApiDefinitionsListDefinitions; + /** Resource for '/workspaces/\{workspaceName\}/apis/\{apiName\}/versions/\{versionName\}/definitions/\{definitionName\}' has methods for the following verbs: get */ + ( + path: "/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}", + workspaceName: string, + apiName: string, + versionName: string, + definitionName: string, + ): ApiDefinitionsGetDefinition; + /** Resource for '/workspaces/\{workspaceName\}/apis/\{apiName\}/versions/\{versionName\}/definitions/\{definitionName\}/operations/\{operationId\}' has methods for the following verbs: get */ + ( + path: "/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/operations/{operationId}", + workspaceName: string, + apiName: string, + versionName: string, + definitionName: string, + operationId: string, + ): ApiDefinitionsGetExportSpecificationOperationStatus; + /** Resource for '/workspaces/\{workspaceName\}/apis/\{apiName\}/versions/\{versionName\}/definitions/\{definitionName\}:exportSpecification' has methods for the following verbs: post */ + ( + path: "/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}:exportSpecification", + workspaceName: string, + apiName: string, + versionName: string, + definitionName: string, + ): ApiDefinitionsExportSpecification; + /** Resource for '/workspaces/\{workspaceName\}/apis/\{apiName\}/deployments' has methods for the following verbs: get */ + ( + path: "/workspaces/{workspaceName}/apis/{apiName}/deployments", + workspaceName: string, + apiName: string, + ): ApiDeploymentsListDeployments; + /** Resource for '/workspaces/\{workspaceName\}/apis/\{apiName\}/deployments/\{deploymentName\}' has methods for the following verbs: get */ + ( + path: "/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}", + workspaceName: string, + apiName: string, + deploymentName: string, + ): ApiDeploymentsGetDeployment; + /** Resource for '/workspaces/\{workspaceName\}/environments' has methods for the following verbs: get */ + ( + path: "/workspaces/{workspaceName}/environments", + workspaceName: string, + ): EnvironmentsList; + /** Resource for '/environments' has methods for the following verbs: get */ + (path: "/environments"): EnvironmentsListAll; + /** Resource for '/workspaces/\{workspaceName\}/environments/\{environmentName\}' has methods for the following verbs: get */ + ( + path: "/workspaces/{workspaceName}/environments/{environmentName}", + workspaceName: string, + environmentName: string, + ): EnvironmentsGet; + /** Resource for '/workspaces/\{workspaceName\}/apis/\{apiName\}/versions' has methods for the following verbs: get */ + ( + path: "/workspaces/{workspaceName}/apis/{apiName}/versions", + workspaceName: string, + apiName: string, + ): ApiVersionsListVersions; + /** Resource for '/workspaces/\{workspaceName\}/apis/\{apiName\}/versions/\{versionName\}' has methods for the following verbs: get */ + ( + path: "/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}", + workspaceName: string, + apiName: string, + versionName: string, + ): ApiVersionsGetVersion; +} + +export type DataApiClient = Client & { + path: Routes; +}; diff --git a/sdk/apicenter/azure-apicenter-rest/src/dataApiClient.ts b/sdk/apicenter/azure-apicenter-rest/src/dataApiClient.ts new file mode 100644 index 000000000000..c2cf05b41998 --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/src/dataApiClient.ts @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { getClient, ClientOptions } from "@azure-rest/core-client"; +import { logger } from "./logger.js"; +import { TokenCredential } from "@azure/core-auth"; +import { DataApiClient } from "./clientDefinitions.js"; + +/** The optional parameters for the client */ +export interface DataApiClientOptions extends ClientOptions { + /** The api version option of the client */ + apiVersion?: string; +} + +/** + * Initialize a new instance of `DataApiClient` + * @param serviceName - Region-unique API Center service name + * @param region - Region name + * @param credentials - uniquely identify client credential + * @param options - the parameter for all optional parameters + */ +export default function createClient( + serviceName: string, + region: string, + credentials: TokenCredential, + { apiVersion = "2024-02-01-preview", ...options }: DataApiClientOptions = {}, +): DataApiClient { + const endpointUrl = + options.endpoint ?? + options.baseUrl ?? + `https://${serviceName}.data.${region}.azure-apicenter.ms`; + const userAgentInfo = `azsdk-js-azure-apicenter-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, + }, + credentials: { + scopes: options.credentials?.scopes ?? [ + "https://azure-apicenter.net/user_impersonation", + ], + }, + }; + const client = getClient(endpointUrl, credentials, options) as DataApiClient; + + client.pipeline.removePolicy({ name: "ApiVersionPolicy" }); + client.pipeline.addPolicy({ + name: "ClientApiVersionPolicy", + sendRequest: (req, next) => { + // Use the apiVersion defined in request url directly + // Append one if there is no apiVersion and we have one at client options + const url = new URL(req.url); + if (!url.searchParams.get("api-version") && apiVersion) { + req.url = `${req.url}${ + Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; + } + + return next(req); + }, + }); + + return client; +} diff --git a/sdk/apicenter/azure-apicenter-rest/src/index.ts b/sdk/apicenter/azure-apicenter-rest/src/index.ts new file mode 100644 index 000000000000..853bd2843423 --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/src/index.ts @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import DataApiClient from "./dataApiClient.js"; + +export * from "./dataApiClient.js"; +export * from "./parameters.js"; +export * from "./responses.js"; +export * from "./clientDefinitions.js"; +export * from "./isUnexpected.js"; +export * from "./outputModels.js"; +export * from "./paginateHelper.js"; +export * from "./pollingHelper.js"; + +export default DataApiClient; diff --git a/sdk/apicenter/azure-apicenter-rest/src/isUnexpected.ts b/sdk/apicenter/azure-apicenter-rest/src/isUnexpected.ts new file mode 100644 index 000000000000..e3d298ab56ea --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/src/isUnexpected.ts @@ -0,0 +1,248 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + ApisList200Response, + ApisListDefaultResponse, + ApisListAll200Response, + ApisListAllDefaultResponse, + ApisGet200Response, + ApisGetDefaultResponse, + ApiDefinitionsListDefinitions200Response, + ApiDefinitionsListDefinitionsDefaultResponse, + ApiDefinitionsGetDefinition200Response, + ApiDefinitionsGetDefinitionDefaultResponse, + ApiDefinitionsGetExportSpecificationOperationStatus200Response, + ApiDefinitionsGetExportSpecificationOperationStatusDefaultResponse, + ApiDefinitionsExportSpecification202Response, + ApiDefinitionsExportSpecificationLogicalResponse, + ApiDefinitionsExportSpecificationDefaultResponse, + ApiDeploymentsListDeployments200Response, + ApiDeploymentsListDeploymentsDefaultResponse, + ApiDeploymentsGetDeployment200Response, + ApiDeploymentsGetDeploymentDefaultResponse, + EnvironmentsList200Response, + EnvironmentsListDefaultResponse, + EnvironmentsListAll200Response, + EnvironmentsListAllDefaultResponse, + EnvironmentsGet200Response, + EnvironmentsGetDefaultResponse, + ApiVersionsListVersions200Response, + ApiVersionsListVersionsDefaultResponse, + ApiVersionsGetVersion200Response, + ApiVersionsGetVersionDefaultResponse, +} from "./responses.js"; + +const responseMap: Record = { + "GET /workspaces/{workspaceName}/apis": ["200"], + "GET /apis": ["200"], + "GET /workspaces/{workspaceName}/apis/{apiName}": ["200"], + "GET /workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions": + ["200"], + "GET /workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}": + ["200"], + "GET /workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/operations/{operationId}": + ["200"], + "GET /workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}:exportSpecification": + ["200", "202"], + "POST /workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}:exportSpecification": + ["202"], + "GET /workspaces/{workspaceName}/apis/{apiName}/deployments": ["200"], + "GET /workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}": + ["200"], + "GET /workspaces/{workspaceName}/environments": ["200"], + "GET /environments": ["200"], + "GET /workspaces/{workspaceName}/environments/{environmentName}": ["200"], + "GET /workspaces/{workspaceName}/apis/{apiName}/versions": ["200"], + "GET /workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}": [ + "200", + ], +}; + +export function isUnexpected( + response: ApisList200Response | ApisListDefaultResponse, +): response is ApisListDefaultResponse; +export function isUnexpected( + response: ApisListAll200Response | ApisListAllDefaultResponse, +): response is ApisListAllDefaultResponse; +export function isUnexpected( + response: ApisGet200Response | ApisGetDefaultResponse, +): response is ApisGetDefaultResponse; +export function isUnexpected( + response: + | ApiDefinitionsListDefinitions200Response + | ApiDefinitionsListDefinitionsDefaultResponse, +): response is ApiDefinitionsListDefinitionsDefaultResponse; +export function isUnexpected( + response: + | ApiDefinitionsGetDefinition200Response + | ApiDefinitionsGetDefinitionDefaultResponse, +): response is ApiDefinitionsGetDefinitionDefaultResponse; +export function isUnexpected( + response: + | ApiDefinitionsGetExportSpecificationOperationStatus200Response + | ApiDefinitionsGetExportSpecificationOperationStatusDefaultResponse, +): response is ApiDefinitionsGetExportSpecificationOperationStatusDefaultResponse; +export function isUnexpected( + response: + | ApiDefinitionsExportSpecification202Response + | ApiDefinitionsExportSpecificationLogicalResponse + | ApiDefinitionsExportSpecificationDefaultResponse, +): response is ApiDefinitionsExportSpecificationDefaultResponse; +export function isUnexpected( + response: + | ApiDeploymentsListDeployments200Response + | ApiDeploymentsListDeploymentsDefaultResponse, +): response is ApiDeploymentsListDeploymentsDefaultResponse; +export function isUnexpected( + response: + | ApiDeploymentsGetDeployment200Response + | ApiDeploymentsGetDeploymentDefaultResponse, +): response is ApiDeploymentsGetDeploymentDefaultResponse; +export function isUnexpected( + response: EnvironmentsList200Response | EnvironmentsListDefaultResponse, +): response is EnvironmentsListDefaultResponse; +export function isUnexpected( + response: EnvironmentsListAll200Response | EnvironmentsListAllDefaultResponse, +): response is EnvironmentsListAllDefaultResponse; +export function isUnexpected( + response: EnvironmentsGet200Response | EnvironmentsGetDefaultResponse, +): response is EnvironmentsGetDefaultResponse; +export function isUnexpected( + response: + | ApiVersionsListVersions200Response + | ApiVersionsListVersionsDefaultResponse, +): response is ApiVersionsListVersionsDefaultResponse; +export function isUnexpected( + response: + | ApiVersionsGetVersion200Response + | ApiVersionsGetVersionDefaultResponse, +): response is ApiVersionsGetVersionDefaultResponse; +export function isUnexpected( + response: + | ApisList200Response + | ApisListDefaultResponse + | ApisListAll200Response + | ApisListAllDefaultResponse + | ApisGet200Response + | ApisGetDefaultResponse + | ApiDefinitionsListDefinitions200Response + | ApiDefinitionsListDefinitionsDefaultResponse + | ApiDefinitionsGetDefinition200Response + | ApiDefinitionsGetDefinitionDefaultResponse + | ApiDefinitionsGetExportSpecificationOperationStatus200Response + | ApiDefinitionsGetExportSpecificationOperationStatusDefaultResponse + | ApiDefinitionsExportSpecification202Response + | ApiDefinitionsExportSpecificationLogicalResponse + | ApiDefinitionsExportSpecificationDefaultResponse + | ApiDeploymentsListDeployments200Response + | ApiDeploymentsListDeploymentsDefaultResponse + | ApiDeploymentsGetDeployment200Response + | ApiDeploymentsGetDeploymentDefaultResponse + | EnvironmentsList200Response + | EnvironmentsListDefaultResponse + | EnvironmentsListAll200Response + | EnvironmentsListAllDefaultResponse + | EnvironmentsGet200Response + | EnvironmentsGetDefaultResponse + | ApiVersionsListVersions200Response + | ApiVersionsListVersionsDefaultResponse + | ApiVersionsGetVersion200Response + | ApiVersionsGetVersionDefaultResponse, +): response is + | ApisListDefaultResponse + | ApisListAllDefaultResponse + | ApisGetDefaultResponse + | ApiDefinitionsListDefinitionsDefaultResponse + | ApiDefinitionsGetDefinitionDefaultResponse + | ApiDefinitionsGetExportSpecificationOperationStatusDefaultResponse + | ApiDefinitionsExportSpecificationDefaultResponse + | ApiDeploymentsListDeploymentsDefaultResponse + | ApiDeploymentsGetDeploymentDefaultResponse + | EnvironmentsListDefaultResponse + | EnvironmentsListAllDefaultResponse + | EnvironmentsGetDefaultResponse + | ApiVersionsListVersionsDefaultResponse + | ApiVersionsGetVersionDefaultResponse { + 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/apicenter/azure-apicenter-rest/src/logger.ts b/sdk/apicenter/azure-apicenter-rest/src/logger.ts new file mode 100644 index 000000000000..207315a3abbf --- /dev/null +++ b/sdk/apicenter/azure-apicenter-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("azure-apicenter-rest"); diff --git a/sdk/apicenter/azure-apicenter-rest/src/outputModels.ts b/sdk/apicenter/azure-apicenter-rest/src/outputModels.ts new file mode 100644 index 000000000000..8747c8eecdb9 --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/src/outputModels.ts @@ -0,0 +1,269 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ErrorModel } from "@azure-rest/core-client"; + +/** Paged collection of Api items */ +export interface PagedApiOutput { + /** The Api items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + +/** API resource model. */ +export interface ApiOutput { + /** Api identifier. */ + name: string; + /** The name of the API. */ + title: string; + /** Short description of the API. */ + summary?: string; + /** The description of the API */ + description?: string; + /** + * Kind of API. For example, REST or GraphQL. + * + * Possible values: "rest", "graphql", "grpc", "soap", "webhook", "websocket" + */ + kind: ApiKindOutput; + /** + * Current lifecycle stage of the API. + * + * Possible values: "design", "development", "testing", "preview", "production", "deprecated", "retired" + */ + readonly lifecycleStage?: LifecycleStageOutput; + /** Terms of service for the API. */ + termsOfService?: TermsOfServiceOutput; + /** The license information for the API. */ + license?: LicenseOutput; + /** External documentation */ + externalDocumentation?: Array; + /** Points of contact for the API. */ + contacts?: Array; + /** The custom metadata defined for API entities. */ + customProperties?: Record; + /** Last updated date and time. */ + readonly lastUpdated?: string; +} + +/** API Terms of Service */ +export interface TermsOfServiceOutput { + /** URL pointing to the terms of service. */ + url: string; +} + +/** API License Model */ +export interface LicenseOutput { + /** Name of the license. */ + name: string; + /** URL pointing to the license details. The URL field is mutually exclusive of the identifier field. */ + url?: string; + /** SPDX license information for the API. The identifier field is mutually exclusive of the URL field. */ + identifier?: string; +} + +/** Api External Documentation Model */ +export interface ExternalDocumentationOutput { + /** Title of the documentation. */ + title: string; + /** Description of the documentation. */ + description: string; + /** URL pointing to the documentation. */ + url: string; +} + +/** API contact information */ +export interface ContactOutput { + /** Name of the contact. */ + name: string; + /** URL for the contact. */ + url?: string; + /** Email address for the contact. */ + email?: string; +} + +/** Paged collection of API items across workspaces. */ +export interface PagedApiAllOutput { + /** The Api items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + +/** Paged collection of ApiDefinition items */ +export interface PagedApiDefinitionOutput { + /** The ApiDefinition items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + +/** API definition resource model. */ +export interface ApiDefinitionOutput { + /** Definition identifier. */ + name: string; + /** The name of the API definition. */ + title: string; + /** The description of the API definition. */ + description?: string; + /** The API specification details. */ + specification?: ApiSpecificationOutput; +} + +/** API specification */ +export interface ApiSpecificationOutput { + /** API specification name, e.g. 'swagger' or 'openapi'. */ + name: string; + /** API specification version, e.g. '3.0.1'. */ + version: string; +} + +/** Provides status details for long running operations. */ +export interface ResourceOperationStatusOutput { + /** The unique ID of the operation. */ + id: string; + /** + * The status of the operation + * + * Possible values: "NotStarted", "Running", "Succeeded", "Failed", "Canceled" + */ + status: OperationStateOutput; + /** Error object that describes the error when status is "Failed". */ + error?: ErrorModel; + /** The result of the operation. */ + result?: ApiSpecExportResultOutput; +} + +/** Export specification result model. */ +export interface ApiSpecExportResultOutput { + /** API definition identifier. */ + definitionName: string; + /** The result of the specification export. */ + value: string; + /** + * The format of the specification export result. + * + * Possible values: "link" + */ + format: ApiSpecExportResultFormatOutput; +} + +/** Paged collection of ApiDeployment items */ +export interface PagedApiDeploymentOutput { + /** The ApiDeployment items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + +/** API deployment resource model. */ +export interface ApiDeploymentOutput { + /** Deployment identifier. */ + name: string; + /** The name of the deployment. */ + title: string; + /** The description of the deployment. */ + description?: string; + /** The name of the deployment environment. */ + environment: string; + /** The server information of the API deployment. */ + server: ApiDeploymentServerOutput; + /** The custom metadata defined for API deployment entities. */ + customProperties?: Record; + /** Indicates if this is currently recommended deployment. */ + recommended?: boolean; +} + +/** Api Deployment Server */ +export interface ApiDeploymentServerOutput { + /** Base runtime URIs for this deployment. */ + runtimeUris: string[]; +} + +/** Paged collection of Environment items */ +export interface PagedEnvironmentOutput { + /** The Environment items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + +/** Environment resource model. */ +export interface EnvironmentOutput { + /** Environment identifier. */ + name: string; + /** The name of the environment. */ + title: string; + /** + * Kind of deployment environment. + * + * Possible values: "development", "testing", "staging", "production" + */ + kind: EnvironmentKindOutput; + /** Description of the environment. */ + description?: string; + /** Server information of the environment. */ + server?: EnvironmentServerOutput; + /** Onboarding information for this environment. */ + onboarding?: EnvironmentOnboardingModelOutput; + /** The custom metadata defined for environment entities. */ + customProperties?: Record; +} + +/** Environment Server */ +export interface EnvironmentServerOutput { + /** Type of the server that represents the environment. */ + type: string; + /** URIs of the server's management portal. */ + managementPortalUris: string[]; +} + +/** Environment Onboarding Model */ +export interface EnvironmentOnboardingModelOutput { + /** Instructions how to onboard to the environment. */ + instructions: string; + /** Developer portal URIs of the environment. */ + developerPortalUris: string[]; +} + +/** Paged collection of Environment items across workspaces */ +export interface PagedEnvironmentAllOutput { + /** The Environment items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + +/** Paged collection of ApiVersion items */ +export interface PagedApiVersionOutput { + /** The ApiVersion items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + +/** API version resource model. */ +export interface ApiVersionOutput { + /** Version identifier. */ + name: string; + /** Version title. */ + title: string; + /** + * Current lifecycle stage of the API version. + * + * Possible values: "design", "development", "testing", "preview", "production", "deprecated", "retired" + */ + lifecycleStage: LifecycleStageOutput; +} + +/** Alias for ApiKindOutput */ +export type ApiKindOutput = string; +/** Alias for LifecycleStageOutput */ +export type LifecycleStageOutput = string; +/** Alias for OperationStateOutput */ +export type OperationStateOutput = string; +/** Alias for ApiSpecExportResultFormatOutput */ +export type ApiSpecExportResultFormatOutput = string; +/** Alias for EnvironmentKindOutput */ +export type EnvironmentKindOutput = string; diff --git a/sdk/apicenter/azure-apicenter-rest/src/paginateHelper.ts b/sdk/apicenter/azure-apicenter-rest/src/paginateHelper.ts new file mode 100644 index 000000000000..5ef95e5ea0a3 --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/src/paginateHelper.ts @@ -0,0 +1,297 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + Client, + createRestError, + PathUncheckedResponse, +} from "@azure-rest/core-client"; + +/** + * returns an async iterator that iterates over results. It also has a `byPage` + * method that returns pages of items at once. + * + * @param pagedResult - an object that specifies how to get pages. + * @returns a paged async iterator that iterates over results. + */ +function getPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings = PageSettings, + TLink = string, +>( + pagedResult: PagedResult, +): PagedAsyncIterableIterator { + const iter = getItemAsyncIterator( + pagedResult, + ); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: + pagedResult?.byPage ?? + (((settings?: PageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken as unknown as TLink | undefined, + }); + }) as unknown as ( + settings?: TPageSettings, + ) => AsyncIterableIterator), + }; +} + +async function* getItemAsyncIterator( + pagedResult: PagedResult, +): AsyncIterableIterator { + const pages = getPageAsyncIterator(pagedResult); + const firstVal = await pages.next(); + // if the result does not have an array shape, i.e. TPage = TElement, then we return it as is + if (!Array.isArray(firstVal.value)) { + // can extract elements from this page + const { toElements } = pagedResult; + if (toElements) { + yield* toElements(firstVal.value) as TElement[]; + for await (const page of pages) { + yield* toElements(page) as TElement[]; + } + } else { + yield firstVal.value; + // `pages` is of type `AsyncIterableIterator` but TPage = TElement in this case + yield* pages as unknown as AsyncIterableIterator; + } + } else { + yield* firstVal.value; + for await (const page of pages) { + // pages is of type `AsyncIterableIterator` so `page` is of type `TPage`. In this branch, + // it must be the case that `TPage = TElement[]` + yield* page as unknown as TElement[]; + } + } +} + +async function* getPageAsyncIterator( + pagedResult: PagedResult, + options: { + pageLink?: TLink; + } = {}, +): AsyncIterableIterator { + const { pageLink } = options; + let response = await pagedResult.getPage( + pageLink ?? pagedResult.firstPageLink, + ); + if (!response) { + return; + } + yield response.page; + while (response.nextPageLink) { + response = await pagedResult.getPage(response.nextPageLink); + if (!response) { + return; + } + yield response.page; + } +} + +/** + * An interface that tracks the settings for paged iteration + */ +export interface PageSettings { + /** + * The token that keeps track of where to continue the iterator + */ + continuationToken?: string; +} + +/** + * An interface that allows async iterable iteration both to completion and by page. + */ +export interface PagedAsyncIterableIterator< + TElement, + TPage = TElement[], + TPageSettings = PageSettings, +> { + /** + * The next method, part of the iteration protocol + */ + next(): Promise>; + /** + * The connection to the async iterator, part of the iteration protocol + */ + [Symbol.asyncIterator](): PagedAsyncIterableIterator< + TElement, + TPage, + TPageSettings + >; + /** + * Return an AsyncIterableIterator that works a page at a time + */ + byPage: (settings?: TPageSettings) => AsyncIterableIterator; +} + +/** + * An interface that describes how to communicate with the service. + */ +interface PagedResult { + /** + * Link to the first page of results. + */ + firstPageLink: TLink; + /** + * A method that returns a page of results. + */ + getPage: ( + pageLink: TLink, + ) => Promise<{ page: TPage; nextPageLink?: TLink } | undefined>; + /** + * a function to implement the `byPage` method on the paged async iterator. + */ + byPage?: (settings?: TPageSettings) => AsyncIterableIterator; + + /** + * A function to extract elements from a page. + */ + toElements?: (page: TPage) => unknown[]; +} + +/** + * 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) => 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/apicenter/azure-apicenter-rest/src/parameters.ts b/sdk/apicenter/azure-apicenter-rest/src/parameters.ts new file mode 100644 index 000000000000..ed66c8474ea0 --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/src/parameters.ts @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { RequestParameters } from "@azure-rest/core-client"; + +export interface ApisListQueryParamProperties { + /** The number of result items to return. */ + top?: number; + /** The number of result items to skip. */ + skip?: number; + /** The maximum number of result items per page. */ + maxpagesize?: number; +} + +export interface ApisListQueryParam { + queryParameters?: ApisListQueryParamProperties; +} + +export type ApisListParameters = ApisListQueryParam & RequestParameters; + +export interface ApisListAllQueryParamProperties { + /** The number of result items to return. */ + top?: number; + /** The number of result items to skip. */ + skip?: number; + /** The maximum number of result items per page. */ + maxpagesize?: number; +} + +export interface ApisListAllQueryParam { + queryParameters?: ApisListAllQueryParamProperties; +} + +export type ApisListAllParameters = ApisListAllQueryParam & RequestParameters; +export type ApisGetParameters = RequestParameters; + +export interface ApiDefinitionsListDefinitionsQueryParamProperties { + /** The number of result items to return. */ + top?: number; + /** The number of result items to skip. */ + skip?: number; + /** The maximum number of result items per page. */ + maxpagesize?: number; +} + +export interface ApiDefinitionsListDefinitionsQueryParam { + queryParameters?: ApiDefinitionsListDefinitionsQueryParamProperties; +} + +export type ApiDefinitionsListDefinitionsParameters = + ApiDefinitionsListDefinitionsQueryParam & RequestParameters; +export type ApiDefinitionsGetDefinitionParameters = RequestParameters; +export type ApiDefinitionsGetExportSpecificationOperationStatusParameters = + RequestParameters; +export type ApiDefinitionsExportSpecificationParameters = RequestParameters; + +export interface ApiDeploymentsListDeploymentsQueryParamProperties { + /** The number of result items to return. */ + top?: number; + /** The number of result items to skip. */ + skip?: number; + /** The maximum number of result items per page. */ + maxpagesize?: number; +} + +export interface ApiDeploymentsListDeploymentsQueryParam { + queryParameters?: ApiDeploymentsListDeploymentsQueryParamProperties; +} + +export type ApiDeploymentsListDeploymentsParameters = + ApiDeploymentsListDeploymentsQueryParam & RequestParameters; +export type ApiDeploymentsGetDeploymentParameters = RequestParameters; + +export interface EnvironmentsListQueryParamProperties { + /** The number of result items to return. */ + top?: number; + /** The number of result items to skip. */ + skip?: number; + /** The maximum number of result items per page. */ + maxpagesize?: number; +} + +export interface EnvironmentsListQueryParam { + queryParameters?: EnvironmentsListQueryParamProperties; +} + +export type EnvironmentsListParameters = EnvironmentsListQueryParam & + RequestParameters; + +export interface EnvironmentsListAllQueryParamProperties { + /** The number of result items to return. */ + top?: number; + /** The number of result items to skip. */ + skip?: number; + /** The maximum number of result items per page. */ + maxpagesize?: number; +} + +export interface EnvironmentsListAllQueryParam { + queryParameters?: EnvironmentsListAllQueryParamProperties; +} + +export type EnvironmentsListAllParameters = EnvironmentsListAllQueryParam & + RequestParameters; +export type EnvironmentsGetParameters = RequestParameters; + +export interface ApiVersionsListVersionsQueryParamProperties { + /** The number of result items to return. */ + top?: number; + /** The number of result items to skip. */ + skip?: number; + /** The maximum number of result items per page. */ + maxpagesize?: number; +} + +export interface ApiVersionsListVersionsQueryParam { + queryParameters?: ApiVersionsListVersionsQueryParamProperties; +} + +export type ApiVersionsListVersionsParameters = + ApiVersionsListVersionsQueryParam & RequestParameters; +export type ApiVersionsGetVersionParameters = RequestParameters; diff --git a/sdk/apicenter/azure-apicenter-rest/src/pollingHelper.ts b/sdk/apicenter/azure-apicenter-rest/src/pollingHelper.ts new file mode 100644 index 000000000000..3773e0102adf --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/src/pollingHelper.ts @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { Client, HttpResponse } from "@azure-rest/core-client"; +import { AbortSignalLike } from "@azure/abort-controller"; +import { + CancelOnProgress, + CreateHttpPollerOptions, + RunningOperation, + OperationResponse, + OperationState, + createHttpPoller, +} from "@azure/core-lro"; +import { + ApiDefinitionsExportSpecification202Response, + ApiDefinitionsExportSpecificationDefaultResponse, + ApiDefinitionsExportSpecificationLogicalResponse, +} from "./responses.js"; + +/** + * A simple poller that can be used to poll a long running operation. + */ +export interface SimplePollerLike< + TState extends OperationState, + TResult, +> { + /** + * Returns true if the poller has finished polling. + */ + isDone(): boolean; + /** + * Returns the state of the operation. + */ + getOperationState(): TState; + /** + * Returns the result value of the operation, + * regardless of the state of the poller. + * It can return undefined or an incomplete form of the final TResult value + * depending on the implementation. + */ + getResult(): TResult | undefined; + /** + * Returns a promise that will resolve once a single polling request finishes. + * It does this by calling the update method of the Poller's operation. + */ + poll(options?: { abortSignal?: AbortSignalLike }): Promise; + /** + * Returns a promise that will resolve once the underlying operation is completed. + */ + pollUntilDone(pollOptions?: { + abortSignal?: AbortSignalLike; + }): Promise; + /** + * Invokes the provided callback after each polling is completed, + * sending the current state of the poller's operation. + * + * It returns a method that can be used to stop receiving updates on the given callback function. + */ + onProgress(callback: (state: TState) => void): CancelOnProgress; + + /** + * Returns a promise that could be used for serialized version of the poller's operation + * by invoking the operation's serialize method. + */ + serialize(): Promise; + + /** + * Wait the poller to be submitted. + */ + submitted(): Promise; + + /** + * Returns a string representation of the poller's operation. Similar to serialize but returns a string. + * @deprecated Use serialize() instead. + */ + toString(): string; + + /** + * Stops the poller from continuing to poll. Please note this will only stop the client-side polling + * @deprecated Use abortSignal to stop polling instead. + */ + stopPolling(): void; + + /** + * Returns true if the poller is stopped. + * @deprecated Use abortSignal status to track this instead. + */ + isStopped(): boolean; +} + +/** + * Helper function that builds a Poller object to help polling a long running operation. + * @param client - Client to use for sending the request to get additional pages. + * @param initialResponse - The initial response. + * @param options - Options to set a resume state or custom polling interval. + * @returns - A poller object to poll for operation state updates and eventually get the final response. + */ +export async function getLongRunningPoller< + TResult extends + | ApiDefinitionsExportSpecificationLogicalResponse + | ApiDefinitionsExportSpecificationDefaultResponse, +>( + client: Client, + initialResponse: + | ApiDefinitionsExportSpecification202Response + | ApiDefinitionsExportSpecificationDefaultResponse, + options?: CreateHttpPollerOptions>, +): Promise, TResult>>; +export async function getLongRunningPoller( + client: Client, + initialResponse: TResult, + options: CreateHttpPollerOptions> = {}, +): Promise, TResult>> { + const abortController = new AbortController(); + const poller: RunningOperation = { + sendInitialRequest: async () => { + // In the case of Rest Clients we are building the LRO poller object from a response that's the reason + // we are not triggering the initial request here, just extracting the information from the + // response we were provided. + return getLroResponse(initialResponse); + }, + sendPollRequest: async ( + path: string, + pollOptions?: { abortSignal?: AbortSignalLike }, + ) => { + // This is the callback that is going to be called to poll the service + // to get the latest status. We use the client provided and the polling path + // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location + // depending on the lro pattern that the service implements. If non is provided we default to the initial path. + function abortListener(): void { + abortController.abort(); + } + const inputAbortSignal = pollOptions?.abortSignal; + const abortSignal = abortController.signal; + if (inputAbortSignal?.aborted) { + abortController.abort(); + } else if (!abortSignal.aborted) { + inputAbortSignal?.addEventListener("abort", abortListener, { + once: true, + }); + } + let response; + try { + response = await client + .pathUnchecked(path ?? initialResponse.request.url) + .get({ abortSignal }); + } finally { + inputAbortSignal?.removeEventListener("abort", abortListener); + } + const lroResponse = getLroResponse(response as TResult); + lroResponse.rawResponse.headers["x-ms-original-url"] = + initialResponse.request.url; + return lroResponse; + }, + }; + + options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true; + const httpPoller = createHttpPoller(poller, options); + const simplePoller: SimplePollerLike, TResult> = { + isDone() { + return httpPoller.isDone; + }, + isStopped() { + return abortController.signal.aborted; + }, + getOperationState() { + if (!httpPoller.operationState) { + throw new Error( + "Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().", + ); + } + return httpPoller.operationState; + }, + getResult() { + return httpPoller.result; + }, + toString() { + if (!httpPoller.operationState) { + throw new Error( + "Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().", + ); + } + return JSON.stringify({ + state: httpPoller.operationState, + }); + }, + stopPolling() { + abortController.abort(); + }, + onProgress: httpPoller.onProgress, + poll: httpPoller.poll, + pollUntilDone: httpPoller.pollUntilDone, + serialize: httpPoller.serialize, + submitted: httpPoller.submitted, + }; + return simplePoller; +} + +/** + * Converts a Rest Client response to a response that the LRO implementation understands + * @param response - a rest client http response + * @returns - An LRO response that the LRO implementation understands + */ +function getLroResponse( + response: TResult, +): OperationResponse { + if (Number.isNaN(response.status)) { + throw new TypeError( + `Status code of the response is not a number. Value: ${response.status}`, + ); + } + + return { + flatResponse: response, + rawResponse: { + ...response, + statusCode: Number.parseInt(response.status), + body: response.body, + }, + }; +} diff --git a/sdk/apicenter/azure-apicenter-rest/src/responses.ts b/sdk/apicenter/azure-apicenter-rest/src/responses.ts new file mode 100644 index 000000000000..8c6e73a21ea0 --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/src/responses.ts @@ -0,0 +1,316 @@ +// 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 { + PagedApiOutput, + PagedApiAllOutput, + ApiKindOutput, + LifecycleStageOutput, + TermsOfServiceOutput, + LicenseOutput, + ExternalDocumentationOutput, + ContactOutput, + PagedApiDefinitionOutput, + ApiSpecificationOutput, + ResourceOperationStatusOutput, + PagedApiDeploymentOutput, + ApiDeploymentServerOutput, + PagedEnvironmentOutput, + PagedEnvironmentAllOutput, + EnvironmentKindOutput, + EnvironmentServerOutput, + EnvironmentOnboardingModelOutput, + PagedApiVersionOutput, +} from "./outputModels.js"; + +/** The request has succeeded. */ +export interface ApisList200Response extends HttpResponse { + status: "200"; + body: PagedApiOutput; +} + +export interface ApisListDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ApisListDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ApisListDefaultHeaders; +} + +/** The request has succeeded. */ +export interface ApisListAll200Response extends HttpResponse { + status: "200"; + body: PagedApiAllOutput; +} + +export interface ApisListAllDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ApisListAllDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ApisListAllDefaultHeaders; +} + +/** The request has succeeded. */ +export interface ApisGet200Response extends HttpResponse { + status: "200"; + body: { + title: string; + summary?: string; + description?: string; + kind: ApiKindOutput; + lifecycleStage?: LifecycleStageOutput; + termsOfService?: TermsOfServiceOutput; + license?: LicenseOutput; + externalDocumentation?: Array; + contacts?: Array; + customProperties?: Record; + lastUpdated?: string; + }; +} + +export interface ApisGetDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ApisGetDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ApisGetDefaultHeaders; +} + +/** The request has succeeded. */ +export interface ApiDefinitionsListDefinitions200Response extends HttpResponse { + status: "200"; + body: PagedApiDefinitionOutput; +} + +export interface ApiDefinitionsListDefinitionsDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ApiDefinitionsListDefinitionsDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ApiDefinitionsListDefinitionsDefaultHeaders; +} + +/** The request has succeeded. */ +export interface ApiDefinitionsGetDefinition200Response extends HttpResponse { + status: "200"; + body: { + title: string; + description?: string; + specification?: ApiSpecificationOutput; + }; +} + +export interface ApiDefinitionsGetDefinitionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ApiDefinitionsGetDefinitionDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ApiDefinitionsGetDefinitionDefaultHeaders; +} + +/** The request has succeeded. */ +export interface ApiDefinitionsGetExportSpecificationOperationStatus200Response + extends HttpResponse { + status: "200"; + body: ResourceOperationStatusOutput; +} + +export interface ApiDefinitionsGetExportSpecificationOperationStatusDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ApiDefinitionsGetExportSpecificationOperationStatusDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & + ApiDefinitionsGetExportSpecificationOperationStatusDefaultHeaders; +} + +export interface ApiDefinitionsExportSpecification202Headers { + /** The location for monitoring the operation state. */ + "operation-location": string; +} + +/** The request has been accepted for processing, but processing has not yet completed. */ +export interface ApiDefinitionsExportSpecification202Response + extends HttpResponse { + status: "202"; + body: ResourceOperationStatusOutput; + headers: RawHttpHeaders & ApiDefinitionsExportSpecification202Headers; +} + +export interface ApiDefinitionsExportSpecificationDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ApiDefinitionsExportSpecificationDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ApiDefinitionsExportSpecificationDefaultHeaders; +} + +/** The final response for long-running exportSpecification operation */ +export interface ApiDefinitionsExportSpecificationLogicalResponse + extends HttpResponse { + status: "200"; + body: ResourceOperationStatusOutput; +} + +/** The request has succeeded. */ +export interface ApiDeploymentsListDeployments200Response extends HttpResponse { + status: "200"; + body: PagedApiDeploymentOutput; +} + +export interface ApiDeploymentsListDeploymentsDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ApiDeploymentsListDeploymentsDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ApiDeploymentsListDeploymentsDefaultHeaders; +} + +/** The request has succeeded. */ +export interface ApiDeploymentsGetDeployment200Response extends HttpResponse { + status: "200"; + body: { + title: string; + description?: string; + environment: string; + server: ApiDeploymentServerOutput; + customProperties?: Record; + recommended?: boolean; + }; +} + +export interface ApiDeploymentsGetDeploymentDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ApiDeploymentsGetDeploymentDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ApiDeploymentsGetDeploymentDefaultHeaders; +} + +/** The request has succeeded. */ +export interface EnvironmentsList200Response extends HttpResponse { + status: "200"; + body: PagedEnvironmentOutput; +} + +export interface EnvironmentsListDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface EnvironmentsListDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & EnvironmentsListDefaultHeaders; +} + +/** The request has succeeded. */ +export interface EnvironmentsListAll200Response extends HttpResponse { + status: "200"; + body: PagedEnvironmentAllOutput; +} + +export interface EnvironmentsListAllDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface EnvironmentsListAllDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & EnvironmentsListAllDefaultHeaders; +} + +/** The request has succeeded. */ +export interface EnvironmentsGet200Response extends HttpResponse { + status: "200"; + body: { + title: string; + kind: EnvironmentKindOutput; + description?: string; + server?: EnvironmentServerOutput; + onboarding?: EnvironmentOnboardingModelOutput; + customProperties?: Record; + }; +} + +export interface EnvironmentsGetDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface EnvironmentsGetDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & EnvironmentsGetDefaultHeaders; +} + +/** The request has succeeded. */ +export interface ApiVersionsListVersions200Response extends HttpResponse { + status: "200"; + body: PagedApiVersionOutput; +} + +export interface ApiVersionsListVersionsDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ApiVersionsListVersionsDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ApiVersionsListVersionsDefaultHeaders; +} + +/** The request has succeeded. */ +export interface ApiVersionsGetVersion200Response extends HttpResponse { + status: "200"; + body: { title: string; lifecycleStage: LifecycleStageOutput }; +} + +export interface ApiVersionsGetVersionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ApiVersionsGetVersionDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ApiVersionsGetVersionDefaultHeaders; +} diff --git a/sdk/apicenter/azure-apicenter-rest/test/public/sampleTest.spec.ts b/sdk/apicenter/azure-apicenter-rest/test/public/sampleTest.spec.ts new file mode 100644 index 000000000000..d4919ac91ac5 --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/test/public/sampleTest.spec.ts @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { createRecorder } from "./utils/recordedClient.js"; +import { assert, beforeEach, afterEach, it, describe } from "vitest"; + +describe("My test", () => { + // let recorder: Recorder; + + beforeEach(async function () { + // recorder = await createRecorder(this); + }); + + afterEach(async function () { + // await recorder.stop(); + }); + + it("sample test", async function () { + assert.equal(1, 1); + }); +}); diff --git a/sdk/apicenter/azure-apicenter-rest/test/public/utils/recordedClient.ts b/sdk/apicenter/azure-apicenter-rest/test/public/utils/recordedClient.ts new file mode 100644 index 000000000000..6e425fdcfdf9 --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/test/public/utils/recordedClient.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + Recorder, + RecorderStartOptions, + VitestTestContext, +} from "@azure-tools/test-recorder"; + +const replaceableVariables: Record = { + SUBSCRIPTION_ID: "azure_subscription_id", +}; + +const recorderEnvSetup: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables, +}; + +/** + * 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: VitestTestContext, +): Promise { + const recorder = new Recorder(context); + await recorder.start(recorderEnvSetup); + return recorder; +} diff --git a/sdk/apicenter/azure-apicenter-rest/tsconfig.browser.config.json b/sdk/apicenter/azure-apicenter-rest/tsconfig.browser.config.json new file mode 100644 index 000000000000..091177fcb991 --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/tsconfig.browser.config.json @@ -0,0 +1,10 @@ +{ + "extends": "./.tshy/build.json", + "include": ["src/**/*.ts", "src/**/*.mts", "test/**/*.spec.ts"], + "exclude": ["test/**/node/**/*.ts"], + "compilerOptions": { + "outDir": "./dist-test/browser", + "rootDir": ".", + "skipLibCheck": true + } +} diff --git a/sdk/apicenter/azure-apicenter-rest/tsconfig.json b/sdk/apicenter/azure-apicenter-rest/tsconfig.json new file mode 100644 index 000000000000..71858ab903e4 --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../../tsconfig", + "compilerOptions": { + "module": "NodeNext", + "moduleResolution": "NodeNext", + "rootDir": ".", + "skipLibCheck": true + }, + "include": [ + "src/**/*.ts", + "src/**/*.mts", + "src/**/*.cts", + "test/**/*.ts", + "test/**/*.ts" + ] +} \ No newline at end of file diff --git a/sdk/apicenter/azure-apicenter-rest/tsp-location.yaml b/sdk/apicenter/azure-apicenter-rest/tsp-location.yaml new file mode 100644 index 000000000000..628fbe0f5c59 --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/apicenter/ApiCenter.DataApi +commit: 4e7c0729e185afa831161ddd683ed1fa589ddd28 +repo: /mnt/vss/_work/1/s/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/apicenter/azure-apicenter-rest/vitest.browser.config.ts b/sdk/apicenter/azure-apicenter-rest/vitest.browser.config.ts new file mode 100644 index 000000000000..da68c1d231aa --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/vitest.browser.config.ts @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig } from "vitest/config"; +import { relativeRecordingsPath } from "@azure-tools/test-recorder"; + +process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath(); + +export default defineConfig({ + define: { + "process.env": process.env, + }, + test: { + reporters: ["basic", "junit"], + outputFile: { + junit: "test-results.browser.xml", + }, + browser: { + enabled: true, + headless: true, + name: "chromium", + provider: "playwright", + }, + fakeTimers: { + toFake: ["setTimeout", "Date"], + }, + watch: false, + include: ["dist-test/browser/**/*.spec.js"], + coverage: { + include: ["dist-test/browser/**/*.spec.js"], + provider: "istanbul", + reporter: ["text", "json", "html"], + reportsDirectory: "coverage-browser", + }, + testTimeout: 1200000, + hookTimeout: 1200000, + }, +}); diff --git a/sdk/apicenter/azure-apicenter-rest/vitest.config.ts b/sdk/apicenter/azure-apicenter-rest/vitest.config.ts new file mode 100644 index 000000000000..2cf5d0e02c2e --- /dev/null +++ b/sdk/apicenter/azure-apicenter-rest/vitest.config.ts @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig } from "vitest/config"; +import { relativeRecordingsPath } from "@azure-tools/test-recorder"; + +export default defineConfig({ + test: { + reporters: ["basic", "junit"], + outputFile: { + junit: "test-results.browser.xml", + }, + fakeTimers: { + toFake: ["setTimeout", "Date"], + }, + watch: false, + include: ["test/**/*.spec.ts"], + exclude: ["test/**/browser/*.spec.ts"], + coverage: { + include: ["src/**/*.ts"], + exclude: [ + "src/**/*-browser.mts", + "src/**/*-react-native.mts", + "vitest*.config.ts", + "samples-dev/**/*.ts", + ], + provider: "istanbul", + reporter: ["text", "json", "html"], + reportsDirectory: "coverage", + }, + testTimeout: 1200000, + hookTimeout: 1200000, + }, +}); diff --git a/sdk/apicenter/ci.yml b/sdk/apicenter/ci.yml new file mode 100644 index 000000000000..77179c6ae229 --- /dev/null +++ b/sdk/apicenter/ci.yml @@ -0,0 +1,39 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + exclude: + - feature/v4 + paths: + include: + - sdk/apicenter/ + exclude: + - sdk/apicenter/arm-apicenter + - sdk/apicenter/ci.mgmt.yml +pr: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + exclude: + - feature/v4 + paths: + include: + - sdk/apicenter/ + exclude: + - sdk/apicenter/arm-apicenter + - sdk/apicenter/ci.mgmt.yml +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: apicenter + Artifacts: + - name: azure-rest-azure-apicenter-rest + safeName: azurerestazureapicenterrest