diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index dff0313f8f2d..315595f6582d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1644,6 +1644,9 @@ sdk/compute/arm-computerecommender/ @qiaozha @MaryGao @JialinHuang803 # PRLabel: %Mgmt sdk/computelimit/arm-computelimit/ @qiaozha @MaryGao @JialinHuang803 +# PRLabel: %Mgmt +sdk/edgemarketplace/arm-edgemarketplace/ @qiaozha @MaryGao @JialinHuang803 + ########### # Config ########### diff --git a/eng/ignore-links.txt b/eng/ignore-links.txt index 7491206b3b10..4a5e83d912eb 100644 --- a/eng/ignore-links.txt +++ b/eng/ignore-links.txt @@ -53,3 +53,4 @@ https://learn.microsoft.com/javascript/api/@azure/arm-computerecommender?view=az https://learn.microsoft.com/javascript/api/@azure/arm-computelimit?view=azure-node-preview https://learn.microsoft.com/javascript/api/@azure/arm-certificateregistration?view=azure-node-preview https://learn.microsoft.com/javascript/api/@azure/arm-domainregistration?view=azure-node-preview +https://learn.microsoft.com/javascript/api/@azure/arm-edgemarketplace?view=azure-node-preview diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9ae538f9b473..ba1a3b07f4fd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12022,6 +12022,88 @@ importers: specifier: catalog:testing version: 4.0.16(@opentelemetry/api@1.9.0)(@types/node@20.19.27)(@vitest/browser-playwright@4.0.16)(jsdom@16.7.0)(msw@2.7.3(@types/node@20.19.27)(typescript@5.9.3))(terser@5.39.0)(tsx@4.21.0)(yaml@2.8.2) + sdk/edgemarketplace/arm-edgemarketplace: + dependencies: + '@azure-rest/core-client': + specifier: ^2.3.1 + version: link:../../core/core-client-rest + '@azure/abort-controller': + specifier: ^2.1.2 + version: link:../../core/abort-controller + '@azure/core-auth': + specifier: ^1.9.0 + version: link:../../core/core-auth + '@azure/core-lro': + specifier: ^3.1.0 + version: link:../../core/core-lro + '@azure/core-rest-pipeline': + specifier: ^1.20.0 + version: link:../../core/core-rest-pipeline + '@azure/core-util': + specifier: ^1.12.0 + version: link:../../core/core-util + '@azure/logger': + specifier: ^1.2.0 + version: link:../../core/logger + tslib: + specifier: ^2.8.1 + version: 2.8.1 + devDependencies: + '@azure-tools/test-credential': + specifier: workspace:^ + version: link:../../test-utils/test-credential + '@azure-tools/test-recorder': + specifier: workspace:^ + version: link:../../test-utils/recorder + '@azure-tools/test-utils-vitest': + specifier: workspace:^ + version: link:../../test-utils/test-utils-vitest + '@azure/dev-tool': + specifier: workspace:^ + version: link:../../../common/tools/dev-tool + '@azure/eslint-plugin-azure-sdk': + specifier: workspace:^ + version: link:../../../common/tools/eslint-plugin-azure-sdk + '@azure/identity': + specifier: catalog:internal + version: 4.13.0 + '@types/node': + specifier: 'catalog:' + version: 20.19.27 + '@vitest/browser-playwright': + specifier: catalog:testing + version: 4.0.16(msw@2.7.3(@types/node@20.19.27)(typescript@5.9.3))(playwright@1.57.0)(vite@7.3.0(@types/node@20.19.27)(terser@5.39.0)(tsx@4.21.0)(yaml@2.8.2))(vitest@4.0.16) + '@vitest/coverage-istanbul': + specifier: catalog:testing + version: 4.0.16(vitest@4.0.16) + cross-env: + specifier: 'catalog:' + version: 10.1.0 + dotenv: + specifier: catalog:testing + version: 16.6.1 + eslint: + specifier: 'catalog:' + version: 9.39.2 + playwright: + specifier: catalog:testing + version: 1.57.0 + prettier: + specifier: 'catalog:' + version: 3.7.4 + rimraf: + specifier: 'catalog:' + version: 6.1.2 + tshy: + specifier: 'catalog:' + version: 3.1.0 + typescript: + specifier: 'catalog:' + version: 5.9.3 + vitest: + specifier: catalog:testing + version: 4.0.16(@opentelemetry/api@1.9.0)(@types/node@20.19.27)(@vitest/browser-playwright@4.0.16)(jsdom@16.7.0)(msw@2.7.3(@types/node@20.19.27)(typescript@5.9.3))(terser@5.39.0)(tsx@4.21.0)(yaml@2.8.2) + sdk/edgezones/arm-edgezones: dependencies: '@azure-rest/core-client': diff --git a/sdk/edgemarketplace/arm-edgemarketplace/CHANGELOG.md b/sdk/edgemarketplace/arm-edgemarketplace/CHANGELOG.md new file mode 100644 index 000000000000..b61e600ff371 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 1.0.0-beta.1 (2026-01-14) + +### Features Added + +Initial release of the @azure/arm-edgemarketplace package diff --git a/sdk/edgemarketplace/arm-edgemarketplace/LICENSE b/sdk/edgemarketplace/arm-edgemarketplace/LICENSE new file mode 100644 index 000000000000..63447fd8bbbf --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +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/edgemarketplace/arm-edgemarketplace/README.md b/sdk/edgemarketplace/arm-edgemarketplace/README.md new file mode 100644 index 000000000000..56558b1b80b4 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/README.md @@ -0,0 +1,115 @@ +# Azure EdgeMarketplace client library for JavaScript + +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure EdgeMarketplace client. + +Edge marketplace extensions + +Key links: + +- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/edgemarketplace/arm-edgemarketplace) +- [Package (NPM)](https://www.npmjs.com/package/@azure/arm-edgemarketplace) +- [API reference documentation](https://learn.microsoft.com/javascript/api/@azure/arm-edgemarketplace?view=azure-node-preview) +- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/edgemarketplace/arm-edgemarketplace/samples) + +## Getting started + +### Currently supported environments + +- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule) +- Latest versions of Safari, Chrome, Edge and Firefox. + +See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details. + +### Prerequisites + +- An [Azure subscription][azure_sub]. + +### Install the `@azure/arm-edgemarketplace` package + +Install the Azure EdgeMarketplace client library for JavaScript with `npm`: + +```bash +npm install @azure/arm-edgemarketplace +``` + +### Create and authenticate a `EdgeMarketplaceClient` + +To create a client object to access the Azure EdgeMarketplace API, you will need the `endpoint` of your Azure EdgeMarketplace resource and a `credential`. The Azure EdgeMarketplace client can use Azure Active Directory credentials to authenticate. +You can find the endpoint for your Azure EdgeMarketplace resource in the [Azure Portal][azure_portal]. + +You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token). + +To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package: + +```bash +npm install @azure/identity +``` + +You will also need to **register a new AAD application and grant access to Azure EdgeMarketplace** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions). + +For more information about how to create an Azure AD Application check out [this guide](https://learn.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). + +Using Node.js and Node-like environments, you can use the `DefaultAzureCredential` class to authenticate the client. + +```ts snippet:ReadmeSampleCreateClient_Node +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +const subscriptionId = "00000000-0000-0000-0000-000000000000"; +const client = new EdgeMarketplaceClient(new DefaultAzureCredential(), subscriptionId); +``` + +For browser environments, use the `InteractiveBrowserCredential` from the `@azure/identity` package to authenticate. + +```ts snippet:ReadmeSampleCreateClient_Browser +import { InteractiveBrowserCredential } from "@azure/identity"; +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; + +const credential = new InteractiveBrowserCredential({ + tenantId: "", + clientId: "", +}); +const subscriptionId = "00000000-0000-0000-0000-000000000000"; +const client = new EdgeMarketplaceClient(credential, subscriptionId); +``` + + +### JavaScript Bundle +To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). + +## Key concepts + +### EdgeMarketplaceClient + +`EdgeMarketplaceClient` is the primary interface for developers using the Azure EdgeMarketplace client library. Explore the methods on this client object to understand the different features of the Azure EdgeMarketplace service that you can access. + +## 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`: + +```ts snippet:SetLogLevel +import { setLogLevel } from "@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). + +## Next steps + +Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/edgemarketplace/arm-edgemarketplace/samples) directory for detailed examples on how to use this library. + +## Contributing + +If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code. + +## Related projects + +- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js) + +[azure_sub]: https://azure.microsoft.com/free/ +[azure_portal]: https://portal.azure.com +[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity +[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential diff --git a/sdk/edgemarketplace/arm-edgemarketplace/api-extractor.json b/sdk/edgemarketplace/arm-edgemarketplace/api-extractor.json new file mode 100644 index 000000000000..870d6d399477 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/api-extractor.json @@ -0,0 +1 @@ +{ "extends": "../../../api-extractor-base.json" } diff --git a/sdk/edgemarketplace/arm-edgemarketplace/eslint.config.mjs b/sdk/edgemarketplace/arm-edgemarketplace/eslint.config.mjs new file mode 100644 index 000000000000..6d2f8a5914c3 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/eslint.config.mjs @@ -0,0 +1,14 @@ +import azsdkEslint from "@azure/eslint-plugin-azure-sdk"; + +export default azsdkEslint.config([ + { + rules: { + "@azure/azure-sdk/ts-modules-only-named": "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-files-required": "off", + "@azure/azure-sdk/ts-package-json-main-is-cjs": "off", + "tsdoc/syntax": "warn", + }, + }, +]); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/metadata.json b/sdk/edgemarketplace/arm-edgemarketplace/metadata.json new file mode 100644 index 000000000000..b4ed5fdb9cb8 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/metadata.json @@ -0,0 +1,52 @@ +{ + "apiVersion": "2025-10-01-preview", + "emitterVersion": "0.47.1", + "crossLanguageDefinitions": { + "CrossLanguagePackageId": "Microsoft.EdgeMarketplace", + "CrossLanguageDefinitionId": { + "@azure/arm-edgemarketplace!OperationListResult:interface": "Azure.ResourceManager.CommonTypes.OperationListResult", + "@azure/arm-edgemarketplace!Operation:interface": "Azure.ResourceManager.CommonTypes.Operation", + "@azure/arm-edgemarketplace!OperationDisplay:interface": "Azure.ResourceManager.CommonTypes.OperationDisplay", + "@azure/arm-edgemarketplace!ErrorResponse:interface": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "@azure/arm-edgemarketplace!ErrorDetail:interface": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "@azure/arm-edgemarketplace!ErrorAdditionalInfo:interface": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "@azure/arm-edgemarketplace!Offer:interface": "Microsoft.EdgeMarketplace.Offer", + "@azure/arm-edgemarketplace!OfferProperties:interface": "Microsoft.EdgeMarketplace.OfferProperties", + "@azure/arm-edgemarketplace!OfferContent:interface": "Microsoft.EdgeMarketplace.OfferContent", + "@azure/arm-edgemarketplace!OfferPublisher:interface": "Microsoft.EdgeMarketplace.OfferPublisher", + "@azure/arm-edgemarketplace!IconFileUris:interface": "Microsoft.EdgeMarketplace.IconFileUris", + "@azure/arm-edgemarketplace!TermsAndConditions:interface": "Microsoft.EdgeMarketplace.TermsAndConditions", + "@azure/arm-edgemarketplace!MarketplaceSku:interface": "Microsoft.EdgeMarketplace.MarketplaceSku", + "@azure/arm-edgemarketplace!SkuOperatingSystem:interface": "Microsoft.EdgeMarketplace.SkuOperatingSystem", + "@azure/arm-edgemarketplace!MarketplaceSkuVersion:interface": "Microsoft.EdgeMarketplace.MarketplaceSkuVersion", + "@azure/arm-edgemarketplace!ExtensionResource:interface": "Azure.ResourceManager.CommonTypes.ExtensionResource", + "@azure/arm-edgemarketplace!Resource:interface": "Azure.ResourceManager.CommonTypes.Resource", + "@azure/arm-edgemarketplace!SystemData:interface": "Azure.ResourceManager.CommonTypes.SystemData", + "@azure/arm-edgemarketplace!OfferListResult:interface": "Azure.ResourceManager.ResourceListResult", + "@azure/arm-edgemarketplace!AccessTokenRequest:interface": "Microsoft.EdgeMarketplace.AccessTokenRequest", + "@azure/arm-edgemarketplace!DiskAccessToken:interface": "Microsoft.EdgeMarketplace.DiskAccessToken", + "@azure/arm-edgemarketplace!ArmOperationStatusResourceProvisioningState:interface": "Azure.ResourceManager.ArmOperationStatus", + "@azure/arm-edgemarketplace!AccessTokenReadRequest:interface": "Microsoft.EdgeMarketplace.AccessTokenReadRequest", + "@azure/arm-edgemarketplace!Publisher:interface": "Microsoft.EdgeMarketplace.Publisher", + "@azure/arm-edgemarketplace!PublisherProperties:interface": "Microsoft.EdgeMarketplace.PublisherProperties", + "@azure/arm-edgemarketplace!PublisherListResult:interface": "Azure.ResourceManager.ResourceListResult", + "@azure/arm-edgemarketplace!KnownOrigin:enum": "Azure.ResourceManager.CommonTypes.Origin", + "@azure/arm-edgemarketplace!KnownActionType:enum": "Azure.ResourceManager.CommonTypes.ActionType", + "@azure/arm-edgemarketplace!KnownOfferAvailability:enum": "Microsoft.EdgeMarketplace.OfferAvailability", + "@azure/arm-edgemarketplace!KnownOfferReleaseType:enum": "Microsoft.EdgeMarketplace.OfferReleaseType", + "@azure/arm-edgemarketplace!KnownResourceProvisioningState:enum": "Azure.ResourceManager.ResourceProvisioningState", + "@azure/arm-edgemarketplace!KnownOfferLaunchType:enum": "Microsoft.EdgeMarketplace.OfferLaunchType", + "@azure/arm-edgemarketplace!KnowncreatedByType:enum": "Azure.ResourceManager.CommonTypes.createdByType", + "@azure/arm-edgemarketplace!KnownVersions:enum": "Microsoft.EdgeMarketplace.Versions", + "@azure/arm-edgemarketplace!PublishersOperations#listBySubscription:member": "Microsoft.EdgeMarketplace.Publishers.listBySubscription", + "@azure/arm-edgemarketplace!PublishersOperations#list:member": "Microsoft.EdgeMarketplace.Publishers.list", + "@azure/arm-edgemarketplace!PublishersOperations#get:member": "Microsoft.EdgeMarketplace.Publishers.get", + "@azure/arm-edgemarketplace!OffersOperations#listBySubscription:member": "Microsoft.EdgeMarketplace.Offers.listBySubscription", + "@azure/arm-edgemarketplace!OffersOperations#getAccessToken:member": "Microsoft.EdgeMarketplace.Offers.getAccessToken", + "@azure/arm-edgemarketplace!OffersOperations#generateAccessToken:member": "Microsoft.EdgeMarketplace.Offers.generateAccessToken", + "@azure/arm-edgemarketplace!OffersOperations#list:member": "Microsoft.EdgeMarketplace.Offers.list", + "@azure/arm-edgemarketplace!OffersOperations#get:member": "Microsoft.EdgeMarketplace.Offers.get", + "@azure/arm-edgemarketplace!OperationsOperations#list:member": "Azure.ResourceManager.Operations.list" + } + } +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/package.json b/sdk/edgemarketplace/arm-edgemarketplace/package.json new file mode 100644 index 000000000000..920bed9507b9 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/package.json @@ -0,0 +1,235 @@ +{ + "name": "@azure/arm-edgemarketplace", + "version": "1.0.0-beta.1", + "description": "A generated SDK for EdgeMarketplaceClient.", + "engines": { + "node": ">=20.0.0" + }, + "sideEffects": false, + "autoPublish": false, + "tshy": { + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./api": "./src/api/index.ts", + "./api/publishers": "./src/api/publishers/index.ts", + "./api/offers": "./src/api/offers/index.ts", + "./api/operations": "./src/api/operations/index.ts", + "./models": "./src/models/index.ts" + }, + "dialects": [ + "esm", + "commonjs" + ], + "esmDialects": [ + "browser", + "react-native" + ], + "selfLink": false, + "project": "../../../tsconfig.src.build.json" + }, + "type": "module", + "browser": "./dist/browser/index.js", + "react-native": "./dist/react-native/index.js", + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "files": [ + "dist/", + "!dist/**/*.d.*ts.map", + "README.md", + "LICENSE" + ], + "sdk-type": "mgmt", + "repository": "github:Azure/azure-sdk-for-js", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/edgemarketplace/arm-edgemarketplace/README.md", + "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", + "//metadata": { + "constantPaths": [ + { + "path": "src/api/edgeMarketplaceContext.ts", + "prefix": "userAgentInfo" + } + ] + }, + "dependencies": { + "@azure/core-util": "^1.12.0", + "@azure-rest/core-client": "^2.3.1", + "@azure/abort-controller": "^2.1.2", + "@azure/core-auth": "^1.9.0", + "@azure/core-lro": "^3.1.0", + "@azure/core-rest-pipeline": "^1.20.0", + "@azure/logger": "^1.2.0", + "tslib": "^2.8.1" + }, + "devDependencies": { + "@azure-tools/test-credential": "workspace:^", + "@azure-tools/test-recorder": "workspace:^", + "@azure-tools/test-utils-vitest": "workspace:^", + "@azure/dev-tool": "workspace:^", + "tshy": "catalog:", + "@azure/eslint-plugin-azure-sdk": "workspace:^", + "@azure/identity": "catalog:internal", + "@types/node": "catalog:", + "cross-env": "catalog:", + "eslint": "catalog:", + "prettier": "catalog:", + "rimraf": "catalog:", + "@vitest/browser-playwright": "catalog:testing", + "@vitest/coverage-istanbul": "catalog:testing", + "dotenv": "catalog:testing", + "playwright": "catalog:testing", + "typescript": "catalog:", + "vitest": "catalog:testing" + }, + "scripts": { + "clean": "rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", + "extract-api": "rimraf review && dev-tool run extract-api", + "pack": "pnpm pack 2>&1", + "lint": "echo skipped", + "lint:fix": "echo skipped", + "build:samples": "tsc -p tsconfig.samples.json && dev-tool samples publish -f", + "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" \"samples-dev/*.ts\"", + "execute:samples": "dev-tool samples run samples-dev", + "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" \"samples-dev/*.ts\"", + "generate:client": "echo skipped", + "test:browser": "dev-tool run build-test && dev-tool run test:vitest --browser", + "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api", + "test:node": "dev-tool run test:vitest", + "test:node:esm": "dev-tool run test:vitest --esm", + "test": "npm run test:node && npm run test:browser", + "update-snippets": "dev-tool run update-snippets" + }, + "//sampleConfiguration": { + "productName": "@azure/arm-edgemarketplace", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://learn.microsoft.com/javascript/api/@azure/arm-edgemarketplace?view=azure-node-preview" + }, + "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" + } + }, + "./api": { + "browser": { + "types": "./dist/browser/api/index.d.ts", + "default": "./dist/browser/api/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/index.d.ts", + "default": "./dist/react-native/api/index.js" + }, + "import": { + "types": "./dist/esm/api/index.d.ts", + "default": "./dist/esm/api/index.js" + }, + "require": { + "types": "./dist/commonjs/api/index.d.ts", + "default": "./dist/commonjs/api/index.js" + } + }, + "./api/publishers": { + "browser": { + "types": "./dist/browser/api/publishers/index.d.ts", + "default": "./dist/browser/api/publishers/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/publishers/index.d.ts", + "default": "./dist/react-native/api/publishers/index.js" + }, + "import": { + "types": "./dist/esm/api/publishers/index.d.ts", + "default": "./dist/esm/api/publishers/index.js" + }, + "require": { + "types": "./dist/commonjs/api/publishers/index.d.ts", + "default": "./dist/commonjs/api/publishers/index.js" + } + }, + "./api/offers": { + "browser": { + "types": "./dist/browser/api/offers/index.d.ts", + "default": "./dist/browser/api/offers/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/offers/index.d.ts", + "default": "./dist/react-native/api/offers/index.js" + }, + "import": { + "types": "./dist/esm/api/offers/index.d.ts", + "default": "./dist/esm/api/offers/index.js" + }, + "require": { + "types": "./dist/commonjs/api/offers/index.d.ts", + "default": "./dist/commonjs/api/offers/index.js" + } + }, + "./api/operations": { + "browser": { + "types": "./dist/browser/api/operations/index.d.ts", + "default": "./dist/browser/api/operations/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/operations/index.d.ts", + "default": "./dist/react-native/api/operations/index.js" + }, + "import": { + "types": "./dist/esm/api/operations/index.d.ts", + "default": "./dist/esm/api/operations/index.js" + }, + "require": { + "types": "./dist/commonjs/api/operations/index.d.ts", + "default": "./dist/commonjs/api/operations/index.js" + } + }, + "./models": { + "browser": { + "types": "./dist/browser/models/index.d.ts", + "default": "./dist/browser/models/index.js" + }, + "react-native": { + "types": "./dist/react-native/models/index.d.ts", + "default": "./dist/react-native/models/index.js" + }, + "import": { + "types": "./dist/esm/models/index.d.ts", + "default": "./dist/esm/models/index.js" + }, + "require": { + "types": "./dist/commonjs/models/index.d.ts", + "default": "./dist/commonjs/models/index.js" + } + } + }, + "main": "./dist/commonjs/index.js", + "types": "./dist/commonjs/index.d.ts", + "module": "./dist/esm/index.js" +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-api-node.api.md b/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-api-node.api.md new file mode 100644 index 000000000000..2f8db105cd92 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-api-node.api.md @@ -0,0 +1,28 @@ +## API Report File for "@azure/arm-edgemarketplace" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { Client } from '@azure-rest/core-client'; +import type { ClientOptions } from '@azure-rest/core-client'; +import type { TokenCredential } from '@azure/core-auth'; + +// @public +export function createEdgeMarketplace(credential: TokenCredential, subscriptionId: string, options?: EdgeMarketplaceClientOptionalParams): EdgeMarketplaceContext; + +// @public +export interface EdgeMarketplaceClientOptionalParams extends ClientOptions { + apiVersion?: string; + cloudSetting?: AzureSupportedClouds; +} + +// @public +export interface EdgeMarketplaceContext extends Client { + apiVersion: string; + subscriptionId: string; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-api-offers-node.api.md b/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-api-offers-node.api.md new file mode 100644 index 000000000000..8eb4de51cf46 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-api-offers-node.api.md @@ -0,0 +1,55 @@ +## API Report File for "@azure/arm-edgemarketplace" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { Client } from '@azure-rest/core-client'; +import type { OperationOptions } from '@azure-rest/core-client'; +import type { OperationState } from '@azure/core-lro'; +import type { PollerLike } from '@azure/core-lro'; + +// @public +export function generateAccessToken(context: EdgeMarketplaceContext, resourceUri: string, offerId: string, body: AccessTokenRequest, options?: OffersGenerateAccessTokenOptionalParams): PollerLike, DiskAccessToken>; + +// @public +export function get(context: EdgeMarketplaceContext, resourceUri: string, offerId: string, options?: OffersGetOptionalParams): Promise; + +// @public +export function getAccessToken(context: EdgeMarketplaceContext, resourceUri: string, offerId: string, body: AccessTokenReadRequest, options?: OffersGetAccessTokenOptionalParams): Promise; + +// @public +export function list(context: EdgeMarketplaceContext, resourceUri: string, options?: OffersListOptionalParams): PagedAsyncIterableIterator; + +// @public +export function listBySubscription(context: EdgeMarketplaceContext, options?: OffersListBySubscriptionOptionalParams): PagedAsyncIterableIterator; + +// @public +export interface OffersGenerateAccessTokenOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export interface OffersGetAccessTokenOptionalParams extends OperationOptions { +} + +// @public +export interface OffersGetOptionalParams extends OperationOptions { +} + +// @public +export interface OffersListBySubscriptionOptionalParams extends OperationOptions { +} + +// @public +export interface OffersListOptionalParams extends OperationOptions { + filter?: string; + maxpagesize?: number; + skip?: number; + skipToken?: string; + top?: number; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-api-operations-node.api.md b/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-api-operations-node.api.md new file mode 100644 index 000000000000..77e3dc42dd62 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-api-operations-node.api.md @@ -0,0 +1,19 @@ +## API Report File for "@azure/arm-edgemarketplace" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { Client } from '@azure-rest/core-client'; +import type { OperationOptions } from '@azure-rest/core-client'; + +// @public +export function list(context: EdgeMarketplaceContext, options?: OperationsListOptionalParams): PagedAsyncIterableIterator; + +// @public +export interface OperationsListOptionalParams extends OperationOptions { +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-api-publishers-node.api.md b/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-api-publishers-node.api.md new file mode 100644 index 000000000000..d20c15a64455 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-api-publishers-node.api.md @@ -0,0 +1,38 @@ +## API Report File for "@azure/arm-edgemarketplace" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { Client } from '@azure-rest/core-client'; +import type { OperationOptions } from '@azure-rest/core-client'; + +// @public +export function get(context: EdgeMarketplaceContext, resourceUri: string, publisherName: string, options?: PublishersGetOptionalParams): Promise; + +// @public +export function list(context: EdgeMarketplaceContext, resourceUri: string, options?: PublishersListOptionalParams): PagedAsyncIterableIterator; + +// @public +export function listBySubscription(context: EdgeMarketplaceContext, options?: PublishersListBySubscriptionOptionalParams): PagedAsyncIterableIterator; + +// @public +export interface PublishersGetOptionalParams extends OperationOptions { +} + +// @public +export interface PublishersListBySubscriptionOptionalParams extends OperationOptions { +} + +// @public +export interface PublishersListOptionalParams extends OperationOptions { + filter?: string; + maxpagesize?: number; + skip?: number; + skipToken?: string; + top?: number; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-models-node.api.md b/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-models-node.api.md new file mode 100644 index 000000000000..a3a1b1fcce01 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-models-node.api.md @@ -0,0 +1,259 @@ +## API Report File for "@azure/arm-edgemarketplace" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +// @public +export interface AccessTokenReadRequest { + requestId: string; +} + +// @public +export interface AccessTokenRequest { + deviceSku?: string; + deviceVersion?: string; + edgeMarketPlaceRegion: string; + egeMarketPlaceResourceId?: string; + hypervGeneration?: string; + marketPlaceSku?: string; + marketPlaceSkuVersion?: string; + publisherName?: string; +} + +// @public +export type ActionType = string; + +// @public +export type CreatedByType = string; + +// @public +export interface DiskAccessToken { + accessToken: string; + diskId?: string; + status?: string; +} + +// @public +export interface ErrorAdditionalInfo { + readonly info?: any; + readonly type?: string; +} + +// @public +export interface ErrorDetail { + readonly additionalInfo?: ErrorAdditionalInfo[]; + readonly code?: string; + readonly details?: ErrorDetail[]; + readonly message?: string; + readonly target?: string; +} + +// @public +export interface ErrorResponse { + error?: ErrorDetail; +} + +// @public +export interface ExtensionResource extends Resource { +} + +// @public +export interface IconFileUris { + large?: string; + medium?: string; + small?: string; + wide?: string; +} + +// @public +export enum KnownActionType { + Internal = "Internal" +} + +// @public +export enum KnownCreatedByType { + Application = "Application", + Key = "Key", + ManagedIdentity = "ManagedIdentity", + User = "User" +} + +// @public +export enum KnownOfferAvailability { + Private = "Private", + Public = "Public" +} + +// @public +export enum KnownOfferLaunchType { + Trusted = "Trusted", + Unknown = "Unknown" +} + +// @public +export enum KnownOfferReleaseType { + GA = "GA", + Preview = "Preview" +} + +// @public +export enum KnownOrigin { + System = "system", + User = "user", + UserSystem = "user,system" +} + +// @public +export enum KnownResourceProvisioningState { + Canceled = "Canceled", + Failed = "Failed", + Succeeded = "Succeeded" +} + +// @public +export enum KnownVersions { + V20241001 = "2024-10-01", + V20251001Preview = "2025-10-01-preview" +} + +// @public +export interface MarketplaceSku { + catalogPlanId: string; + description?: string; + displayName?: string; + displayRank?: number; + generation?: string; + longSummary?: string; + marketplaceSkuId: string; + marketplaceSkuVersions?: MarketplaceSkuVersion[]; + operatingSystem?: SkuOperatingSystem; + summary?: string; + type?: string; +} + +// @public +export interface MarketplaceSkuVersion { + launchType?: OfferLaunchType; + minimumDownloadSizeInMb?: number; + name: string; + sizeOnDiskInMb?: number; + stageName?: string; +} + +// @public +export interface Offer extends ExtensionResource { + properties?: OfferProperties; +} + +// @public +export type OfferAvailability = string; + +// @public +export interface OfferContent { + availability?: OfferAvailability; + categoryIds?: string[]; + description?: string; + displayName: string; + iconFileUris?: IconFileUris; + longSummary?: string; + offerId: string; + offerPublisher?: OfferPublisher; + offerType?: string; + operatingSystems?: string[]; + popularity?: number; + releaseType?: OfferReleaseType; + summary?: string; + supportUri?: string; + termsAndConditions?: TermsAndConditions; +} + +// @public +export type OfferLaunchType = string; + +// @public +export interface OfferProperties { + contentUrl?: string; + contentVersion?: string; + marketplaceSkus?: MarketplaceSku[]; + offerContent: OfferContent; + readonly provisioningState?: ResourceProvisioningState; +} + +// @public +export interface OfferPublisher { + publisherDisplayName: string; + publisherId: string; +} + +// @public +export type OfferReleaseType = string; + +// @public +export interface Operation { + readonly actionType?: ActionType; + display?: OperationDisplay; + readonly isDataAction?: boolean; + readonly name?: string; + readonly origin?: Origin; +} + +// @public +export interface OperationDisplay { + readonly description?: string; + readonly operation?: string; + readonly provider?: string; + readonly resource?: string; +} + +// @public +export type Origin = string; + +// @public +export interface Publisher extends ExtensionResource { + properties?: PublisherProperties; +} + +// @public +export interface PublisherProperties { + readonly provisioningState?: ResourceProvisioningState; +} + +// @public +export interface Resource { + readonly id?: string; + readonly name?: string; + readonly systemData?: SystemData; + readonly type?: string; +} + +// @public +export type ResourceProvisioningState = string; + +// @public +export interface SkuOperatingSystem { + family?: string; + name: string; + type?: string; +} + +// @public +export interface SystemData { + createdAt?: Date; + createdBy?: string; + createdByType?: CreatedByType; + lastModifiedAt?: Date; + lastModifiedBy?: string; + lastModifiedByType?: CreatedByType; +} + +// @public +export interface TermsAndConditions { + legalTermsType?: string; + legalTermsUri?: string; + privacyPolicyUri?: string; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-node.api.md b/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-node.api.md new file mode 100644 index 000000000000..cdb4f37008e7 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/review/arm-edgemarketplace-node.api.md @@ -0,0 +1,389 @@ +## API Report File for "@azure/arm-edgemarketplace" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { AbortSignalLike } from '@azure/abort-controller'; +import type { ClientOptions } from '@azure-rest/core-client'; +import type { OperationOptions } from '@azure-rest/core-client'; +import type { OperationState } from '@azure/core-lro'; +import type { PathUncheckedResponse } from '@azure-rest/core-client'; +import type { Pipeline } from '@azure/core-rest-pipeline'; +import type { PollerLike } from '@azure/core-lro'; +import type { TokenCredential } from '@azure/core-auth'; + +// @public +export interface AccessTokenReadRequest { + requestId: string; +} + +// @public +export interface AccessTokenRequest { + deviceSku?: string; + deviceVersion?: string; + edgeMarketPlaceRegion: string; + egeMarketPlaceResourceId?: string; + hypervGeneration?: string; + marketPlaceSku?: string; + marketPlaceSkuVersion?: string; + publisherName?: string; +} + +// @public +export type ActionType = string; + +// @public +export enum AzureClouds { + AZURE_CHINA_CLOUD = "AZURE_CHINA_CLOUD", + AZURE_PUBLIC_CLOUD = "AZURE_PUBLIC_CLOUD", + AZURE_US_GOVERNMENT = "AZURE_US_GOVERNMENT" +} + +// @public +export type AzureSupportedClouds = `${AzureClouds}`; + +// @public +export type ContinuablePage = TPage & { + continuationToken?: string; +}; + +// @public +export type CreatedByType = string; + +// @public +export interface DiskAccessToken { + accessToken: string; + diskId?: string; + status?: string; +} + +// @public (undocumented) +export class EdgeMarketplaceClient { + constructor(credential: TokenCredential, options?: EdgeMarketplaceClientOptionalParams); + constructor(credential: TokenCredential, subscriptionId: string, options?: EdgeMarketplaceClientOptionalParams); + readonly offers: OffersOperations; + readonly operations: OperationsOperations; + readonly pipeline: Pipeline; + readonly publishers: PublishersOperations; +} + +// @public +export interface EdgeMarketplaceClientOptionalParams extends ClientOptions { + apiVersion?: string; + cloudSetting?: AzureSupportedClouds; +} + +// @public +export interface ErrorAdditionalInfo { + readonly info?: any; + readonly type?: string; +} + +// @public +export interface ErrorDetail { + readonly additionalInfo?: ErrorAdditionalInfo[]; + readonly code?: string; + readonly details?: ErrorDetail[]; + readonly message?: string; + readonly target?: string; +} + +// @public +export interface ErrorResponse { + error?: ErrorDetail; +} + +// @public +export interface ExtensionResource extends Resource { +} + +// @public +export interface IconFileUris { + large?: string; + medium?: string; + small?: string; + wide?: string; +} + +// @public +export enum KnownActionType { + Internal = "Internal" +} + +// @public +export enum KnownCreatedByType { + Application = "Application", + Key = "Key", + ManagedIdentity = "ManagedIdentity", + User = "User" +} + +// @public +export enum KnownOfferAvailability { + Private = "Private", + Public = "Public" +} + +// @public +export enum KnownOfferLaunchType { + Trusted = "Trusted", + Unknown = "Unknown" +} + +// @public +export enum KnownOfferReleaseType { + GA = "GA", + Preview = "Preview" +} + +// @public +export enum KnownOrigin { + System = "system", + User = "user", + UserSystem = "user,system" +} + +// @public +export enum KnownResourceProvisioningState { + Canceled = "Canceled", + Failed = "Failed", + Succeeded = "Succeeded" +} + +// @public +export enum KnownVersions { + V20241001 = "2024-10-01", + V20251001Preview = "2025-10-01-preview" +} + +// @public +export interface MarketplaceSku { + catalogPlanId: string; + description?: string; + displayName?: string; + displayRank?: number; + generation?: string; + longSummary?: string; + marketplaceSkuId: string; + marketplaceSkuVersions?: MarketplaceSkuVersion[]; + operatingSystem?: SkuOperatingSystem; + summary?: string; + type?: string; +} + +// @public +export interface MarketplaceSkuVersion { + launchType?: OfferLaunchType; + minimumDownloadSizeInMb?: number; + name: string; + sizeOnDiskInMb?: number; + stageName?: string; +} + +// @public +export interface Offer extends ExtensionResource { + properties?: OfferProperties; +} + +// @public +export type OfferAvailability = string; + +// @public +export interface OfferContent { + availability?: OfferAvailability; + categoryIds?: string[]; + description?: string; + displayName: string; + iconFileUris?: IconFileUris; + longSummary?: string; + offerId: string; + offerPublisher?: OfferPublisher; + offerType?: string; + operatingSystems?: string[]; + popularity?: number; + releaseType?: OfferReleaseType; + summary?: string; + supportUri?: string; + termsAndConditions?: TermsAndConditions; +} + +// @public +export type OfferLaunchType = string; + +// @public +export interface OfferProperties { + contentUrl?: string; + contentVersion?: string; + marketplaceSkus?: MarketplaceSku[]; + offerContent: OfferContent; + readonly provisioningState?: ResourceProvisioningState; +} + +// @public +export interface OfferPublisher { + publisherDisplayName: string; + publisherId: string; +} + +// @public +export type OfferReleaseType = string; + +// @public +export interface OffersGenerateAccessTokenOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export interface OffersGetAccessTokenOptionalParams extends OperationOptions { +} + +// @public +export interface OffersGetOptionalParams extends OperationOptions { +} + +// @public +export interface OffersListBySubscriptionOptionalParams extends OperationOptions { +} + +// @public +export interface OffersListOptionalParams extends OperationOptions { + filter?: string; + maxpagesize?: number; + skip?: number; + skipToken?: string; + top?: number; +} + +// @public +export interface OffersOperations { + generateAccessToken: (resourceUri: string, offerId: string, body: AccessTokenRequest, options?: OffersGenerateAccessTokenOptionalParams) => PollerLike, DiskAccessToken>; + get: (resourceUri: string, offerId: string, options?: OffersGetOptionalParams) => Promise; + getAccessToken: (resourceUri: string, offerId: string, body: AccessTokenReadRequest, options?: OffersGetAccessTokenOptionalParams) => Promise; + list: (resourceUri: string, options?: OffersListOptionalParams) => PagedAsyncIterableIterator; + listBySubscription: (options?: OffersListBySubscriptionOptionalParams) => PagedAsyncIterableIterator; +} + +// @public +export interface Operation { + readonly actionType?: ActionType; + display?: OperationDisplay; + readonly isDataAction?: boolean; + readonly name?: string; + readonly origin?: Origin; +} + +// @public +export interface OperationDisplay { + readonly description?: string; + readonly operation?: string; + readonly provider?: string; + readonly resource?: string; +} + +// @public +export interface OperationsListOptionalParams extends OperationOptions { +} + +// @public +export interface OperationsOperations { + list: (options?: OperationsListOptionalParams) => PagedAsyncIterableIterator; +} + +// @public +export type Origin = string; + +// @public +export interface PagedAsyncIterableIterator { + [Symbol.asyncIterator](): PagedAsyncIterableIterator; + byPage: (settings?: TPageSettings) => AsyncIterableIterator>; + next(): Promise>; +} + +// @public +export interface PageSettings { + continuationToken?: string; +} + +// @public +export interface Publisher extends ExtensionResource { + properties?: PublisherProperties; +} + +// @public +export interface PublisherProperties { + readonly provisioningState?: ResourceProvisioningState; +} + +// @public +export interface PublishersGetOptionalParams extends OperationOptions { +} + +// @public +export interface PublishersListBySubscriptionOptionalParams extends OperationOptions { +} + +// @public +export interface PublishersListOptionalParams extends OperationOptions { + filter?: string; + maxpagesize?: number; + skip?: number; + skipToken?: string; + top?: number; +} + +// @public +export interface PublishersOperations { + get: (resourceUri: string, publisherName: string, options?: PublishersGetOptionalParams) => Promise; + list: (resourceUri: string, options?: PublishersListOptionalParams) => PagedAsyncIterableIterator; + listBySubscription: (options?: PublishersListBySubscriptionOptionalParams) => PagedAsyncIterableIterator; +} + +// @public +export interface Resource { + readonly id?: string; + readonly name?: string; + readonly systemData?: SystemData; + readonly type?: string; +} + +// @public +export type ResourceProvisioningState = string; + +// @public +export function restorePoller(client: EdgeMarketplaceClient, serializedState: string, sourceOperation: (...args: any[]) => PollerLike, TResult>, options?: RestorePollerOptions): PollerLike, TResult>; + +// @public (undocumented) +export interface RestorePollerOptions extends OperationOptions { + abortSignal?: AbortSignalLike; + processResponseBody?: (result: TResponse) => Promise; + updateIntervalInMs?: number; +} + +// @public +export interface SkuOperatingSystem { + family?: string; + name: string; + type?: string; +} + +// @public +export interface SystemData { + createdAt?: Date; + createdBy?: string; + createdByType?: CreatedByType; + lastModifiedAt?: Date; + lastModifiedBy?: string; + lastModifiedByType?: CreatedByType; +} + +// @public +export interface TermsAndConditions { + legalTermsType?: string; + legalTermsUri?: string; + privacyPolicyUri?: string; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/edgemarketplace/arm-edgemarketplace/sample.env b/sdk/edgemarketplace/arm-edgemarketplace/sample.env new file mode 100644 index 000000000000..508439fc7d62 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/sample.env @@ -0,0 +1 @@ +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/offersGenerateAccessTokenSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/offersGenerateAccessTokenSample.ts new file mode 100644 index 000000000000..80c52e5d1aac --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/offersGenerateAccessTokenSample.ts @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to a long-running resource action. + * + * @summary a long-running resource action. + * x-ms-original-file: 2025-10-01-preview/GenerateAccessToken.json + */ +async function offersGenerateAccessToken(): Promise { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const result = await client.offers.generateAccessToken( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + "0001-com-ubuntu-pro-jammy", + { + deviceVersion: "1.0.18062.1", + deviceSku: "edge", + egeMarketPlaceResourceId: "testid", + edgeMarketPlaceRegion: "EastUS2Euap", + hypervGeneration: "V2", + marketPlaceSku: "2022-datacenter-azure-edition-core", + marketPlaceSkuVersion: "20348.1129.221007", + publisherName: "ubuntu", + }, + ); + console.log(result); +} + +async function main(): Promise { + await offersGenerateAccessToken(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/offersGetAccessTokenSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/offersGetAccessTokenSample.ts new file mode 100644 index 000000000000..f5e0877214b1 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/offersGetAccessTokenSample.ts @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get access token. + * + * @summary get access token. + * x-ms-original-file: 2025-10-01-preview/GetAccessToken.json + */ +async function offersGetAccessToken(): Promise { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const result = await client.offers.getAccessToken( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + "0001-com-ubuntu-pro-jammy", + { requestId: "1.0.18062.1" }, + ); + console.log(result); +} + +async function main(): Promise { + await offersGetAccessToken(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/offersGetSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/offersGetSample.ts new file mode 100644 index 000000000000..2ae09ce3cfa9 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/offersGetSample.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a Offer + * + * @summary get a Offer + * x-ms-original-file: 2025-10-01-preview/GetOffer.json + */ +async function offersGet(): Promise { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const result = await client.offers.get( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + "0001-com-ubuntu-pro-jammy", + ); + console.log(result); +} + +async function main(): Promise { + await offersGet(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/offersListBySubscriptionSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/offersListBySubscriptionSample.ts new file mode 100644 index 000000000000..208fd766ea10 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/offersListBySubscriptionSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Offer resources by subscription ID + * + * @summary list Offer resources by subscription ID + * x-ms-original-file: 2025-10-01-preview/ListOffersBySubscription.json + */ +async function offersListBySubscription(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "4bed37fd-19a1-4d31-8b44-40267555bec5"; + const client = new EdgeMarketplaceClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.offers.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await offersListBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/offersListSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/offersListSample.ts new file mode 100644 index 000000000000..4d36dc2c4327 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/offersListSample.ts @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Offer resources by parent + * + * @summary list Offer resources by parent + * x-ms-original-file: 2025-10-01-preview/ListOffers.json + */ +async function offersList(): Promise { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const resArray = new Array(); + for await (const item of client.offers.list( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await offersList(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/operationsListSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/operationsListSample.ts new file mode 100644 index 000000000000..58eb6af4bb09 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/operationsListSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list the operations for the provider + * + * @summary list the operations for the provider + * x-ms-original-file: 2025-10-01-preview/ListOperations.json + */ +async function operationsList(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new EdgeMarketplaceClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.operations.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await operationsList(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/publishersGetSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/publishersGetSample.ts new file mode 100644 index 000000000000..eeb323c31b74 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/publishersGetSample.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a Publisher + * + * @summary get a Publisher + * x-ms-original-file: 2025-10-01-preview/GetPublisher.json + */ +async function publishersGet(): Promise { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const result = await client.publishers.get( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + "canonical", + ); + console.log(result); +} + +async function main(): Promise { + await publishersGet(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/publishersListBySubscriptionSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/publishersListBySubscriptionSample.ts new file mode 100644 index 000000000000..0badec9f7b80 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/publishersListBySubscriptionSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Publisher resources by subscription ID + * + * @summary list Publisher resources by subscription ID + * x-ms-original-file: 2025-10-01-preview/ListPublishersBySubscription.json + */ +async function publishersListBySubscription(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "4bed37fd-19a1-4d31-8b44-40267555bec5"; + const client = new EdgeMarketplaceClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.publishers.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await publishersListBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/publishersListSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/publishersListSample.ts new file mode 100644 index 000000000000..decf1b184c42 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples-dev/publishersListSample.ts @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Publisher resources by parent + * + * @summary list Publisher resources by parent + * x-ms-original-file: 2025-10-01-preview/ListPublishers.json + */ +async function publishersList(): Promise { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const resArray = new Array(); + for await (const item of client.publishers.list( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await publishersList(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/README.md b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/README.md new file mode 100644 index 000000000000..e48290ada0fd --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/README.md @@ -0,0 +1,66 @@ +# @azure/arm-edgemarketplace client library samples for JavaScript (Beta) + +These sample programs show how to use the JavaScript client libraries for @azure/arm-edgemarketplace in some common scenarios. + +| **File Name** | **Description** | +| --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | +| [offersGenerateAccessTokenSample.js][offersgenerateaccesstokensample] | a long-running resource action. x-ms-original-file: 2025-10-01-preview/GenerateAccessToken.json | +| [offersGetAccessTokenSample.js][offersgetaccesstokensample] | get access token. x-ms-original-file: 2025-10-01-preview/GetAccessToken.json | +| [offersGetSample.js][offersgetsample] | get a Offer x-ms-original-file: 2025-10-01-preview/GetOffer.json | +| [offersListBySubscriptionSample.js][offerslistbysubscriptionsample] | list Offer resources by subscription ID x-ms-original-file: 2025-10-01-preview/ListOffersBySubscription.json | +| [offersListSample.js][offerslistsample] | list Offer resources by parent x-ms-original-file: 2025-10-01-preview/ListOffers.json | +| [operationsListSample.js][operationslistsample] | list the operations for the provider x-ms-original-file: 2025-10-01-preview/ListOperations.json | +| [publishersGetSample.js][publishersgetsample] | get a Publisher x-ms-original-file: 2025-10-01-preview/GetPublisher.json | +| [publishersListBySubscriptionSample.js][publisherslistbysubscriptionsample] | list Publisher resources by subscription ID x-ms-original-file: 2025-10-01-preview/ListPublishersBySubscription.json | +| [publishersListSample.js][publisherslistsample] | list Publisher resources by parent x-ms-original-file: 2025-10-01-preview/ListPublishers.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +3. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node offersGenerateAccessTokenSample.js +``` + +Alternatively, run a single sample with the required environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +node offersGenerateAccessTokenSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[offersgenerateaccesstokensample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersGenerateAccessTokenSample.js +[offersgetaccesstokensample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersGetAccessTokenSample.js +[offersgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersGetSample.js +[offerslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersListBySubscriptionSample.js +[offerslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersListSample.js +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/operationsListSample.js +[publishersgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/publishersGetSample.js +[publisherslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/publishersListBySubscriptionSample.js +[publisherslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/publishersListSample.js +[apiref]: https://learn.microsoft.com/javascript/api/@azure/arm-edgemarketplace?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/edgemarketplace/arm-edgemarketplace/README.md diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersGenerateAccessTokenSample.js b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersGenerateAccessTokenSample.js new file mode 100644 index 000000000000..6f1324257b73 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersGenerateAccessTokenSample.js @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { EdgeMarketplaceClient } = require("@azure/arm-edgemarketplace"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to a long-running resource action. + * + * @summary a long-running resource action. + * x-ms-original-file: 2025-10-01-preview/GenerateAccessToken.json + */ +async function offersGenerateAccessToken() { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const result = await client.offers.generateAccessToken( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + "0001-com-ubuntu-pro-jammy", + { + deviceVersion: "1.0.18062.1", + deviceSku: "edge", + egeMarketPlaceResourceId: "testid", + edgeMarketPlaceRegion: "EastUS2Euap", + hypervGeneration: "V2", + marketPlaceSku: "2022-datacenter-azure-edition-core", + marketPlaceSkuVersion: "20348.1129.221007", + publisherName: "ubuntu", + }, + ); + console.log(result); +} + +async function main() { + await offersGenerateAccessToken(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersGetAccessTokenSample.js b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersGetAccessTokenSample.js new file mode 100644 index 000000000000..af839883e17a --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersGetAccessTokenSample.js @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { EdgeMarketplaceClient } = require("@azure/arm-edgemarketplace"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to get access token. + * + * @summary get access token. + * x-ms-original-file: 2025-10-01-preview/GetAccessToken.json + */ +async function offersGetAccessToken() { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const result = await client.offers.getAccessToken( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + "0001-com-ubuntu-pro-jammy", + { requestId: "1.0.18062.1" }, + ); + console.log(result); +} + +async function main() { + await offersGetAccessToken(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersGetSample.js b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersGetSample.js new file mode 100644 index 000000000000..28a1745255c3 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersGetSample.js @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { EdgeMarketplaceClient } = require("@azure/arm-edgemarketplace"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to get a Offer + * + * @summary get a Offer + * x-ms-original-file: 2025-10-01-preview/GetOffer.json + */ +async function offersGet() { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const result = await client.offers.get( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + "0001-com-ubuntu-pro-jammy", + ); + console.log(result); +} + +async function main() { + await offersGet(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersListBySubscriptionSample.js b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersListBySubscriptionSample.js new file mode 100644 index 000000000000..3f219debc0d7 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersListBySubscriptionSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { EdgeMarketplaceClient } = require("@azure/arm-edgemarketplace"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list Offer resources by subscription ID + * + * @summary list Offer resources by subscription ID + * x-ms-original-file: 2025-10-01-preview/ListOffersBySubscription.json + */ +async function offersListBySubscription() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "4bed37fd-19a1-4d31-8b44-40267555bec5"; + const client = new EdgeMarketplaceClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.offers.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await offersListBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersListSample.js b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersListSample.js new file mode 100644 index 000000000000..c8ee3b8e8afb --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/offersListSample.js @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { EdgeMarketplaceClient } = require("@azure/arm-edgemarketplace"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list Offer resources by parent + * + * @summary list Offer resources by parent + * x-ms-original-file: 2025-10-01-preview/ListOffers.json + */ +async function offersList() { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const resArray = new Array(); + for await (const item of client.offers.list( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await offersList(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/operationsListSample.js b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/operationsListSample.js new file mode 100644 index 000000000000..28d751bd4085 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/operationsListSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { EdgeMarketplaceClient } = require("@azure/arm-edgemarketplace"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list the operations for the provider + * + * @summary list the operations for the provider + * x-ms-original-file: 2025-10-01-preview/ListOperations.json + */ +async function operationsList() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new EdgeMarketplaceClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.operations.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await operationsList(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/package.json b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/package.json new file mode 100644 index 000000000000..7b6c812c17f1 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/package.json @@ -0,0 +1,36 @@ +{ + "name": "@azure-samples/arm-edgemarketplace-js-beta", + "private": true, + "version": "1.0.0", + "description": "@azure/arm-edgemarketplace client library samples for JavaScript (Beta)", + "engines": { + "node": ">=20.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/edgemarketplace/arm-edgemarketplace" + }, + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/edgemarketplace/arm-edgemarketplace", + "dependencies": { + "@azure/arm-edgemarketplace": "next", + "dotenv": "latest", + "@azure/identity": "^4.13.0" + }, + "devDependencies": { + "cross-env": "latest" + } +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/publishersGetSample.js b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/publishersGetSample.js new file mode 100644 index 000000000000..6f72a22b19d2 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/publishersGetSample.js @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { EdgeMarketplaceClient } = require("@azure/arm-edgemarketplace"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to get a Publisher + * + * @summary get a Publisher + * x-ms-original-file: 2025-10-01-preview/GetPublisher.json + */ +async function publishersGet() { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const result = await client.publishers.get( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + "canonical", + ); + console.log(result); +} + +async function main() { + await publishersGet(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/publishersListBySubscriptionSample.js b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/publishersListBySubscriptionSample.js new file mode 100644 index 000000000000..f12368de09f0 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/publishersListBySubscriptionSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { EdgeMarketplaceClient } = require("@azure/arm-edgemarketplace"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list Publisher resources by subscription ID + * + * @summary list Publisher resources by subscription ID + * x-ms-original-file: 2025-10-01-preview/ListPublishersBySubscription.json + */ +async function publishersListBySubscription() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "4bed37fd-19a1-4d31-8b44-40267555bec5"; + const client = new EdgeMarketplaceClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.publishers.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await publishersListBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/publishersListSample.js b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/publishersListSample.js new file mode 100644 index 000000000000..39a4e97e9de0 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/publishersListSample.js @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { EdgeMarketplaceClient } = require("@azure/arm-edgemarketplace"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list Publisher resources by parent + * + * @summary list Publisher resources by parent + * x-ms-original-file: 2025-10-01-preview/ListPublishers.json + */ +async function publishersList() { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const resArray = new Array(); + for await (const item of client.publishers.list( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await publishersList(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/sample.env b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/sample.env new file mode 100644 index 000000000000..508439fc7d62 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/javascript/sample.env @@ -0,0 +1 @@ +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/README.md b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/README.md new file mode 100644 index 000000000000..1264bee47543 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/README.md @@ -0,0 +1,79 @@ +# @azure/arm-edgemarketplace client library samples for TypeScript (Beta) + +These sample programs show how to use the TypeScript client libraries for @azure/arm-edgemarketplace in some common scenarios. + +| **File Name** | **Description** | +| --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | +| [offersGenerateAccessTokenSample.ts][offersgenerateaccesstokensample] | a long-running resource action. x-ms-original-file: 2025-10-01-preview/GenerateAccessToken.json | +| [offersGetAccessTokenSample.ts][offersgetaccesstokensample] | get access token. x-ms-original-file: 2025-10-01-preview/GetAccessToken.json | +| [offersGetSample.ts][offersgetsample] | get a Offer x-ms-original-file: 2025-10-01-preview/GetOffer.json | +| [offersListBySubscriptionSample.ts][offerslistbysubscriptionsample] | list Offer resources by subscription ID x-ms-original-file: 2025-10-01-preview/ListOffersBySubscription.json | +| [offersListSample.ts][offerslistsample] | list Offer resources by parent x-ms-original-file: 2025-10-01-preview/ListOffers.json | +| [operationsListSample.ts][operationslistsample] | list the operations for the provider x-ms-original-file: 2025-10-01-preview/ListOperations.json | +| [publishersGetSample.ts][publishersgetsample] | get a Publisher x-ms-original-file: 2025-10-01-preview/GetPublisher.json | +| [publishersListBySubscriptionSample.ts][publisherslistbysubscriptionsample] | list Publisher resources by subscription ID x-ms-original-file: 2025-10-01-preview/ListPublishersBySubscription.json | +| [publishersListSample.ts][publisherslistsample] | list Publisher resources by parent x-ms-original-file: 2025-10-01-preview/ListPublishers.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using: + +```bash +npm install -g typescript +``` + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Compile the samples: + +```bash +npm run build +``` + +3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +4. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node dist/offersGenerateAccessTokenSample.js +``` + +Alternatively, run a single sample with the required environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +node dist/offersGenerateAccessTokenSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[offersgenerateaccesstokensample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersGenerateAccessTokenSample.ts +[offersgetaccesstokensample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersGetAccessTokenSample.ts +[offersgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersGetSample.ts +[offerslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersListBySubscriptionSample.ts +[offerslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersListSample.ts +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/operationsListSample.ts +[publishersgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/publishersGetSample.ts +[publisherslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/publishersListBySubscriptionSample.ts +[publisherslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/publishersListSample.ts +[apiref]: https://learn.microsoft.com/javascript/api/@azure/arm-edgemarketplace?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/edgemarketplace/arm-edgemarketplace/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/package.json b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/package.json new file mode 100644 index 000000000000..5273368f3999 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/package.json @@ -0,0 +1,43 @@ +{ + "name": "@azure-samples/arm-edgemarketplace-ts-beta", + "private": true, + "version": "1.0.0", + "description": "@azure/arm-edgemarketplace client library samples for TypeScript (Beta)", + "engines": { + "node": ">=20.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/edgemarketplace/arm-edgemarketplace" + }, + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/edgemarketplace/arm-edgemarketplace", + "dependencies": { + "@azure/arm-edgemarketplace": "next", + "dotenv": "latest", + "@azure/identity": "^4.13.0" + }, + "devDependencies": { + "@types/node": "^20.0.0", + "cross-env": "latest", + "rimraf": "latest", + "typescript": "~5.9.3" + } +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/sample.env b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/sample.env new file mode 100644 index 000000000000..508439fc7d62 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/sample.env @@ -0,0 +1 @@ +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersGenerateAccessTokenSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersGenerateAccessTokenSample.ts new file mode 100644 index 000000000000..80c52e5d1aac --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersGenerateAccessTokenSample.ts @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to a long-running resource action. + * + * @summary a long-running resource action. + * x-ms-original-file: 2025-10-01-preview/GenerateAccessToken.json + */ +async function offersGenerateAccessToken(): Promise { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const result = await client.offers.generateAccessToken( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + "0001-com-ubuntu-pro-jammy", + { + deviceVersion: "1.0.18062.1", + deviceSku: "edge", + egeMarketPlaceResourceId: "testid", + edgeMarketPlaceRegion: "EastUS2Euap", + hypervGeneration: "V2", + marketPlaceSku: "2022-datacenter-azure-edition-core", + marketPlaceSkuVersion: "20348.1129.221007", + publisherName: "ubuntu", + }, + ); + console.log(result); +} + +async function main(): Promise { + await offersGenerateAccessToken(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersGetAccessTokenSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersGetAccessTokenSample.ts new file mode 100644 index 000000000000..f5e0877214b1 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersGetAccessTokenSample.ts @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get access token. + * + * @summary get access token. + * x-ms-original-file: 2025-10-01-preview/GetAccessToken.json + */ +async function offersGetAccessToken(): Promise { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const result = await client.offers.getAccessToken( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + "0001-com-ubuntu-pro-jammy", + { requestId: "1.0.18062.1" }, + ); + console.log(result); +} + +async function main(): Promise { + await offersGetAccessToken(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersGetSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersGetSample.ts new file mode 100644 index 000000000000..2ae09ce3cfa9 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersGetSample.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a Offer + * + * @summary get a Offer + * x-ms-original-file: 2025-10-01-preview/GetOffer.json + */ +async function offersGet(): Promise { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const result = await client.offers.get( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + "0001-com-ubuntu-pro-jammy", + ); + console.log(result); +} + +async function main(): Promise { + await offersGet(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersListBySubscriptionSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersListBySubscriptionSample.ts new file mode 100644 index 000000000000..208fd766ea10 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersListBySubscriptionSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Offer resources by subscription ID + * + * @summary list Offer resources by subscription ID + * x-ms-original-file: 2025-10-01-preview/ListOffersBySubscription.json + */ +async function offersListBySubscription(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "4bed37fd-19a1-4d31-8b44-40267555bec5"; + const client = new EdgeMarketplaceClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.offers.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await offersListBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersListSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersListSample.ts new file mode 100644 index 000000000000..4d36dc2c4327 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/offersListSample.ts @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Offer resources by parent + * + * @summary list Offer resources by parent + * x-ms-original-file: 2025-10-01-preview/ListOffers.json + */ +async function offersList(): Promise { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const resArray = new Array(); + for await (const item of client.offers.list( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await offersList(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/operationsListSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/operationsListSample.ts new file mode 100644 index 000000000000..58eb6af4bb09 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/operationsListSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list the operations for the provider + * + * @summary list the operations for the provider + * x-ms-original-file: 2025-10-01-preview/ListOperations.json + */ +async function operationsList(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new EdgeMarketplaceClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.operations.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await operationsList(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/publishersGetSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/publishersGetSample.ts new file mode 100644 index 000000000000..eeb323c31b74 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/publishersGetSample.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a Publisher + * + * @summary get a Publisher + * x-ms-original-file: 2025-10-01-preview/GetPublisher.json + */ +async function publishersGet(): Promise { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const result = await client.publishers.get( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + "canonical", + ); + console.log(result); +} + +async function main(): Promise { + await publishersGet(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/publishersListBySubscriptionSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/publishersListBySubscriptionSample.ts new file mode 100644 index 000000000000..0badec9f7b80 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/publishersListBySubscriptionSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Publisher resources by subscription ID + * + * @summary list Publisher resources by subscription ID + * x-ms-original-file: 2025-10-01-preview/ListPublishersBySubscription.json + */ +async function publishersListBySubscription(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "4bed37fd-19a1-4d31-8b44-40267555bec5"; + const client = new EdgeMarketplaceClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.publishers.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await publishersListBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/publishersListSample.ts b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/publishersListSample.ts new file mode 100644 index 000000000000..decf1b184c42 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/src/publishersListSample.ts @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "@azure/arm-edgemarketplace"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Publisher resources by parent + * + * @summary list Publisher resources by parent + * x-ms-original-file: 2025-10-01-preview/ListPublishers.json + */ +async function publishersList(): Promise { + const credential = new DefaultAzureCredential(); + const client = new EdgeMarketplaceClient(credential); + const resArray = new Array(); + for await (const item of client.publishers.list( + "subscriptions/4bed37fd-19a1-4d31-8b44-40267555bec5/resourceGroups/edgemarketplace-rg/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/edgemarketplace-demo", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await publishersList(); +} + +main().catch(console.error); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/tsconfig.json b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/tsconfig.json new file mode 100644 index 000000000000..400db87cf648 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/samples/v1-beta/typescript/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "ES2023", + "module": "commonjs", + "lib": [], + "importHelpers": true, + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node10", + "esModuleInterop": true, + "outDir": "./dist", + "resolveJsonModule": true + }, + "include": [ + "./src" + ] +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/api/edgeMarketplaceContext.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/api/edgeMarketplaceContext.ts new file mode 100644 index 000000000000..2de595fa63d0 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/api/edgeMarketplaceContext.ts @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { logger } from "../logger.js"; +import { KnownVersions } from "../models/models.js"; +import type { AzureSupportedClouds } from "../static-helpers/cloudSettingHelpers.js"; +import { getArmEndpoint } from "../static-helpers/cloudSettingHelpers.js"; +import type { Client, ClientOptions } from "@azure-rest/core-client"; +import { getClient } from "@azure-rest/core-client"; +import type { TokenCredential } from "@azure/core-auth"; + +/** Edge marketplace extensions */ +export interface EdgeMarketplaceContext extends Client { + /** The API version to use for this operation. */ + /** Known values of {@link KnownVersions} that the service accepts. */ + apiVersion: string; + /** The ID of the target subscription. The value must be an UUID. */ + subscriptionId: string; +} + +/** Optional parameters for the client. */ +export interface EdgeMarketplaceClientOptionalParams extends ClientOptions { + /** The API version to use for this operation. */ + /** Known values of {@link KnownVersions} that the service accepts. */ + apiVersion?: string; + /** Specifies the Azure cloud environment for the client. */ + cloudSetting?: AzureSupportedClouds; +} + +/** Edge marketplace extensions */ +export function createEdgeMarketplace( + credential: TokenCredential, + subscriptionId: string, + options: EdgeMarketplaceClientOptionalParams = {}, +): EdgeMarketplaceContext { + const endpointUrl = + options.endpoint ?? getArmEndpoint(options.cloudSetting) ?? "https://management.azure.com"; + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentInfo = `azsdk-js-arm-edgemarketplace/1.0.0-beta.1`; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}` + : `azsdk-js-api ${userAgentInfo}`; + const { apiVersion: _, ...updatedOptions } = { + ...options, + userAgentOptions: { userAgentPrefix }, + loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info }, + credentials: { scopes: options.credentials?.scopes ?? [`${endpointUrl}/.default`] }, + }; + const clientContext = getClient(endpointUrl, credential, updatedOptions); + clientContext.pipeline.removePolicy({ name: "ApiVersionPolicy" }); + const apiVersion = options.apiVersion ?? "2025-10-01-preview"; + clientContext.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")) { + req.url = `${req.url}${ + Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; + } + + return next(req); + }, + }); + return { ...clientContext, apiVersion, subscriptionId } as EdgeMarketplaceContext; +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/api/index.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/api/index.ts new file mode 100644 index 000000000000..19e873de0356 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/api/index.ts @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + createEdgeMarketplace, + EdgeMarketplaceContext, + EdgeMarketplaceClientOptionalParams, +} from "./edgeMarketplaceContext.js"; diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/api/offers/index.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/api/offers/index.ts new file mode 100644 index 000000000000..08f24f600e80 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/api/offers/index.ts @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + listBySubscription, + getAccessToken, + generateAccessToken, + list, + get, +} from "./operations.js"; +export { + OffersListBySubscriptionOptionalParams, + OffersGetAccessTokenOptionalParams, + OffersGenerateAccessTokenOptionalParams, + OffersListOptionalParams, + OffersGetOptionalParams, +} from "./options.js"; diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/api/offers/operations.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/api/offers/operations.ts new file mode 100644 index 000000000000..2767efa89a0d --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/api/offers/operations.ts @@ -0,0 +1,284 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { EdgeMarketplaceContext as Client } from "../index.js"; +import type { + Offer, + _OfferListResult, + AccessTokenRequest, + DiskAccessToken, + AccessTokenReadRequest, +} from "../../models/models.js"; +import { + errorResponseDeserializer, + offerDeserializer, + _offerListResultDeserializer, + accessTokenRequestSerializer, + diskAccessTokenDeserializer, + accessTokenReadRequestSerializer, +} from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { buildPagedAsyncIterator } from "../../static-helpers/pagingHelpers.js"; +import { getLongRunningPoller } from "../../static-helpers/pollingHelpers.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import type { + OffersListBySubscriptionOptionalParams, + OffersGetAccessTokenOptionalParams, + OffersGenerateAccessTokenOptionalParams, + OffersListOptionalParams, + OffersGetOptionalParams, +} from "./options.js"; +import type { StreamableMethod, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError, operationOptionsToRequestParameters } from "@azure-rest/core-client"; +import type { PollerLike, OperationState } from "@azure/core-lro"; + +export function _listBySubscriptionSend( + context: Client, + options: OffersListBySubscriptionOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.EdgeMarketplace/offers{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listBySubscriptionDeserialize( + result: PathUncheckedResponse, +): Promise<_OfferListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _offerListResultDeserializer(result.body); +} + +/** List Offer resources by subscription ID */ +export function listBySubscription( + context: Client, + options: OffersListBySubscriptionOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listBySubscriptionSend(context, options), + _listBySubscriptionDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _getAccessTokenSend( + context: Client, + resourceUri: string, + offerId: string, + body: AccessTokenReadRequest, + options: OffersGetAccessTokenOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/{+resourceUri}/providers/Microsoft.EdgeMarketplace/offers/{offerId}/getAccessToken{?api%2Dversion}", + { + resourceUri: resourceUri, + offerId: offerId, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: accessTokenReadRequestSerializer(body), + }); +} + +export async function _getAccessTokenDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return diskAccessTokenDeserializer(result.body); +} + +/** get access token. */ +export async function getAccessToken( + context: Client, + resourceUri: string, + offerId: string, + body: AccessTokenReadRequest, + options: OffersGetAccessTokenOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getAccessTokenSend(context, resourceUri, offerId, body, options); + return _getAccessTokenDeserialize(result); +} + +export function _generateAccessTokenSend( + context: Client, + resourceUri: string, + offerId: string, + body: AccessTokenRequest, + options: OffersGenerateAccessTokenOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/{+resourceUri}/providers/Microsoft.EdgeMarketplace/offers/{offerId}/generateAccessToken{?api%2Dversion}", + { + resourceUri: resourceUri, + offerId: offerId, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: accessTokenRequestSerializer(body), + }); +} + +export async function _generateAccessTokenDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["202", "200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return diskAccessTokenDeserializer(result.body); +} + +/** A long-running resource action. */ +export function generateAccessToken( + context: Client, + resourceUri: string, + offerId: string, + body: AccessTokenRequest, + options: OffersGenerateAccessTokenOptionalParams = { requestOptions: {} }, +): PollerLike, DiskAccessToken> { + return getLongRunningPoller(context, _generateAccessTokenDeserialize, ["202", "200", "201"], { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _generateAccessTokenSend(context, resourceUri, offerId, body, options), + resourceLocationConfig: "location", + }) as PollerLike, DiskAccessToken>; +} + +export function _listSend( + context: Client, + resourceUri: string, + options: OffersListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/{+resourceUri}/providers/Microsoft.EdgeMarketplace/offers{?api%2Dversion,%24top,skip,maxpagesize,%24filter,%24skipToken}", + { + resourceUri: resourceUri, + "api%2Dversion": context.apiVersion, + "%24top": options?.top, + skip: options?.skip, + maxpagesize: options?.maxpagesize, + "%24filter": options?.filter, + "%24skipToken": options?.skipToken, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listDeserialize(result: PathUncheckedResponse): Promise<_OfferListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _offerListResultDeserializer(result.body); +} + +/** List Offer resources by parent */ +export function list( + context: Client, + resourceUri: string, + options: OffersListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listSend(context, resourceUri, options), + _listDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _getSend( + context: Client, + resourceUri: string, + offerId: string, + options: OffersGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/{+resourceUri}/providers/Microsoft.EdgeMarketplace/offers/{offerId}{?api%2Dversion}", + { + resourceUri: resourceUri, + offerId: offerId, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return offerDeserializer(result.body); +} + +/** Get a Offer */ +export async function get( + context: Client, + resourceUri: string, + offerId: string, + options: OffersGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getSend(context, resourceUri, offerId, options); + return _getDeserialize(result); +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/api/offers/options.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/api/offers/options.ts new file mode 100644 index 000000000000..f189e1653a04 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/api/offers/options.ts @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface OffersListBySubscriptionOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface OffersGetAccessTokenOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface OffersGenerateAccessTokenOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface OffersListOptionalParams extends OperationOptions { + /** 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; + /** Filter the result list using the given expression. */ + filter?: string; + /** Skip over when retrieving results. */ + skipToken?: string; +} + +/** Optional parameters. */ +export interface OffersGetOptionalParams extends OperationOptions {} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/api/operations/index.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/api/operations/index.ts new file mode 100644 index 000000000000..24a804d14fcf --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/api/operations/index.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { list } from "./operations.js"; +export { OperationsListOptionalParams } from "./options.js"; diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/api/operations/operations.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/api/operations/operations.ts new file mode 100644 index 000000000000..3d82418e80a3 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/api/operations/operations.ts @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { EdgeMarketplaceContext as Client } from "../index.js"; +import type { _OperationListResult, Operation } from "../../models/models.js"; +import { + _operationListResultDeserializer, + errorResponseDeserializer, +} from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { buildPagedAsyncIterator } from "../../static-helpers/pagingHelpers.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import type { OperationsListOptionalParams } from "./options.js"; +import type { StreamableMethod, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError, operationOptionsToRequestParameters } from "@azure-rest/core-client"; + +export function _listSend( + context: Client, + options: OperationsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.EdgeMarketplace/operations{?api%2Dversion}", + { + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listDeserialize( + result: PathUncheckedResponse, +): Promise<_OperationListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _operationListResultDeserializer(result.body); +} + +/** List the operations for the provider */ +export function list( + context: Client, + options: OperationsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listSend(context, options), + _listDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/api/operations/options.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/api/operations/options.ts new file mode 100644 index 000000000000..b9a3fd9758a3 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/api/operations/options.ts @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface OperationsListOptionalParams extends OperationOptions {} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/api/publishers/index.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/api/publishers/index.ts new file mode 100644 index 000000000000..2c13453b641a --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/api/publishers/index.ts @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { listBySubscription, list, get } from "./operations.js"; +export { + PublishersListBySubscriptionOptionalParams, + PublishersListOptionalParams, + PublishersGetOptionalParams, +} from "./options.js"; diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/api/publishers/operations.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/api/publishers/operations.ts new file mode 100644 index 000000000000..44ebbd46f12a --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/api/publishers/operations.ts @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { EdgeMarketplaceContext as Client } from "../index.js"; +import type { Publisher, _PublisherListResult } from "../../models/models.js"; +import { + errorResponseDeserializer, + publisherDeserializer, + _publisherListResultDeserializer, +} from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { buildPagedAsyncIterator } from "../../static-helpers/pagingHelpers.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import type { + PublishersListBySubscriptionOptionalParams, + PublishersListOptionalParams, + PublishersGetOptionalParams, +} from "./options.js"; +import type { StreamableMethod, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError, operationOptionsToRequestParameters } from "@azure-rest/core-client"; + +export function _listBySubscriptionSend( + context: Client, + options: PublishersListBySubscriptionOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.EdgeMarketplace/publishers{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listBySubscriptionDeserialize( + result: PathUncheckedResponse, +): Promise<_PublisherListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _publisherListResultDeserializer(result.body); +} + +/** List Publisher resources by subscription ID */ +export function listBySubscription( + context: Client, + options: PublishersListBySubscriptionOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listBySubscriptionSend(context, options), + _listBySubscriptionDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _listSend( + context: Client, + resourceUri: string, + options: PublishersListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/{+resourceUri}/providers/Microsoft.EdgeMarketplace/publishers{?api%2Dversion,%24top,skip,maxpagesize,%24filter,%24skipToken}", + { + resourceUri: resourceUri, + "api%2Dversion": context.apiVersion, + "%24top": options?.top, + skip: options?.skip, + maxpagesize: options?.maxpagesize, + "%24filter": options?.filter, + "%24skipToken": options?.skipToken, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listDeserialize( + result: PathUncheckedResponse, +): Promise<_PublisherListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _publisherListResultDeserializer(result.body); +} + +/** List Publisher resources by parent */ +export function list( + context: Client, + resourceUri: string, + options: PublishersListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listSend(context, resourceUri, options), + _listDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _getSend( + context: Client, + resourceUri: string, + publisherName: string, + options: PublishersGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/{+resourceUri}/providers/Microsoft.EdgeMarketplace/publishers/{publisherName}{?api%2Dversion}", + { + resourceUri: resourceUri, + publisherName: publisherName, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return publisherDeserializer(result.body); +} + +/** Get a Publisher */ +export async function get( + context: Client, + resourceUri: string, + publisherName: string, + options: PublishersGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getSend(context, resourceUri, publisherName, options); + return _getDeserialize(result); +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/api/publishers/options.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/api/publishers/options.ts new file mode 100644 index 000000000000..832786c26252 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/api/publishers/options.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface PublishersListBySubscriptionOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PublishersListOptionalParams extends OperationOptions { + /** 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; + /** Filter the result list using the given expression. */ + filter?: string; + /** Skip over when retrieving results. */ + skipToken?: string; +} + +/** Optional parameters. */ +export interface PublishersGetOptionalParams extends OperationOptions {} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/classic/index.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/classic/index.ts new file mode 100644 index 000000000000..4fb04a0cabba --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/classic/index.ts @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { OffersOperations } from "./offers/index.js"; +export { OperationsOperations } from "./operations/index.js"; +export { PublishersOperations } from "./publishers/index.js"; diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/classic/offers/index.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/classic/offers/index.ts new file mode 100644 index 000000000000..9510671b22ac --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/classic/offers/index.ts @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { EdgeMarketplaceContext } from "../../api/edgeMarketplaceContext.js"; +import { + listBySubscription, + getAccessToken, + generateAccessToken, + list, + get, +} from "../../api/offers/operations.js"; +import type { + OffersListBySubscriptionOptionalParams, + OffersGetAccessTokenOptionalParams, + OffersGenerateAccessTokenOptionalParams, + OffersListOptionalParams, + OffersGetOptionalParams, +} from "../../api/offers/options.js"; +import type { + Offer, + AccessTokenRequest, + DiskAccessToken, + AccessTokenReadRequest, +} from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import type { PollerLike, OperationState } from "@azure/core-lro"; + +/** Interface representing a Offers operations. */ +export interface OffersOperations { + /** List Offer resources by subscription ID */ + listBySubscription: ( + options?: OffersListBySubscriptionOptionalParams, + ) => PagedAsyncIterableIterator; + /** get access token. */ + getAccessToken: ( + resourceUri: string, + offerId: string, + body: AccessTokenReadRequest, + options?: OffersGetAccessTokenOptionalParams, + ) => Promise; + /** A long-running resource action. */ + generateAccessToken: ( + resourceUri: string, + offerId: string, + body: AccessTokenRequest, + options?: OffersGenerateAccessTokenOptionalParams, + ) => PollerLike, DiskAccessToken>; + /** List Offer resources by parent */ + list: ( + resourceUri: string, + options?: OffersListOptionalParams, + ) => PagedAsyncIterableIterator; + /** Get a Offer */ + get: (resourceUri: string, offerId: string, options?: OffersGetOptionalParams) => Promise; +} + +function _getOffers(context: EdgeMarketplaceContext) { + return { + listBySubscription: (options?: OffersListBySubscriptionOptionalParams) => + listBySubscription(context, options), + getAccessToken: ( + resourceUri: string, + offerId: string, + body: AccessTokenReadRequest, + options?: OffersGetAccessTokenOptionalParams, + ) => getAccessToken(context, resourceUri, offerId, body, options), + generateAccessToken: ( + resourceUri: string, + offerId: string, + body: AccessTokenRequest, + options?: OffersGenerateAccessTokenOptionalParams, + ) => generateAccessToken(context, resourceUri, offerId, body, options), + list: (resourceUri: string, options?: OffersListOptionalParams) => + list(context, resourceUri, options), + get: (resourceUri: string, offerId: string, options?: OffersGetOptionalParams) => + get(context, resourceUri, offerId, options), + }; +} + +export function _getOffersOperations(context: EdgeMarketplaceContext): OffersOperations { + return { + ..._getOffers(context), + }; +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/classic/operations/index.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/classic/operations/index.ts new file mode 100644 index 000000000000..43b0783a7001 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/classic/operations/index.ts @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { EdgeMarketplaceContext } from "../../api/edgeMarketplaceContext.js"; +import { list } from "../../api/operations/operations.js"; +import type { OperationsListOptionalParams } from "../../api/operations/options.js"; +import type { Operation } from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a Operations operations. */ +export interface OperationsOperations { + /** List the operations for the provider */ + list: (options?: OperationsListOptionalParams) => PagedAsyncIterableIterator; +} + +function _getOperations(context: EdgeMarketplaceContext) { + return { + list: (options?: OperationsListOptionalParams) => list(context, options), + }; +} + +export function _getOperationsOperations(context: EdgeMarketplaceContext): OperationsOperations { + return { + ..._getOperations(context), + }; +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/classic/publishers/index.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/classic/publishers/index.ts new file mode 100644 index 000000000000..bbbe46d5e7d2 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/classic/publishers/index.ts @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { EdgeMarketplaceContext } from "../../api/edgeMarketplaceContext.js"; +import { listBySubscription, list, get } from "../../api/publishers/operations.js"; +import type { + PublishersListBySubscriptionOptionalParams, + PublishersListOptionalParams, + PublishersGetOptionalParams, +} from "../../api/publishers/options.js"; +import type { Publisher } from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a Publishers operations. */ +export interface PublishersOperations { + /** List Publisher resources by subscription ID */ + listBySubscription: ( + options?: PublishersListBySubscriptionOptionalParams, + ) => PagedAsyncIterableIterator; + /** List Publisher resources by parent */ + list: ( + resourceUri: string, + options?: PublishersListOptionalParams, + ) => PagedAsyncIterableIterator; + /** Get a Publisher */ + get: ( + resourceUri: string, + publisherName: string, + options?: PublishersGetOptionalParams, + ) => Promise; +} + +function _getPublishers(context: EdgeMarketplaceContext) { + return { + listBySubscription: (options?: PublishersListBySubscriptionOptionalParams) => + listBySubscription(context, options), + list: (resourceUri: string, options?: PublishersListOptionalParams) => + list(context, resourceUri, options), + get: (resourceUri: string, publisherName: string, options?: PublishersGetOptionalParams) => + get(context, resourceUri, publisherName, options), + }; +} + +export function _getPublishersOperations(context: EdgeMarketplaceContext): PublishersOperations { + return { + ..._getPublishers(context), + }; +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/edgeMarketplaceClient.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/edgeMarketplaceClient.ts new file mode 100644 index 000000000000..a783c01d6ed2 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/edgeMarketplaceClient.ts @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { EdgeMarketplaceContext, EdgeMarketplaceClientOptionalParams } from "./api/index.js"; +import { createEdgeMarketplace } from "./api/index.js"; +import type { OffersOperations } from "./classic/offers/index.js"; +import { _getOffersOperations } from "./classic/offers/index.js"; +import type { OperationsOperations } from "./classic/operations/index.js"; +import { _getOperationsOperations } from "./classic/operations/index.js"; +import type { PublishersOperations } from "./classic/publishers/index.js"; +import { _getPublishersOperations } from "./classic/publishers/index.js"; +import type { TokenCredential } from "@azure/core-auth"; +import type { Pipeline } from "@azure/core-rest-pipeline"; + +export { EdgeMarketplaceClientOptionalParams } from "./api/edgeMarketplaceContext.js"; + +export class EdgeMarketplaceClient { + private _client: EdgeMarketplaceContext; + /** The pipeline used by this client to make requests */ + public readonly pipeline: Pipeline; + + constructor(credential: TokenCredential, options?: EdgeMarketplaceClientOptionalParams); + constructor( + credential: TokenCredential, + subscriptionId: string, + options?: EdgeMarketplaceClientOptionalParams, + ); + /** Edge marketplace extensions */ + constructor( + credential: TokenCredential, + subscriptionIdOrOptions?: string | EdgeMarketplaceClientOptionalParams, + options?: EdgeMarketplaceClientOptionalParams, + ) { + let subscriptionId: string | undefined; + + if (typeof subscriptionIdOrOptions === "string") { + subscriptionId = subscriptionIdOrOptions; + } else if (typeof subscriptionIdOrOptions === "object") { + options = subscriptionIdOrOptions; + } + + options = options ?? {}; + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-client` + : `azsdk-js-client`; + this._client = createEdgeMarketplace(credential, subscriptionId ?? "", { + ...options, + userAgentOptions: { userAgentPrefix }, + }); + this.pipeline = this._client.pipeline; + this.publishers = _getPublishersOperations(this._client); + this.offers = _getOffersOperations(this._client); + this.operations = _getOperationsOperations(this._client); + } + + /** The operation groups for publishers */ + public readonly publishers: PublishersOperations; + /** The operation groups for offers */ + public readonly offers: OffersOperations; + /** The operation groups for operations */ + public readonly operations: OperationsOperations; +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/index.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/index.ts new file mode 100644 index 000000000000..8e2fb0db7046 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/index.ts @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { AzureClouds, AzureSupportedClouds } from "./static-helpers/cloudSettingHelpers.js"; +import { + PageSettings, + ContinuablePage, + PagedAsyncIterableIterator, +} from "./static-helpers/pagingHelpers.js"; + +export { EdgeMarketplaceClient } from "./edgeMarketplaceClient.js"; +export { restorePoller, RestorePollerOptions } from "./restorePollerHelpers.js"; +export { + Operation, + OperationDisplay, + KnownOrigin, + Origin, + KnownActionType, + ActionType, + ErrorResponse, + ErrorDetail, + ErrorAdditionalInfo, + Offer, + OfferProperties, + OfferContent, + OfferPublisher, + KnownOfferAvailability, + OfferAvailability, + KnownOfferReleaseType, + OfferReleaseType, + IconFileUris, + TermsAndConditions, + KnownResourceProvisioningState, + ResourceProvisioningState, + MarketplaceSku, + SkuOperatingSystem, + MarketplaceSkuVersion, + KnownOfferLaunchType, + OfferLaunchType, + ExtensionResource, + Resource, + SystemData, + KnownCreatedByType, + CreatedByType, + AccessTokenRequest, + DiskAccessToken, + AccessTokenReadRequest, + Publisher, + PublisherProperties, + KnownVersions, +} from "./models/index.js"; +export { EdgeMarketplaceClientOptionalParams } from "./api/index.js"; +export { + OffersListBySubscriptionOptionalParams, + OffersGetAccessTokenOptionalParams, + OffersGenerateAccessTokenOptionalParams, + OffersListOptionalParams, + OffersGetOptionalParams, +} from "./api/offers/index.js"; +export { OperationsListOptionalParams } from "./api/operations/index.js"; +export { + PublishersListBySubscriptionOptionalParams, + PublishersListOptionalParams, + PublishersGetOptionalParams, +} from "./api/publishers/index.js"; +export { OffersOperations, OperationsOperations, PublishersOperations } from "./classic/index.js"; +export { PageSettings, ContinuablePage, PagedAsyncIterableIterator }; +export { AzureClouds, AzureSupportedClouds }; diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/logger.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/logger.ts new file mode 100644 index 000000000000..b6437805b0e3 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/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("arm-edgemarketplace"); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/models/index.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/models/index.ts new file mode 100644 index 000000000000..ead920afb16f --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/models/index.ts @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + Operation, + OperationDisplay, + KnownOrigin, + Origin, + KnownActionType, + ActionType, + ErrorResponse, + ErrorDetail, + ErrorAdditionalInfo, + Offer, + OfferProperties, + OfferContent, + OfferPublisher, + KnownOfferAvailability, + OfferAvailability, + KnownOfferReleaseType, + OfferReleaseType, + IconFileUris, + TermsAndConditions, + KnownResourceProvisioningState, + ResourceProvisioningState, + MarketplaceSku, + SkuOperatingSystem, + MarketplaceSkuVersion, + KnownOfferLaunchType, + OfferLaunchType, + ExtensionResource, + Resource, + SystemData, + KnownCreatedByType, + CreatedByType, + AccessTokenRequest, + DiskAccessToken, + AccessTokenReadRequest, + Publisher, + PublisherProperties, + KnownVersions, +} from "./models.js"; diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/models/models.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/models/models.ts new file mode 100644 index 000000000000..ec9c628c86c6 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/models/models.ts @@ -0,0 +1,753 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * This file contains only generated model types and their (de)serializers. + * Disable the following rules for internal models with '_' prefix and deserializers which require 'any' for raw JSON input. + */ +/* eslint-disable @typescript-eslint/naming-convention */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/** A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. */ +export interface _OperationListResult { + /** The Operation items on this page */ + value: Operation[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _operationListResultDeserializer(item: any): _OperationListResult { + return { + value: operationArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function operationArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return operationDeserializer(item); + }); +} + +/** Details of a REST API operation, returned from the Resource Provider Operations API */ +export interface Operation { + /** The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" */ + readonly name?: string; + /** Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. */ + readonly isDataAction?: boolean; + /** Localized display information for this particular operation. */ + display?: OperationDisplay; + /** The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" */ + readonly origin?: Origin; + /** Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. */ + readonly actionType?: ActionType; +} + +export function operationDeserializer(item: any): Operation { + return { + name: item["name"], + isDataAction: item["isDataAction"], + display: !item["display"] ? item["display"] : operationDisplayDeserializer(item["display"]), + origin: item["origin"], + actionType: item["actionType"], + }; +} + +/** Localized display information for and operation. */ +export interface OperationDisplay { + /** The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". */ + readonly provider?: string; + /** The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". */ + readonly resource?: string; + /** The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". */ + readonly operation?: string; + /** The short, localized friendly description of the operation; suitable for tool tips and detailed views. */ + readonly description?: string; +} + +export function operationDisplayDeserializer(item: any): OperationDisplay { + return { + provider: item["provider"], + resource: item["resource"], + operation: item["operation"], + description: item["description"], + }; +} + +/** The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" */ +export enum KnownOrigin { + /** Indicates the operation is initiated by a user. */ + User = "user", + /** Indicates the operation is initiated by a system. */ + System = "system", + /** Indicates the operation is initiated by a user or system. */ + UserSystem = "user,system", +} + +/** + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" \ + * {@link KnownOrigin} can be used interchangeably with Origin, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **user**: Indicates the operation is initiated by a user. \ + * **system**: Indicates the operation is initiated by a system. \ + * **user,system**: Indicates the operation is initiated by a user or system. + */ +export type Origin = string; + +/** Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. */ +export enum KnownActionType { + /** Actions are for internal-only APIs. */ + Internal = "Internal", +} + +/** + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. \ + * {@link KnownActionType} can be used interchangeably with ActionType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Internal**: Actions are for internal-only APIs. + */ +export type ActionType = string; + +/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. */ +export interface ErrorResponse { + /** The error object. */ + error?: ErrorDetail; +} + +export function errorResponseDeserializer(item: any): ErrorResponse { + return { + error: !item["error"] ? item["error"] : errorDetailDeserializer(item["error"]), + }; +} + +/** The error detail. */ +export interface ErrorDetail { + /** The error code. */ + readonly code?: string; + /** The error message. */ + readonly message?: string; + /** The error target. */ + readonly target?: string; + /** The error details. */ + readonly details?: ErrorDetail[]; + /** The error additional info. */ + readonly additionalInfo?: ErrorAdditionalInfo[]; +} + +export function errorDetailDeserializer(item: any): ErrorDetail { + return { + code: item["code"], + message: item["message"], + target: item["target"], + details: !item["details"] ? item["details"] : errorDetailArrayDeserializer(item["details"]), + additionalInfo: !item["additionalInfo"] + ? item["additionalInfo"] + : errorAdditionalInfoArrayDeserializer(item["additionalInfo"]), + }; +} + +export function errorDetailArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return errorDetailDeserializer(item); + }); +} + +export function errorAdditionalInfoArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return errorAdditionalInfoDeserializer(item); + }); +} + +/** The resource management error additional info. */ +export interface ErrorAdditionalInfo { + /** The additional info type. */ + readonly type?: string; + /** The additional info. */ + readonly info?: any; +} + +export function errorAdditionalInfoDeserializer(item: any): ErrorAdditionalInfo { + return { + type: item["type"], + info: item["info"], + }; +} + +/** An offer. */ +export interface Offer extends ExtensionResource { + /** The resource-specific properties for this resource. */ + properties?: OfferProperties; +} + +export function offerDeserializer(item: any): Offer { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : offerPropertiesDeserializer(item["properties"]), + }; +} + +/** The offer properties */ +export interface OfferProperties { + /** The content version */ + contentVersion?: string; + /** The content url */ + contentUrl?: string; + /** The offer content */ + offerContent: OfferContent; + /** The resource provisioning state */ + readonly provisioningState?: ResourceProvisioningState; + /** The marketplace skus */ + marketplaceSkus?: MarketplaceSku[]; +} + +export function offerPropertiesDeserializer(item: any): OfferProperties { + return { + contentVersion: item["contentVersion"], + contentUrl: item["contentUrl"], + offerContent: offerContentDeserializer(item["offerContent"]), + provisioningState: item["provisioningState"], + marketplaceSkus: !item["marketplaceSkus"] + ? item["marketplaceSkus"] + : marketplaceSkuArrayDeserializer(item["marketplaceSkus"]), + }; +} + +/** The offer content */ +export interface OfferContent { + /** The display name of the offer */ + displayName: string; + /** The summary */ + summary?: string; + /** The long summary */ + longSummary?: string; + /** The description */ + description?: string; + /** The offer id */ + offerId: string; + /** The offer type */ + offerType?: string; + /** The support uri */ + supportUri?: string; + /** The popularity of the offer */ + popularity?: number; + /** The publisher of the offer */ + offerPublisher?: OfferPublisher; + /** The availability of the offer */ + availability?: OfferAvailability; + /** The release type of the offer */ + releaseType?: OfferReleaseType; + /** The icon files */ + iconFileUris?: IconFileUris; + /** The terms and conditions */ + termsAndConditions?: TermsAndConditions; + /** The category ids */ + categoryIds?: string[]; + /** The operating systems */ + operatingSystems?: string[]; +} + +export function offerContentDeserializer(item: any): OfferContent { + return { + displayName: item["displayName"], + summary: item["summary"], + longSummary: item["longSummary"], + description: item["description"], + offerId: item["offerId"], + offerType: item["offerType"], + supportUri: item["supportUri"], + popularity: item["popularity"], + offerPublisher: !item["offerPublisher"] + ? item["offerPublisher"] + : offerPublisherDeserializer(item["offerPublisher"]), + availability: item["availability"], + releaseType: item["releaseType"], + iconFileUris: !item["iconFileUris"] + ? item["iconFileUris"] + : iconFileUrisDeserializer(item["iconFileUris"]), + termsAndConditions: !item["termsAndConditions"] + ? item["termsAndConditions"] + : termsAndConditionsDeserializer(item["termsAndConditions"]), + categoryIds: !item["categoryIds"] + ? item["categoryIds"] + : item["categoryIds"].map((p: any) => { + return p; + }), + operatingSystems: !item["operatingSystems"] + ? item["operatingSystems"] + : item["operatingSystems"].map((p: any) => { + return p; + }), + }; +} + +/** The offer publisher */ +export interface OfferPublisher { + /** The publisher Id */ + publisherId: string; + /** The publisher name */ + publisherDisplayName: string; +} + +export function offerPublisherDeserializer(item: any): OfferPublisher { + return { + publisherId: item["publisherId"], + publisherDisplayName: item["publisherDisplayName"], + }; +} + +/** OfferAvailability Enum */ +export enum KnownOfferAvailability { + /** The offer availability is private */ + Private = "Private", + /** The offer availability is public */ + Public = "Public", +} + +/** + * OfferAvailability Enum \ + * {@link KnownOfferAvailability} can be used interchangeably with OfferAvailability, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Private**: The offer availability is private \ + * **Public**: The offer availability is public + */ +export type OfferAvailability = string; + +/** Offer release type Enum */ +export enum KnownOfferReleaseType { + /** The offer in preview */ + Preview = "Preview", + /** The offer in GA */ + GA = "GA", +} + +/** + * Offer release type Enum \ + * {@link KnownOfferReleaseType} can be used interchangeably with OfferReleaseType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Preview**: The offer in preview \ + * **GA**: The offer in GA + */ +export type OfferReleaseType = string; + +/** Icon files */ +export interface IconFileUris { + /** uri of small icon */ + small?: string; + /** uri of medium icon */ + medium?: string; + /** uri of wide icon */ + wide?: string; + /** uri of large icon */ + large?: string; +} + +export function iconFileUrisDeserializer(item: any): IconFileUris { + return { + small: item["small"], + medium: item["medium"], + wide: item["wide"], + large: item["large"], + }; +} + +/** Terms and conditions */ +export interface TermsAndConditions { + /** The legal terms and conditions uri */ + legalTermsUri?: string; + /** The type of legal terms */ + legalTermsType?: string; + /** The privacy policy uri */ + privacyPolicyUri?: string; +} + +export function termsAndConditionsDeserializer(item: any): TermsAndConditions { + return { + legalTermsUri: item["legalTermsUri"], + legalTermsType: item["legalTermsType"], + privacyPolicyUri: item["privacyPolicyUri"], + }; +} + +/** The provisioning state of a resource type. */ +export enum KnownResourceProvisioningState { + /** Resource has been created. */ + Succeeded = "Succeeded", + /** Resource creation failed. */ + Failed = "Failed", + /** Resource creation was canceled. */ + Canceled = "Canceled", +} + +/** + * The provisioning state of a resource type. \ + * {@link KnownResourceProvisioningState} can be used interchangeably with ResourceProvisioningState, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Succeeded**: Resource has been created. \ + * **Failed**: Resource creation failed. \ + * **Canceled**: Resource creation was canceled. + */ +export type ResourceProvisioningState = string; + +export function marketplaceSkuArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return marketplaceSkuDeserializer(item); + }); +} + +/** The marketplace sku */ +export interface MarketplaceSku { + /** The catalog plan id */ + catalogPlanId: string; + /** The marketplace sku id */ + marketplaceSkuId: string; + /** The type of marketplace sku */ + type?: string; + /** The display name of marketplace sku */ + displayName?: string; + /** The summary */ + summary?: string; + /** The long summary */ + longSummary?: string; + /** The description */ + description?: string; + /** The generation */ + generation?: string; + /** The display rank of the sku */ + displayRank?: number; + /** The operating system supported */ + operatingSystem?: SkuOperatingSystem; + /** The marketplace sku version */ + marketplaceSkuVersions?: MarketplaceSkuVersion[]; +} + +export function marketplaceSkuDeserializer(item: any): MarketplaceSku { + return { + catalogPlanId: item["catalogPlanId"], + marketplaceSkuId: item["marketplaceSkuId"], + type: item["type"], + displayName: item["displayName"], + summary: item["summary"], + longSummary: item["longSummary"], + description: item["description"], + generation: item["generation"], + displayRank: item["displayRank"], + operatingSystem: !item["operatingSystem"] + ? item["operatingSystem"] + : skuOperatingSystemDeserializer(item["operatingSystem"]), + marketplaceSkuVersions: !item["marketplaceSkuVersions"] + ? item["marketplaceSkuVersions"] + : marketplaceSkuVersionArrayDeserializer(item["marketplaceSkuVersions"]), + }; +} + +/** The sku operating system */ +export interface SkuOperatingSystem { + /** The family of the operating system */ + family?: string; + /** The type of the operating system */ + type?: string; + /** The name of the operating system */ + name: string; +} + +export function skuOperatingSystemDeserializer(item: any): SkuOperatingSystem { + return { + family: item["family"], + type: item["type"], + name: item["name"], + }; +} + +export function marketplaceSkuVersionArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return marketplaceSkuVersionDeserializer(item); + }); +} + +/** The marketplace sku version */ +export interface MarketplaceSkuVersion { + /** The name of sku version */ + name: string; + /** The size of the image */ + sizeOnDiskInMb?: number; + /** The size of the download */ + minimumDownloadSizeInMb?: number; + /** The stage name */ + stageName?: string; + /** The launch type */ + launchType?: OfferLaunchType; +} + +export function marketplaceSkuVersionDeserializer(item: any): MarketplaceSkuVersion { + return { + name: item["name"], + sizeOnDiskInMb: item["sizeOnDiskInMb"], + minimumDownloadSizeInMb: item["minimumDownloadSizeInMb"], + stageName: item["stageName"], + launchType: item["launchType"], + }; +} + +/** Offer launch type Enum */ +export enum KnownOfferLaunchType { + /** The offer has been certified */ + Trusted = "Trusted", + /** The offer has not been certified */ + Unknown = "Unknown", +} + +/** + * Offer launch type Enum \ + * {@link KnownOfferLaunchType} can be used interchangeably with OfferLaunchType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Trusted**: The offer has been certified \ + * **Unknown**: The offer has not been certified + */ +export type OfferLaunchType = string; + +/** The base extension resource. */ +export interface ExtensionResource extends Resource {} + +export function extensionResourceDeserializer(item: any): ExtensionResource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + }; +} + +/** Common fields that are returned in the response for all Azure Resource Manager resources */ +export interface Resource { + /** Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} */ + readonly id?: string; + /** The name of the resource */ + readonly name?: string; + /** The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" */ + readonly type?: string; + /** Azure Resource Manager metadata containing createdBy and modifiedBy information. */ + readonly systemData?: SystemData; +} + +export function resourceDeserializer(item: any): Resource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + }; +} + +/** Metadata pertaining to creation and last modification of the resource. */ +export interface SystemData { + /** The identity that created the resource. */ + createdBy?: string; + /** The type of identity that created the resource. */ + createdByType?: CreatedByType; + /** The timestamp of resource creation (UTC). */ + createdAt?: Date; + /** The identity that last modified the resource. */ + lastModifiedBy?: string; + /** The type of identity that last modified the resource. */ + lastModifiedByType?: CreatedByType; + /** The timestamp of resource last modification (UTC) */ + lastModifiedAt?: Date; +} + +export function systemDataDeserializer(item: any): SystemData { + return { + createdBy: item["createdBy"], + createdByType: item["createdByType"], + createdAt: !item["createdAt"] ? item["createdAt"] : new Date(item["createdAt"]), + lastModifiedBy: item["lastModifiedBy"], + lastModifiedByType: item["lastModifiedByType"], + lastModifiedAt: !item["lastModifiedAt"] + ? item["lastModifiedAt"] + : new Date(item["lastModifiedAt"]), + }; +} + +/** The kind of entity that created the resource. */ +export enum KnownCreatedByType { + /** The entity was created by a user. */ + User = "User", + /** The entity was created by an application. */ + Application = "Application", + /** The entity was created by a managed identity. */ + ManagedIdentity = "ManagedIdentity", + /** The entity was created by a key. */ + Key = "Key", +} + +/** + * The kind of entity that created the resource. \ + * {@link KnownCreatedByType} can be used interchangeably with CreatedByType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **User**: The entity was created by a user. \ + * **Application**: The entity was created by an application. \ + * **ManagedIdentity**: The entity was created by a managed identity. \ + * **Key**: The entity was created by a key. + */ +export type CreatedByType = string; + +/** The response of a Offer list operation. */ +export interface _OfferListResult { + /** The Offer items on this page */ + value: Offer[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _offerListResultDeserializer(item: any): _OfferListResult { + return { + value: offerArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function offerArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return offerDeserializer(item); + }); +} + +/** Access token request object */ +export interface AccessTokenRequest { + /** The name of the publisher. */ + publisherName?: string; + /** The region where the disk will be created. */ + edgeMarketPlaceRegion: string; + /** The region where the disk will be created. */ + egeMarketPlaceResourceId?: string; + /** The hyperv version. */ + hypervGeneration?: string; + /** The marketplace sku. */ + marketPlaceSku?: string; + /** The marketplace sku version. */ + marketPlaceSkuVersion?: string; + /** The device sku. */ + deviceSku?: string; + /** The device sku version. */ + deviceVersion?: string; +} + +export function accessTokenRequestSerializer(item: AccessTokenRequest): any { + return { + publisherName: item["publisherName"], + edgeMarketPlaceRegion: item["edgeMarketPlaceRegion"], + egeMarketPlaceResourceId: item["egeMarketPlaceResourceId"], + hypervGeneration: item["hypervGeneration"], + marketPlaceSku: item["marketPlaceSku"], + marketPlaceSkuVersion: item["marketPlaceSkuVersion"], + deviceSku: item["deviceSku"], + deviceVersion: item["deviceVersion"], + }; +} + +/** The disk access token */ +export interface DiskAccessToken { + /** The disk id. */ + diskId?: string; + /** The access token creation status. */ + status?: string; + /** The access token. */ + accessToken: string; +} + +export function diskAccessTokenDeserializer(item: any): DiskAccessToken { + return { + diskId: item["diskId"], + status: item["status"], + accessToken: item["accessToken"], + }; +} + +/** Access token request object */ +export interface AccessTokenReadRequest { + /** The name of the publisher. */ + requestId: string; +} + +export function accessTokenReadRequestSerializer(item: AccessTokenReadRequest): any { + return { requestId: item["requestId"] }; +} + +/** A publisher who provides offers. */ +export interface Publisher extends ExtensionResource { + /** The resource-specific properties for this resource. */ + properties?: PublisherProperties; +} + +export function publisherDeserializer(item: any): Publisher { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : publisherPropertiesDeserializer(item["properties"]), + }; +} + +/** Publisher properties */ +export interface PublisherProperties { + /** The resource provisioning state */ + readonly provisioningState?: ResourceProvisioningState; +} + +export function publisherPropertiesDeserializer(item: any): PublisherProperties { + return { + provisioningState: item["provisioningState"], + }; +} + +/** The response of a Publisher list operation. */ +export interface _PublisherListResult { + /** The Publisher items on this page */ + value: Publisher[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _publisherListResultDeserializer(item: any): _PublisherListResult { + return { + value: publisherArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function publisherArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return publisherDeserializer(item); + }); +} + +/** The available API versions. */ +export enum KnownVersions { + /** Version 2024-10-01 */ + V20241001 = "2024-10-01", + /** Version 2025-10-01-preview */ + V20251001Preview = "2025-10-01-preview", +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/restorePollerHelpers.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/restorePollerHelpers.ts new file mode 100644 index 000000000000..f41af859166b --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/restorePollerHelpers.ts @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { EdgeMarketplaceClient } from "./edgeMarketplaceClient.js"; +import { _generateAccessTokenDeserialize } from "./api/offers/operations.js"; +import { getLongRunningPoller } from "./static-helpers/pollingHelpers.js"; +import type { OperationOptions, PathUncheckedResponse } from "@azure-rest/core-client"; +import type { AbortSignalLike } from "@azure/abort-controller"; +import type { PollerLike, OperationState, ResourceLocationConfig } from "@azure/core-lro"; +import { deserializeState } from "@azure/core-lro"; + +export interface RestorePollerOptions< + TResult, + TResponse extends PathUncheckedResponse = PathUncheckedResponse, +> extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** + * The signal which can be used to abort requests. + */ + abortSignal?: AbortSignalLike; + /** Deserialization function for raw response body */ + processResponseBody?: (result: TResponse) => Promise; +} + +/** + * Creates a poller from the serialized state of another poller. This can be + * useful when you want to create pollers on a different host or a poller + * needs to be constructed after the original one is not in scope. + */ +export function restorePoller( + client: EdgeMarketplaceClient, + serializedState: string, + sourceOperation: (...args: any[]) => PollerLike, TResult>, + options?: RestorePollerOptions, +): PollerLike, TResult> { + const pollerConfig = deserializeState(serializedState).config; + const { initialRequestUrl, requestMethod, metadata } = pollerConfig; + if (!initialRequestUrl || !requestMethod) { + throw new Error( + `Invalid serialized state: ${serializedState} for sourceOperation ${sourceOperation?.name}`, + ); + } + const resourceLocationConfig = metadata?.["resourceLocationConfig"] as + | ResourceLocationConfig + | undefined; + const { deserializer, expectedStatuses = [] } = + getDeserializationHelper(initialRequestUrl, requestMethod) ?? {}; + const deserializeHelper = options?.processResponseBody ?? deserializer; + if (!deserializeHelper) { + throw new Error( + `Please ensure the operation is in this client! We can't find its deserializeHelper for ${sourceOperation?.name}.`, + ); + } + return getLongRunningPoller( + (client as any)["_client"] ?? client, + deserializeHelper as (result: TResponse) => Promise, + expectedStatuses, + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + resourceLocationConfig, + restoreFrom: serializedState, + initialRequestUrl, + }, + ); +} + +interface DeserializationHelper { + deserializer: (result: PathUncheckedResponse) => Promise; + expectedStatuses: string[]; +} + +const deserializeMap: Record = { + "POST /{resourceUri}/providers/Microsoft.EdgeMarketplace/offers/{offerId}/generateAccessToken": { + deserializer: _generateAccessTokenDeserialize, + expectedStatuses: ["202", "200", "201"], + }, +}; + +function getDeserializationHelper( + urlStr: string, + method: string, +): DeserializationHelper | undefined { + const path = new URL(urlStr).pathname; + 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: DeserializationHelper | undefined; + + // Iterate the responseMap to find a match + for (const [key, value] of Object.entries(deserializeMap)) { + // 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/edgemarketplace/arm-edgemarketplace/src/static-helpers/cloudSettingHelpers.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/static-helpers/cloudSettingHelpers.ts new file mode 100644 index 000000000000..613112c6e397 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/static-helpers/cloudSettingHelpers.ts @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * An enum to describe Azure Cloud environments. + * @enum {string} + */ +export enum AzureClouds { + /** Azure public cloud, which is the default cloud for Azure SDKs. */ + AZURE_PUBLIC_CLOUD = "AZURE_PUBLIC_CLOUD", + /** Azure China cloud */ + AZURE_CHINA_CLOUD = "AZURE_CHINA_CLOUD", + /** Azure US government cloud */ + AZURE_US_GOVERNMENT = "AZURE_US_GOVERNMENT", +} + +/** The supported values for cloud setting as a string literal type */ +export type AzureSupportedClouds = `${AzureClouds}`; + +/** + * Gets the Azure Resource Manager endpoint URL for the specified cloud setting. + * @param cloudSetting - The Azure cloud environment setting. Use one of the AzureClouds enum values. + * @returns The ARM endpoint URL for the specified cloud, or undefined if cloudSetting is undefined. + * @throws {Error} Throws an error if an unknown cloud setting is provided. + */ +export function getArmEndpoint(cloudSetting?: AzureSupportedClouds): string | undefined { + if (cloudSetting === undefined) { + return undefined; + } + const cloudEndpoints: Record = { + AZURE_CHINA_CLOUD: "https://management.chinacloudapi.cn/", + AZURE_US_GOVERNMENT: "https://management.usgovcloudapi.net/", + AZURE_PUBLIC_CLOUD: "https://management.azure.com/", + }; + if (cloudSetting in cloudEndpoints) { + return cloudEndpoints[cloudSetting]; + } else { + throw new Error( + `Unknown cloud setting: ${cloudSetting}. Please refer to the enum AzureClouds for possible values.`, + ); + } +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/static-helpers/pagingHelpers.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/static-helpers/pagingHelpers.ts new file mode 100644 index 000000000000..6f219e3c88cf --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/static-helpers/pagingHelpers.ts @@ -0,0 +1,246 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { Client, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError } from "@azure-rest/core-client"; +import { RestError } from "@azure/core-rest-pipeline"; + +/** + * Options for the byPage method + */ +export interface PageSettings { + /** + * A reference to a specific page to start iterating from. + */ + continuationToken?: string; +} + +/** + * An interface that describes a page of results. + */ +export type ContinuablePage = TPage & { + /** + * 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 extends PageSettings = 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. + */ +export interface PagedResult< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + /** + * Link to the first page of results. + */ + firstPageLink?: string; + /** + * A method that returns a page of results. + */ + getPage: (pageLink?: string) => Promise<{ page: TPage; nextPageLink?: string } | 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) => TElement[]; +} + +/** + * Options for the paging helper + */ +export interface BuildPagedAsyncIteratorOptions { + itemName?: string; + nextLinkName?: string; + nextLinkMethod?: "GET" | "POST"; +} + +/** + * Helper to paginate results in a generic way and return a PagedAsyncIterableIterator + */ +export function buildPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, + TResponse extends PathUncheckedResponse = PathUncheckedResponse, +>( + client: Client, + getInitialResponse: () => PromiseLike, + processResponseBody: (result: TResponse) => PromiseLike, + expectedStatuses: string[], + options: BuildPagedAsyncIteratorOptions = {}, +): PagedAsyncIterableIterator { + const itemName = options.itemName ?? "value"; + const nextLinkName = options.nextLinkName ?? "nextLink"; + const nextLinkMethod = options.nextLinkMethod ?? "GET"; + const pagedResult: PagedResult = { + getPage: async (pageLink?: string) => { + const result = + pageLink === undefined + ? await getInitialResponse() + : nextLinkMethod === "POST" + ? await client.pathUnchecked(pageLink).post() + : await client.pathUnchecked(pageLink).get(); + checkPagingRequest(result, expectedStatuses); + const results = await processResponseBody(result as TResponse); + const nextLink = getNextLink(results, nextLinkName); + const values = getElements(results, itemName) as TPage; + return { + page: values, + nextPageLink: nextLink, + }; + }, + byPage: (settings?: TPageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken, + }); + }, + }; + return getPagedAsyncIterator(pagedResult); +} + +/** + * 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 extends PageSettings = PageSettings, +>( + pagedResult: PagedResult, +): PagedAsyncIterableIterator { + const iter = getItemAsyncIterator(pagedResult); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: + pagedResult?.byPage ?? + ((settings?: TPageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken, + }); + }), + }; +} + +async function* getItemAsyncIterator( + pagedResult: PagedResult, +): AsyncIterableIterator { + const pages = getPageAsyncIterator(pagedResult); + for await (const page of pages) { + yield* page as unknown as TElement[]; + } +} + +async function* getPageAsyncIterator( + pagedResult: PagedResult, + options: { + pageLink?: string; + } = {}, +): AsyncIterableIterator> { + const { pageLink } = options; + let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink); + if (!response) { + return; + } + let result = response.page as ContinuablePage; + result.continuationToken = response.nextPageLink; + yield result; + while (response.nextPageLink) { + response = await pagedResult.getPage(response.nextPageLink); + if (!response) { + return; + } + result = response.page as ContinuablePage; + result.continuationToken = response.nextPageLink; + yield result; + } +} + +/** + * 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" && nextLink !== null) { + throw new RestError( + `Body Property ${nextLinkName} should be a string or undefined or null but got ${typeof nextLink}`, + ); + } + + if (nextLink === null) { + return 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[]; + if (!Array.isArray(value)) { + throw new RestError( + `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, expectedStatuses: string[]): void { + if (!expectedStatuses.includes(response.status)) { + throw createRestError( + `Pagination failed with unexpected statusCode ${response.status}`, + response, + ); + } +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/static-helpers/pollingHelpers.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/static-helpers/pollingHelpers.ts new file mode 100644 index 000000000000..63b3c201e5a8 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/static-helpers/pollingHelpers.ts @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { + PollerLike, + OperationState, + ResourceLocationConfig, + RunningOperation, + OperationResponse, +} from "@azure/core-lro"; +import { createHttpPoller } from "@azure/core-lro"; + +import type { Client, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError } from "@azure-rest/core-client"; +import type { AbortSignalLike } from "@azure/abort-controller"; + +export interface GetLongRunningPollerOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** + * The signal which can be used to abort requests. + */ + abortSignal?: AbortSignalLike; + /** + * The potential location of the result of the LRO if specified by the LRO extension in the swagger. + */ + resourceLocationConfig?: ResourceLocationConfig; + /** + * The original url of the LRO + * Should not be null when restoreFrom is set + */ + initialRequestUrl?: string; + /** + * A serialized poller which can be used to resume an existing paused Long-Running-Operation. + */ + restoreFrom?: string; + /** + * The function to get the initial response + */ + getInitialResponse?: () => PromiseLike; +} +export function getLongRunningPoller( + client: Client, + processResponseBody: (result: TResponse) => Promise, + expectedStatuses: string[], + options: GetLongRunningPollerOptions, +): PollerLike, TResult> { + const { restoreFrom, getInitialResponse } = options; + if (!restoreFrom && !getInitialResponse) { + throw new Error("Either restoreFrom or getInitialResponse must be specified"); + } + let initialResponse: TResponse | undefined = undefined; + const pollAbortController = new AbortController(); + const poller: RunningOperation = { + sendInitialRequest: async () => { + if (!getInitialResponse) { + throw new Error("getInitialResponse is required when initializing a new poller"); + } + initialResponse = await getInitialResponse(); + return getLroResponse(initialResponse, expectedStatuses); + }, + sendPollRequest: async ( + path: string, + pollOptions?: { + abortSignal?: AbortSignalLike; + }, + ) => { + // The poll request would both listen to the user provided abort signal and the poller's own abort signal + function abortListener(): void { + pollAbortController.abort(); + } + const abortSignal = pollAbortController.signal; + if (options.abortSignal?.aborted) { + pollAbortController.abort(); + } else if (pollOptions?.abortSignal?.aborted) { + pollAbortController.abort(); + } else if (!abortSignal.aborted) { + options.abortSignal?.addEventListener("abort", abortListener, { + once: true, + }); + pollOptions?.abortSignal?.addEventListener("abort", abortListener, { + once: true, + }); + } + let response; + try { + response = await client.pathUnchecked(path).get({ abortSignal }); + } finally { + options.abortSignal?.removeEventListener("abort", abortListener); + pollOptions?.abortSignal?.removeEventListener("abort", abortListener); + } + + return getLroResponse(response as TResponse, expectedStatuses); + }, + }; + return createHttpPoller(poller, { + intervalInMs: options?.updateIntervalInMs, + resourceLocationConfig: options?.resourceLocationConfig, + restoreFrom: options?.restoreFrom, + processResult: (result: unknown) => { + return processResponseBody(result as TResponse); + }, + }); +} +/** + * Converts a Rest Client response to a response that the LRO implementation understands + * @param response - a rest client http response + * @param deserializeFn - deserialize function to convert Rest response to modular output + * @returns - An LRO response that the LRO implementation understands + */ +function getLroResponse( + response: TResponse, + expectedStatuses: string[], +): OperationResponse { + if (!expectedStatuses.includes(response.status)) { + throw createRestError(response); + } + + return { + flatResponse: response, + rawResponse: { + ...response, + statusCode: Number.parseInt(response.status), + body: response.body, + }, + }; +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/src/static-helpers/urlTemplate.ts b/sdk/edgemarketplace/arm-edgemarketplace/src/static-helpers/urlTemplate.ts new file mode 100644 index 000000000000..c7109898692a --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/src/static-helpers/urlTemplate.ts @@ -0,0 +1,227 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// --------------------- +// interfaces +// --------------------- +interface ValueOptions { + isFirst: boolean; // is first value in the expression + op?: string; // operator + varValue?: any; // variable value + varName?: string; // variable name + modifier?: string; // modifier e.g * + reserved?: boolean; // if true we'll keep reserved words with not encoding +} + +export interface UrlTemplateOptions { + // if set to true, reserved characters will not be encoded + allowReserved?: boolean; +} + +// --------------------- +// helpers +// --------------------- +function encodeComponent(val: string, reserved?: boolean, op?: string): string { + return (reserved ?? op === "+") || op === "#" + ? encodeReservedComponent(val) + : encodeRFC3986URIComponent(val); +} + +function encodeReservedComponent(str: string): string { + return str + .split(/(%[0-9A-Fa-f]{2})/g) + .map((part) => (!/%[0-9A-Fa-f]/.test(part) ? encodeURI(part) : part)) + .join(""); +} + +function encodeRFC3986URIComponent(str: string): string { + return encodeURIComponent(str).replace( + /[!'()*]/g, + (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`, + ); +} + +function isDefined(val: any): boolean { + return val !== undefined && val !== null; +} + +function getNamedAndIfEmpty(op?: string): [boolean, string] { + return [!!op && [";", "?", "&"].includes(op), !!op && ["?", "&"].includes(op) ? "=" : ""]; +} + +function getFirstOrSep(op?: string, isFirst = false): string { + if (isFirst) { + return !op || op === "+" ? "" : op; + } else if (!op || op === "+" || op === "#") { + return ","; + } else if (op === "?") { + return "&"; + } else { + return op; + } +} + +function getExpandedValue(option: ValueOptions): string { + let isFirst = option.isFirst; + const { op, varName, varValue: value, reserved } = option; + const vals: string[] = []; + const [named, ifEmpty] = getNamedAndIfEmpty(op); + + if (Array.isArray(value)) { + for (const val of value.filter(isDefined)) { + // prepare the following parts: separator, varName, value + vals.push(`${getFirstOrSep(op, isFirst)}`); + if (named && varName) { + vals.push(`${encodeURIComponent(varName)}`); + if (val === "") { + vals.push(ifEmpty); + } else { + vals.push("="); + } + } + vals.push(encodeComponent(val, reserved, op)); + isFirst = false; + } + } else if (typeof value === "object") { + for (const key of Object.keys(value)) { + const val = value[key]; + if (!isDefined(val)) { + continue; + } + // prepare the following parts: separator, key, value + vals.push(`${getFirstOrSep(op, isFirst)}`); + if (key) { + vals.push(`${encodeURIComponent(key)}`); + if (named && val === "") { + vals.push(ifEmpty); + } else { + vals.push("="); + } + } + vals.push(encodeComponent(val, reserved, op)); + isFirst = false; + } + } + return vals.join(""); +} + +function getNonExpandedValue(option: ValueOptions): string | undefined { + const { op, varName, varValue: value, isFirst, reserved } = option; + const vals: string[] = []; + const first = getFirstOrSep(op, isFirst); + const [named, ifEmpty] = getNamedAndIfEmpty(op); + if (named && varName) { + vals.push(encodeComponent(varName, reserved, op)); + if (value === "") { + if (!ifEmpty) { + vals.push(ifEmpty); + } + return !vals.join("") ? undefined : `${first}${vals.join("")}`; + } + vals.push("="); + } + + const items = []; + if (Array.isArray(value)) { + for (const val of value.filter(isDefined)) { + items.push(encodeComponent(val, reserved, op)); + } + } else if (typeof value === "object") { + for (const key of Object.keys(value)) { + if (!isDefined(value[key])) { + continue; + } + items.push(encodeRFC3986URIComponent(key)); + items.push(encodeComponent(value[key], reserved, op)); + } + } + vals.push(items.join(",")); + return !vals.join(",") ? undefined : `${first}${vals.join("")}`; +} + +function getVarValue(option: ValueOptions): string | undefined { + const { op, varName, modifier, isFirst, reserved, varValue: value } = option; + + if (!isDefined(value)) { + return undefined; + } else if (["string", "number", "boolean"].includes(typeof value)) { + let val = value.toString(); + const [named, ifEmpty] = getNamedAndIfEmpty(op); + const vals: string[] = [getFirstOrSep(op, isFirst)]; + if (named && varName) { + // No need to encode varName considering it is already encoded + vals.push(varName); + if (val === "") { + vals.push(ifEmpty); + } else { + vals.push("="); + } + } + if (modifier && modifier !== "*") { + val = val.substring(0, parseInt(modifier, 10)); + } + vals.push(encodeComponent(val, reserved, op)); + return vals.join(""); + } else if (modifier === "*") { + return getExpandedValue(option); + } else { + return getNonExpandedValue(option); + } +} + +// --------------------------------------------------------------------------------------------------- +// This is an implementation of RFC 6570 URI Template: https://datatracker.ietf.org/doc/html/rfc6570. +// --------------------------------------------------------------------------------------------------- +export function expandUrlTemplate( + template: string, + context: Record, + option?: UrlTemplateOptions, +): string { + const result = template.replace(/\{([^{}]+)\}|([^{}]+)/g, (_, expr, text) => { + if (!expr) { + return encodeReservedComponent(text); + } + let op; + if (["+", "#", ".", "/", ";", "?", "&"].includes(expr[0])) { + op = expr[0]; + expr = expr.slice(1); + } + const varList = expr.split(/,/g); + const result = []; + for (const varSpec of varList) { + const varMatch = /([^:*]*)(?::(\d+)|(\*))?/.exec(varSpec); + if (!varMatch || !varMatch[1]) { + continue; + } + const varValue = getVarValue({ + isFirst: result.length === 0, + op, + varValue: context[varMatch[1]], + varName: varMatch[1], + modifier: varMatch[2] || varMatch[3], + reserved: option?.allowReserved, + }); + if (varValue) { + result.push(varValue); + } + } + return result.join(""); + }); + + return normalizeUnreserved(result); +} + +/** + * Normalize an expanded URI by decoding percent-encoded unreserved characters. + * RFC 3986 unreserved: "-" / "." / "~" + */ +function normalizeUnreserved(uri: string): string { + return uri.replace(/%([0-9A-Fa-f]{2})/g, (match, hex) => { + const char = String.fromCharCode(parseInt(hex, 16)); + // Decode only if it's unreserved + if (/[\-.~]/.test(char)) { + return char; + } + return match; // leave other encodings intact + }); +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/test/public/sampleTest.spec.ts b/sdk/edgemarketplace/arm-edgemarketplace/test/public/sampleTest.spec.ts new file mode 100644 index 000000000000..19cf10ee4956 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/test/public/sampleTest.spec.ts @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// import { Recorder } from "@azure-tools/test-recorder"; +// import { createRecorder } from "./utils/recordedClient.js"; +import { + assert, + // beforeEach, + // afterEach, + it, + describe, +} from "vitest"; + +describe("My test", () => { + // let recorder: Recorder; + + // beforeEach(async function(ctx) { + // recorder = await createRecorder(ctx); + // }); + + // afterEach(async function() { + // await recorder.stop(); + // ); + + it("sample test", async function () { + assert.equal(1, 1); + }); +}); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/test/public/utils/recordedClient.ts b/sdk/edgemarketplace/arm-edgemarketplace/test/public/utils/recordedClient.ts new file mode 100644 index 000000000000..285e4643c45e --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/test/public/utils/recordedClient.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { RecorderStartOptions, VitestTestContext } from "@azure-tools/test-recorder"; +import { Recorder } 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/edgemarketplace/arm-edgemarketplace/test/snippets.spec.ts b/sdk/edgemarketplace/arm-edgemarketplace/test/snippets.spec.ts new file mode 100644 index 000000000000..594233a62856 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/test/snippets.spec.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { EdgeMarketplaceClient } from "../src/index.js"; +import { DefaultAzureCredential, InteractiveBrowserCredential } from "@azure/identity"; +import { setLogLevel } from "@azure/logger"; +import { describe, it } from "vitest"; + +describe("snippets", () => { + it("ReadmeSampleCreateClient_Node", async () => { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new EdgeMarketplaceClient(new DefaultAzureCredential(), subscriptionId); + }); + + it("ReadmeSampleCreateClient_Browser", async () => { + const credential = new InteractiveBrowserCredential({ + tenantId: "", + clientId: "", + }); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new EdgeMarketplaceClient(credential, subscriptionId); + }); + + it("SetLogLevel", async () => { + setLogLevel("info"); + }); +}); diff --git a/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.browser.config.json b/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.browser.config.json new file mode 100644 index 000000000000..a0590e9c1065 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.browser.config.json @@ -0,0 +1,10 @@ +{ + "extends": "../../../tsconfig.browser.base.json", + "compilerOptions": { + "paths": { + "@azure/arm-edgemarketplace": ["./dist/browser/index.d.ts"], + "@azure/arm-edgemarketplace/*": ["./dist/browser/*"], + "$internal/*": ["./dist/browser/*"] + } + } +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.json b/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.json new file mode 100644 index 000000000000..0e57dbd186e5 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.json @@ -0,0 +1,16 @@ +{ + "references": [ + { + "path": "./tsconfig.src.json" + }, + { + "path": "./tsconfig.samples.json" + }, + { + "path": "./tsconfig.test.json" + }, + { + "path": "./tsconfig.snippets.json" + } + ] +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.samples.json b/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.samples.json new file mode 100644 index 000000000000..8cdedcc65326 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.samples.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.samples.base.json", + "compilerOptions": { + "paths": { + "@azure/arm-edgemarketplace": ["./dist/esm"] + } + } +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.snippets.json b/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.snippets.json new file mode 100644 index 000000000000..6f3148b5ed97 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.snippets.json @@ -0,0 +1,3 @@ +{ + "extends": ["../../../tsconfig.snippets.base.json"] +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.src.json b/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.src.json new file mode 100644 index 000000000000..bae70752dd38 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.src.json @@ -0,0 +1,3 @@ +{ + "extends": "../../../tsconfig.lib.json" +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.test.json b/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.test.json new file mode 100644 index 000000000000..42798ad68913 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.test.json @@ -0,0 +1,14 @@ +{ + "references": [ + { + "path": "./tsconfig.test.node.json" + }, + { + "path": "./tsconfig.browser.config.json" + } + ], + "compilerOptions": { + "composite": true + }, + "files": [] +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.test.node.json b/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.test.node.json new file mode 100644 index 000000000000..488155b0bde3 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/tsconfig.test.node.json @@ -0,0 +1,10 @@ +{ + "extends": "../../../tsconfig.test.node.base.json", + "compilerOptions": { + "paths": { + "@azure/arm-edgemarketplace": ["./src/index.ts"], + "@azure/arm-edgemarketplace/*": ["./src/*"], + "$internal/*": ["./src/*"] + } + } +} diff --git a/sdk/edgemarketplace/arm-edgemarketplace/tsp-location.yaml b/sdk/edgemarketplace/arm-edgemarketplace/tsp-location.yaml new file mode 100644 index 000000000000..42ede624dfd1 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/edgemarketplace/Microsoft.EdgeMarketPlace.Management +commit: 06616874d9002bb259ca541be63272c3a4edafa8 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/edgemarketplace/arm-edgemarketplace/vitest.browser.config.ts b/sdk/edgemarketplace/arm-edgemarketplace/vitest.browser.config.ts new file mode 100644 index 000000000000..72964f281efe --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/vitest.browser.config.ts @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import viteConfig from "../../../vitest.browser.shared.config.ts"; + +export default viteConfig; diff --git a/sdk/edgemarketplace/arm-edgemarketplace/vitest.config.ts b/sdk/edgemarketplace/arm-edgemarketplace/vitest.config.ts new file mode 100644 index 000000000000..0dfa15cc4498 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/vitest.config.ts @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import viteConfig from "../../../vitest.shared.config.ts"; + +export default viteConfig; diff --git a/sdk/edgemarketplace/arm-edgemarketplace/vitest.esm.config.ts b/sdk/edgemarketplace/arm-edgemarketplace/vitest.esm.config.ts new file mode 100644 index 000000000000..5e9735e9b144 --- /dev/null +++ b/sdk/edgemarketplace/arm-edgemarketplace/vitest.esm.config.ts @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { mergeConfig } from "vitest/config"; +import vitestConfig from "./vitest.config.ts"; +import vitestEsmConfig from "../../../vitest.esm.shared.config.ts"; + +export default mergeConfig(vitestConfig, vitestEsmConfig); diff --git a/sdk/edgemarketplace/ci.mgmt.yml b/sdk/edgemarketplace/ci.mgmt.yml new file mode 100644 index 000000000000..73f24928fff2 --- /dev/null +++ b/sdk/edgemarketplace/ci.mgmt.yml @@ -0,0 +1,35 @@ +# 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/edgemarketplace/arm-edgemarketplace + - sdk/edgemarketplace/ci.mgmt.yml +pr: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + exclude: + - feature/v4 + paths: + include: + - sdk/edgemarketplace/arm-edgemarketplace + - sdk/edgemarketplace/ci.mgmt.yml +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: edgemarketplace + Artifacts: + - name: azure-arm-edgemarketplace + safeName: azurearmedgemarketplace