From a75a22928d7ac8c5ccf609289ffa0cde4a576801 Mon Sep 17 00:00:00 2001 From: ZiWei Chen <98569699+kazrael2119@users.noreply.github.com> Date: Fri, 20 Dec 2024 08:15:02 +0800 Subject: [PATCH] [data-plane] refresh developer-devcenter-rest sdk (#30936) https://github.com/Azure/azure-sdk-for-js/issues/30680 --- common/config/rush/pnpm-lock.yaml | 19 +- .../developer-devcenter-rest/CHANGELOG.md | 8 +- .../developer-devcenter-rest/LICENSE | 2 +- .../eslint.config.mjs | 7 + .../developer-devcenter-rest/package.json | 72 ++-- .../review/developer-devcenter.api.md | 119 ++++--- .../developer-devcenter-rest/sample.env | 2 +- .../src/azureDeveloperDevCenter.ts | 29 +- .../developer-devcenter-rest/src/models.ts | 76 +---- .../src/outputModels.ts | 314 +++++++++++------- .../src/paginateHelper.ts | 146 +++++++- .../src/parameters.ts | 4 +- .../test/public/utils/env.browser.ts | 2 - .../test/public/utils/env.ts | 6 - .../test/public/utils/recordedClient.ts | 1 - .../developer-devcenter-rest/tsconfig.json | 12 +- .../tsp-location.yaml | 3 +- .../vitest.browser.config.ts | 5 + .../developer-devcenter-rest/vitest.config.ts | 32 +- 19 files changed, 541 insertions(+), 318 deletions(-) delete mode 100644 sdk/devcenter/developer-devcenter-rest/test/public/utils/env.browser.ts delete mode 100644 sdk/devcenter/developer-devcenter-rest/test/public/utils/env.ts diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index db2ac9704e38..5edc03d16e04 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1337,10 +1337,6 @@ packages: resolution: {integrity: sha512-0YIpccoX8m/k00O7mDDMdJpbr6mf1yWo2dfmxt5A8XVZVVMz2SSKaEbMCeJRvgQ0IaSlqhjT47p4hVIRRy90xw==} engines: {node: '>=18.0.0'} - '@azure/core-lro@3.0.0': - resolution: {integrity: sha512-t46lsD0jDJ1o71hIGzoUfT9jH+rIkNJAJLhhPqW8XLbPueHBnP4x5PNJ2szXlLoztH/00OcUUH3FbFnAntOSWA==} - engines: {node: '>=18.0.0'} - '@azure/core-paging@1.6.2': resolution: {integrity: sha512-YKWi9YuCU04B55h25cnOYZHxXYtEvQEbKST5vqRga7hWY9ydd3FZHdeQF8pyh+acWZvppw13M/LMGx0LABUVMA==} engines: {node: '>=18.0.0'} @@ -3671,7 +3667,7 @@ packages: version: 0.0.0 '@rush-temp/developer-devcenter@file:projects/developer-devcenter.tgz': - resolution: {integrity: sha512-DUh+U6IwsLDin8o4TepU5ulb/ihIVvtVS5Ic7lo7fqWL+nu2co9OPa2LADWNZkynKnQ2PdpfYSUoHLswQ1Dg3A==, tarball: file:projects/developer-devcenter.tgz} + resolution: {integrity: sha512-zGrduZzNBYJVUxltyUcs6kpIlS2rvzxJkOjvFDlk132R/26IoWgcmseVvGkobtxPAr34R1UMqfGumW/Sb2y19A==, tarball: file:projects/developer-devcenter.tgz} version: 0.0.0 '@rush-temp/digital-twins-core@file:projects/digital-twins-core.tgz': @@ -8426,13 +8422,6 @@ snapshots: '@azure/logger': 1.1.4 tslib: 2.8.1 - '@azure/core-lro@3.0.0': - dependencies: - '@azure/abort-controller': 2.1.2 - '@azure/core-util': 1.11.0 - '@azure/logger': 1.1.4 - tslib: 2.8.1 - '@azure/core-paging@1.6.2': dependencies: tslib: 2.8.1 @@ -16842,13 +16831,14 @@ snapshots: '@rush-temp/developer-devcenter@file:projects/developer-devcenter.tgz(msw@2.6.8(@types/node@22.7.9)(typescript@5.7.2))(vite@5.4.11(@types/node@22.7.9))': dependencies: - '@azure/core-lro': 3.0.0 + '@microsoft/api-extractor': 7.48.0(@types/node@18.19.68) '@types/node': 18.19.68 '@vitest/browser': 2.1.8(@types/node@18.19.68)(playwright@1.49.1)(typescript@5.7.2)(vite@5.4.11(@types/node@22.7.9))(vitest@2.1.8) '@vitest/coverage-istanbul': 2.1.8(vitest@2.1.8) dotenv: 16.4.7 - eslint: 9.17.0 + eslint: 8.57.1 playwright: 1.49.1 + tshy: 2.0.1 tslib: 2.8.1 typescript: 5.7.2 vitest: 2.1.8(@types/node@18.19.68)(@vitest/browser@2.1.8)(msw@2.6.8(@types/node@22.7.9)(typescript@5.7.2)) @@ -16857,7 +16847,6 @@ snapshots: - '@vitest/ui' - bufferutil - happy-dom - - jiti - jsdom - less - lightningcss diff --git a/sdk/devcenter/developer-devcenter-rest/CHANGELOG.md b/sdk/devcenter/developer-devcenter-rest/CHANGELOG.md index 05d3e55b8752..91f07510a0e0 100644 --- a/sdk/devcenter/developer-devcenter-rest/CHANGELOG.md +++ b/sdk/devcenter/developer-devcenter-rest/CHANGELOG.md @@ -1,14 +1,10 @@ # Release History -## 1.0.1 (Unreleased) +## 1.0.1 (2024-12-16) ### Features Added -### Breaking Changes - -### Bugs Fixed - -### Other Changes +- refresh @azure-rest/developer-devcenter sdk ## 1.0.0 (2024-07-08) diff --git a/sdk/devcenter/developer-devcenter-rest/LICENSE b/sdk/devcenter/developer-devcenter-rest/LICENSE index 5d1d36e0af80..7d5934740965 100644 --- a/sdk/devcenter/developer-devcenter-rest/LICENSE +++ b/sdk/devcenter/developer-devcenter-rest/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2022 Microsoft +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 diff --git a/sdk/devcenter/developer-devcenter-rest/eslint.config.mjs b/sdk/devcenter/developer-devcenter-rest/eslint.config.mjs index b57e15e8e044..a9fcfbef11ff 100644 --- a/sdk/devcenter/developer-devcenter-rest/eslint.config.mjs +++ b/sdk/devcenter/developer-devcenter-rest/eslint.config.mjs @@ -4,6 +4,13 @@ export default azsdkEslint.config([ { 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/devcenter/developer-devcenter-rest/package.json b/sdk/devcenter/developer-devcenter-rest/package.json index c3b63dd65fd2..22ad684dee3d 100644 --- a/sdk/devcenter/developer-devcenter-rest/package.json +++ b/sdk/devcenter/developer-devcenter-rest/package.json @@ -38,7 +38,8 @@ "dist", "README.md", "LICENSE", - "review/*" + "review/*", + "CHANGELOG.md" ], "sdk-type": "client", "repository": "github:Azure/azure-sdk-for-js", @@ -51,59 +52,59 @@ "constantPaths": [ { "path": "src/azureDeveloperDevCenter.ts", - "prefix": "package-version" + "prefix": "userAgentInfo" } ] }, "dependencies": { - "@azure-rest/core-client": "^2.0.0", - "@azure/abort-controller": "^2.0.0", + "@azure-rest/core-client": "^2.3.1", "@azure/core-auth": "^1.6.0", - "@azure/core-lro": "3.0.0", - "@azure/core-paging": "^1.5.0", "@azure/core-rest-pipeline": "^1.5.0", "@azure/logger": "^1.0.0", - "tslib": "^2.6.2" + "tslib": "^2.6.2", + "@azure/core-lro": "^3.1.0", + "@azure/abort-controller": "^2.1.2" }, "devDependencies": { - "@azure-tools/test-credential": "^2.0.0", - "@azure-tools/test-recorder": "^4.0.0", - "@azure/core-util": "^1.0.0", - "@azure/dev-tool": "^1.0.0", - "@azure/eslint-plugin-azure-sdk": "^3.0.0", - "@azure/identity": "^4.0.1", + "dotenv": "^16.0.0", + "@microsoft/api-extractor": "^7.40.3", "@types/node": "^18.0.0", + "eslint": "^8.55.0", + "typescript": "~5.7.2", + "tshy": "^2.0.0", + "@azure/identity": "^4.2.1", "@vitest/browser": "^2.0.5", "@vitest/coverage-istanbul": "^2.0.5", - "dotenv": "^16.0.0", - "eslint": "^9.9.0", "playwright": "^1.41.2", - "typescript": "~5.7.2", - "vitest": "^2.0.5" + "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": { - "build": "npm run clean && dev-tool run build-package && dev-tool run vendored mkdirp ./review && dev-tool run extract-api", - "build:samples": "dev-tool samples publish --force", - "build:test": "npm run clean && dev-tool run build-package && dev-tool run build-test", - "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}\"", "clean": "dev-tool run vendored rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", - "execute:samples": "dev-tool samples run samples-dev", "extract-api": "dev-tool run vendored rimraf review && dev-tool run vendored mkdirp ./review && dev-tool run extract-api", - "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", + "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": "echo skipped", + "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", - "lint": "eslint package.json api-extractor.json src test", - "lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]", - "minify": "dev-tool run vendored uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", - "pack": "npm pack 2>&1", - "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", + "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", - "unit-test": "npm run unit-test:node && npm run unit-test:browser", - "unit-test:browser": "echo skipped", - "unit-test:node": "dev-tool run test:vitest -- -c vitest.config.ts", + "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": { @@ -129,12 +130,5 @@ }, "main": "./dist/commonjs/index.js", "types": "./dist/commonjs/index.d.ts", - "//sampleConfiguration": { - "productName": "Azure DevCenter", - "productSlugs": [ - "azure" - ], - "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure-rest/developer-devcenter" - }, "module": "./dist/esm/index.js" } diff --git a/sdk/devcenter/developer-devcenter-rest/review/developer-devcenter.api.md b/sdk/devcenter/developer-devcenter-rest/review/developer-devcenter.api.md index 1a1623300616..afe50709983a 100644 --- a/sdk/devcenter/developer-devcenter-rest/review/developer-devcenter.api.md +++ b/sdk/devcenter/developer-devcenter-rest/review/developer-devcenter.api.md @@ -13,8 +13,6 @@ import type { ErrorModel } from '@azure-rest/core-client'; import type { ErrorResponse } from '@azure-rest/core-client'; import type { HttpResponse } from '@azure-rest/core-client'; import type { OperationState } from '@azure/core-lro'; -import type { Paged } from '@azure/core-paging'; -import type { PagedAsyncIterableIterator } from '@azure/core-paging'; import type { PathUncheckedResponse } from '@azure-rest/core-client'; import type { RawHttpHeaders } from '@azure/core-rest-pipeline'; import type { RequestParameters } from '@azure-rest/core-client'; @@ -26,13 +24,18 @@ export type AzureDeveloperDevCenterClient = Client & { path: Routes; }; +// @public +export interface AzureDeveloperDevCenterClientOptions extends ClientOptions { + apiVersion?: string; +} + // @public export interface CatalogOutput { readonly name: string; } // @public -function createClient(endpointParam: string, credentials: TokenCredential, options?: ClientOptions): AzureDeveloperDevCenterClient; +function createClient(endpointParam: string, credentials: TokenCredential, { apiVersion, ...options }?: AzureDeveloperDevCenterClientOptions): AzureDeveloperDevCenterClient; export default createClient; // @public @@ -338,7 +341,7 @@ export interface DevBoxActionDelayResultOutput { } // @public -export type DevBoxActionDelayResultStatusOutput = "Succeeded" | "Failed" | string; +export type DevBoxActionDelayResultStatusOutput = string; // @public export interface DevBoxActionOutput { @@ -350,7 +353,7 @@ export interface DevBoxActionOutput { } // @public -export type DevBoxActionTypeOutput = "Stop" | string; +export type DevBoxActionTypeOutput = string; // @public export interface DevBoxNextActionOutput { @@ -379,10 +382,10 @@ export interface DevBoxOutput { } // @public -export type DevBoxProvisioningState = "Succeeded" | "Failed" | "Canceled" | "Creating" | "Deleting" | "Updating" | "Starting" | "Stopping" | "Provisioning" | "ProvisionedWithWarning" | "InGracePeriod" | "NotProvisioned" | string; +export type DevBoxProvisioningState = string; // @public -export type DevBoxProvisioningStateOutput = "Succeeded" | "Failed" | "Canceled" | "Creating" | "Deleting" | "Updating" | "Starting" | "Stopping" | "Provisioning" | "ProvisionedWithWarning" | "InGracePeriod" | "NotProvisioned" | string; +export type DevBoxProvisioningStateOutput = string; // @public export interface Environment { @@ -429,13 +432,13 @@ export interface EnvironmentOutput { } // @public -export type EnvironmentProvisioningState = "Succeeded" | "Failed" | "Canceled" | "Creating" | "Accepted" | "Deleting" | "Updating" | "Preparing" | "Running" | "Syncing" | "MovingResources" | "TransientFailure" | "StorageProvisioningFailed" | string; +export type EnvironmentProvisioningState = string; // @public -export type EnvironmentProvisioningStateOutput = "Succeeded" | "Failed" | "Canceled" | "Creating" | "Accepted" | "Deleting" | "Updating" | "Preparing" | "Running" | "Syncing" | "MovingResources" | "TransientFailure" | "StorageProvisioningFailed" | string; +export type EnvironmentProvisioningStateOutput = string; // @public -export type EnvironmentTypeEnableStatusOutput = "Enabled" | "Disabled" | string; +export type EnvironmentTypeEnableStatusOutput = string; // @public export interface EnvironmentTypeOutput { @@ -656,7 +659,7 @@ export function getLongRunningPoller(client: Client, initialResponse: DeleteEnvironment202Response | DeleteEnvironment204Response | DeleteEnvironmentDefaultResponse, options?: CreateHttpPollerOptions>): Promise, TResult>>; // @public -export type GetPage = (pageLink: string, maxPageSize?: number) => Promise<{ +export type GetPage = (pageLink: string) => Promise<{ page: TPage; nextPageLink?: string; }>; @@ -800,10 +803,10 @@ export interface HardwareProfileOutput { } // @public -export type HibernateSupport = "Enabled" | "Disabled" | "OsUnsupported" | string; +export type HibernateSupport = string; // @public -export type HibernateSupportOutput = "Enabled" | "Disabled" | "OsUnsupported" | string; +export type HibernateSupportOutput = string; // @public export interface ImageReference { @@ -1321,13 +1324,13 @@ export interface ListSchedulesByPoolDefaultResponse extends HttpResponse { export type ListSchedulesByPoolParameters = RequestParameters; // @public -export type LocalAdminStatus = "Enabled" | "Disabled" | string; +export type LocalAdminStatus = string; // @public -export type LocalAdminStatusOutput = "Enabled" | "Disabled" | string; +export type LocalAdminStatusOutput = string; // @public -export type OperationStateOutput = "NotStarted" | "Running" | "Succeeded" | "Failed" | "Canceled"; +export type OperationStateOutput = string; // @public export interface OperationStatusOutput { @@ -1352,40 +1355,82 @@ export interface OsDiskOutput { } // @public -export type OsType = "Windows" | string; +export type OsType = string; // @public -export type OsTypeOutput = "Windows" | string; +export type OsTypeOutput = string; // @public -export type PagedCatalogOutput = Paged; +export interface PagedAsyncIterableIterator { + [Symbol.asyncIterator](): PagedAsyncIterableIterator; + byPage: (settings?: TPageSettings) => AsyncIterableIterator; + next(): Promise>; +} // @public -export type PagedDevBoxActionDelayResultOutput = Paged; +export interface PagedCatalogOutput { + nextLink?: string; + value: Array; +} // @public -export type PagedDevBoxActionOutput = Paged; +export interface PagedDevBoxActionDelayResultOutput { + nextLink?: string; + value: Array; +} // @public -export type PagedDevBoxOutput = Paged; +export interface PagedDevBoxActionOutput { + nextLink?: string; + value: Array; +} // @public -export type PagedEnvironmentDefinitionOutput = Paged; +export interface PagedDevBoxOutput { + nextLink?: string; + value: Array; +} // @public -export type PagedEnvironmentOutput = Paged; +export interface PagedEnvironmentDefinitionOutput { + nextLink?: string; + value: Array; +} // @public -export type PagedEnvironmentTypeOutput = Paged; +export interface PagedEnvironmentOutput { + nextLink?: string; + value: Array; +} // @public -export type PagedPoolOutput = Paged; +export interface PagedEnvironmentTypeOutput { + nextLink?: string; + value: Array; +} // @public -export type PagedProjectOutput = Paged; +export interface PagedPoolOutput { + nextLink?: string; + value: Array; +} + +// @public +export interface PagedProjectOutput { + nextLink?: string; + value: Array; +} // @public -export type PagedScheduleOutput = Paged; +export interface PagedScheduleOutput { + nextLink?: string; + value: Array; +} + +// @public +export interface PageSettings { + continuationToken?: string; +} // @public export function paginate(client: Client, initialResponse: TResponse, options?: PagingOptions): PagedAsyncIterableIterator>; @@ -1403,10 +1448,10 @@ export interface PagingOptions { } // @public -export type ParameterTypeOutput = "array" | "boolean" | "integer" | "number" | "object" | "string" | string; +export type ParameterTypeOutput = string; // @public -export type PoolHealthStatusOutput = "Unknown" | "Pending" | "Healthy" | "Warning" | "Unhealthy" | string; +export type PoolHealthStatusOutput = string; // @public export interface PoolOutput { @@ -1423,10 +1468,10 @@ export interface PoolOutput { } // @public -export type PowerState = "Unknown" | "Running" | "Deallocated" | "PoweredOff" | "Hibernated" | string; +export type PowerState = string; // @public -export type PowerStateOutput = "Unknown" | "Running" | "Deallocated" | "PoweredOff" | "Hibernated" | string; +export type PowerStateOutput = string; // @public export interface ProjectOutput { @@ -1521,10 +1566,10 @@ export interface Routes { } // @public -export type ScheduledFrequencyOutput = "Daily" | string; +export type ScheduledFrequencyOutput = string; // @public -export type ScheduledTypeOutput = "StopDevBox" | string; +export type ScheduledTypeOutput = string; // @public export interface ScheduleOutput { @@ -1587,10 +1632,10 @@ export interface SkipActionDefaultResponse extends HttpResponse { export type SkipActionParameters = RequestParameters; // @public -export type SkuName = "general_i_8c32gb256ssd_v2" | "general_i_8c32gb512ssd_v2" | "general_i_8c32gb1024ssd_v2" | "general_i_8c32gb2048ssd_v2" | "general_i_16c64gb256ssd_v2" | "general_i_16c64gb512ssd_v2" | "general_i_16c64gb1024ssd_v2" | "general_i_16c64gb2048ssd_v2" | "general_i_32c128gb512ssd_v2" | "general_i_32c128gb1024ssd_v2" | "general_i_32c128gb2048ssd_v2" | "general_a_8c32gb256ssd_v2" | "general_a_8c32gb512ssd_v2" | "general_a_8c32gb1024ssd_v2" | "general_a_8c32gb2048ssd_v2" | "general_a_16c64gb256ssd_v2" | "general_a_16c64gb512ssd_v2" | "general_a_16c64gb1024ssd_v2" | "general_a_16c64gb2048ssd_v2" | "general_a_32c128gb512ssd_v2" | "general_a_32c128gb1024ssd_v2" | "general_a_32c128gb2048ssd_v2" | string; +export type SkuName = string; // @public -export type SkuNameOutput = "general_i_8c32gb256ssd_v2" | "general_i_8c32gb512ssd_v2" | "general_i_8c32gb1024ssd_v2" | "general_i_8c32gb2048ssd_v2" | "general_i_16c64gb256ssd_v2" | "general_i_16c64gb512ssd_v2" | "general_i_16c64gb1024ssd_v2" | "general_i_16c64gb2048ssd_v2" | "general_i_32c128gb512ssd_v2" | "general_i_32c128gb1024ssd_v2" | "general_i_32c128gb2048ssd_v2" | "general_a_8c32gb256ssd_v2" | "general_a_8c32gb512ssd_v2" | "general_a_8c32gb1024ssd_v2" | "general_a_8c32gb2048ssd_v2" | "general_a_16c64gb256ssd_v2" | "general_a_16c64gb512ssd_v2" | "general_a_16c64gb1024ssd_v2" | "general_a_16c64gb2048ssd_v2" | "general_a_32c128gb512ssd_v2" | "general_a_32c128gb1024ssd_v2" | "general_a_32c128gb2048ssd_v2" | string; +export type SkuNameOutput = string; // @public (undocumented) export interface StartDevBox { @@ -1702,7 +1747,7 @@ export interface StopOnDisconnectConfigurationOutput { } // @public -export type StopOnDisconnectEnableStatusOutput = "Enabled" | "Disabled" | string; +export type StopOnDisconnectEnableStatusOutput = string; // @public export interface StorageProfile { diff --git a/sdk/devcenter/developer-devcenter-rest/sample.env b/sdk/devcenter/developer-devcenter-rest/sample.env index 8aac9140677e..508439fc7d62 100644 --- a/sdk/devcenter/developer-devcenter-rest/sample.env +++ b/sdk/devcenter/developer-devcenter-rest/sample.env @@ -1 +1 @@ -DEVCENTER_ENDPOINT= \ No newline at end of file +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/devcenter/developer-devcenter-rest/src/azureDeveloperDevCenter.ts b/sdk/devcenter/developer-devcenter-rest/src/azureDeveloperDevCenter.ts index 5cee288a02cf..7aaf406c643f 100644 --- a/sdk/devcenter/developer-devcenter-rest/src/azureDeveloperDevCenter.ts +++ b/sdk/devcenter/developer-devcenter-rest/src/azureDeveloperDevCenter.ts @@ -7,6 +7,12 @@ import { logger } from "./logger.js"; import type { TokenCredential } from "@azure/core-auth"; import type { AzureDeveloperDevCenterClient } from "./clientDefinitions.js"; +/** The optional parameters for the client */ +export interface AzureDeveloperDevCenterClientOptions extends ClientOptions { + /** The api version option of the client */ + apiVersion?: string; +} + /** * Initialize a new instance of `AzureDeveloperDevCenterClient` * @param endpointParam - The DevCenter-specific URI to operate on. @@ -16,11 +22,10 @@ import type { AzureDeveloperDevCenterClient } from "./clientDefinitions.js"; export default function createClient( endpointParam: string, credentials: TokenCredential, - options: ClientOptions = {}, + { apiVersion = "2023-04-01", ...options }: AzureDeveloperDevCenterClientOptions = {}, ): AzureDeveloperDevCenterClient { const endpointUrl = options.endpoint ?? options.baseUrl ?? `${endpointParam}`; - options.apiVersion = options.apiVersion ?? "2023-04-01"; - const userAgentInfo = `azsdk-js-developer-devcenter-rest/1.0.0`; + const userAgentInfo = `azsdk-js-developer-devcenter-rest/1.0.1`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}` @@ -37,8 +42,24 @@ export default function createClient( scopes: options.credentials?.scopes ?? ["https://devcenter.azure.com/.default"], }, }; - const client = getClient(endpointUrl, credentials, options) as AzureDeveloperDevCenterClient; + 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/devcenter/developer-devcenter-rest/src/models.ts b/sdk/devcenter/developer-devcenter-rest/src/models.ts index 5cc3f6631828..6ec8cb1b34d2 100644 --- a/sdk/devcenter/developer-devcenter-rest/src/models.ts +++ b/sdk/devcenter/developer-devcenter-rest/src/models.ts @@ -20,7 +20,11 @@ export interface ImageReference {} export interface DevBox { /** The name of the Dev Box pool this machine belongs to. */ poolName: string; - /** Indicates whether the owner of the Dev Box is a local administrator. */ + /** + * Indicates whether the owner of the Dev Box is a local administrator. + * + * Possible values: "Enabled", "Disabled" + */ localAdministrator?: LocalAdminStatus; } @@ -37,72 +41,16 @@ export interface Environment { } /** Alias for OsType */ -export type OsType = "Windows" | string; +export type OsType = string; /** Alias for SkuName */ -export type SkuName = - | "general_i_8c32gb256ssd_v2" - | "general_i_8c32gb512ssd_v2" - | "general_i_8c32gb1024ssd_v2" - | "general_i_8c32gb2048ssd_v2" - | "general_i_16c64gb256ssd_v2" - | "general_i_16c64gb512ssd_v2" - | "general_i_16c64gb1024ssd_v2" - | "general_i_16c64gb2048ssd_v2" - | "general_i_32c128gb512ssd_v2" - | "general_i_32c128gb1024ssd_v2" - | "general_i_32c128gb2048ssd_v2" - | "general_a_8c32gb256ssd_v2" - | "general_a_8c32gb512ssd_v2" - | "general_a_8c32gb1024ssd_v2" - | "general_a_8c32gb2048ssd_v2" - | "general_a_16c64gb256ssd_v2" - | "general_a_16c64gb512ssd_v2" - | "general_a_16c64gb1024ssd_v2" - | "general_a_16c64gb2048ssd_v2" - | "general_a_32c128gb512ssd_v2" - | "general_a_32c128gb1024ssd_v2" - | "general_a_32c128gb2048ssd_v2" - | string; +export type SkuName = string; /** Alias for HibernateSupport */ -export type HibernateSupport = "Enabled" | "Disabled" | "OsUnsupported" | string; +export type HibernateSupport = string; /** Alias for LocalAdminStatus */ -export type LocalAdminStatus = "Enabled" | "Disabled" | string; +export type LocalAdminStatus = string; /** Alias for DevBoxProvisioningState */ -export type DevBoxProvisioningState = - | "Succeeded" - | "Failed" - | "Canceled" - | "Creating" - | "Deleting" - | "Updating" - | "Starting" - | "Stopping" - | "Provisioning" - | "ProvisionedWithWarning" - | "InGracePeriod" - | "NotProvisioned" - | string; +export type DevBoxProvisioningState = string; /** Alias for PowerState */ -export type PowerState = - | "Unknown" - | "Running" - | "Deallocated" - | "PoweredOff" - | "Hibernated" - | string; +export type PowerState = string; /** Alias for EnvironmentProvisioningState */ -export type EnvironmentProvisioningState = - | "Succeeded" - | "Failed" - | "Canceled" - | "Creating" - | "Accepted" - | "Deleting" - | "Updating" - | "Preparing" - | "Running" - | "Syncing" - | "MovingResources" - | "TransientFailure" - | "StorageProvisioningFailed" - | string; +export type EnvironmentProvisioningState = string; diff --git a/sdk/devcenter/developer-devcenter-rest/src/outputModels.ts b/sdk/devcenter/developer-devcenter-rest/src/outputModels.ts index 2ee29c1db672..bd8507e52a65 100644 --- a/sdk/devcenter/developer-devcenter-rest/src/outputModels.ts +++ b/sdk/devcenter/developer-devcenter-rest/src/outputModels.ts @@ -1,9 +1,16 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Paged } from "@azure/core-paging"; import type { ErrorModel } from "@azure-rest/core-client"; +/** Paged collection of Project items */ +export interface PagedProjectOutput { + /** The Project items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + /** Project details. */ export interface ProjectOutput { /** Name of the project. */ @@ -23,13 +30,17 @@ export interface OperationStatusOutput { readonly id: string; /** The operation id name. */ readonly name: string; - /** Provisioning state of the resource. */ + /** + * Provisioning state of the resource. + * + * Possible values: "NotStarted", "Running", "Succeeded", "Failed", "Canceled" + */ status: OperationStateOutput; /** The id of the resource. */ resourceId?: string; - /** The start time of the operation. */ + /** The start time of the operation, in RFC3339 format. */ startTime?: string; - /** The end time of the operation. */ + /** The end time of the operation, in RFC3339 format. */ endTime?: string; /** Percent of the operation that is complete. */ percentComplete?: number; @@ -39,17 +50,33 @@ export interface OperationStatusOutput { error?: ErrorModel; } +/** Paged collection of Pool items */ +export interface PagedPoolOutput { + /** The Pool items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + /** A pool of Dev Boxes. */ export interface PoolOutput { /** Pool name. */ readonly name: string; /** Azure region where Dev Boxes in the pool are located. */ location: string; - /** The operating system type of Dev Boxes in this pool. */ + /** + * The operating system type of Dev Boxes in this pool. + * + * Possible values: "Windows" + */ osType?: OsTypeOutput; /** Hardware settings for the Dev Boxes created in this pool. */ hardwareProfile?: HardwareProfileOutput; - /** Indicates whether hibernate is enabled/disabled or unknown. */ + /** + * Indicates whether hibernate is enabled/disabled or unknown. + * + * Possible values: "Enabled", "Disabled", "OsUnsupported" + */ hibernateSupport?: HibernateSupportOutput; /** Storage settings for Dev Box created in this pool. */ storageProfile?: StorageProfileOutput; @@ -58,6 +85,8 @@ export interface PoolOutput { /** * Indicates whether owners of Dev Boxes in this pool are local administrators on * the Dev Boxes. + * + * Possible values: "Enabled", "Disabled" */ localAdministrator?: LocalAdminStatusOutput; /** Stop on disconnect configuration settings for Dev Boxes created in this pool. */ @@ -65,13 +94,19 @@ export interface PoolOutput { /** * Overall health status of the Pool. Indicates whether or not the Pool is * available to create Dev Boxes. + * + * Possible values: "Unknown", "Pending", "Healthy", "Warning", "Unhealthy" */ healthStatus: PoolHealthStatusOutput; } /** Hardware specifications for the Dev Box. */ export interface HardwareProfileOutput { - /** The name of the SKU. */ + /** + * The name of the SKU. + * + * Possible values: "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", "general_a_32c128gb1024ssd_v2", "general_a_32c128gb2048ssd_v2" + */ readonly skuName?: SkuNameOutput; /** The number of vCPUs available for the Dev Box. */ readonly vCPUs?: number; @@ -101,7 +136,7 @@ export interface ImageReferenceOutput { readonly operatingSystem?: string; /** The operating system build number of the image. */ readonly osBuildNumber?: string; - /** The datetime that the backing image version was published. */ + /** The datetime that the backing image version was published, in RFC3339 format. */ readonly publishedDate?: string; } @@ -110,6 +145,8 @@ export interface StopOnDisconnectConfigurationOutput { /** * Indicates whether the feature to stop the devbox on disconnect once the grace * period has lapsed is enabled. + * + * Possible values: "Enabled", "Disabled" */ status: StopOnDisconnectEnableStatusOutput; /** @@ -119,6 +156,14 @@ export interface StopOnDisconnectConfigurationOutput { gracePeriodMinutes?: number; } +/** Paged collection of DevBox items */ +export interface PagedDevBoxOutput { + /** The DevBox items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + /** A Dev Box. */ export interface DevBoxOutput { /** Display name for the Dev Box. */ @@ -127,16 +172,28 @@ export interface DevBoxOutput { readonly projectName?: string; /** The name of the Dev Box pool this machine belongs to. */ poolName: string; - /** Indicates whether hibernate is enabled/disabled or unknown. */ + /** + * Indicates whether hibernate is enabled/disabled or unknown. + * + * Possible values: "Enabled", "Disabled", "OsUnsupported" + */ readonly hibernateSupport?: HibernateSupportOutput; - /** The current provisioning state of the Dev Box. */ + /** + * The current provisioning state of the Dev Box. + * + * Possible values: "Succeeded", "Failed", "Canceled", "Creating", "Deleting", "Updating", "Starting", "Stopping", "Provisioning", "ProvisionedWithWarning", "InGracePeriod", "NotProvisioned" + */ readonly provisioningState?: DevBoxProvisioningStateOutput; /** * The current action state of the Dev Box. This is state is based on previous * action performed by user. */ readonly actionState?: string; - /** The current power state of the Dev Box. */ + /** + * The current power state of the Dev Box. + * + * Possible values: "Unknown", "Running", "Deallocated", "PoweredOff", "Hibernated" + */ readonly powerState?: PowerStateOutput; /** * A unique identifier for the Dev Box. This is a GUID-formatted string (e.g. @@ -150,7 +207,11 @@ export interface DevBoxOutput { * Virtual Network it is attached to. */ readonly location?: string; - /** The operating system type of this Dev Box. */ + /** + * The operating system type of this Dev Box. + * + * Possible values: "Windows" + */ readonly osType?: OsTypeOutput; /** The AAD object id of the user this Dev Box is assigned to. */ readonly user?: string; @@ -160,19 +221,39 @@ export interface DevBoxOutput { readonly storageProfile?: StorageProfileOutput; /** Information about the image used for this Dev Box. */ readonly imageReference?: ImageReferenceOutput; - /** Creation time of this Dev Box. */ + /** Creation time of this Dev Box, in RFC3339 format. */ readonly createdTime?: string; - /** Indicates whether the owner of the Dev Box is a local administrator. */ + /** + * Indicates whether the owner of the Dev Box is a local administrator. + * + * Possible values: "Enabled", "Disabled" + */ localAdministrator?: LocalAdminStatusOutput; } +/** Paged collection of Schedule items */ +export interface PagedScheduleOutput { + /** The Schedule items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + /** A Schedule to execute action. */ export interface ScheduleOutput { /** Display name for the Schedule. */ readonly name: string; - /** Supported type this scheduled task represents. */ + /** + * Supported type this scheduled task represents. + * + * Possible values: "StopDevBox" + */ type: ScheduledTypeOutput; - /** The frequency of this scheduled task. */ + /** + * The frequency of this scheduled task. + * + * Possible values: "Daily" + */ frequency: ScheduledFrequencyOutput; /** The target time to trigger the action. The format is HH:MM. */ time: string; @@ -188,15 +269,27 @@ export interface RemoteConnectionOutput { rdpConnectionUrl?: string; } +/** Paged collection of DevBoxAction items */ +export interface PagedDevBoxActionOutput { + /** The DevBoxAction items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + /** An action which will take place on a Dev Box. */ export interface DevBoxActionOutput { /** The name of the action. */ readonly name: string; - /** The action that will be taken. */ + /** + * The action that will be taken. + * + * Possible values: "Stop" + */ actionType: DevBoxActionTypeOutput; /** The id of the resource which triggered this action. */ sourceId: string; - /** The earliest time that the action could occur (UTC). */ + /** The earliest time that the action could occur (UTC), in RFC3339 format. */ suspendedUntil?: string; /** Details about the next run of this action. */ next?: DevBoxNextActionOutput; @@ -204,15 +297,27 @@ export interface DevBoxActionOutput { /** Details about the next run of an action. */ export interface DevBoxNextActionOutput { - /** The time the action will be triggered (UTC). */ + /** The time the action will be triggered (UTC), in RFC3339 format. */ scheduledTime: string; } +/** Paged collection of DevBoxActionDelayResult items */ +export interface PagedDevBoxActionDelayResultOutput { + /** The DevBoxActionDelayResult items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + /** The action delay result. */ export interface DevBoxActionDelayResultOutput { /** The name of the action. */ name: string; - /** The result of the delay operation on this action. */ + /** + * The result of the delay operation on this action. + * + * Possible values: "Succeeded", "Failed" + */ result: DevBoxActionDelayResultStatusOutput; /** The delayed action. */ action?: DevBoxActionOutput; @@ -220,6 +325,14 @@ export interface DevBoxActionDelayResultOutput { error?: ErrorModel; } +/** 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; +} + /** Properties of an environment. */ export interface EnvironmentOutput { /** Parameters object for the environment. */ @@ -230,7 +343,11 @@ export interface EnvironmentOutput { environmentType: string; /** The AAD object id of the owner of this Environment. */ readonly user?: string; - /** The provisioning state of the environment. */ + /** + * The provisioning state of the environment. + * + * Possible values: "Succeeded", "Failed", "Canceled", "Creating", "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", "MovingResources", "TransientFailure", "StorageProvisioningFailed" + */ readonly provisioningState?: EnvironmentProvisioningStateOutput; /** The identifier of the resource group containing the environment's resources. */ readonly resourceGroupId?: string; @@ -242,12 +359,28 @@ export interface EnvironmentOutput { readonly error?: ErrorModel; } +/** Paged collection of Catalog items */ +export interface PagedCatalogOutput { + /** The Catalog items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + /** A catalog. */ export interface CatalogOutput { /** Name of the catalog. */ readonly name: string; } +/** Paged collection of EnvironmentDefinition items */ +export interface PagedEnvironmentDefinitionOutput { + /** The EnvironmentDefinition items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + /** An environment definition. */ export interface EnvironmentDefinitionOutput { /** The ID of the environment definition. */ @@ -279,6 +412,8 @@ export interface EnvironmentDefinitionParameterOutput { /** * A string of one of the basic JSON types (number, integer, array, object, * boolean, string). + * + * Possible values: "array", "boolean", "integer", "number", "object", "string" */ type: ParameterTypeOutput; /** @@ -292,6 +427,14 @@ export interface EnvironmentDefinitionParameterOutput { allowed?: string[]; } +/** Paged collection of EnvironmentType items */ +export interface PagedEnvironmentTypeOutput { + /** The EnvironmentType items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + /** Properties of an environment type. */ export interface EnvironmentTypeOutput { /** Name of the environment type. */ @@ -302,128 +445,43 @@ export interface EnvironmentTypeOutput { * or management group. */ deploymentTargetId: string; - /** Indicates whether this environment type is enabled for use in this project. */ + /** + * Indicates whether this environment type is enabled for use in this project. + * + * Possible values: "Enabled", "Disabled" + */ status: EnvironmentTypeEnableStatusOutput; } -/** Paged collection of Project items */ -export type PagedProjectOutput = Paged; -/** Enum describing allowed operation states. */ -export type OperationStateOutput = "NotStarted" | "Running" | "Succeeded" | "Failed" | "Canceled"; -/** Paged collection of Pool items */ -export type PagedPoolOutput = Paged; +/** Alias for OperationStateOutput */ +export type OperationStateOutput = string; /** Alias for OsTypeOutput */ -export type OsTypeOutput = "Windows" | string; +export type OsTypeOutput = string; /** Alias for SkuNameOutput */ -export type SkuNameOutput = - | "general_i_8c32gb256ssd_v2" - | "general_i_8c32gb512ssd_v2" - | "general_i_8c32gb1024ssd_v2" - | "general_i_8c32gb2048ssd_v2" - | "general_i_16c64gb256ssd_v2" - | "general_i_16c64gb512ssd_v2" - | "general_i_16c64gb1024ssd_v2" - | "general_i_16c64gb2048ssd_v2" - | "general_i_32c128gb512ssd_v2" - | "general_i_32c128gb1024ssd_v2" - | "general_i_32c128gb2048ssd_v2" - | "general_a_8c32gb256ssd_v2" - | "general_a_8c32gb512ssd_v2" - | "general_a_8c32gb1024ssd_v2" - | "general_a_8c32gb2048ssd_v2" - | "general_a_16c64gb256ssd_v2" - | "general_a_16c64gb512ssd_v2" - | "general_a_16c64gb1024ssd_v2" - | "general_a_16c64gb2048ssd_v2" - | "general_a_32c128gb512ssd_v2" - | "general_a_32c128gb1024ssd_v2" - | "general_a_32c128gb2048ssd_v2" - | string; +export type SkuNameOutput = string; /** Alias for HibernateSupportOutput */ -export type HibernateSupportOutput = "Enabled" | "Disabled" | "OsUnsupported" | string; +export type HibernateSupportOutput = string; /** Alias for LocalAdminStatusOutput */ -export type LocalAdminStatusOutput = "Enabled" | "Disabled" | string; +export type LocalAdminStatusOutput = string; /** Alias for StopOnDisconnectEnableStatusOutput */ -export type StopOnDisconnectEnableStatusOutput = "Enabled" | "Disabled" | string; +export type StopOnDisconnectEnableStatusOutput = string; /** Alias for PoolHealthStatusOutput */ -export type PoolHealthStatusOutput = - | "Unknown" - | "Pending" - | "Healthy" - | "Warning" - | "Unhealthy" - | string; -/** Paged collection of DevBox items */ -export type PagedDevBoxOutput = Paged; +export type PoolHealthStatusOutput = string; /** Alias for DevBoxProvisioningStateOutput */ -export type DevBoxProvisioningStateOutput = - | "Succeeded" - | "Failed" - | "Canceled" - | "Creating" - | "Deleting" - | "Updating" - | "Starting" - | "Stopping" - | "Provisioning" - | "ProvisionedWithWarning" - | "InGracePeriod" - | "NotProvisioned" - | string; +export type DevBoxProvisioningStateOutput = string; /** Alias for PowerStateOutput */ -export type PowerStateOutput = - | "Unknown" - | "Running" - | "Deallocated" - | "PoweredOff" - | "Hibernated" - | string; -/** Paged collection of Schedule items */ -export type PagedScheduleOutput = Paged; +export type PowerStateOutput = string; /** Alias for ScheduledTypeOutput */ -export type ScheduledTypeOutput = "StopDevBox" | string; +export type ScheduledTypeOutput = string; /** Alias for ScheduledFrequencyOutput */ -export type ScheduledFrequencyOutput = "Daily" | string; -/** Paged collection of DevBoxAction items */ -export type PagedDevBoxActionOutput = Paged; +export type ScheduledFrequencyOutput = string; /** Alias for DevBoxActionTypeOutput */ -export type DevBoxActionTypeOutput = "Stop" | string; -/** Paged collection of DevBoxActionDelayResult items */ -export type PagedDevBoxActionDelayResultOutput = Paged; +export type DevBoxActionTypeOutput = string; /** Alias for DevBoxActionDelayResultStatusOutput */ -export type DevBoxActionDelayResultStatusOutput = "Succeeded" | "Failed" | string; -/** Paged collection of Environment items */ -export type PagedEnvironmentOutput = Paged; +export type DevBoxActionDelayResultStatusOutput = string; /** Alias for EnvironmentProvisioningStateOutput */ -export type EnvironmentProvisioningStateOutput = - | "Succeeded" - | "Failed" - | "Canceled" - | "Creating" - | "Accepted" - | "Deleting" - | "Updating" - | "Preparing" - | "Running" - | "Syncing" - | "MovingResources" - | "TransientFailure" - | "StorageProvisioningFailed" - | string; -/** Paged collection of Catalog items */ -export type PagedCatalogOutput = Paged; -/** Paged collection of EnvironmentDefinition items */ -export type PagedEnvironmentDefinitionOutput = Paged; +export type EnvironmentProvisioningStateOutput = string; /** Alias for ParameterTypeOutput */ -export type ParameterTypeOutput = - | "array" - | "boolean" - | "integer" - | "number" - | "object" - | "string" - | string; -/** Paged collection of EnvironmentType items */ -export type PagedEnvironmentTypeOutput = Paged; +export type ParameterTypeOutput = string; /** Alias for EnvironmentTypeEnableStatusOutput */ -export type EnvironmentTypeEnableStatusOutput = "Enabled" | "Disabled" | string; +export type EnvironmentTypeEnableStatusOutput = string; diff --git a/sdk/devcenter/developer-devcenter-rest/src/paginateHelper.ts b/sdk/devcenter/developer-devcenter-rest/src/paginateHelper.ts index 5d541b4e406d..9ea946d9d6c5 100644 --- a/sdk/devcenter/developer-devcenter-rest/src/paginateHelper.ts +++ b/sdk/devcenter/developer-devcenter-rest/src/paginateHelper.ts @@ -1,11 +1,148 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { PagedAsyncIterableIterator, PagedResult } from "@azure/core-paging"; -import { getPagedAsyncIterator } from "@azure/core-paging"; import type { Client, PathUncheckedResponse } from "@azure-rest/core-client"; import { createRestError } 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; + /** + * 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 */ @@ -14,10 +151,7 @@ export type GetArrayType = T extends Array ? TData : never; /** * The type of a custom function that defines how to get a page and a link to the next one if any. */ -export type GetPage = ( - pageLink: string, - maxPageSize?: number, -) => Promise<{ +export type GetPage = (pageLink: string) => Promise<{ page: TPage; nextPageLink?: string; }>; diff --git a/sdk/devcenter/developer-devcenter-rest/src/parameters.ts b/sdk/devcenter/developer-devcenter-rest/src/parameters.ts index 4a119290acb1..38510c3ffbdf 100644 --- a/sdk/devcenter/developer-devcenter-rest/src/parameters.ts +++ b/sdk/devcenter/developer-devcenter-rest/src/parameters.ts @@ -42,7 +42,7 @@ export type GetActionParameters = RequestParameters; export type SkipActionParameters = RequestParameters; export interface DelayActionQueryParamProperties { - /** The time to delay the Dev Box action or actions until. */ + /** The time to delay the Dev Box action or actions until, in RFC3339 format. */ until: Date | string; } @@ -53,7 +53,7 @@ export interface DelayActionQueryParam { export type DelayActionParameters = DelayActionQueryParam & RequestParameters; export interface DelayActionsQueryParamProperties { - /** The time to delay the Dev Box action or actions until. */ + /** The time to delay the Dev Box action or actions until, in RFC3339 format. */ until: Date | string; } diff --git a/sdk/devcenter/developer-devcenter-rest/test/public/utils/env.browser.ts b/sdk/devcenter/developer-devcenter-rest/test/public/utils/env.browser.ts deleted file mode 100644 index fc36ab244fad..000000000000 --- a/sdk/devcenter/developer-devcenter-rest/test/public/utils/env.browser.ts +++ /dev/null @@ -1,2 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. diff --git a/sdk/devcenter/developer-devcenter-rest/test/public/utils/env.ts b/sdk/devcenter/developer-devcenter-rest/test/public/utils/env.ts deleted file mode 100644 index 866412f4082d..000000000000 --- a/sdk/devcenter/developer-devcenter-rest/test/public/utils/env.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import * as dotenv from "dotenv"; - -dotenv.config(); diff --git a/sdk/devcenter/developer-devcenter-rest/test/public/utils/recordedClient.ts b/sdk/devcenter/developer-devcenter-rest/test/public/utils/recordedClient.ts index b7b4220b4e91..0f53a50a03c1 100644 --- a/sdk/devcenter/developer-devcenter-rest/test/public/utils/recordedClient.ts +++ b/sdk/devcenter/developer-devcenter-rest/test/public/utils/recordedClient.ts @@ -4,7 +4,6 @@ import { type TaskContext } from "vitest"; import type { RecorderStartOptions } from "@azure-tools/test-recorder"; import { isPlaybackMode, Recorder } from "@azure-tools/test-recorder"; -import "./env"; import type { AzureDeveloperDevCenterClient } from "../../../src/clientDefinitions.js"; import type { ClientOptions } from "@azure-rest/core-client"; import { AzurePowerShellCredential } from "@azure/identity"; diff --git a/sdk/devcenter/developer-devcenter-rest/tsconfig.json b/sdk/devcenter/developer-devcenter-rest/tsconfig.json index 273d9078a24a..19ceb382b521 100644 --- a/sdk/devcenter/developer-devcenter-rest/tsconfig.json +++ b/sdk/devcenter/developer-devcenter-rest/tsconfig.json @@ -1,7 +1,13 @@ { "references": [ - { "path": "./tsconfig.src.json" }, - { "path": "./tsconfig.samples.json" }, - { "path": "./tsconfig.test.json" } + { + "path": "./tsconfig.src.json" + }, + { + "path": "./tsconfig.samples.json" + }, + { + "path": "./tsconfig.test.json" + } ] } diff --git a/sdk/devcenter/developer-devcenter-rest/tsp-location.yaml b/sdk/devcenter/developer-devcenter-rest/tsp-location.yaml index 51144d95c5c6..beffe9b98218 100644 --- a/sdk/devcenter/developer-devcenter-rest/tsp-location.yaml +++ b/sdk/devcenter/developer-devcenter-rest/tsp-location.yaml @@ -1,3 +1,4 @@ directory: specification/devcenter/DevCenter commit: 3dbffd014194b1985f6498b259fe8d91461c898c -repo: Azure/azure-rest-api-specs \ No newline at end of file +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/devcenter/developer-devcenter-rest/vitest.browser.config.ts b/sdk/devcenter/developer-devcenter-rest/vitest.browser.config.ts index 3be6992329dc..da68c1d231aa 100644 --- a/sdk/devcenter/developer-devcenter-rest/vitest.browser.config.ts +++ b/sdk/devcenter/developer-devcenter-rest/vitest.browser.config.ts @@ -2,6 +2,9 @@ // 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: { @@ -29,5 +32,7 @@ export default defineConfig({ reporter: ["text", "json", "html"], reportsDirectory: "coverage-browser", }, + testTimeout: 1200000, + hookTimeout: 1200000, }, }); diff --git a/sdk/devcenter/developer-devcenter-rest/vitest.config.ts b/sdk/devcenter/developer-devcenter-rest/vitest.config.ts index 0dfa15cc4498..2cf5d0e02c2e 100644 --- a/sdk/devcenter/developer-devcenter-rest/vitest.config.ts +++ b/sdk/devcenter/developer-devcenter-rest/vitest.config.ts @@ -1,6 +1,34 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import viteConfig from "../../../vitest.shared.config.ts"; +import { defineConfig } from "vitest/config"; +import { relativeRecordingsPath } from "@azure-tools/test-recorder"; -export default viteConfig; +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, + }, +});