diff --git a/sdk/chaos/xxxx/LICENSE b/sdk/chaos/xxxx/LICENSE new file mode 100644 index 000000000000..2ad4de7b17f0 --- /dev/null +++ b/sdk/chaos/xxxx/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2025 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/chaos/xxxx/README.md b/sdk/chaos/xxxx/README.md new file mode 100644 index 000000000000..811b5a73464e --- /dev/null +++ b/sdk/chaos/xxxx/README.md @@ -0,0 +1,102 @@ +# Azure ChaosManagement client library for JavaScript + +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure ChaosManagement client. + +Chaos Management Client + +Key links: + +- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/chaos/xxxx) +- [Package (NPM)](https://www.npmjs.com/package/@azure/arm-chaos) +- [API reference documentation](https://learn.microsoft.com/javascript/api/@azure/arm-chaos?view=azure-node-preview) + +## 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-chaos` package + +Install the Azure ChaosManagement client library for JavaScript with `npm`: + +```bash +npm install @azure/arm-chaos +``` + +### Create and authenticate a `ChaosClient` + +To create a client object to access the Azure ChaosManagement API, you will need the `endpoint` of your Azure ChaosManagement resource and a `credential`. The Azure ChaosManagement client can use Azure Active Directory credentials to authenticate. +You can find the endpoint for your Azure ChaosManagement 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 ChaosManagement** 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). + +```javascript +const { ChaosClient } = require("@azure/arm-chaos"); +const { DefaultAzureCredential } = require("@azure/identity"); +// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details. + +const subscriptionId = "00000000-0000-0000-0000-000000000000"; +const client = new ChaosClient(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new ChaosClient(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 + +### ChaosClient + +`ChaosClient` is the primary interface for developers using the Azure ChaosManagement client library. Explore the methods on this client object to understand the different features of the Azure ChaosManagement 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`: + +```javascript +const { setLogLevel } = require("@azure/logger"); +setLogLevel("info"); +``` + +For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). + + +## 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/chaos/xxxx/api-extractor.json b/sdk/chaos/xxxx/api-extractor.json new file mode 100644 index 000000000000..a220d0c7d312 --- /dev/null +++ b/sdk/chaos/xxxx/api-extractor.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "mainEntryPointFilePath": "./dist/esm/index.d.ts", + "docModel": { "enabled": true }, + "apiReport": { "enabled": true, "reportFolder": "./review" }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "./types/arm-chaos.d.ts" + }, + "messages": { + "tsdocMessageReporting": { "default": { "logLevel": "none" } }, + "extractorMessageReporting": { + "ae-missing-release-tag": { "logLevel": "none" }, + "ae-unresolved-link": { "logLevel": "none" } + } + } +} diff --git a/sdk/chaos/xxxx/eslint.config.mjs b/sdk/chaos/xxxx/eslint.config.mjs new file mode 100644 index 000000000000..ac1c3c967e61 --- /dev/null +++ b/sdk/chaos/xxxx/eslint.config.mjs @@ -0,0 +1,16 @@ +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-apiextractor-json-types": "warn", + "@azure/azure-sdk/ts-package-json-types": "warn", + "@azure/azure-sdk/ts-package-json-engine-is-present": "warn", + "@azure/azure-sdk/ts-package-json-module": "off", + "@azure/azure-sdk/ts-package-json-files-required": "off", + "@azure/azure-sdk/ts-package-json-main-is-cjs": "off", + "tsdoc/syntax": "warn" + } + } +]); diff --git a/sdk/chaos/xxxx/package.json b/sdk/chaos/xxxx/package.json new file mode 100644 index 000000000000..09f83da1774d --- /dev/null +++ b/sdk/chaos/xxxx/package.json @@ -0,0 +1,91 @@ +{ + "name": "@azure/arm-chaos", + "version": "1.0.0-beta.1", + "description": "A generated SDK for ChaosClient.", + "engines": { + "node": ">=18.0.0" + }, + "sideEffects": false, + "autoPublish": false, + "tshy": { + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./models": "./src/models/index.ts" + }, + "dialects": ["esm", "commonjs"], + "esmDialects": ["browser", "react-native"], + "selfLink": false + }, + "type": "module", + "keywords": ["node", "azure", "cloud", "typescript", "browser", "isomorphic"], + "author": "Microsoft Corporation", + "license": "MIT", + "files": ["dist", "README.md", "LICENSE", "review/*", "CHANGELOG.md"], + "sdk-type": "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/chaos/xxxx/README.md", + "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", + "//metadata": { + "constantPaths": [ + { + "path": "src/api/chaosManagementContext.ts", + "prefix": "userAgentInfo" + } + ] + }, + "dependencies": { + "@azure/core-util": "^1.9.2", + "@azure-rest/core-client": "^2.3.1", + "@azure/core-auth": "^1.6.0", + "@azure/core-rest-pipeline": "^1.5.0", + "@azure/logger": "^1.0.0", + "tslib": "^2.6.2", + "@azure/core-lro": "^3.1.0", + "@azure/abort-controller": "^2.1.2" + }, + "devDependencies": { + "dotenv": "^16.0.0", + "@microsoft/api-extractor": "^7.40.3", + "@types/node": "^18.0.0", + "eslint": "^9.9.0", + "typescript": "~5.6.2", + "@azure/identity": "^4.2.1", + "@vitest/browser": "^2.0.5", + "@vitest/coverage-istanbul": "^2.0.5", + "playwright": "^1.41.2", + "vitest": "^2.0.5", + "@azure-tools/test-credential": "^2.0.0", + "@azure-tools/test-recorder": "^4.0.0", + "@azure/dev-tool": "^1.0.0", + "@azure/eslint-plugin-azure-sdk": "^3.0.0" + }, + "scripts": { + "clean": "dev-tool run vendored rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", + "extract-api": "dev-tool run vendored rimraf review && dev-tool run vendored mkdirp ./review && dev-tool run extract-api", + "pack": "npm pack 2>&1", + "lint": "eslint package.json api-extractor.json src test", + "lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]", + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "unit-test:browser": "npm run build:test && dev-tool run test:vitest --browser", + "unit-test:node": "dev-tool run test:vitest", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "integration-test:browser": "echo skipped", + "integration-test:node": "echo skipped", + "build:samples": "echo skipped", + "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" ", + "execute:samples": "echo skipped", + "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" ", + "generate:client": "echo skipped", + "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser", + "minify": "dev-tool run vendored uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", + "build:test": "npm run clean && dev-tool run build-package && dev-tool run build-test", + "build": "npm run clean && dev-tool run build-package && dev-tool run vendored mkdirp ./review && dev-tool run extract-api", + "test:node": "npm run clean && dev-tool run build-package && npm run unit-test:node && npm run integration-test:node", + "test": "npm run clean && dev-tool run build-package && npm run unit-test:node && dev-tool run bundle && npm run unit-test:browser && npm run integration-test", + "update-snippets": "echo skipped" + } +} diff --git a/sdk/chaos/xxxx/sample.env b/sdk/chaos/xxxx/sample.env new file mode 100644 index 000000000000..508439fc7d62 --- /dev/null +++ b/sdk/chaos/xxxx/sample.env @@ -0,0 +1 @@ +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/chaos/xxxx/src/api/capabilities/index.ts b/sdk/chaos/xxxx/src/api/capabilities/index.ts new file mode 100644 index 000000000000..cc1b6e139bf7 --- /dev/null +++ b/sdk/chaos/xxxx/src/api/capabilities/index.ts @@ -0,0 +1,310 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + CapabilitiesCreateOrUpdateOptionalParams, + CapabilitiesDeleteOptionalParams, + CapabilitiesGetOptionalParams, + CapabilitiesListOptionalParams, + ChaosManagementContext as Client, +} from "../index.js"; +import { + errorResponseDeserializer, + Capability, + capabilitySerializer, + capabilityDeserializer, + _CapabilityListResult, + _capabilityListResultDeserializer, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _capabilitiesListSend( + context: Client, + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + options: CapabilitiesListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities", + context.subscriptionId, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { + "api-version": context.apiVersion, + continuationToken: options?.continuationToken, + }, + }); +} + +export async function _capabilitiesListDeserialize( + result: PathUncheckedResponse, +): Promise<_CapabilityListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _capabilityListResultDeserializer(result.body); +} + +/** Get a list of Capability resources that extend a Target resource. */ +export function capabilitiesList( + context: Client, + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + options: CapabilitiesListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => + _capabilitiesListSend( + context, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + options, + ), + _capabilitiesListDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _capabilitiesDeleteSend( + context: Client, + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + capabilityName: string, + options: CapabilitiesDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}", + context.subscriptionId, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + capabilityName, + ) + .delete({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _capabilitiesDeleteDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "204"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** Delete a Capability that extends a Target resource. */ +export async function capabilitiesDelete( + context: Client, + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + capabilityName: string, + options: CapabilitiesDeleteOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _capabilitiesDeleteSend( + context, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + capabilityName, + options, + ); + return _capabilitiesDeleteDeserialize(result); +} + +export function _capabilitiesCreateOrUpdateSend( + context: Client, + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + capabilityName: string, + resource: Capability, + options: CapabilitiesCreateOrUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}", + context.subscriptionId, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + capabilityName, + ) + .put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + body: capabilitySerializer(resource), + }); +} + +export async function _capabilitiesCreateOrUpdateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return capabilityDeserializer(result.body); +} + +/** Create or update a Capability resource that extends a Target resource. */ +export async function capabilitiesCreateOrUpdate( + context: Client, + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + capabilityName: string, + resource: Capability, + options: CapabilitiesCreateOrUpdateOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _capabilitiesCreateOrUpdateSend( + context, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + capabilityName, + resource, + options, + ); + return _capabilitiesCreateOrUpdateDeserialize(result); +} + +export function _capabilitiesGetSend( + context: Client, + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + capabilityName: string, + options: CapabilitiesGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}", + context.subscriptionId, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + capabilityName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _capabilitiesGetDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return capabilityDeserializer(result.body); +} + +/** Get a Capability resource that extends a Target resource. */ +export async function capabilitiesGet( + context: Client, + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + capabilityName: string, + options: CapabilitiesGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _capabilitiesGetSend( + context, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + capabilityName, + options, + ); + return _capabilitiesGetDeserialize(result); +} diff --git a/sdk/chaos/xxxx/src/api/capabilityTypes/index.ts b/sdk/chaos/xxxx/src/api/capabilityTypes/index.ts new file mode 100644 index 000000000000..e4a39b5bac13 --- /dev/null +++ b/sdk/chaos/xxxx/src/api/capabilityTypes/index.ts @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + CapabilityTypesGetOptionalParams, + CapabilityTypesListOptionalParams, + ChaosManagementContext as Client, +} from "../index.js"; +import { + errorResponseDeserializer, + CapabilityType, + capabilityTypeDeserializer, + _CapabilityTypeListResult, + _capabilityTypeListResultDeserializer, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _capabilityTypesListSend( + context: Client, + location: string, + targetTypeName: string, + options: CapabilityTypesListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/targetTypes/{targetTypeName}/capabilityTypes", + context.subscriptionId, + location, + targetTypeName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { + "api-version": context.apiVersion, + continuationToken: options?.continuationToken, + }, + }); +} + +export async function _capabilityTypesListDeserialize( + result: PathUncheckedResponse, +): Promise<_CapabilityTypeListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _capabilityTypeListResultDeserializer(result.body); +} + +/** Get a list of Capability Type resources for given Target Type and location. */ +export function capabilityTypesList( + context: Client, + location: string, + targetTypeName: string, + options: CapabilityTypesListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _capabilityTypesListSend(context, location, targetTypeName, options), + _capabilityTypesListDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _capabilityTypesGetSend( + context: Client, + location: string, + targetTypeName: string, + capabilityTypeName: string, + options: CapabilityTypesGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/targetTypes/{targetTypeName}/capabilityTypes/{capabilityTypeName}", + context.subscriptionId, + location, + targetTypeName, + capabilityTypeName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _capabilityTypesGetDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return capabilityTypeDeserializer(result.body); +} + +/** Get a Capability Type resource for given Target Type and location. */ +export async function capabilityTypesGet( + context: Client, + location: string, + targetTypeName: string, + capabilityTypeName: string, + options: CapabilityTypesGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _capabilityTypesGetSend( + context, + location, + targetTypeName, + capabilityTypeName, + options, + ); + return _capabilityTypesGetDeserialize(result); +} diff --git a/sdk/chaos/xxxx/src/api/chaosManagementContext.ts b/sdk/chaos/xxxx/src/api/chaosManagementContext.ts new file mode 100644 index 000000000000..1753b274ec2b --- /dev/null +++ b/sdk/chaos/xxxx/src/api/chaosManagementContext.ts @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { logger } from "../logger.js"; +import { KnownVersions } from "../models/models.js"; +import { Client, ClientOptions, getClient } from "@azure-rest/core-client"; +import { TokenCredential } from "@azure/core-auth"; + +/** Chaos Management Client */ +export interface ChaosManagementContext 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 ChaosManagementClientOptionalParams extends ClientOptions { + /** The API version to use for this operation. */ + /** Known values of {@link KnownVersions} that the service accepts. */ + apiVersion?: string; +} + +/** Chaos Management Client */ +export function createChaosManagement( + credential: TokenCredential, + subscriptionId: string, + options: ChaosManagementClientOptionalParams = {}, +): ChaosManagementContext { + const endpointUrl = + options.endpoint ?? options.baseUrl ?? "https://management.azure.com"; + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentInfo = `azsdk-js-arm-chaos/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 ?? "2024-11-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 ChaosManagementContext; +} diff --git a/sdk/chaos/xxxx/src/api/experimentExecutions/index.ts b/sdk/chaos/xxxx/src/api/experimentExecutions/index.ts new file mode 100644 index 000000000000..4e557a0bd18b --- /dev/null +++ b/sdk/chaos/xxxx/src/api/experimentExecutions/index.ts @@ -0,0 +1,210 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + ChaosManagementContext as Client, + ExperimentExecutionsGetExecutionDetailsOptionalParams, + ExperimentExecutionsGetExecutionOptionalParams, + ExperimentExecutionsListAllExecutionsOptionalParams, +} from "../index.js"; +import { + errorResponseDeserializer, + ExperimentExecution, + experimentExecutionDeserializer, + _ExperimentExecutionListResult, + _experimentExecutionListResultDeserializer, + ExperimentExecutionDetails, + experimentExecutionDetailsDeserializer, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _experimentExecutionsGetExecutionDetailsSend( + context: Client, + resourceGroupName: string, + experimentName: string, + executionId: string, + options: ExperimentExecutionsGetExecutionDetailsOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions/{executionId}/getExecutionDetails", + context.subscriptionId, + resourceGroupName, + experimentName, + executionId, + ) + .post({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _experimentExecutionsGetExecutionDetailsDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return experimentExecutionDetailsDeserializer(result.body); +} + +/** Execution details of an experiment resource. */ +export async function experimentExecutionsGetExecutionDetails( + context: Client, + resourceGroupName: string, + experimentName: string, + executionId: string, + options: ExperimentExecutionsGetExecutionDetailsOptionalParams = { + requestOptions: {}, + }, +): Promise { + const result = await _experimentExecutionsGetExecutionDetailsSend( + context, + resourceGroupName, + experimentName, + executionId, + options, + ); + return _experimentExecutionsGetExecutionDetailsDeserialize(result); +} + +export function _experimentExecutionsListAllExecutionsSend( + context: Client, + resourceGroupName: string, + experimentName: string, + options: ExperimentExecutionsListAllExecutionsOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions", + context.subscriptionId, + resourceGroupName, + experimentName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _experimentExecutionsListAllExecutionsDeserialize( + result: PathUncheckedResponse, +): Promise<_ExperimentExecutionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _experimentExecutionListResultDeserializer(result.body); +} + +/** Get a list of executions of an Experiment resource. */ +export function experimentExecutionsListAllExecutions( + context: Client, + resourceGroupName: string, + experimentName: string, + options: ExperimentExecutionsListAllExecutionsOptionalParams = { + requestOptions: {}, + }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => + _experimentExecutionsListAllExecutionsSend( + context, + resourceGroupName, + experimentName, + options, + ), + _experimentExecutionsListAllExecutionsDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _experimentExecutionsGetExecutionSend( + context: Client, + resourceGroupName: string, + experimentName: string, + executionId: string, + options: ExperimentExecutionsGetExecutionOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions/{executionId}", + context.subscriptionId, + resourceGroupName, + experimentName, + executionId, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _experimentExecutionsGetExecutionDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return experimentExecutionDeserializer(result.body); +} + +/** Get an execution of an Experiment resource. */ +export async function experimentExecutionsGetExecution( + context: Client, + resourceGroupName: string, + experimentName: string, + executionId: string, + options: ExperimentExecutionsGetExecutionOptionalParams = { + requestOptions: {}, + }, +): Promise { + const result = await _experimentExecutionsGetExecutionSend( + context, + resourceGroupName, + experimentName, + executionId, + options, + ); + return _experimentExecutionsGetExecutionDeserialize(result); +} diff --git a/sdk/chaos/xxxx/src/api/experiments/index.ts b/sdk/chaos/xxxx/src/api/experiments/index.ts new file mode 100644 index 000000000000..45e2c9726420 --- /dev/null +++ b/sdk/chaos/xxxx/src/api/experiments/index.ts @@ -0,0 +1,511 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + ChaosManagementContext as Client, + ExperimentsCancelOptionalParams, + ExperimentsCreateOrUpdateOptionalParams, + ExperimentsDeleteOptionalParams, + ExperimentsGetOptionalParams, + ExperimentsListAllOptionalParams, + ExperimentsListOptionalParams, + ExperimentsStartOptionalParams, + ExperimentsUpdateOptionalParams, +} from "../index.js"; +import { + errorResponseDeserializer, + Experiment, + experimentSerializer, + experimentDeserializer, + ExperimentUpdate, + experimentUpdateSerializer, + _ExperimentListResult, + _experimentListResultDeserializer, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { getLongRunningPoller } from "../../static-helpers/pollingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; +import { PollerLike, OperationState } from "@azure/core-lro"; + +export function _experimentsStartSend( + context: Client, + resourceGroupName: string, + experimentName: string, + options: ExperimentsStartOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/start", + context.subscriptionId, + resourceGroupName, + experimentName, + ) + .post({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _experimentsStartDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["202", "200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** Start a Experiment resource. */ +export function experimentsStart( + context: Client, + resourceGroupName: string, + experimentName: string, + options: ExperimentsStartOptionalParams = { requestOptions: {} }, +): PollerLike, void> { + return getLongRunningPoller( + context, + _experimentsStartDeserialize, + ["202", "200"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _experimentsStartSend( + context, + resourceGroupName, + experimentName, + options, + ), + resourceLocationConfig: "location", + }, + ) as PollerLike, void>; +} + +export function _experimentsCancelSend( + context: Client, + resourceGroupName: string, + experimentName: string, + options: ExperimentsCancelOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/cancel", + context.subscriptionId, + resourceGroupName, + experimentName, + ) + .post({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _experimentsCancelDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["202", "200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** Cancel a running Experiment resource. */ +export function experimentsCancel( + context: Client, + resourceGroupName: string, + experimentName: string, + options: ExperimentsCancelOptionalParams = { requestOptions: {} }, +): PollerLike, void> { + return getLongRunningPoller( + context, + _experimentsCancelDeserialize, + ["202", "200"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _experimentsCancelSend( + context, + resourceGroupName, + experimentName, + options, + ), + resourceLocationConfig: "location", + }, + ) as PollerLike, void>; +} + +export function _experimentsListAllSend( + context: Client, + options: ExperimentsListAllOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/experiments", + context.subscriptionId, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { + "api-version": context.apiVersion, + running: options?.running, + continuationToken: options?.continuationToken, + }, + }); +} + +export async function _experimentsListAllDeserialize( + result: PathUncheckedResponse, +): Promise<_ExperimentListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _experimentListResultDeserializer(result.body); +} + +/** Get a list of Experiment resources in a subscription. */ +export function experimentsListAll( + context: Client, + options: ExperimentsListAllOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _experimentsListAllSend(context, options), + _experimentsListAllDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _experimentsListSend( + context: Client, + resourceGroupName: string, + options: ExperimentsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments", + context.subscriptionId, + resourceGroupName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { + "api-version": context.apiVersion, + running: options?.running, + continuationToken: options?.continuationToken, + }, + }); +} + +export async function _experimentsListDeserialize( + result: PathUncheckedResponse, +): Promise<_ExperimentListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _experimentListResultDeserializer(result.body); +} + +/** Get a list of Experiment resources in a resource group. */ +export function experimentsList( + context: Client, + resourceGroupName: string, + options: ExperimentsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _experimentsListSend(context, resourceGroupName, options), + _experimentsListDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _experimentsDeleteSend( + context: Client, + resourceGroupName: string, + experimentName: string, + options: ExperimentsDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}", + context.subscriptionId, + resourceGroupName, + experimentName, + ) + .delete({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _experimentsDeleteDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["202", "204", "200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** Delete a Experiment resource. */ +export function experimentsDelete( + context: Client, + resourceGroupName: string, + experimentName: string, + options: ExperimentsDeleteOptionalParams = { requestOptions: {} }, +): PollerLike, void> { + return getLongRunningPoller( + context, + _experimentsDeleteDeserialize, + ["202", "204", "200"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _experimentsDeleteSend( + context, + resourceGroupName, + experimentName, + options, + ), + resourceLocationConfig: "location", + }, + ) as PollerLike, void>; +} + +export function _experimentsUpdateSend( + context: Client, + resourceGroupName: string, + experimentName: string, + properties: ExperimentUpdate, + options: ExperimentsUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}", + context.subscriptionId, + resourceGroupName, + experimentName, + ) + .patch({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + body: experimentUpdateSerializer(properties), + }); +} + +export async function _experimentsUpdateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "202"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return experimentDeserializer(result.body); +} + +/** The operation to update an experiment. */ +export function experimentsUpdate( + context: Client, + resourceGroupName: string, + experimentName: string, + properties: ExperimentUpdate, + options: ExperimentsUpdateOptionalParams = { requestOptions: {} }, +): PollerLike, Experiment> { + return getLongRunningPoller( + context, + _experimentsUpdateDeserialize, + ["200", "202"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _experimentsUpdateSend( + context, + resourceGroupName, + experimentName, + properties, + options, + ), + resourceLocationConfig: "location", + }, + ) as PollerLike, Experiment>; +} + +export function _experimentsCreateOrUpdateSend( + context: Client, + resourceGroupName: string, + experimentName: string, + resource: Experiment, + options: ExperimentsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}", + context.subscriptionId, + resourceGroupName, + experimentName, + ) + .put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + body: experimentSerializer(resource), + }); +} + +export async function _experimentsCreateOrUpdateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return experimentDeserializer(result.body); +} + +/** Create or update a Experiment resource. */ +export function experimentsCreateOrUpdate( + context: Client, + resourceGroupName: string, + experimentName: string, + resource: Experiment, + options: ExperimentsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): PollerLike, Experiment> { + return getLongRunningPoller( + context, + _experimentsCreateOrUpdateDeserialize, + ["200", "201"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _experimentsCreateOrUpdateSend( + context, + resourceGroupName, + experimentName, + resource, + options, + ), + resourceLocationConfig: "azure-async-operation", + }, + ) as PollerLike, Experiment>; +} + +export function _experimentsGetSend( + context: Client, + resourceGroupName: string, + experimentName: string, + options: ExperimentsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}", + context.subscriptionId, + resourceGroupName, + experimentName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _experimentsGetDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return experimentDeserializer(result.body); +} + +/** Get a Experiment resource. */ +export async function experimentsGet( + context: Client, + resourceGroupName: string, + experimentName: string, + options: ExperimentsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _experimentsGetSend( + context, + resourceGroupName, + experimentName, + options, + ); + return _experimentsGetDeserialize(result); +} diff --git a/sdk/chaos/xxxx/src/api/index.ts b/sdk/chaos/xxxx/src/api/index.ts new file mode 100644 index 000000000000..07a7b5eb011d --- /dev/null +++ b/sdk/chaos/xxxx/src/api/index.ts @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + createChaosManagement, + ChaosManagementContext, + ChaosManagementClientOptionalParams, +} from "./chaosManagementContext.js"; +export { + OperationStatusesGetOptionalParams, + TargetTypesListOptionalParams, + TargetTypesGetOptionalParams, + PrivateEndpointConnectionsListPrivateEndpointConnectionsOptionalParams, + PrivateEndpointConnectionsDeleteAPrivateEndpointConnectionOptionalParams, + PrivateEndpointConnectionsGetAPrivateEndpointConnectionOptionalParams, + PrivateAccessesPrivateLinkResourcesOptionalParams, + PrivateAccessesListAllOptionalParams, + PrivateAccessesListOptionalParams, + PrivateAccessesDeleteOptionalParams, + PrivateAccessesUpdateOptionalParams, + PrivateAccessesCreateOrUpdateOptionalParams, + PrivateAccessesGetOptionalParams, + ExperimentExecutionsGetExecutionDetailsOptionalParams, + ExperimentExecutionsListAllExecutionsOptionalParams, + ExperimentExecutionsGetExecutionOptionalParams, + ExperimentsStartOptionalParams, + ExperimentsCancelOptionalParams, + ExperimentsListAllOptionalParams, + ExperimentsListOptionalParams, + ExperimentsDeleteOptionalParams, + ExperimentsUpdateOptionalParams, + ExperimentsCreateOrUpdateOptionalParams, + ExperimentsGetOptionalParams, + CapabilityTypesListOptionalParams, + CapabilityTypesGetOptionalParams, + TargetsListOptionalParams, + TargetsDeleteOptionalParams, + TargetsCreateOrUpdateOptionalParams, + TargetsGetOptionalParams, + OperationsListOptionalParams, + CapabilitiesListOptionalParams, + CapabilitiesDeleteOptionalParams, + CapabilitiesCreateOrUpdateOptionalParams, + CapabilitiesGetOptionalParams, +} from "./options.js"; +export { + capabilitiesList, + capabilitiesDelete, + capabilitiesCreateOrUpdate, + capabilitiesGet, +} from "./capabilities/index.js"; +export { + capabilityTypesList, + capabilityTypesGet, +} from "./capabilityTypes/index.js"; +export { + experimentExecutionsGetExecutionDetails, + experimentExecutionsListAllExecutions, + experimentExecutionsGetExecution, +} from "./experimentExecutions/index.js"; +export { + experimentsStart, + experimentsCancel, + experimentsListAll, + experimentsList, + experimentsDelete, + experimentsUpdate, + experimentsCreateOrUpdate, + experimentsGet, +} from "./experiments/index.js"; +export { operationsList } from "./operations/index.js"; +export { operationStatusesGet } from "./operationStatuses/index.js"; +export { + privateAccessesPrivateLinkResources, + privateAccessesListAll, + privateAccessesList, + privateAccessesDelete, + privateAccessesUpdate, + privateAccessesCreateOrUpdate, + privateAccessesGet, +} from "./privateAccesses/index.js"; +export { + privateEndpointConnectionsListPrivateEndpointConnections, + privateEndpointConnectionsDeleteAPrivateEndpointConnection, + privateEndpointConnectionsGetAPrivateEndpointConnection, +} from "./privateEndpointConnections/index.js"; +export { + targetsList, + targetsDelete, + targetsCreateOrUpdate, + targetsGet, +} from "./targets/index.js"; +export { targetTypesList, targetTypesGet } from "./targetTypes/index.js"; diff --git a/sdk/chaos/xxxx/src/api/operationStatuses/index.ts b/sdk/chaos/xxxx/src/api/operationStatuses/index.ts new file mode 100644 index 000000000000..496d00c2a655 --- /dev/null +++ b/sdk/chaos/xxxx/src/api/operationStatuses/index.ts @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + ChaosManagementContext as Client, + OperationStatusesGetOptionalParams, +} from "../index.js"; +import { + OperationStatusResult, + operationStatusResultDeserializer, + errorResponseDeserializer, +} from "../../models/models.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _operationStatusesGetSend( + context: Client, + location: string, + operationId: string, + options: OperationStatusesGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/operationStatuses/{operationId}", + context.subscriptionId, + location, + operationId, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _operationStatusesGetDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return operationStatusResultDeserializer(result.body); +} + +/** Returns the current status of an async operation. */ +export async function operationStatusesGet( + context: Client, + location: string, + operationId: string, + options: OperationStatusesGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _operationStatusesGetSend( + context, + location, + operationId, + options, + ); + return _operationStatusesGetDeserialize(result); +} diff --git a/sdk/chaos/xxxx/src/api/operations/index.ts b/sdk/chaos/xxxx/src/api/operations/index.ts new file mode 100644 index 000000000000..9f39cea8aa23 --- /dev/null +++ b/sdk/chaos/xxxx/src/api/operations/index.ts @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + ChaosManagementContext as Client, + OperationsListOptionalParams, +} from "../index.js"; +import { + errorResponseDeserializer, + _OperationListResult, + _operationListResultDeserializer, + Operation, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _operationsListSend( + context: Client, + options: OperationsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path("/providers/Microsoft.Chaos/operations") + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _operationsListDeserialize( + 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 operationsList( + context: Client, + options: OperationsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _operationsListSend(context, options), + _operationsListDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} diff --git a/sdk/chaos/xxxx/src/api/options.ts b/sdk/chaos/xxxx/src/api/options.ts new file mode 100644 index 000000000000..6d8480036797 --- /dev/null +++ b/sdk/chaos/xxxx/src/api/options.ts @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface OperationStatusesGetOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface TargetTypesListOptionalParams extends OperationOptions { + /** String that sets the continuation token. */ + continuationToken?: string; +} + +/** Optional parameters. */ +export interface TargetTypesGetOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PrivateEndpointConnectionsListPrivateEndpointConnectionsOptionalParams + extends OperationOptions {} + +/** Optional parameters. */ +export interface PrivateEndpointConnectionsDeleteAPrivateEndpointConnectionOptionalParams + extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface PrivateEndpointConnectionsGetAPrivateEndpointConnectionOptionalParams + extends OperationOptions {} + +/** Optional parameters. */ +export interface PrivateAccessesPrivateLinkResourcesOptionalParams + extends OperationOptions {} + +/** Optional parameters. */ +export interface PrivateAccessesListAllOptionalParams extends OperationOptions { + /** String that sets the continuation token. */ + continuationToken?: string; +} + +/** Optional parameters. */ +export interface PrivateAccessesListOptionalParams extends OperationOptions { + /** String that sets the continuation token. */ + continuationToken?: string; +} + +/** Optional parameters. */ +export interface PrivateAccessesDeleteOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface PrivateAccessesUpdateOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface PrivateAccessesCreateOrUpdateOptionalParams + extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface PrivateAccessesGetOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface ExperimentExecutionsGetExecutionDetailsOptionalParams + extends OperationOptions {} + +/** Optional parameters. */ +export interface ExperimentExecutionsListAllExecutionsOptionalParams + extends OperationOptions {} + +/** Optional parameters. */ +export interface ExperimentExecutionsGetExecutionOptionalParams + extends OperationOptions {} + +/** Optional parameters. */ +export interface ExperimentsStartOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface ExperimentsCancelOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface ExperimentsListAllOptionalParams extends OperationOptions { + /** Optional value that indicates whether to filter results based on if the Experiment is currently running. If null, then the results will not be filtered. */ + running?: boolean; + /** String that sets the continuation token. */ + continuationToken?: string; +} + +/** Optional parameters. */ +export interface ExperimentsListOptionalParams extends OperationOptions { + /** Optional value that indicates whether to filter results based on if the Experiment is currently running. If null, then the results will not be filtered. */ + running?: boolean; + /** String that sets the continuation token. */ + continuationToken?: string; +} + +/** Optional parameters. */ +export interface ExperimentsDeleteOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface ExperimentsUpdateOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface ExperimentsCreateOrUpdateOptionalParams + extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface ExperimentsGetOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface CapabilityTypesListOptionalParams extends OperationOptions { + /** String that sets the continuation token. */ + continuationToken?: string; +} + +/** Optional parameters. */ +export interface CapabilityTypesGetOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface TargetsListOptionalParams extends OperationOptions { + /** String that sets the continuation token. */ + continuationToken?: string; +} + +/** Optional parameters. */ +export interface TargetsDeleteOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface TargetsCreateOrUpdateOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface TargetsGetOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface OperationsListOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface CapabilitiesListOptionalParams extends OperationOptions { + /** String that sets the continuation token. */ + continuationToken?: string; +} + +/** Optional parameters. */ +export interface CapabilitiesDeleteOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface CapabilitiesCreateOrUpdateOptionalParams + extends OperationOptions {} + +/** Optional parameters. */ +export interface CapabilitiesGetOptionalParams extends OperationOptions {} diff --git a/sdk/chaos/xxxx/src/api/privateAccesses/index.ts b/sdk/chaos/xxxx/src/api/privateAccesses/index.ts new file mode 100644 index 000000000000..f71b8daee69e --- /dev/null +++ b/sdk/chaos/xxxx/src/api/privateAccesses/index.ts @@ -0,0 +1,449 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + ChaosManagementContext as Client, + PrivateAccessesCreateOrUpdateOptionalParams, + PrivateAccessesDeleteOptionalParams, + PrivateAccessesGetOptionalParams, + PrivateAccessesListAllOptionalParams, + PrivateAccessesListOptionalParams, + PrivateAccessesPrivateLinkResourcesOptionalParams, + PrivateAccessesUpdateOptionalParams, +} from "../index.js"; +import { + errorResponseDeserializer, + PrivateAccess, + privateAccessSerializer, + privateAccessDeserializer, + PrivateAccessPatch, + privateAccessPatchSerializer, + _PrivateAccessListResult, + _privateAccessListResultDeserializer, + _PrivateLinkResourceListResult, + _privateLinkResourceListResultDeserializer, + PrivateLinkResource, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { getLongRunningPoller } from "../../static-helpers/pollingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; +import { PollerLike, OperationState } from "@azure/core-lro"; + +export function _privateAccessesPrivateLinkResourcesSend( + context: Client, + resourceGroupName: string, + privateAccessName: string, + options: PrivateAccessesPrivateLinkResourcesOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateLinkResources", + context.subscriptionId, + resourceGroupName, + privateAccessName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _privateAccessesPrivateLinkResourcesDeserialize( + result: PathUncheckedResponse, +): Promise<_PrivateLinkResourceListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _privateLinkResourceListResultDeserializer(result.body); +} + +/** Gets the private link resources possible under private access resource */ +export function privateAccessesPrivateLinkResources( + context: Client, + resourceGroupName: string, + privateAccessName: string, + options: PrivateAccessesPrivateLinkResourcesOptionalParams = { + requestOptions: {}, + }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => + _privateAccessesPrivateLinkResourcesSend( + context, + resourceGroupName, + privateAccessName, + options, + ), + _privateAccessesPrivateLinkResourcesDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _privateAccessesListAllSend( + context: Client, + options: PrivateAccessesListAllOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/privateAccesses", + context.subscriptionId, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { + "api-version": context.apiVersion, + continuationToken: options?.continuationToken, + }, + }); +} + +export async function _privateAccessesListAllDeserialize( + result: PathUncheckedResponse, +): Promise<_PrivateAccessListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _privateAccessListResultDeserializer(result.body); +} + +/** Get a list of private access resources in a subscription. */ +export function privateAccessesListAll( + context: Client, + options: PrivateAccessesListAllOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _privateAccessesListAllSend(context, options), + _privateAccessesListAllDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _privateAccessesListSend( + context: Client, + resourceGroupName: string, + options: PrivateAccessesListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses", + context.subscriptionId, + resourceGroupName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { + "api-version": context.apiVersion, + continuationToken: options?.continuationToken, + }, + }); +} + +export async function _privateAccessesListDeserialize( + result: PathUncheckedResponse, +): Promise<_PrivateAccessListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _privateAccessListResultDeserializer(result.body); +} + +/** Get a list of private access resources in a resource group. */ +export function privateAccessesList( + context: Client, + resourceGroupName: string, + options: PrivateAccessesListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _privateAccessesListSend(context, resourceGroupName, options), + _privateAccessesListDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _privateAccessesDeleteSend( + context: Client, + resourceGroupName: string, + privateAccessName: string, + options: PrivateAccessesDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}", + context.subscriptionId, + resourceGroupName, + privateAccessName, + ) + .delete({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _privateAccessesDeleteDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["202", "204", "200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** Delete a private access */ +export function privateAccessesDelete( + context: Client, + resourceGroupName: string, + privateAccessName: string, + options: PrivateAccessesDeleteOptionalParams = { requestOptions: {} }, +): PollerLike, void> { + return getLongRunningPoller( + context, + _privateAccessesDeleteDeserialize, + ["202", "204", "200"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _privateAccessesDeleteSend( + context, + resourceGroupName, + privateAccessName, + options, + ), + resourceLocationConfig: "location", + }, + ) as PollerLike, void>; +} + +export function _privateAccessesUpdateSend( + context: Client, + resourceGroupName: string, + privateAccessName: string, + properties: PrivateAccessPatch, + options: PrivateAccessesUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}", + context.subscriptionId, + resourceGroupName, + privateAccessName, + ) + .patch({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + body: privateAccessPatchSerializer(properties), + }); +} + +export async function _privateAccessesUpdateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "202"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return privateAccessDeserializer(result.body); +} + +/** Patch a private access tags */ +export function privateAccessesUpdate( + context: Client, + resourceGroupName: string, + privateAccessName: string, + properties: PrivateAccessPatch, + options: PrivateAccessesUpdateOptionalParams = { requestOptions: {} }, +): PollerLike, PrivateAccess> { + return getLongRunningPoller( + context, + _privateAccessesUpdateDeserialize, + ["200", "202"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _privateAccessesUpdateSend( + context, + resourceGroupName, + privateAccessName, + properties, + options, + ), + resourceLocationConfig: "location", + }, + ) as PollerLike, PrivateAccess>; +} + +export function _privateAccessesCreateOrUpdateSend( + context: Client, + resourceGroupName: string, + privateAccessName: string, + resource: PrivateAccess, + options: PrivateAccessesCreateOrUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}", + context.subscriptionId, + resourceGroupName, + privateAccessName, + ) + .put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + body: privateAccessSerializer(resource), + }); +} + +export async function _privateAccessesCreateOrUpdateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return privateAccessDeserializer(result.body); +} + +/** Create or update a private access */ +export function privateAccessesCreateOrUpdate( + context: Client, + resourceGroupName: string, + privateAccessName: string, + resource: PrivateAccess, + options: PrivateAccessesCreateOrUpdateOptionalParams = { requestOptions: {} }, +): PollerLike, PrivateAccess> { + return getLongRunningPoller( + context, + _privateAccessesCreateOrUpdateDeserialize, + ["200", "201"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _privateAccessesCreateOrUpdateSend( + context, + resourceGroupName, + privateAccessName, + resource, + options, + ), + resourceLocationConfig: "azure-async-operation", + }, + ) as PollerLike, PrivateAccess>; +} + +export function _privateAccessesGetSend( + context: Client, + resourceGroupName: string, + privateAccessName: string, + options: PrivateAccessesGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}", + context.subscriptionId, + resourceGroupName, + privateAccessName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _privateAccessesGetDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return privateAccessDeserializer(result.body); +} + +/** Get a private access resource */ +export async function privateAccessesGet( + context: Client, + resourceGroupName: string, + privateAccessName: string, + options: PrivateAccessesGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _privateAccessesGetSend( + context, + resourceGroupName, + privateAccessName, + options, + ); + return _privateAccessesGetDeserialize(result); +} diff --git a/sdk/chaos/xxxx/src/api/privateEndpointConnections/index.ts b/sdk/chaos/xxxx/src/api/privateEndpointConnections/index.ts new file mode 100644 index 000000000000..bdc9a7d45704 --- /dev/null +++ b/sdk/chaos/xxxx/src/api/privateEndpointConnections/index.ts @@ -0,0 +1,223 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + ChaosManagementContext as Client, + PrivateEndpointConnectionsDeleteAPrivateEndpointConnectionOptionalParams, + PrivateEndpointConnectionsGetAPrivateEndpointConnectionOptionalParams, + PrivateEndpointConnectionsListPrivateEndpointConnectionsOptionalParams, +} from "../index.js"; +import { + errorResponseDeserializer, + PrivateEndpointConnection, + privateEndpointConnectionDeserializer, + _PrivateEndpointConnectionListResult, + _privateEndpointConnectionListResultDeserializer, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { getLongRunningPoller } from "../../static-helpers/pollingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; +import { PollerLike, OperationState } from "@azure/core-lro"; + +export function _privateEndpointConnectionsListPrivateEndpointConnectionsSend( + context: Client, + resourceGroupName: string, + privateAccessName: string, + options: PrivateEndpointConnectionsListPrivateEndpointConnectionsOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections", + context.subscriptionId, + resourceGroupName, + privateAccessName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _privateEndpointConnectionsListPrivateEndpointConnectionsDeserialize( + result: PathUncheckedResponse, +): Promise<_PrivateEndpointConnectionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _privateEndpointConnectionListResultDeserializer(result.body); +} + +/** List information about private endpoint connections under a private access resource */ +export function privateEndpointConnectionsListPrivateEndpointConnections( + context: Client, + resourceGroupName: string, + privateAccessName: string, + options: PrivateEndpointConnectionsListPrivateEndpointConnectionsOptionalParams = { + requestOptions: {}, + }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => + _privateEndpointConnectionsListPrivateEndpointConnectionsSend( + context, + resourceGroupName, + privateAccessName, + options, + ), + _privateEndpointConnectionsListPrivateEndpointConnectionsDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _privateEndpointConnectionsDeleteAPrivateEndpointConnectionSend( + context: Client, + resourceGroupName: string, + privateAccessName: string, + privateEndpointConnectionName: string, + options: PrivateEndpointConnectionsDeleteAPrivateEndpointConnectionOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", + context.subscriptionId, + resourceGroupName, + privateAccessName, + privateEndpointConnectionName, + ) + .delete({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _privateEndpointConnectionsDeleteAPrivateEndpointConnectionDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["202", "204", "200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** Deletes a private endpoint connection under a private access resource. */ +export function privateEndpointConnectionsDeleteAPrivateEndpointConnection( + context: Client, + resourceGroupName: string, + privateAccessName: string, + privateEndpointConnectionName: string, + options: PrivateEndpointConnectionsDeleteAPrivateEndpointConnectionOptionalParams = { + requestOptions: {}, + }, +): PollerLike, void> { + return getLongRunningPoller( + context, + _privateEndpointConnectionsDeleteAPrivateEndpointConnectionDeserialize, + ["202", "204", "200"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _privateEndpointConnectionsDeleteAPrivateEndpointConnectionSend( + context, + resourceGroupName, + privateAccessName, + privateEndpointConnectionName, + options, + ), + resourceLocationConfig: "location", + }, + ) as PollerLike, void>; +} + +export function _privateEndpointConnectionsGetAPrivateEndpointConnectionSend( + context: Client, + resourceGroupName: string, + privateAccessName: string, + privateEndpointConnectionName: string, + options: PrivateEndpointConnectionsGetAPrivateEndpointConnectionOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", + context.subscriptionId, + resourceGroupName, + privateAccessName, + privateEndpointConnectionName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _privateEndpointConnectionsGetAPrivateEndpointConnectionDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return privateEndpointConnectionDeserializer(result.body); +} + +/** Gets information about a private endpoint connection under a private access resource. */ +export async function privateEndpointConnectionsGetAPrivateEndpointConnection( + context: Client, + resourceGroupName: string, + privateAccessName: string, + privateEndpointConnectionName: string, + options: PrivateEndpointConnectionsGetAPrivateEndpointConnectionOptionalParams = { + requestOptions: {}, + }, +): Promise { + const result = + await _privateEndpointConnectionsGetAPrivateEndpointConnectionSend( + context, + resourceGroupName, + privateAccessName, + privateEndpointConnectionName, + options, + ); + return _privateEndpointConnectionsGetAPrivateEndpointConnectionDeserialize( + result, + ); +} diff --git a/sdk/chaos/xxxx/src/api/targetTypes/index.ts b/sdk/chaos/xxxx/src/api/targetTypes/index.ts new file mode 100644 index 000000000000..3b4298c43cce --- /dev/null +++ b/sdk/chaos/xxxx/src/api/targetTypes/index.ts @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + ChaosManagementContext as Client, + TargetTypesGetOptionalParams, + TargetTypesListOptionalParams, +} from "../index.js"; +import { + errorResponseDeserializer, + TargetType, + targetTypeDeserializer, + _TargetTypeListResult, + _targetTypeListResultDeserializer, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _targetTypesListSend( + context: Client, + location: string, + options: TargetTypesListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/targetTypes", + context.subscriptionId, + location, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { + "api-version": context.apiVersion, + continuationToken: options?.continuationToken, + }, + }); +} + +export async function _targetTypesListDeserialize( + result: PathUncheckedResponse, +): Promise<_TargetTypeListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _targetTypeListResultDeserializer(result.body); +} + +/** Get a list of Target Type resources for given location. */ +export function targetTypesList( + context: Client, + location: string, + options: TargetTypesListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _targetTypesListSend(context, location, options), + _targetTypesListDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _targetTypesGetSend( + context: Client, + location: string, + targetTypeName: string, + options: TargetTypesGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/targetTypes/{targetTypeName}", + context.subscriptionId, + location, + targetTypeName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _targetTypesGetDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return targetTypeDeserializer(result.body); +} + +/** Get a Target Type resources for given location. */ +export async function targetTypesGet( + context: Client, + location: string, + targetTypeName: string, + options: TargetTypesGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _targetTypesGetSend( + context, + location, + targetTypeName, + options, + ); + return _targetTypesGetDeserialize(result); +} diff --git a/sdk/chaos/xxxx/src/api/targets/index.ts b/sdk/chaos/xxxx/src/api/targets/index.ts new file mode 100644 index 000000000000..336ec3503781 --- /dev/null +++ b/sdk/chaos/xxxx/src/api/targets/index.ts @@ -0,0 +1,294 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + ChaosManagementContext as Client, + TargetsCreateOrUpdateOptionalParams, + TargetsDeleteOptionalParams, + TargetsGetOptionalParams, + TargetsListOptionalParams, +} from "../index.js"; +import { + errorResponseDeserializer, + Target, + targetSerializer, + targetDeserializer, + _TargetListResult, + _targetListResultDeserializer, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _targetsListSend( + context: Client, + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + options: TargetsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets", + context.subscriptionId, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { + "api-version": context.apiVersion, + continuationToken: options?.continuationToken, + }, + }); +} + +export async function _targetsListDeserialize( + result: PathUncheckedResponse, +): Promise<_TargetListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _targetListResultDeserializer(result.body); +} + +/** Get a list of Target resources that extend a tracked regional resource. */ +export function targetsList( + context: Client, + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + options: TargetsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => + _targetsListSend( + context, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + options, + ), + _targetsListDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _targetsDeleteSend( + context: Client, + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + options: TargetsDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}", + context.subscriptionId, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + ) + .delete({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _targetsDeleteDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "204"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** Delete a Target resource that extends a tracked regional resource. */ +export async function targetsDelete( + context: Client, + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + options: TargetsDeleteOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _targetsDeleteSend( + context, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + options, + ); + return _targetsDeleteDeserialize(result); +} + +export function _targetsCreateOrUpdateSend( + context: Client, + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + resource: Target, + options: TargetsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}", + context.subscriptionId, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + ) + .put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + body: targetSerializer(resource), + }); +} + +export async function _targetsCreateOrUpdateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return targetDeserializer(result.body); +} + +/** Create or update a Target resource that extends a tracked regional resource. */ +export async function targetsCreateOrUpdate( + context: Client, + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + resource: Target, + options: TargetsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _targetsCreateOrUpdateSend( + context, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + resource, + options, + ); + return _targetsCreateOrUpdateDeserialize(result); +} + +export function _targetsGetSend( + context: Client, + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + options: TargetsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}", + context.subscriptionId, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _targetsGetDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return targetDeserializer(result.body); +} + +/** Get a Target resource that extends a tracked regional resource. */ +export async function targetsGet( + context: Client, + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + options: TargetsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _targetsGetSend( + context, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + options, + ); + return _targetsGetDeserialize(result); +} diff --git a/sdk/chaos/xxxx/src/chaosManagementClient.ts b/sdk/chaos/xxxx/src/chaosManagementClient.ts new file mode 100644 index 000000000000..476f52c479ee --- /dev/null +++ b/sdk/chaos/xxxx/src/chaosManagementClient.ts @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + _getOperationStatusesOperations, + OperationStatusesOperations, +} from "./classic/operationStatuses/index.js"; +import { + _getTargetTypesOperations, + TargetTypesOperations, +} from "./classic/targetTypes/index.js"; +import { + _getPrivateEndpointConnectionsOperations, + PrivateEndpointConnectionsOperations, +} from "./classic/privateEndpointConnections/index.js"; +import { + _getPrivateAccessesOperations, + PrivateAccessesOperations, +} from "./classic/privateAccesses/index.js"; +import { + _getExperimentExecutionsOperations, + ExperimentExecutionsOperations, +} from "./classic/experimentExecutions/index.js"; +import { + _getExperimentsOperations, + ExperimentsOperations, +} from "./classic/experiments/index.js"; +import { + _getCapabilityTypesOperations, + CapabilityTypesOperations, +} from "./classic/capabilityTypes/index.js"; +import { + _getTargetsOperations, + TargetsOperations, +} from "./classic/targets/index.js"; +import { + _getOperationsOperations, + OperationsOperations, +} from "./classic/operations/index.js"; +import { + _getCapabilitiesOperations, + CapabilitiesOperations, +} from "./classic/capabilities/index.js"; +import { + createChaosManagement, + ChaosManagementContext, + ChaosManagementClientOptionalParams, +} from "./api/index.js"; +import { Pipeline } from "@azure/core-rest-pipeline"; +import { TokenCredential } from "@azure/core-auth"; + +export { ChaosManagementClientOptionalParams } from "./api/chaosManagementContext.js"; + +export class ChaosManagementClient { + private _client: ChaosManagementContext; + /** The pipeline used by this client to make requests */ + public readonly pipeline: Pipeline; + + /** Chaos Management Client */ + constructor( + credential: TokenCredential, + subscriptionId: string, + options: ChaosManagementClientOptionalParams = {}, + ) { + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-client` + : `azsdk-js-client`; + this._client = createChaosManagement(credential, subscriptionId, { + ...options, + userAgentOptions: { userAgentPrefix }, + }); + this.pipeline = this._client.pipeline; + this.operationStatuses = _getOperationStatusesOperations(this._client); + this.targetTypes = _getTargetTypesOperations(this._client); + this.privateEndpointConnections = _getPrivateEndpointConnectionsOperations( + this._client, + ); + this.privateAccesses = _getPrivateAccessesOperations(this._client); + this.experimentExecutions = _getExperimentExecutionsOperations( + this._client, + ); + this.experiments = _getExperimentsOperations(this._client); + this.capabilityTypes = _getCapabilityTypesOperations(this._client); + this.targets = _getTargetsOperations(this._client); + this.operations = _getOperationsOperations(this._client); + this.capabilities = _getCapabilitiesOperations(this._client); + } + + /** The operation groups for operationStatuses */ + public readonly operationStatuses: OperationStatusesOperations; + /** The operation groups for targetTypes */ + public readonly targetTypes: TargetTypesOperations; + /** The operation groups for privateEndpointConnections */ + public readonly privateEndpointConnections: PrivateEndpointConnectionsOperations; + /** The operation groups for privateAccesses */ + public readonly privateAccesses: PrivateAccessesOperations; + /** The operation groups for experimentExecutions */ + public readonly experimentExecutions: ExperimentExecutionsOperations; + /** The operation groups for experiments */ + public readonly experiments: ExperimentsOperations; + /** The operation groups for capabilityTypes */ + public readonly capabilityTypes: CapabilityTypesOperations; + /** The operation groups for targets */ + public readonly targets: TargetsOperations; + /** The operation groups for operations */ + public readonly operations: OperationsOperations; + /** The operation groups for capabilities */ + public readonly capabilities: CapabilitiesOperations; +} diff --git a/sdk/chaos/xxxx/src/classic/capabilities/index.ts b/sdk/chaos/xxxx/src/classic/capabilities/index.ts new file mode 100644 index 000000000000..77a6efa1512d --- /dev/null +++ b/sdk/chaos/xxxx/src/classic/capabilities/index.ts @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ChaosManagementContext } from "../../api/chaosManagementContext.js"; +import { + capabilitiesList, + capabilitiesDelete, + capabilitiesCreateOrUpdate, + capabilitiesGet, +} from "../../api/capabilities/index.js"; +import { Capability } from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { + CapabilitiesListOptionalParams, + CapabilitiesDeleteOptionalParams, + CapabilitiesCreateOrUpdateOptionalParams, + CapabilitiesGetOptionalParams, +} from "../../api/options.js"; + +/** Interface representing a Capabilities operations. */ +export interface CapabilitiesOperations { + /** Get a list of Capability resources that extend a Target resource. */ + list: ( + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + options?: CapabilitiesListOptionalParams, + ) => PagedAsyncIterableIterator; + /** Delete a Capability that extends a Target resource. */ + delete: ( + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + capabilityName: string, + options?: CapabilitiesDeleteOptionalParams, + ) => Promise; + /** Create or update a Capability resource that extends a Target resource. */ + createOrUpdate: ( + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + capabilityName: string, + resource: Capability, + options?: CapabilitiesCreateOrUpdateOptionalParams, + ) => Promise; + /** Get a Capability resource that extends a Target resource. */ + get: ( + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + capabilityName: string, + options?: CapabilitiesGetOptionalParams, + ) => Promise; +} + +function _getCapabilities(context: ChaosManagementContext) { + return { + list: ( + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + options?: CapabilitiesListOptionalParams, + ) => + capabilitiesList( + context, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + options, + ), + delete: ( + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + capabilityName: string, + options?: CapabilitiesDeleteOptionalParams, + ) => + capabilitiesDelete( + context, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + capabilityName, + options, + ), + createOrUpdate: ( + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + capabilityName: string, + resource: Capability, + options?: CapabilitiesCreateOrUpdateOptionalParams, + ) => + capabilitiesCreateOrUpdate( + context, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + capabilityName, + resource, + options, + ), + get: ( + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + capabilityName: string, + options?: CapabilitiesGetOptionalParams, + ) => + capabilitiesGet( + context, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + capabilityName, + options, + ), + }; +} + +export function _getCapabilitiesOperations( + context: ChaosManagementContext, +): CapabilitiesOperations { + return { + ..._getCapabilities(context), + }; +} diff --git a/sdk/chaos/xxxx/src/classic/capabilityTypes/index.ts b/sdk/chaos/xxxx/src/classic/capabilityTypes/index.ts new file mode 100644 index 000000000000..ad31cc60598b --- /dev/null +++ b/sdk/chaos/xxxx/src/classic/capabilityTypes/index.ts @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ChaosManagementContext } from "../../api/chaosManagementContext.js"; +import { + capabilityTypesList, + capabilityTypesGet, +} from "../../api/capabilityTypes/index.js"; +import { CapabilityType } from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { + CapabilityTypesListOptionalParams, + CapabilityTypesGetOptionalParams, +} from "../../api/options.js"; + +/** Interface representing a CapabilityTypes operations. */ +export interface CapabilityTypesOperations { + /** Get a list of Capability Type resources for given Target Type and location. */ + list: ( + location: string, + targetTypeName: string, + options?: CapabilityTypesListOptionalParams, + ) => PagedAsyncIterableIterator; + /** Get a Capability Type resource for given Target Type and location. */ + get: ( + location: string, + targetTypeName: string, + capabilityTypeName: string, + options?: CapabilityTypesGetOptionalParams, + ) => Promise; +} + +function _getCapabilityTypes(context: ChaosManagementContext) { + return { + list: ( + location: string, + targetTypeName: string, + options?: CapabilityTypesListOptionalParams, + ) => capabilityTypesList(context, location, targetTypeName, options), + get: ( + location: string, + targetTypeName: string, + capabilityTypeName: string, + options?: CapabilityTypesGetOptionalParams, + ) => + capabilityTypesGet( + context, + location, + targetTypeName, + capabilityTypeName, + options, + ), + }; +} + +export function _getCapabilityTypesOperations( + context: ChaosManagementContext, +): CapabilityTypesOperations { + return { + ..._getCapabilityTypes(context), + }; +} diff --git a/sdk/chaos/xxxx/src/classic/experimentExecutions/index.ts b/sdk/chaos/xxxx/src/classic/experimentExecutions/index.ts new file mode 100644 index 000000000000..76dee57ec48f --- /dev/null +++ b/sdk/chaos/xxxx/src/classic/experimentExecutions/index.ts @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ChaosManagementContext } from "../../api/chaosManagementContext.js"; +import { + experimentExecutionsGetExecutionDetails, + experimentExecutionsListAllExecutions, + experimentExecutionsGetExecution, +} from "../../api/experimentExecutions/index.js"; +import { + ExperimentExecutionsGetExecutionDetailsOptionalParams, + ExperimentExecutionsListAllExecutionsOptionalParams, + ExperimentExecutionsGetExecutionOptionalParams, +} from "../../api/options.js"; +import { + ExperimentExecution, + ExperimentExecutionDetails, +} from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a ExperimentExecutions operations. */ +export interface ExperimentExecutionsOperations { + /** Execution details of an experiment resource. */ + getExecutionDetails: ( + resourceGroupName: string, + experimentName: string, + executionId: string, + options?: ExperimentExecutionsGetExecutionDetailsOptionalParams, + ) => Promise; + /** Get a list of executions of an Experiment resource. */ + listAllExecutions: ( + resourceGroupName: string, + experimentName: string, + options?: ExperimentExecutionsListAllExecutionsOptionalParams, + ) => PagedAsyncIterableIterator; + /** Get an execution of an Experiment resource. */ + getExecution: ( + resourceGroupName: string, + experimentName: string, + executionId: string, + options?: ExperimentExecutionsGetExecutionOptionalParams, + ) => Promise; +} + +function _getExperimentExecutions(context: ChaosManagementContext) { + return { + getExecutionDetails: ( + resourceGroupName: string, + experimentName: string, + executionId: string, + options?: ExperimentExecutionsGetExecutionDetailsOptionalParams, + ) => + experimentExecutionsGetExecutionDetails( + context, + resourceGroupName, + experimentName, + executionId, + options, + ), + listAllExecutions: ( + resourceGroupName: string, + experimentName: string, + options?: ExperimentExecutionsListAllExecutionsOptionalParams, + ) => + experimentExecutionsListAllExecutions( + context, + resourceGroupName, + experimentName, + options, + ), + getExecution: ( + resourceGroupName: string, + experimentName: string, + executionId: string, + options?: ExperimentExecutionsGetExecutionOptionalParams, + ) => + experimentExecutionsGetExecution( + context, + resourceGroupName, + experimentName, + executionId, + options, + ), + }; +} + +export function _getExperimentExecutionsOperations( + context: ChaosManagementContext, +): ExperimentExecutionsOperations { + return { + ..._getExperimentExecutions(context), + }; +} diff --git a/sdk/chaos/xxxx/src/classic/experiments/index.ts b/sdk/chaos/xxxx/src/classic/experiments/index.ts new file mode 100644 index 000000000000..49cc45bd231d --- /dev/null +++ b/sdk/chaos/xxxx/src/classic/experiments/index.ts @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ChaosManagementContext } from "../../api/chaosManagementContext.js"; +import { + experimentsStart, + experimentsCancel, + experimentsListAll, + experimentsList, + experimentsDelete, + experimentsUpdate, + experimentsCreateOrUpdate, + experimentsGet, +} from "../../api/experiments/index.js"; +import { + ExperimentsStartOptionalParams, + ExperimentsCancelOptionalParams, + ExperimentsListAllOptionalParams, + ExperimentsListOptionalParams, + ExperimentsDeleteOptionalParams, + ExperimentsUpdateOptionalParams, + ExperimentsCreateOrUpdateOptionalParams, + ExperimentsGetOptionalParams, +} from "../../api/options.js"; +import { Experiment, ExperimentUpdate } from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { PollerLike, OperationState } from "@azure/core-lro"; + +/** Interface representing a Experiments operations. */ +export interface ExperimentsOperations { + /** Start a Experiment resource. */ + start: ( + resourceGroupName: string, + experimentName: string, + options?: ExperimentsStartOptionalParams, + ) => PollerLike, void>; + /** Cancel a running Experiment resource. */ + cancel: ( + resourceGroupName: string, + experimentName: string, + options?: ExperimentsCancelOptionalParams, + ) => PollerLike, void>; + /** Get a list of Experiment resources in a subscription. */ + listAll: ( + options?: ExperimentsListAllOptionalParams, + ) => PagedAsyncIterableIterator; + /** Get a list of Experiment resources in a resource group. */ + list: ( + resourceGroupName: string, + options?: ExperimentsListOptionalParams, + ) => PagedAsyncIterableIterator; + /** Delete a Experiment resource. */ + delete: ( + resourceGroupName: string, + experimentName: string, + options?: ExperimentsDeleteOptionalParams, + ) => PollerLike, void>; + /** The operation to update an experiment. */ + update: ( + resourceGroupName: string, + experimentName: string, + properties: ExperimentUpdate, + options?: ExperimentsUpdateOptionalParams, + ) => PollerLike, Experiment>; + /** Create or update a Experiment resource. */ + createOrUpdate: ( + resourceGroupName: string, + experimentName: string, + resource: Experiment, + options?: ExperimentsCreateOrUpdateOptionalParams, + ) => PollerLike, Experiment>; + /** Get a Experiment resource. */ + get: ( + resourceGroupName: string, + experimentName: string, + options?: ExperimentsGetOptionalParams, + ) => Promise; +} + +function _getExperiments(context: ChaosManagementContext) { + return { + start: ( + resourceGroupName: string, + experimentName: string, + options?: ExperimentsStartOptionalParams, + ) => experimentsStart(context, resourceGroupName, experimentName, options), + cancel: ( + resourceGroupName: string, + experimentName: string, + options?: ExperimentsCancelOptionalParams, + ) => experimentsCancel(context, resourceGroupName, experimentName, options), + listAll: (options?: ExperimentsListAllOptionalParams) => + experimentsListAll(context, options), + list: ( + resourceGroupName: string, + options?: ExperimentsListOptionalParams, + ) => experimentsList(context, resourceGroupName, options), + delete: ( + resourceGroupName: string, + experimentName: string, + options?: ExperimentsDeleteOptionalParams, + ) => experimentsDelete(context, resourceGroupName, experimentName, options), + update: ( + resourceGroupName: string, + experimentName: string, + properties: ExperimentUpdate, + options?: ExperimentsUpdateOptionalParams, + ) => + experimentsUpdate( + context, + resourceGroupName, + experimentName, + properties, + options, + ), + createOrUpdate: ( + resourceGroupName: string, + experimentName: string, + resource: Experiment, + options?: ExperimentsCreateOrUpdateOptionalParams, + ) => + experimentsCreateOrUpdate( + context, + resourceGroupName, + experimentName, + resource, + options, + ), + get: ( + resourceGroupName: string, + experimentName: string, + options?: ExperimentsGetOptionalParams, + ) => experimentsGet(context, resourceGroupName, experimentName, options), + }; +} + +export function _getExperimentsOperations( + context: ChaosManagementContext, +): ExperimentsOperations { + return { + ..._getExperiments(context), + }; +} diff --git a/sdk/chaos/xxxx/src/classic/index.ts b/sdk/chaos/xxxx/src/classic/index.ts new file mode 100644 index 000000000000..0c7d469c5bcd --- /dev/null +++ b/sdk/chaos/xxxx/src/classic/index.ts @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { CapabilitiesOperations } from "./capabilities/index.js"; +export { CapabilityTypesOperations } from "./capabilityTypes/index.js"; +export { ExperimentExecutionsOperations } from "./experimentExecutions/index.js"; +export { ExperimentsOperations } from "./experiments/index.js"; +export { OperationsOperations } from "./operations/index.js"; +export { OperationStatusesOperations } from "./operationStatuses/index.js"; +export { PrivateAccessesOperations } from "./privateAccesses/index.js"; +export { PrivateEndpointConnectionsOperations } from "./privateEndpointConnections/index.js"; +export { TargetsOperations } from "./targets/index.js"; +export { TargetTypesOperations } from "./targetTypes/index.js"; diff --git a/sdk/chaos/xxxx/src/classic/operationStatuses/index.ts b/sdk/chaos/xxxx/src/classic/operationStatuses/index.ts new file mode 100644 index 000000000000..0bad7d8d0c6a --- /dev/null +++ b/sdk/chaos/xxxx/src/classic/operationStatuses/index.ts @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ChaosManagementContext } from "../../api/chaosManagementContext.js"; +import { operationStatusesGet } from "../../api/operationStatuses/index.js"; +import { OperationStatusesGetOptionalParams } from "../../api/options.js"; +import { OperationStatusResult } from "../../models/models.js"; + +/** Interface representing a OperationStatuses operations. */ +export interface OperationStatusesOperations { + /** Returns the current status of an async operation. */ + get: ( + location: string, + operationId: string, + options?: OperationStatusesGetOptionalParams, + ) => Promise; +} + +function _getOperationStatuses(context: ChaosManagementContext) { + return { + get: ( + location: string, + operationId: string, + options?: OperationStatusesGetOptionalParams, + ) => operationStatusesGet(context, location, operationId, options), + }; +} + +export function _getOperationStatusesOperations( + context: ChaosManagementContext, +): OperationStatusesOperations { + return { + ..._getOperationStatuses(context), + }; +} diff --git a/sdk/chaos/xxxx/src/classic/operations/index.ts b/sdk/chaos/xxxx/src/classic/operations/index.ts new file mode 100644 index 000000000000..1d8d733f9abd --- /dev/null +++ b/sdk/chaos/xxxx/src/classic/operations/index.ts @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ChaosManagementContext } from "../../api/chaosManagementContext.js"; +import { operationsList } from "../../api/operations/index.js"; +import { OperationsListOptionalParams } from "../../api/options.js"; +import { Operation } from "../../models/models.js"; +import { 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: ChaosManagementContext) { + return { + list: (options?: OperationsListOptionalParams) => + operationsList(context, options), + }; +} + +export function _getOperationsOperations( + context: ChaosManagementContext, +): OperationsOperations { + return { + ..._getOperations(context), + }; +} diff --git a/sdk/chaos/xxxx/src/classic/privateAccesses/index.ts b/sdk/chaos/xxxx/src/classic/privateAccesses/index.ts new file mode 100644 index 000000000000..7fe6a82b34cc --- /dev/null +++ b/sdk/chaos/xxxx/src/classic/privateAccesses/index.ts @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ChaosManagementContext } from "../../api/chaosManagementContext.js"; +import { + PrivateAccessesPrivateLinkResourcesOptionalParams, + PrivateAccessesListAllOptionalParams, + PrivateAccessesListOptionalParams, + PrivateAccessesDeleteOptionalParams, + PrivateAccessesUpdateOptionalParams, + PrivateAccessesCreateOrUpdateOptionalParams, + PrivateAccessesGetOptionalParams, +} from "../../api/options.js"; +import { + privateAccessesPrivateLinkResources, + privateAccessesListAll, + privateAccessesList, + privateAccessesDelete, + privateAccessesUpdate, + privateAccessesCreateOrUpdate, + privateAccessesGet, +} from "../../api/privateAccesses/index.js"; +import { + PrivateAccess, + PrivateAccessPatch, + PrivateLinkResource, +} from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { PollerLike, OperationState } from "@azure/core-lro"; + +/** Interface representing a PrivateAccesses operations. */ +export interface PrivateAccessesOperations { + /** Gets the private link resources possible under private access resource */ + privateLinkResources: ( + resourceGroupName: string, + privateAccessName: string, + options?: PrivateAccessesPrivateLinkResourcesOptionalParams, + ) => PagedAsyncIterableIterator; + /** Get a list of private access resources in a subscription. */ + listAll: ( + options?: PrivateAccessesListAllOptionalParams, + ) => PagedAsyncIterableIterator; + /** Get a list of private access resources in a resource group. */ + list: ( + resourceGroupName: string, + options?: PrivateAccessesListOptionalParams, + ) => PagedAsyncIterableIterator; + /** Delete a private access */ + delete: ( + resourceGroupName: string, + privateAccessName: string, + options?: PrivateAccessesDeleteOptionalParams, + ) => PollerLike, void>; + /** Patch a private access tags */ + update: ( + resourceGroupName: string, + privateAccessName: string, + properties: PrivateAccessPatch, + options?: PrivateAccessesUpdateOptionalParams, + ) => PollerLike, PrivateAccess>; + /** Create or update a private access */ + createOrUpdate: ( + resourceGroupName: string, + privateAccessName: string, + resource: PrivateAccess, + options?: PrivateAccessesCreateOrUpdateOptionalParams, + ) => PollerLike, PrivateAccess>; + /** Get a private access resource */ + get: ( + resourceGroupName: string, + privateAccessName: string, + options?: PrivateAccessesGetOptionalParams, + ) => Promise; +} + +function _getPrivateAccesses(context: ChaosManagementContext) { + return { + privateLinkResources: ( + resourceGroupName: string, + privateAccessName: string, + options?: PrivateAccessesPrivateLinkResourcesOptionalParams, + ) => + privateAccessesPrivateLinkResources( + context, + resourceGroupName, + privateAccessName, + options, + ), + listAll: (options?: PrivateAccessesListAllOptionalParams) => + privateAccessesListAll(context, options), + list: ( + resourceGroupName: string, + options?: PrivateAccessesListOptionalParams, + ) => privateAccessesList(context, resourceGroupName, options), + delete: ( + resourceGroupName: string, + privateAccessName: string, + options?: PrivateAccessesDeleteOptionalParams, + ) => + privateAccessesDelete( + context, + resourceGroupName, + privateAccessName, + options, + ), + update: ( + resourceGroupName: string, + privateAccessName: string, + properties: PrivateAccessPatch, + options?: PrivateAccessesUpdateOptionalParams, + ) => + privateAccessesUpdate( + context, + resourceGroupName, + privateAccessName, + properties, + options, + ), + createOrUpdate: ( + resourceGroupName: string, + privateAccessName: string, + resource: PrivateAccess, + options?: PrivateAccessesCreateOrUpdateOptionalParams, + ) => + privateAccessesCreateOrUpdate( + context, + resourceGroupName, + privateAccessName, + resource, + options, + ), + get: ( + resourceGroupName: string, + privateAccessName: string, + options?: PrivateAccessesGetOptionalParams, + ) => + privateAccessesGet( + context, + resourceGroupName, + privateAccessName, + options, + ), + }; +} + +export function _getPrivateAccessesOperations( + context: ChaosManagementContext, +): PrivateAccessesOperations { + return { + ..._getPrivateAccesses(context), + }; +} diff --git a/sdk/chaos/xxxx/src/classic/privateEndpointConnections/index.ts b/sdk/chaos/xxxx/src/classic/privateEndpointConnections/index.ts new file mode 100644 index 000000000000..79cd8ee17a07 --- /dev/null +++ b/sdk/chaos/xxxx/src/classic/privateEndpointConnections/index.ts @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ChaosManagementContext } from "../../api/chaosManagementContext.js"; +import { + PrivateEndpointConnectionsListPrivateEndpointConnectionsOptionalParams, + PrivateEndpointConnectionsDeleteAPrivateEndpointConnectionOptionalParams, + PrivateEndpointConnectionsGetAPrivateEndpointConnectionOptionalParams, +} from "../../api/options.js"; +import { + privateEndpointConnectionsListPrivateEndpointConnections, + privateEndpointConnectionsDeleteAPrivateEndpointConnection, + privateEndpointConnectionsGetAPrivateEndpointConnection, +} from "../../api/privateEndpointConnections/index.js"; +import { PrivateEndpointConnection } from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { PollerLike, OperationState } from "@azure/core-lro"; + +/** Interface representing a PrivateEndpointConnections operations. */ +export interface PrivateEndpointConnectionsOperations { + /** List information about private endpoint connections under a private access resource */ + listPrivateEndpointConnections: ( + resourceGroupName: string, + privateAccessName: string, + options?: PrivateEndpointConnectionsListPrivateEndpointConnectionsOptionalParams, + ) => PagedAsyncIterableIterator; + /** Deletes a private endpoint connection under a private access resource. */ + deleteAPrivateEndpointConnection: ( + resourceGroupName: string, + privateAccessName: string, + privateEndpointConnectionName: string, + options?: PrivateEndpointConnectionsDeleteAPrivateEndpointConnectionOptionalParams, + ) => PollerLike, void>; + /** Gets information about a private endpoint connection under a private access resource. */ + getAPrivateEndpointConnection: ( + resourceGroupName: string, + privateAccessName: string, + privateEndpointConnectionName: string, + options?: PrivateEndpointConnectionsGetAPrivateEndpointConnectionOptionalParams, + ) => Promise; +} + +function _getPrivateEndpointConnections(context: ChaosManagementContext) { + return { + listPrivateEndpointConnections: ( + resourceGroupName: string, + privateAccessName: string, + options?: PrivateEndpointConnectionsListPrivateEndpointConnectionsOptionalParams, + ) => + privateEndpointConnectionsListPrivateEndpointConnections( + context, + resourceGroupName, + privateAccessName, + options, + ), + deleteAPrivateEndpointConnection: ( + resourceGroupName: string, + privateAccessName: string, + privateEndpointConnectionName: string, + options?: PrivateEndpointConnectionsDeleteAPrivateEndpointConnectionOptionalParams, + ) => + privateEndpointConnectionsDeleteAPrivateEndpointConnection( + context, + resourceGroupName, + privateAccessName, + privateEndpointConnectionName, + options, + ), + getAPrivateEndpointConnection: ( + resourceGroupName: string, + privateAccessName: string, + privateEndpointConnectionName: string, + options?: PrivateEndpointConnectionsGetAPrivateEndpointConnectionOptionalParams, + ) => + privateEndpointConnectionsGetAPrivateEndpointConnection( + context, + resourceGroupName, + privateAccessName, + privateEndpointConnectionName, + options, + ), + }; +} + +export function _getPrivateEndpointConnectionsOperations( + context: ChaosManagementContext, +): PrivateEndpointConnectionsOperations { + return { + ..._getPrivateEndpointConnections(context), + }; +} diff --git a/sdk/chaos/xxxx/src/classic/targetTypes/index.ts b/sdk/chaos/xxxx/src/classic/targetTypes/index.ts new file mode 100644 index 000000000000..a4f35c19b827 --- /dev/null +++ b/sdk/chaos/xxxx/src/classic/targetTypes/index.ts @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ChaosManagementContext } from "../../api/chaosManagementContext.js"; +import { + TargetTypesListOptionalParams, + TargetTypesGetOptionalParams, +} from "../../api/options.js"; +import { + targetTypesList, + targetTypesGet, +} from "../../api/targetTypes/index.js"; +import { TargetType } from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a TargetTypes operations. */ +export interface TargetTypesOperations { + /** Get a list of Target Type resources for given location. */ + list: ( + location: string, + options?: TargetTypesListOptionalParams, + ) => PagedAsyncIterableIterator; + /** Get a Target Type resources for given location. */ + get: ( + location: string, + targetTypeName: string, + options?: TargetTypesGetOptionalParams, + ) => Promise; +} + +function _getTargetTypes(context: ChaosManagementContext) { + return { + list: (location: string, options?: TargetTypesListOptionalParams) => + targetTypesList(context, location, options), + get: ( + location: string, + targetTypeName: string, + options?: TargetTypesGetOptionalParams, + ) => targetTypesGet(context, location, targetTypeName, options), + }; +} + +export function _getTargetTypesOperations( + context: ChaosManagementContext, +): TargetTypesOperations { + return { + ..._getTargetTypes(context), + }; +} diff --git a/sdk/chaos/xxxx/src/classic/targets/index.ts b/sdk/chaos/xxxx/src/classic/targets/index.ts new file mode 100644 index 000000000000..6a288c958247 --- /dev/null +++ b/sdk/chaos/xxxx/src/classic/targets/index.ts @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ChaosManagementContext } from "../../api/chaosManagementContext.js"; +import { + TargetsListOptionalParams, + TargetsDeleteOptionalParams, + TargetsCreateOrUpdateOptionalParams, + TargetsGetOptionalParams, +} from "../../api/options.js"; +import { + targetsList, + targetsDelete, + targetsCreateOrUpdate, + targetsGet, +} from "../../api/targets/index.js"; +import { Target } from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a Targets operations. */ +export interface TargetsOperations { + /** Get a list of Target resources that extend a tracked regional resource. */ + list: ( + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + options?: TargetsListOptionalParams, + ) => PagedAsyncIterableIterator; + /** Delete a Target resource that extends a tracked regional resource. */ + delete: ( + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + options?: TargetsDeleteOptionalParams, + ) => Promise; + /** Create or update a Target resource that extends a tracked regional resource. */ + createOrUpdate: ( + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + resource: Target, + options?: TargetsCreateOrUpdateOptionalParams, + ) => Promise; + /** Get a Target resource that extends a tracked regional resource. */ + get: ( + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + options?: TargetsGetOptionalParams, + ) => Promise; +} + +function _getTargets(context: ChaosManagementContext) { + return { + list: ( + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + options?: TargetsListOptionalParams, + ) => + targetsList( + context, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + options, + ), + delete: ( + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + options?: TargetsDeleteOptionalParams, + ) => + targetsDelete( + context, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + options, + ), + createOrUpdate: ( + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + resource: Target, + options?: TargetsCreateOrUpdateOptionalParams, + ) => + targetsCreateOrUpdate( + context, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + resource, + options, + ), + get: ( + resourceGroupName: string, + parentProviderNamespace: string, + parentResourceType: string, + parentResourceName: string, + targetName: string, + options?: TargetsGetOptionalParams, + ) => + targetsGet( + context, + resourceGroupName, + parentProviderNamespace, + parentResourceType, + parentResourceName, + targetName, + options, + ), + }; +} + +export function _getTargetsOperations( + context: ChaosManagementContext, +): TargetsOperations { + return { + ..._getTargets(context), + }; +} diff --git a/sdk/chaos/xxxx/src/index.ts b/sdk/chaos/xxxx/src/index.ts new file mode 100644 index 000000000000..caee0c6e49b7 --- /dev/null +++ b/sdk/chaos/xxxx/src/index.ts @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + PageSettings, + ContinuablePage, + PagedAsyncIterableIterator, +} from "./static-helpers/pagingHelpers.js"; + +export { ChaosManagementClient } from "./chaosManagementClient.js"; +export { restorePoller, RestorePollerOptions } from "./restorePollerHelpers.js"; +export { + OperationStatusResult, + ErrorDetail, + ErrorAdditionalInfo, + ErrorResponse, + TargetType, + TargetTypeProperties, + ProxyResource, + Resource, + SystemData, + KnownCreatedByType, + CreatedByType, + PrivateEndpointConnection, + PrivateEndpointConnectionProperties, + PrivateEndpoint, + PrivateLinkServiceConnectionState, + KnownPrivateEndpointServiceConnectionStatus, + PrivateEndpointServiceConnectionStatus, + KnownProvisioningState, + ProvisioningState, + PrivateAccess, + PrivateAccessProperties, + KnownPublicNetworkAccessOption, + PublicNetworkAccessOption, + TrackedResource, + PrivateAccessPatch, + PrivateLinkResource, + PrivateLinkResourceProperties, + ExperimentExecution, + ExperimentExecutionProperties, + ExperimentExecutionDetails, + ExperimentExecutionDetailsProperties, + ExperimentExecutionDetailsPropertiesRunInformation, + StepStatus, + BranchStatus, + ActionStatus, + ExperimentExecutionActionTargetDetailsProperties, + ExperimentExecutionActionTargetDetailsError, + Experiment, + ManagedServiceIdentity, + KnownManagedServiceIdentityType, + ManagedServiceIdentityType, + UserAssignedIdentity, + ExperimentProperties, + ChaosExperimentStep, + ChaosExperimentBranch, + ChaosExperimentAction, + ChaosExperimentActionUnion, + KnownExperimentActionType, + ExperimentActionType, + ContinuousAction, + KeyValuePair, + DelayAction, + DiscreteAction, + ChaosTargetSelector, + ChaosTargetSelectorUnion, + KnownSelectorType, + SelectorType, + ChaosTargetFilter, + ChaosTargetFilterUnion, + KnownFilterType, + FilterType, + ChaosTargetSimpleFilter, + ChaosTargetSimpleFilterParameters, + ChaosTargetListSelector, + TargetReference, + KnownTargetReferenceType, + TargetReferenceType, + ChaosTargetQuerySelector, + CustomerDataStorageProperties, + ExperimentUpdate, + CapabilityType, + CapabilityTypeProperties, + CapabilityTypePropertiesRuntimeProperties, + Target, + Operation, + OperationDisplay, + KnownOrigin, + Origin, + KnownActionType, + ActionType, + Capability, + CapabilityProperties, + KnownVersions, +} from "./models/index.js"; +export { + ChaosManagementClientOptionalParams, + OperationStatusesGetOptionalParams, + TargetTypesListOptionalParams, + TargetTypesGetOptionalParams, + PrivateEndpointConnectionsListPrivateEndpointConnectionsOptionalParams, + PrivateEndpointConnectionsDeleteAPrivateEndpointConnectionOptionalParams, + PrivateEndpointConnectionsGetAPrivateEndpointConnectionOptionalParams, + PrivateAccessesPrivateLinkResourcesOptionalParams, + PrivateAccessesListAllOptionalParams, + PrivateAccessesListOptionalParams, + PrivateAccessesDeleteOptionalParams, + PrivateAccessesUpdateOptionalParams, + PrivateAccessesCreateOrUpdateOptionalParams, + PrivateAccessesGetOptionalParams, + ExperimentExecutionsGetExecutionDetailsOptionalParams, + ExperimentExecutionsListAllExecutionsOptionalParams, + ExperimentExecutionsGetExecutionOptionalParams, + ExperimentsStartOptionalParams, + ExperimentsCancelOptionalParams, + ExperimentsListAllOptionalParams, + ExperimentsListOptionalParams, + ExperimentsDeleteOptionalParams, + ExperimentsUpdateOptionalParams, + ExperimentsCreateOrUpdateOptionalParams, + ExperimentsGetOptionalParams, + CapabilityTypesListOptionalParams, + CapabilityTypesGetOptionalParams, + TargetsListOptionalParams, + TargetsDeleteOptionalParams, + TargetsCreateOrUpdateOptionalParams, + TargetsGetOptionalParams, + OperationsListOptionalParams, + CapabilitiesListOptionalParams, + CapabilitiesDeleteOptionalParams, + CapabilitiesCreateOrUpdateOptionalParams, + CapabilitiesGetOptionalParams, +} from "./api/index.js"; +export { + CapabilitiesOperations, + CapabilityTypesOperations, + ExperimentExecutionsOperations, + ExperimentsOperations, + OperationsOperations, + OperationStatusesOperations, + PrivateAccessesOperations, + PrivateEndpointConnectionsOperations, + TargetsOperations, + TargetTypesOperations, +} from "./classic/index.js"; +export { PageSettings, ContinuablePage, PagedAsyncIterableIterator }; diff --git a/sdk/chaos/xxxx/src/logger.ts b/sdk/chaos/xxxx/src/logger.ts new file mode 100644 index 000000000000..d43914f56e0a --- /dev/null +++ b/sdk/chaos/xxxx/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-chaos"); diff --git a/sdk/chaos/xxxx/src/models/index.ts b/sdk/chaos/xxxx/src/models/index.ts new file mode 100644 index 000000000000..8e1ff1c1c458 --- /dev/null +++ b/sdk/chaos/xxxx/src/models/index.ts @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + OperationStatusResult, + ErrorDetail, + ErrorAdditionalInfo, + ErrorResponse, + TargetType, + TargetTypeProperties, + ProxyResource, + Resource, + SystemData, + KnownCreatedByType, + CreatedByType, + PrivateEndpointConnection, + PrivateEndpointConnectionProperties, + PrivateEndpoint, + PrivateLinkServiceConnectionState, + KnownPrivateEndpointServiceConnectionStatus, + PrivateEndpointServiceConnectionStatus, + KnownProvisioningState, + ProvisioningState, + PrivateAccess, + PrivateAccessProperties, + KnownPublicNetworkAccessOption, + PublicNetworkAccessOption, + TrackedResource, + PrivateAccessPatch, + PrivateLinkResource, + PrivateLinkResourceProperties, + ExperimentExecution, + ExperimentExecutionProperties, + ExperimentExecutionDetails, + ExperimentExecutionDetailsProperties, + ExperimentExecutionDetailsPropertiesRunInformation, + StepStatus, + BranchStatus, + ActionStatus, + ExperimentExecutionActionTargetDetailsProperties, + ExperimentExecutionActionTargetDetailsError, + Experiment, + ManagedServiceIdentity, + KnownManagedServiceIdentityType, + ManagedServiceIdentityType, + UserAssignedIdentity, + ExperimentProperties, + ChaosExperimentStep, + ChaosExperimentBranch, + ChaosExperimentAction, + ChaosExperimentActionUnion, + KnownExperimentActionType, + ExperimentActionType, + ContinuousAction, + KeyValuePair, + DelayAction, + DiscreteAction, + ChaosTargetSelector, + ChaosTargetSelectorUnion, + KnownSelectorType, + SelectorType, + ChaosTargetFilter, + ChaosTargetFilterUnion, + KnownFilterType, + FilterType, + ChaosTargetSimpleFilter, + ChaosTargetSimpleFilterParameters, + ChaosTargetListSelector, + TargetReference, + KnownTargetReferenceType, + TargetReferenceType, + ChaosTargetQuerySelector, + CustomerDataStorageProperties, + ExperimentUpdate, + CapabilityType, + CapabilityTypeProperties, + CapabilityTypePropertiesRuntimeProperties, + Target, + Operation, + OperationDisplay, + KnownOrigin, + Origin, + KnownActionType, + ActionType, + Capability, + CapabilityProperties, + KnownVersions, +} from "./models.js"; diff --git a/sdk/chaos/xxxx/src/models/models.ts b/sdk/chaos/xxxx/src/models/models.ts new file mode 100644 index 000000000000..807d6fd69fd3 --- /dev/null +++ b/sdk/chaos/xxxx/src/models/models.ts @@ -0,0 +1,2255 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** The current status of an async operation. */ +export interface OperationStatusResult { + /** Fully qualified ID for the async operation. */ + id?: string; + /** Name of the async operation. */ + name?: string; + /** Operation status. */ + status: string; + /** Percent of the operation that is complete. */ + percentComplete?: number; + /** The start time of the operation. */ + startTime?: Date; + /** The end time of the operation. */ + endTime?: Date; + /** The operations list. */ + operations?: OperationStatusResult[]; + /** If present, details of the operation error. */ + error?: ErrorDetail; + /** Fully qualified ID of the resource against which the original async operation was started. */ + readonly resourceId?: string; +} + +export function operationStatusResultDeserializer( + item: any, +): OperationStatusResult { + return { + id: item["id"], + name: item["name"], + status: item["status"], + percentComplete: item["percentComplete"], + startTime: !item["startTime"] + ? item["startTime"] + : new Date(item["startTime"]), + endTime: !item["endTime"] ? item["endTime"] : new Date(item["endTime"]), + operations: !item["operations"] + ? item["operations"] + : operationStatusResultArrayDeserializer(item["operations"]), + error: !item["error"] + ? item["error"] + : errorDetailDeserializer(item["error"]), + resourceId: item["resourceId"], + }; +} + +export function operationStatusResultArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return operationStatusResultDeserializer(item); + }); +} + +/** 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?: Record; +} + +export function errorAdditionalInfoDeserializer( + item: any, +): ErrorAdditionalInfo { + return { + type: item["type"], + info: !item["info"] + ? item["info"] + : _errorAdditionalInfoInfoDeserializer(item["info"]), + }; +} + +/** model interface _ErrorAdditionalInfoInfo */ +export interface _ErrorAdditionalInfoInfo {} + +export function _errorAdditionalInfoInfoDeserializer( + item: any, +): _ErrorAdditionalInfoInfo { + return item; +} + +/** 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"]), + }; +} + +/** Model that represents a Target Type resource. */ +export interface TargetType extends ProxyResource { + /** The properties of the target type resource. */ + properties: TargetTypeProperties; +} + +export function targetTypeDeserializer(item: any): TargetType { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: targetTypePropertiesDeserializer(item["properties"]), + }; +} + +/** Model that represents the base Target Type properties model. */ +export interface TargetTypeProperties { + /** Localized string of the display name. */ + readonly displayName?: string; + /** Localized string of the description. */ + readonly description?: string; + /** URL to retrieve JSON schema of the Target Type properties. */ + readonly propertiesSchema?: string; + /** List of resource types this Target Type can extend. */ + readonly resourceTypes?: string[]; +} + +export function targetTypePropertiesDeserializer( + item: any, +): TargetTypeProperties { + return { + displayName: item["displayName"], + description: item["description"], + propertiesSchema: item["propertiesSchema"], + resourceTypes: !item["resourceTypes"] + ? item["resourceTypes"] + : item["resourceTypes"].map((p: any) => { + return p; + }), + }; +} + +/** The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location */ +export interface ProxyResource extends Resource {} + +export function proxyResourceSerializer(item: ProxyResource): any { + return item; +} + +export function proxyResourceDeserializer(item: any): ProxyResource { + 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 resourceSerializer(item: Resource): any { + return item; +} + +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; + +/** Model that represents a list of Target Type resources and a link for pagination. */ +export interface _TargetTypeListResult { + /** The TargetType items on this page */ + value: TargetType[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _targetTypeListResultDeserializer( + item: any, +): _TargetTypeListResult { + return { + value: targetTypeArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function targetTypeArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return targetTypeDeserializer(item); + }); +} + +/** The private endpoint connection resource. */ +export interface PrivateEndpointConnection extends ProxyResource { + /** Resource properties. */ + properties?: PrivateEndpointConnectionProperties; +} + +export function privateEndpointConnectionDeserializer( + item: any, +): PrivateEndpointConnection { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : privateEndpointConnectionPropertiesDeserializer(item["properties"]), + }; +} + +/** Properties of the private endpoint connection. */ +export interface PrivateEndpointConnectionProperties { + /** The group ids for the private endpoint resource. */ + readonly groupIds?: string[]; + /** The private endpoint resource. */ + privateEndpoint?: PrivateEndpoint; + /** A collection of information about the state of the connection between service consumer and provider. */ + privateLinkServiceConnectionState: PrivateLinkServiceConnectionState; + /** The provisioning state of the private endpoint connection resource. */ + readonly provisioningState?: ProvisioningState; +} + +export function privateEndpointConnectionPropertiesDeserializer( + item: any, +): PrivateEndpointConnectionProperties { + return { + groupIds: !item["groupIds"] + ? item["groupIds"] + : item["groupIds"].map((p: any) => { + return p; + }), + privateEndpoint: !item["privateEndpoint"] + ? item["privateEndpoint"] + : privateEndpointDeserializer(item["privateEndpoint"]), + privateLinkServiceConnectionState: + privateLinkServiceConnectionStateDeserializer( + item["privateLinkServiceConnectionState"], + ), + provisioningState: item["provisioningState"], + }; +} + +/** The private endpoint resource. */ +export interface PrivateEndpoint { + /** The ARM identifier for private endpoint. */ + readonly id?: string; +} + +export function privateEndpointDeserializer(item: any): PrivateEndpoint { + return { + id: item["id"], + }; +} + +/** A collection of information about the state of the connection between service consumer and provider. */ +export interface PrivateLinkServiceConnectionState { + /** Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. */ + status?: PrivateEndpointServiceConnectionStatus; + /** The reason for approval/rejection of the connection. */ + description?: string; + /** A message indicating if changes on the service provider require any updates on the consumer. */ + actionsRequired?: string; +} + +export function privateLinkServiceConnectionStateDeserializer( + item: any, +): PrivateLinkServiceConnectionState { + return { + status: item["status"], + description: item["description"], + actionsRequired: item["actionsRequired"], + }; +} + +/** The private endpoint connection status. */ +export enum KnownPrivateEndpointServiceConnectionStatus { + /** Pending status. */ + Pending = "Pending", + /** Approved status. */ + Approved = "Approved", + /** Rejected status. */ + Rejected = "Rejected", +} + +/** + * The private endpoint connection status. \ + * {@link KnownPrivateEndpointServiceConnectionStatus} can be used interchangeably with PrivateEndpointServiceConnectionStatus, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Pending**: Pending status. \ + * **Approved**: Approved status. \ + * **Rejected**: Rejected status. + */ +export type PrivateEndpointServiceConnectionStatus = string; + +/** Current provisioning state for a given Azure Chaos resource. */ +export enum KnownProvisioningState { + /** Resource has been created. */ + Succeeded = "Succeeded", + /** Resource creation failed. */ + Failed = "Failed", + /** Resource creation was canceled. */ + Canceled = "Canceled", + /** Initial creation in progress. */ + Creating = "Creating", + /** Update in progress. */ + Updating = "Updating", + /** Deletion in progress. */ + Deleting = "Deleting", +} + +/** + * Current provisioning state for a given Azure Chaos resource. \ + * {@link KnownProvisioningState} can be used interchangeably with ProvisioningState, + * 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. \ + * **Creating**: Initial creation in progress. \ + * **Updating**: Update in progress. \ + * **Deleting**: Deletion in progress. + */ +export type ProvisioningState = string; + +/** A list of private link resources */ +export interface _PrivateEndpointConnectionListResult { + /** The PrivateEndpointConnection items on this page */ + value: PrivateEndpointConnection[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _privateEndpointConnectionListResultDeserializer( + item: any, +): _PrivateEndpointConnectionListResult { + return { + value: privateEndpointConnectionArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function privateEndpointConnectionArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return privateEndpointConnectionDeserializer(item); + }); +} + +/** PrivateAccesses tracked resource. */ +export interface PrivateAccess extends TrackedResource { + /** The resource-specific properties for this resource. */ + properties: PrivateAccessProperties; +} + +export function privateAccessSerializer(item: PrivateAccess): any { + return { + tags: item["tags"], + location: item["location"], + properties: privateAccessPropertiesSerializer(item["properties"]), + }; +} + +export function privateAccessDeserializer(item: any): PrivateAccess { + return { + tags: item["tags"], + location: item["location"], + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: privateAccessPropertiesDeserializer(item["properties"]), + }; +} + +/** The properties of a private access resource */ +export interface PrivateAccessProperties { + /** Most recent provisioning state for the given privateAccess resource. */ + readonly provisioningState?: ProvisioningState; + /** A readonly collection of private endpoint connection. Currently only one endpoint connection is supported. */ + readonly privateEndpointConnections?: PrivateEndpointConnection[]; + /** Public Network Access Control for PrivateAccess resource. */ + publicNetworkAccess?: PublicNetworkAccessOption; +} + +export function privateAccessPropertiesSerializer( + item: PrivateAccessProperties, +): any { + return { publicNetworkAccess: item["publicNetworkAccess"] }; +} + +export function privateAccessPropertiesDeserializer( + item: any, +): PrivateAccessProperties { + return { + provisioningState: item["provisioningState"], + privateEndpointConnections: !item["privateEndpointConnections"] + ? item["privateEndpointConnections"] + : privateEndpointConnectionArrayDeserializer( + item["privateEndpointConnections"], + ), + publicNetworkAccess: item["publicNetworkAccess"], + }; +} + +/** Public Network Access Control for PrivateAccess resource. */ +export enum KnownPublicNetworkAccessOption { + /** Enabled access. */ + Enabled = "Enabled", + /** Disabled access. */ + Disabled = "Disabled", +} + +/** + * Public Network Access Control for PrivateAccess resource. \ + * {@link KnownPublicNetworkAccessOption} can be used interchangeably with PublicNetworkAccessOption, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Enabled**: Enabled access. \ + * **Disabled**: Disabled access. + */ +export type PublicNetworkAccessOption = string; + +/** The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' */ +export interface TrackedResource extends Resource { + /** Resource tags. */ + tags?: Record; + /** The geo-location where the resource lives */ + location: string; +} + +export function trackedResourceSerializer(item: TrackedResource): any { + return { tags: item["tags"], location: item["location"] }; +} + +export function trackedResourceDeserializer(item: any): TrackedResource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + tags: item["tags"], + location: item["location"], + }; +} + +/** Describes a private access update. */ +export interface PrivateAccessPatch { + /** Resource tags. */ + tags?: Record; +} + +export function privateAccessPatchSerializer(item: PrivateAccessPatch): any { + return { tags: item["tags"] }; +} + +/** Model that represents a list of private access resources and a link for pagination. */ +export interface _PrivateAccessListResult { + /** The PrivateAccess items on this page */ + value: PrivateAccess[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _privateAccessListResultDeserializer( + item: any, +): _PrivateAccessListResult { + return { + value: privateAccessArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function privateAccessArraySerializer( + result: Array, +): any[] { + return result.map((item) => { + return privateAccessSerializer(item); + }); +} + +export function privateAccessArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return privateAccessDeserializer(item); + }); +} + +/** A list of private link resources */ +export interface _PrivateLinkResourceListResult { + /** The PrivateLinkResource items on this page */ + value: PrivateLinkResource[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _privateLinkResourceListResultDeserializer( + item: any, +): _PrivateLinkResourceListResult { + return { + value: privateLinkResourceArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function privateLinkResourceArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return privateLinkResourceDeserializer(item); + }); +} + +/** A private link resource. */ +export interface PrivateLinkResource extends TrackedResource { + /** The resource-specific properties for this resource. */ + properties: PrivateLinkResourceProperties; +} + +export function privateLinkResourceDeserializer( + item: any, +): PrivateLinkResource { + return { + tags: item["tags"], + location: item["location"], + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: privateLinkResourcePropertiesDeserializer(item["properties"]), + }; +} + +/** Properties of a private link resource. */ +export interface PrivateLinkResourceProperties { + /** The private link resource group id. */ + readonly groupId?: string; + /** The private link resource required member names. */ + readonly requiredMembers?: string[]; + /** The private link resource private link DNS zone name. */ + requiredZoneNames?: string[]; + /** Resource provisioning state. Not currently in use. */ + readonly provisioningState?: ProvisioningState; +} + +export function privateLinkResourcePropertiesDeserializer( + item: any, +): PrivateLinkResourceProperties { + return { + groupId: item["groupId"], + requiredMembers: !item["requiredMembers"] + ? item["requiredMembers"] + : item["requiredMembers"].map((p: any) => { + return p; + }), + requiredZoneNames: !item["requiredZoneNames"] + ? item["requiredZoneNames"] + : item["requiredZoneNames"].map((p: any) => { + return p; + }), + provisioningState: item["provisioningState"], + }; +} + +/** Model that represents the execution of a Experiment. */ +export interface ExperimentExecution extends ProxyResource { + /** The properties of experiment execution status. */ + properties?: ExperimentExecutionProperties; +} + +export function experimentExecutionDeserializer( + item: any, +): ExperimentExecution { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : experimentExecutionPropertiesDeserializer(item["properties"]), + }; +} + +/** Model that represents the execution properties of an Experiment. */ +export interface ExperimentExecutionProperties { + /** The status of the execution. */ + readonly status?: string; + /** String that represents the start date time. */ + readonly startedAt?: Date; + /** String that represents the stop date time. */ + readonly stoppedAt?: Date; + /** Resource provisioning state. Not currently in use for executions. */ + readonly provisioningState?: ProvisioningState; +} + +export function experimentExecutionPropertiesDeserializer( + item: any, +): ExperimentExecutionProperties { + return { + status: item["status"], + startedAt: !item["startedAt"] + ? item["startedAt"] + : new Date(item["startedAt"]), + stoppedAt: !item["stoppedAt"] + ? item["stoppedAt"] + : new Date(item["stoppedAt"]), + provisioningState: item["provisioningState"], + }; +} + +/** Model that represents a list of Experiment executions and a link for pagination. */ +export interface _ExperimentExecutionListResult { + /** The ExperimentExecution items on this page */ + value: ExperimentExecution[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _experimentExecutionListResultDeserializer( + item: any, +): _ExperimentExecutionListResult { + return { + value: experimentExecutionArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function experimentExecutionArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return experimentExecutionDeserializer(item); + }); +} + +/** Model that represents the execution details of an Experiment. */ +export interface ExperimentExecutionDetails { + /** String of the resource type. */ + readonly type?: string; + /** String of the fully qualified resource ID. */ + readonly id?: string; + /** String of the resource name. */ + readonly name?: string; + /** The properties of the experiment execution details. */ + readonly properties?: ExperimentExecutionDetailsProperties; +} + +export function experimentExecutionDetailsDeserializer( + item: any, +): ExperimentExecutionDetails { + return { + type: item["type"], + id: item["id"], + name: item["name"], + properties: !item["properties"] + ? item["properties"] + : experimentExecutionDetailsPropertiesDeserializer(item["properties"]), + }; +} + +/** Model that represents the extended properties of an experiment execution. */ +export interface ExperimentExecutionDetailsProperties { + /** The status of the execution. */ + readonly status?: string; + /** String that represents the start date time. */ + readonly startedAt?: Date; + /** String that represents the stop date time. */ + readonly stoppedAt?: Date; + /** Resource provisioning state. Not currently in use for executions. */ + readonly provisioningState?: ProvisioningState; + /** The reason why the execution failed. */ + readonly failureReason?: string; + /** String that represents the last action date time. */ + readonly lastActionAt?: Date; + /** The information of the experiment run. */ + readonly runInformation?: ExperimentExecutionDetailsPropertiesRunInformation; +} + +export function experimentExecutionDetailsPropertiesDeserializer( + item: any, +): ExperimentExecutionDetailsProperties { + return { + status: item["status"], + startedAt: !item["startedAt"] + ? item["startedAt"] + : new Date(item["startedAt"]), + stoppedAt: !item["stoppedAt"] + ? item["stoppedAt"] + : new Date(item["stoppedAt"]), + provisioningState: item["provisioningState"], + failureReason: item["failureReason"], + lastActionAt: !item["lastActionAt"] + ? item["lastActionAt"] + : new Date(item["lastActionAt"]), + runInformation: !item["runInformation"] + ? item["runInformation"] + : experimentExecutionDetailsPropertiesRunInformationDeserializer( + item["runInformation"], + ), + }; +} + +/** The information of the experiment run. */ +export interface ExperimentExecutionDetailsPropertiesRunInformation { + /** The steps of the experiment run. */ + readonly steps?: StepStatus[]; +} + +export function experimentExecutionDetailsPropertiesRunInformationDeserializer( + item: any, +): ExperimentExecutionDetailsPropertiesRunInformation { + return { + steps: !item["steps"] + ? item["steps"] + : stepStatusArrayDeserializer(item["steps"]), + }; +} + +export function stepStatusArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return stepStatusDeserializer(item); + }); +} + +/** Model that represents the a list of branches and branch statuses. */ +export interface StepStatus { + /** The name of the step. */ + readonly stepName?: string; + /** The id of the step. */ + readonly stepId?: string; + /** The value of the status of the step. */ + readonly status?: string; + /** The array of branches. */ + readonly branches?: BranchStatus[]; +} + +export function stepStatusDeserializer(item: any): StepStatus { + return { + stepName: item["stepName"], + stepId: item["stepId"], + status: item["status"], + branches: !item["branches"] + ? item["branches"] + : branchStatusArrayDeserializer(item["branches"]), + }; +} + +export function branchStatusArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return branchStatusDeserializer(item); + }); +} + +/** Model that represents the a list of actions and action statuses. */ +export interface BranchStatus { + /** The name of the branch status. */ + readonly branchName?: string; + /** The id of the branch status. */ + readonly branchId?: string; + /** The status of the branch. */ + readonly status?: string; + /** The array of actions. */ + readonly actions?: ActionStatus[]; +} + +export function branchStatusDeserializer(item: any): BranchStatus { + return { + branchName: item["branchName"], + branchId: item["branchId"], + status: item["status"], + actions: !item["actions"] + ? item["actions"] + : actionStatusArrayDeserializer(item["actions"]), + }; +} + +export function actionStatusArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return actionStatusDeserializer(item); + }); +} + +/** Model that represents the an action and its status. */ +export interface ActionStatus { + /** The name of the action status. */ + readonly actionName?: string; + /** The id of the action status. */ + readonly actionId?: string; + /** The status of the action. */ + readonly status?: string; + /** String that represents the start time of the action. */ + readonly startTime?: Date; + /** String that represents the end time of the action. */ + readonly endTime?: Date; + /** The array of targets. */ + readonly targets?: ExperimentExecutionActionTargetDetailsProperties[]; +} + +export function actionStatusDeserializer(item: any): ActionStatus { + return { + actionName: item["actionName"], + actionId: item["actionId"], + status: item["status"], + startTime: !item["startTime"] + ? item["startTime"] + : new Date(item["startTime"]), + endTime: !item["endTime"] ? item["endTime"] : new Date(item["endTime"]), + targets: !item["targets"] + ? item["targets"] + : experimentExecutionActionTargetDetailsPropertiesArrayDeserializer( + item["targets"], + ), + }; +} + +export function experimentExecutionActionTargetDetailsPropertiesArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return experimentExecutionActionTargetDetailsPropertiesDeserializer(item); + }); +} + +/** Model that represents the Experiment action target details properties model. */ +export interface ExperimentExecutionActionTargetDetailsProperties { + /** The status of the execution. */ + readonly status?: string; + /** The target for the action. */ + readonly target?: string; + /** String that represents the failed date time. */ + readonly targetFailedTime?: Date; + /** String that represents the completed date time. */ + readonly targetCompletedTime?: Date; + /** The error of the action. */ + readonly error?: ExperimentExecutionActionTargetDetailsError; +} + +export function experimentExecutionActionTargetDetailsPropertiesDeserializer( + item: any, +): ExperimentExecutionActionTargetDetailsProperties { + return { + status: item["status"], + target: item["target"], + targetFailedTime: !item["targetFailedTime"] + ? item["targetFailedTime"] + : new Date(item["targetFailedTime"]), + targetCompletedTime: !item["targetCompletedTime"] + ? item["targetCompletedTime"] + : new Date(item["targetCompletedTime"]), + error: !item["error"] + ? item["error"] + : experimentExecutionActionTargetDetailsErrorDeserializer(item["error"]), + }; +} + +/** Model that represents the Experiment action target details error model. */ +export interface ExperimentExecutionActionTargetDetailsError { + /** The error code. */ + readonly code?: string; + /** The error message */ + readonly message?: string; +} + +export function experimentExecutionActionTargetDetailsErrorDeserializer( + item: any, +): ExperimentExecutionActionTargetDetailsError { + return { + code: item["code"], + message: item["message"], + }; +} + +/** Model that represents a Experiment resource. */ +export interface Experiment extends TrackedResource { + /** The managed service identities assigned to this resource. */ + identity?: ManagedServiceIdentity; + /** The properties of the experiment resource. */ + properties: ExperimentProperties; +} + +export function experimentSerializer(item: Experiment): any { + return { + tags: item["tags"], + location: item["location"], + identity: !item["identity"] + ? item["identity"] + : managedServiceIdentitySerializer(item["identity"]), + properties: experimentPropertiesSerializer(item["properties"]), + }; +} + +export function experimentDeserializer(item: any): Experiment { + return { + tags: item["tags"], + location: item["location"], + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + identity: !item["identity"] + ? item["identity"] + : managedServiceIdentityDeserializer(item["identity"]), + properties: experimentPropertiesDeserializer(item["properties"]), + }; +} + +/** Managed service identity (system assigned and/or user assigned identities) */ +export interface ManagedServiceIdentity { + /** The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. */ + readonly principalId?: string; + /** The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. */ + readonly tenantId?: string; + /** The type of managed identity assigned to this resource. */ + type: ManagedServiceIdentityType; + /** The identities assigned to this resource by the user. */ + userAssignedIdentities?: Record; +} + +export function managedServiceIdentitySerializer( + item: ManagedServiceIdentity, +): any { + return { + type: item["type"], + userAssignedIdentities: item["userAssignedIdentities"], + }; +} + +export function managedServiceIdentityDeserializer( + item: any, +): ManagedServiceIdentity { + return { + principalId: item["principalId"], + tenantId: item["tenantId"], + type: item["type"], + userAssignedIdentities: item["userAssignedIdentities"], + }; +} + +/** Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). */ +export enum KnownManagedServiceIdentityType { + /** No managed identity. */ + None = "None", + /** System assigned managed identity. */ + SystemAssigned = "SystemAssigned", + /** User assigned managed identity. */ + UserAssigned = "UserAssigned", + /** System and user assigned managed identity. */ + "SystemAssigned,UserAssigned" = "SystemAssigned,UserAssigned", +} + +/** + * Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). \ + * {@link KnownManagedServiceIdentityType} can be used interchangeably with ManagedServiceIdentityType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **None**: No managed identity. \ + * **SystemAssigned**: System assigned managed identity. \ + * **UserAssigned**: User assigned managed identity. \ + * **SystemAssigned,UserAssigned**: System and user assigned managed identity. + */ +export type ManagedServiceIdentityType = string; + +/** User assigned identity properties */ +export interface UserAssignedIdentity { + /** The principal ID of the assigned identity. */ + readonly principalId?: string; + /** The client ID of the assigned identity. */ + readonly clientId?: string; +} + +export function userAssignedIdentitySerializer( + item: UserAssignedIdentity, +): any { + return item; +} + +export function userAssignedIdentityDeserializer( + item: any, +): UserAssignedIdentity { + return { + principalId: item["principalId"], + clientId: item["clientId"], + }; +} + +/** Model that represents the Experiment properties model. */ +export interface ExperimentProperties { + /** Most recent provisioning state for the given experiment resource. */ + readonly provisioningState?: ProvisioningState; + /** List of steps. */ + steps: ChaosExperimentStep[]; + /** List of selectors. */ + selectors: ChaosTargetSelectorUnion[]; + /** Optional customer-managed Storage account where Experiment schema will be stored. */ + customerDataStorage?: CustomerDataStorageProperties; +} + +export function experimentPropertiesSerializer( + item: ExperimentProperties, +): any { + return { + steps: chaosExperimentStepArraySerializer(item["steps"]), + selectors: chaosTargetSelectorUnionArraySerializer(item["selectors"]), + customerDataStorage: !item["customerDataStorage"] + ? item["customerDataStorage"] + : customerDataStoragePropertiesSerializer(item["customerDataStorage"]), + }; +} + +export function experimentPropertiesDeserializer( + item: any, +): ExperimentProperties { + return { + provisioningState: item["provisioningState"], + steps: chaosExperimentStepArrayDeserializer(item["steps"]), + selectors: chaosTargetSelectorUnionArrayDeserializer(item["selectors"]), + customerDataStorage: !item["customerDataStorage"] + ? item["customerDataStorage"] + : customerDataStoragePropertiesDeserializer(item["customerDataStorage"]), + }; +} + +export function chaosExperimentStepArraySerializer( + result: Array, +): any[] { + return result.map((item) => { + return chaosExperimentStepSerializer(item); + }); +} + +export function chaosExperimentStepArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return chaosExperimentStepDeserializer(item); + }); +} + +/** Model that represents a step in the Experiment resource. */ +export interface ChaosExperimentStep { + /** String of the step name. */ + name: string; + /** List of branches. */ + branches: ChaosExperimentBranch[]; +} + +export function chaosExperimentStepSerializer(item: ChaosExperimentStep): any { + return { + name: item["name"], + branches: chaosExperimentBranchArraySerializer(item["branches"]), + }; +} + +export function chaosExperimentStepDeserializer( + item: any, +): ChaosExperimentStep { + return { + name: item["name"], + branches: chaosExperimentBranchArrayDeserializer(item["branches"]), + }; +} + +export function chaosExperimentBranchArraySerializer( + result: Array, +): any[] { + return result.map((item) => { + return chaosExperimentBranchSerializer(item); + }); +} + +export function chaosExperimentBranchArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return chaosExperimentBranchDeserializer(item); + }); +} + +/** Model that represents a branch in the step. 9 total per experiment. */ +export interface ChaosExperimentBranch { + /** String of the branch name. */ + name: string; + /** List of actions. */ + actions: ChaosExperimentActionUnion[]; +} + +export function chaosExperimentBranchSerializer( + item: ChaosExperimentBranch, +): any { + return { + name: item["name"], + actions: chaosExperimentActionUnionArraySerializer(item["actions"]), + }; +} + +export function chaosExperimentBranchDeserializer( + item: any, +): ChaosExperimentBranch { + return { + name: item["name"], + actions: chaosExperimentActionUnionArrayDeserializer(item["actions"]), + }; +} + +export function chaosExperimentActionUnionArraySerializer( + result: Array, +): any[] { + return result.map((item) => { + return chaosExperimentActionUnionSerializer(item); + }); +} + +export function chaosExperimentActionUnionArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return chaosExperimentActionUnionDeserializer(item); + }); +} + +/** Model that represents the base action model. 9 total per experiment. */ +export interface ChaosExperimentAction { + /** String that represents a Capability URN. */ + name: string; + /** Chaos experiment action discriminator type */ + /** The discriminator possible values: continuous, delay, discrete */ + type: ExperimentActionType; +} + +export function chaosExperimentActionSerializer( + item: ChaosExperimentAction, +): any { + return { name: item["name"], type: item["type"] }; +} + +export function chaosExperimentActionDeserializer( + item: any, +): ChaosExperimentAction { + return { + name: item["name"], + type: item["type"], + }; +} + +/** Alias for ChaosExperimentActionUnion */ +export type ChaosExperimentActionUnion = + | ContinuousAction + | DelayAction + | DiscreteAction + | ChaosExperimentAction; + +export function chaosExperimentActionUnionSerializer( + item: ChaosExperimentActionUnion, +): any { + switch (item.type) { + case "continuous": + return continuousActionSerializer(item as ContinuousAction); + + case "delay": + return delayActionSerializer(item as DelayAction); + + case "discrete": + return discreteActionSerializer(item as DiscreteAction); + + default: + return chaosExperimentActionSerializer(item); + } +} + +export function chaosExperimentActionUnionDeserializer( + item: any, +): ChaosExperimentActionUnion { + switch (item.type) { + case "continuous": + return continuousActionDeserializer(item as ContinuousAction); + + case "delay": + return delayActionDeserializer(item as DelayAction); + + case "discrete": + return discreteActionDeserializer(item as DiscreteAction); + + default: + return chaosExperimentActionDeserializer(item); + } +} + +/** Enum union of Chaos experiment action types. */ +export enum KnownExperimentActionType { + delay = "delay", + discrete = "discrete", + continuous = "continuous", +} + +/** + * Enum union of Chaos experiment action types. \ + * {@link KnownExperimentActionType} can be used interchangeably with ExperimentActionType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **delay** \ + * **discrete** \ + * **continuous** + */ +export type ExperimentActionType = string; + +/** Model that represents a continuous action. */ +export interface ContinuousAction extends ChaosExperimentAction { + /** ISO8601 formatted string that represents a duration. */ + duration: string; + /** List of key value pairs. */ + parameters: KeyValuePair[]; + /** String that represents a selector. */ + selectorId: string; + /** Enum that discriminates between action models. */ + type: "continuous"; +} + +export function continuousActionSerializer(item: ContinuousAction): any { + return { + name: item["name"], + type: item["type"], + duration: item["duration"], + parameters: keyValuePairArraySerializer(item["parameters"]), + selectorId: item["selectorId"], + }; +} + +export function continuousActionDeserializer(item: any): ContinuousAction { + return { + name: item["name"], + type: item["type"], + duration: item["duration"], + parameters: keyValuePairArrayDeserializer(item["parameters"]), + selectorId: item["selectorId"], + }; +} + +export function keyValuePairArraySerializer( + result: Array, +): any[] { + return result.map((item) => { + return keyValuePairSerializer(item); + }); +} + +export function keyValuePairArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return keyValuePairDeserializer(item); + }); +} + +/** A map to describe the settings of an action. */ +export interface KeyValuePair { + /** The name of the setting for the action. */ + key: string; + /** The value of the setting for the action. */ + value: string; +} + +export function keyValuePairSerializer(item: KeyValuePair): any { + return { key: item["key"], value: item["value"] }; +} + +export function keyValuePairDeserializer(item: any): KeyValuePair { + return { + key: item["key"], + value: item["value"], + }; +} + +/** Model that represents a delay action. */ +export interface DelayAction extends ChaosExperimentAction { + /** ISO8601 formatted string that represents a duration. */ + duration: string; + /** Enum that discriminates between action models. */ + type: "delay"; +} + +export function delayActionSerializer(item: DelayAction): any { + return { name: item["name"], type: item["type"], duration: item["duration"] }; +} + +export function delayActionDeserializer(item: any): DelayAction { + return { + name: item["name"], + type: item["type"], + duration: item["duration"], + }; +} + +/** Model that represents a discrete action. */ +export interface DiscreteAction extends ChaosExperimentAction { + /** List of key value pairs. */ + parameters: KeyValuePair[]; + /** String that represents a selector. */ + selectorId: string; + /** Enum that discriminates between action models. */ + type: "discrete"; +} + +export function discreteActionSerializer(item: DiscreteAction): any { + return { + name: item["name"], + type: item["type"], + parameters: keyValuePairArraySerializer(item["parameters"]), + selectorId: item["selectorId"], + }; +} + +export function discreteActionDeserializer(item: any): DiscreteAction { + return { + name: item["name"], + type: item["type"], + parameters: keyValuePairArrayDeserializer(item["parameters"]), + selectorId: item["selectorId"], + }; +} + +export function chaosTargetSelectorUnionArraySerializer( + result: Array, +): any[] { + return result.map((item) => { + return chaosTargetSelectorUnionSerializer(item); + }); +} + +export function chaosTargetSelectorUnionArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return chaosTargetSelectorUnionDeserializer(item); + }); +} + +/** Model that represents a selector in the Experiment resource. */ +export interface ChaosTargetSelector { + /** String of the selector ID. */ + id: string; + /** Chaos target selector discriminator type */ + /** The discriminator possible values: List, Query */ + type: SelectorType; + /** Model that represents available filter types that can be applied to a targets list. */ + filter?: ChaosTargetFilterUnion; +} + +export function chaosTargetSelectorSerializer(item: ChaosTargetSelector): any { + return { + id: item["id"], + type: item["type"], + filter: !item["filter"] + ? item["filter"] + : chaosTargetFilterUnionSerializer(item["filter"]), + }; +} + +export function chaosTargetSelectorDeserializer( + item: any, +): ChaosTargetSelector { + return { + id: item["id"], + type: item["type"], + filter: !item["filter"] + ? item["filter"] + : chaosTargetFilterUnionDeserializer(item["filter"]), + }; +} + +/** Alias for ChaosTargetSelectorUnion */ +export type ChaosTargetSelectorUnion = + | ChaosTargetListSelector + | ChaosTargetQuerySelector + | ChaosTargetSelector; + +export function chaosTargetSelectorUnionSerializer( + item: ChaosTargetSelectorUnion, +): any { + switch (item.type) { + case "List": + return chaosTargetListSelectorSerializer(item as ChaosTargetListSelector); + + case "Query": + return chaosTargetQuerySelectorSerializer( + item as ChaosTargetQuerySelector, + ); + + default: + return chaosTargetSelectorSerializer(item); + } +} + +export function chaosTargetSelectorUnionDeserializer( + item: any, +): ChaosTargetSelectorUnion { + switch (item.type) { + case "List": + return chaosTargetListSelectorDeserializer( + item as ChaosTargetListSelector, + ); + + case "Query": + return chaosTargetQuerySelectorDeserializer( + item as ChaosTargetQuerySelector, + ); + + default: + return chaosTargetSelectorDeserializer(item); + } +} + +/** Enum of the selector type. */ +export enum KnownSelectorType { + /** List selector type. */ + List = "List", + /** Query selector type. */ + Query = "Query", +} + +/** + * Enum of the selector type. \ + * {@link KnownSelectorType} can be used interchangeably with SelectorType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **List**: List selector type. \ + * **Query**: Query selector type. + */ +export type SelectorType = string; + +/** Model that represents available filter types that can be applied to a targets list. */ +export interface ChaosTargetFilter { + /** Chaos target filter discriminator type */ + /** The discriminator possible values: Simple */ + type: FilterType; +} + +export function chaosTargetFilterSerializer(item: ChaosTargetFilter): any { + return { type: item["type"] }; +} + +export function chaosTargetFilterDeserializer(item: any): ChaosTargetFilter { + return { + type: item["type"], + }; +} + +/** Alias for ChaosTargetFilterUnion */ +export type ChaosTargetFilterUnion = + | ChaosTargetSimpleFilter + | ChaosTargetFilter; + +export function chaosTargetFilterUnionSerializer( + item: ChaosTargetFilterUnion, +): any { + switch (item.type) { + case "Simple": + return chaosTargetSimpleFilterSerializer(item as ChaosTargetSimpleFilter); + + default: + return chaosTargetFilterSerializer(item); + } +} + +export function chaosTargetFilterUnionDeserializer( + item: any, +): ChaosTargetFilterUnion { + switch (item.type) { + case "Simple": + return chaosTargetSimpleFilterDeserializer( + item as ChaosTargetSimpleFilter, + ); + + default: + return chaosTargetFilterDeserializer(item); + } +} + +/** Enum that discriminates between filter types. Currently only `Simple` type is supported. */ +export enum KnownFilterType { + /** Simple filter type. */ + Simple = "Simple", +} + +/** + * Enum that discriminates between filter types. Currently only `Simple` type is supported. \ + * {@link KnownFilterType} can be used interchangeably with FilterType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Simple**: Simple filter type. + */ +export type FilterType = string; + +/** Model that represents a simple target filter. */ +export interface ChaosTargetSimpleFilter extends ChaosTargetFilter { + /** Model that represents the Simple filter parameters. */ + parameters?: ChaosTargetSimpleFilterParameters; + /** Enum that discriminates between filter types. Currently only `Simple` type is supported. */ + type: "Simple"; +} + +export function chaosTargetSimpleFilterSerializer( + item: ChaosTargetSimpleFilter, +): any { + return { + type: item["type"], + parameters: !item["parameters"] + ? item["parameters"] + : chaosTargetSimpleFilterParametersSerializer(item["parameters"]), + }; +} + +export function chaosTargetSimpleFilterDeserializer( + item: any, +): ChaosTargetSimpleFilter { + return { + type: item["type"], + parameters: !item["parameters"] + ? item["parameters"] + : chaosTargetSimpleFilterParametersDeserializer(item["parameters"]), + }; +} + +/** Model that represents the Simple filter parameters. */ +export interface ChaosTargetSimpleFilterParameters { + /** List of Azure availability zones to filter targets by. */ + zones?: string[]; +} + +export function chaosTargetSimpleFilterParametersSerializer( + item: ChaosTargetSimpleFilterParameters, +): any { + return { + zones: !item["zones"] + ? item["zones"] + : item["zones"].map((p: any) => { + return p; + }), + }; +} + +export function chaosTargetSimpleFilterParametersDeserializer( + item: any, +): ChaosTargetSimpleFilterParameters { + return { + zones: !item["zones"] + ? item["zones"] + : item["zones"].map((p: any) => { + return p; + }), + }; +} + +/** Model that represents a list selector. */ +export interface ChaosTargetListSelector extends ChaosTargetSelector { + /** List of Target references. */ + targets: TargetReference[]; + /** Enum of the selector type. */ + type: "List"; +} + +export function chaosTargetListSelectorSerializer( + item: ChaosTargetListSelector, +): any { + return { + id: item["id"], + type: item["type"], + filter: !item["filter"] + ? item["filter"] + : chaosTargetFilterUnionSerializer(item["filter"]), + targets: targetReferenceArraySerializer(item["targets"]), + }; +} + +export function chaosTargetListSelectorDeserializer( + item: any, +): ChaosTargetListSelector { + return { + id: item["id"], + type: item["type"], + filter: !item["filter"] + ? item["filter"] + : chaosTargetFilterUnionDeserializer(item["filter"]), + targets: targetReferenceArrayDeserializer(item["targets"]), + }; +} + +export function targetReferenceArraySerializer( + result: Array, +): any[] { + return result.map((item) => { + return targetReferenceSerializer(item); + }); +} + +export function targetReferenceArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return targetReferenceDeserializer(item); + }); +} + +/** Model that represents a reference to a Target in the selector. */ +export interface TargetReference { + /** Enum of the Target reference type. */ + type: TargetReferenceType; + /** String of the resource ID of a Target resource. */ + id: string; +} + +export function targetReferenceSerializer(item: TargetReference): any { + return { type: item["type"], id: item["id"] }; +} + +export function targetReferenceDeserializer(item: any): TargetReference { + return { + type: item["type"], + id: item["id"], + }; +} + +/** Enum of the Target reference type. */ +export enum KnownTargetReferenceType { + /** Chaos target reference type. */ + ChaosTarget = "ChaosTarget", +} + +/** + * Enum of the Target reference type. \ + * {@link KnownTargetReferenceType} can be used interchangeably with TargetReferenceType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **ChaosTarget**: Chaos target reference type. + */ +export type TargetReferenceType = string; + +/** Model that represents a query selector. */ +export interface ChaosTargetQuerySelector extends ChaosTargetSelector { + /** Azure Resource Graph (ARG) Query Language query for target resources. */ + queryString: string; + /** Subscription id list to scope resource query. */ + subscriptionIds: string[]; + /** Enum of the selector type. */ + type: "Query"; +} + +export function chaosTargetQuerySelectorSerializer( + item: ChaosTargetQuerySelector, +): any { + return { + id: item["id"], + type: item["type"], + filter: !item["filter"] + ? item["filter"] + : chaosTargetFilterUnionSerializer(item["filter"]), + queryString: item["queryString"], + subscriptionIds: item["subscriptionIds"].map((p: any) => { + return p; + }), + }; +} + +export function chaosTargetQuerySelectorDeserializer( + item: any, +): ChaosTargetQuerySelector { + return { + id: item["id"], + type: item["type"], + filter: !item["filter"] + ? item["filter"] + : chaosTargetFilterUnionDeserializer(item["filter"]), + queryString: item["queryString"], + subscriptionIds: item["subscriptionIds"].map((p: any) => { + return p; + }), + }; +} + +/** Model that represents the Customer Managed Storage for an Experiment. */ +export interface CustomerDataStorageProperties { + /** ARM Resource ID of the Storage account to use for Customer Data storage. */ + storageAccountResourceId?: string; + /** Name of the Azure Blob Storage container to use or create. */ + blobContainerName?: string; +} + +export function customerDataStoragePropertiesSerializer( + item: CustomerDataStorageProperties, +): any { + return { + storageAccountResourceId: item["storageAccountResourceId"], + blobContainerName: item["blobContainerName"], + }; +} + +export function customerDataStoragePropertiesDeserializer( + item: any, +): CustomerDataStorageProperties { + return { + storageAccountResourceId: item["storageAccountResourceId"], + blobContainerName: item["blobContainerName"], + }; +} + +/** Describes an experiment update. */ +export interface ExperimentUpdate { + /** Resource tags. */ + tags?: Record; + /** The managed service identities assigned to this resource. */ + identity?: ManagedServiceIdentity; +} + +export function experimentUpdateSerializer(item: ExperimentUpdate): any { + return { + tags: item["tags"], + identity: !item["identity"] + ? item["identity"] + : managedServiceIdentitySerializer(item["identity"]), + }; +} + +/** Model that represents a list of Experiment resources and a link for pagination. */ +export interface _ExperimentListResult { + /** The Experiment items on this page */ + value: Experiment[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _experimentListResultDeserializer( + item: any, +): _ExperimentListResult { + return { + value: experimentArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function experimentArraySerializer(result: Array): any[] { + return result.map((item) => { + return experimentSerializer(item); + }); +} + +export function experimentArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return experimentDeserializer(item); + }); +} + +/** Model that represents a Capability Type resource. */ +export interface CapabilityType extends ProxyResource { + /** The properties of the capability type resource. */ + properties?: CapabilityTypeProperties; +} + +export function capabilityTypeDeserializer(item: any): CapabilityType { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : capabilityTypePropertiesDeserializer(item["properties"]), + }; +} + +/** Model that represents the Capability Type properties model. */ +export interface CapabilityTypeProperties { + /** String of the Publisher that this Capability Type extends. */ + readonly publisher?: string; + /** String of the Target Type that this Capability Type extends. */ + readonly targetType?: string; + /** Localized string of the display name. */ + readonly displayName?: string; + /** Localized string of the description. */ + readonly description?: string; + /** URL to retrieve JSON schema of the Capability Type parameters. */ + readonly parametersSchema?: string; + /** String of the URN for this Capability Type. */ + readonly urn?: string; + /** String of the kind of this Capability Type. */ + readonly kind?: string; + /** Control plane actions necessary to execute capability type. */ + readonly azureRbacActions?: string[]; + /** Data plane actions necessary to execute capability type. */ + readonly azureRbacDataActions?: string[]; + /** Runtime properties of this Capability Type. */ + readonly runtimeProperties?: CapabilityTypePropertiesRuntimeProperties; +} + +export function capabilityTypePropertiesDeserializer( + item: any, +): CapabilityTypeProperties { + return { + publisher: item["publisher"], + targetType: item["targetType"], + displayName: item["displayName"], + description: item["description"], + parametersSchema: item["parametersSchema"], + urn: item["urn"], + kind: item["kind"], + azureRbacActions: !item["azureRbacActions"] + ? item["azureRbacActions"] + : item["azureRbacActions"].map((p: any) => { + return p; + }), + azureRbacDataActions: !item["azureRbacDataActions"] + ? item["azureRbacDataActions"] + : item["azureRbacDataActions"].map((p: any) => { + return p; + }), + runtimeProperties: !item["runtimeProperties"] + ? item["runtimeProperties"] + : capabilityTypePropertiesRuntimePropertiesDeserializer( + item["runtimeProperties"], + ), + }; +} + +/** Runtime properties of this Capability Type. */ +export interface CapabilityTypePropertiesRuntimeProperties { + /** String of the kind of the resource's action type (continuous or discrete). */ + readonly kind?: string; +} + +export function capabilityTypePropertiesRuntimePropertiesDeserializer( + item: any, +): CapabilityTypePropertiesRuntimeProperties { + return { + kind: item["kind"], + }; +} + +/** Model that represents a list of Capability Type resources and a link for pagination. */ +export interface _CapabilityTypeListResult { + /** The CapabilityType items on this page */ + value: CapabilityType[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _capabilityTypeListResultDeserializer( + item: any, +): _CapabilityTypeListResult { + return { + value: capabilityTypeArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function capabilityTypeArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return capabilityTypeDeserializer(item); + }); +} + +/** Model that represents a Target resource. */ +export interface Target extends ProxyResource { + /** The properties of the target resource. */ + properties?: Record; + /** Azure resource location. */ + location?: string; +} + +export function targetSerializer(item: Target): any { + return { properties: item["properties"], location: item["location"] }; +} + +export function targetDeserializer(item: any): Target { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: item["properties"], + location: item["location"], + }; +} + +/** Model that represents a list of Target resources and a link for pagination. */ +export interface _TargetListResult { + /** The Target items on this page */ + value: Target[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _targetListResultDeserializer(item: any): _TargetListResult { + return { + value: targetArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function targetArraySerializer(result: Array): any[] { + return result.map((item) => { + return targetSerializer(item); + }); +} + +export function targetArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return targetDeserializer(item); + }); +} + +/** 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. */ + "user,system" = "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; + +/** Model that represents a Capability resource. */ +export interface Capability extends ProxyResource { + /** The properties of a capability resource. */ + properties?: CapabilityProperties; +} + +export function capabilitySerializer(item: Capability): any { + return { + properties: !item["properties"] + ? item["properties"] + : capabilityPropertiesSerializer(item["properties"]), + }; +} + +export function capabilityDeserializer(item: any): Capability { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : capabilityPropertiesDeserializer(item["properties"]), + }; +} + +/** Model that represents the Capability properties model. */ +export interface CapabilityProperties { + /** String of the Publisher that this Capability extends. */ + readonly publisher?: string; + /** String of the Target Type that this Capability extends. */ + readonly targetType?: string; + /** Localized string of the description. */ + readonly description?: string; + /** URL to retrieve JSON schema of the Capability parameters. */ + readonly parametersSchema?: string; + /** String of the URN for this Capability Type. */ + readonly urn?: string; + /** Resource provisioning state. Not currently in use because resource is created synchronously. */ + readonly provisioningState?: ProvisioningState; +} + +export function capabilityPropertiesSerializer( + item: CapabilityProperties, +): any { + return item; +} + +export function capabilityPropertiesDeserializer( + item: any, +): CapabilityProperties { + return { + publisher: item["publisher"], + targetType: item["targetType"], + description: item["description"], + parametersSchema: item["parametersSchema"], + urn: item["urn"], + provisioningState: item["provisioningState"], + }; +} + +/** Model that represents a list of Capability resources and a link for pagination. */ +export interface _CapabilityListResult { + /** The Capability items on this page */ + value: Capability[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _capabilityListResultDeserializer( + item: any, +): _CapabilityListResult { + return { + value: capabilityArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function capabilityArraySerializer(result: Array): any[] { + return result.map((item) => { + return capabilitySerializer(item); + }); +} + +export function capabilityArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return capabilityDeserializer(item); + }); +} + +/** The available API versions. */ +export enum KnownVersions { + /** The 2024-11-01-preview API version. */ + v2024_11_01_preview = "2024-11-01-preview", +} diff --git a/sdk/chaos/xxxx/src/restorePollerHelpers.ts b/sdk/chaos/xxxx/src/restorePollerHelpers.ts new file mode 100644 index 000000000000..35e9dddc9b2b --- /dev/null +++ b/sdk/chaos/xxxx/src/restorePollerHelpers.ts @@ -0,0 +1,219 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ChaosManagementClient } from "./chaosManagementClient.js"; +import { _privateEndpointConnectionsDeleteAPrivateEndpointConnectionDeserialize } from "./api/privateEndpointConnections/index.js"; +import { + _privateAccessesDeleteDeserialize, + _privateAccessesUpdateDeserialize, + _privateAccessesCreateOrUpdateDeserialize, +} from "./api/privateAccesses/index.js"; +import { + _experimentsStartDeserialize, + _experimentsCancelDeserialize, + _experimentsDeleteDeserialize, + _experimentsUpdateDeserialize, + _experimentsCreateOrUpdateDeserialize, +} from "./api/experiments/index.js"; +import { getLongRunningPoller } from "./static-helpers/pollingHelpers.js"; +import { + OperationOptions, + PathUncheckedResponse, +} from "@azure-rest/core-client"; +import { AbortSignalLike } from "@azure/abort-controller"; +import { + PollerLike, + OperationState, + deserializeState, + ResourceLocationConfig, +} 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: ChaosManagementClient, + 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: Function; + expectedStatuses: string[]; +} + +const deserializeMap: Record = { + "DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}": + { + deserializer: + _privateEndpointConnectionsDeleteAPrivateEndpointConnectionDeserialize, + expectedStatuses: ["202", "204", "200"], + }, + "DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}": + { + deserializer: _privateAccessesDeleteDeserialize, + expectedStatuses: ["202", "204", "200"], + }, + "PATCH /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}": + { + deserializer: _privateAccessesUpdateDeserialize, + expectedStatuses: ["200", "202"], + }, + "PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}": + { + deserializer: _privateAccessesCreateOrUpdateDeserialize, + expectedStatuses: ["200", "201"], + }, + "POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/start": + { + deserializer: _experimentsStartDeserialize, + expectedStatuses: ["202", "200"], + }, + "POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/cancel": + { + deserializer: _experimentsCancelDeserialize, + expectedStatuses: ["202", "200"], + }, + "DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}": + { + deserializer: _experimentsDeleteDeserialize, + expectedStatuses: ["202", "204", "200"], + }, + "PATCH /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}": + { + deserializer: _experimentsUpdateDeserialize, + expectedStatuses: ["200", "202"], + }, + "PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}": + { + deserializer: _experimentsCreateOrUpdateDeserialize, + expectedStatuses: ["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/chaos/xxxx/src/static-helpers/pagingHelpers.ts b/sdk/chaos/xxxx/src/static-helpers/pagingHelpers.ts new file mode 100644 index 000000000000..97a81e74e301 --- /dev/null +++ b/sdk/chaos/xxxx/src/static-helpers/pagingHelpers.ts @@ -0,0 +1,274 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + Client, + createRestError, + PathUncheckedResponse, +} 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< + TElement, + TPage, + TPageSettings + >; + /** + * Return an AsyncIterableIterator that works a page at a time + */ + byPage: ( + settings?: TPageSettings, + ) => AsyncIterableIterator>; +} + +/** + * An interface that describes how to communicate with the service. + */ +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; +} + +/** + * 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 pagedResult: PagedResult = { + getPage: async (pageLink?: string) => { + const result = + pageLink === undefined + ? await getInitialResponse() + : 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< + TElement, + TPage, + TPageSettings extends PageSettings, +>( + pagedResult: PagedResult, +): AsyncIterableIterator { + const pages = getPageAsyncIterator(pagedResult); + for await (const page of pages) { + yield* page as unknown as TElement[]; + } +} + +async function* getPageAsyncIterator< + TElement, + TPage, + TPageSettings extends PageSettings, +>( + 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/chaos/xxxx/src/static-helpers/pollingHelpers.ts b/sdk/chaos/xxxx/src/static-helpers/pollingHelpers.ts new file mode 100644 index 000000000000..2edbf783be53 --- /dev/null +++ b/sdk/chaos/xxxx/src/static-helpers/pollingHelpers.ts @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + PollerLike, + OperationState, + ResourceLocationConfig, + RunningOperation, + createHttpPoller, + OperationResponse, +} from "@azure/core-lro"; + +import { + Client, + PathUncheckedResponse, + createRestError, +} from "@azure-rest/core-client"; +import { 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< + TResponse extends PathUncheckedResponse, + TResult = void, +>( + 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/chaos/xxxx/test/public/sampleTest.spec.ts b/sdk/chaos/xxxx/test/public/sampleTest.spec.ts new file mode 100644 index 000000000000..d4919ac91ac5 --- /dev/null +++ b/sdk/chaos/xxxx/test/public/sampleTest.spec.ts @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { createRecorder } from "./utils/recordedClient.js"; +import { assert, beforeEach, afterEach, it, describe } from "vitest"; + +describe("My test", () => { + // let recorder: Recorder; + + beforeEach(async function () { + // recorder = await createRecorder(this); + }); + + afterEach(async function () { + // await recorder.stop(); + }); + + it("sample test", async function () { + assert.equal(1, 1); + }); +}); diff --git a/sdk/chaos/xxxx/test/public/utils/recordedClient.ts b/sdk/chaos/xxxx/test/public/utils/recordedClient.ts new file mode 100644 index 000000000000..6e425fdcfdf9 --- /dev/null +++ b/sdk/chaos/xxxx/test/public/utils/recordedClient.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + Recorder, + RecorderStartOptions, + VitestTestContext, +} from "@azure-tools/test-recorder"; + +const replaceableVariables: Record = { + SUBSCRIPTION_ID: "azure_subscription_id", +}; + +const recorderEnvSetup: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables, +}; + +/** + * creates the recorder and reads the environment variables from the `.env` file. + * Should be called first in the test suite to make sure environment variables are + * read before they are being used. + */ +export async function createRecorder( + context: VitestTestContext, +): Promise { + const recorder = new Recorder(context); + await recorder.start(recorderEnvSetup); + return recorder; +} diff --git a/sdk/chaos/xxxx/tsconfig.browser.config.json b/sdk/chaos/xxxx/tsconfig.browser.config.json new file mode 100644 index 000000000000..091177fcb991 --- /dev/null +++ b/sdk/chaos/xxxx/tsconfig.browser.config.json @@ -0,0 +1,10 @@ +{ + "extends": "./.tshy/build.json", + "include": ["src/**/*.ts", "src/**/*.mts", "test/**/*.spec.ts"], + "exclude": ["test/**/node/**/*.ts"], + "compilerOptions": { + "outDir": "./dist-test/browser", + "rootDir": ".", + "skipLibCheck": true + } +} diff --git a/sdk/chaos/xxxx/tsconfig.json b/sdk/chaos/xxxx/tsconfig.json new file mode 100644 index 000000000000..72266609583d --- /dev/null +++ b/sdk/chaos/xxxx/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../../tsconfig", + "compilerOptions": { + "module": "NodeNext", + "moduleResolution": "NodeNext", + "rootDir": ".", + "skipLibCheck": true + }, + "include": [ + "src/**/*.ts", + "src/**/*.mts", + "src/**/*.cts", + "test/**/*.ts", + "test/**/*.ts" + ] +} diff --git a/sdk/chaos/xxxx/tsp-location.yaml b/sdk/chaos/xxxx/tsp-location.yaml new file mode 100644 index 000000000000..6fc4e169ac42 --- /dev/null +++ b/sdk/chaos/xxxx/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/chaos/Chaos.Management +commit: 58d7c9f2eabf5132fd6bd04bcddbf3681e73208f +repo: ../azure-rest-api-specs +additionalDirectories: diff --git a/sdk/chaos/xxxx/vitest.browser.config.ts b/sdk/chaos/xxxx/vitest.browser.config.ts new file mode 100644 index 000000000000..da68c1d231aa --- /dev/null +++ b/sdk/chaos/xxxx/vitest.browser.config.ts @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig } from "vitest/config"; +import { relativeRecordingsPath } from "@azure-tools/test-recorder"; + +process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath(); + +export default defineConfig({ + define: { + "process.env": process.env, + }, + test: { + reporters: ["basic", "junit"], + outputFile: { + junit: "test-results.browser.xml", + }, + browser: { + enabled: true, + headless: true, + name: "chromium", + provider: "playwright", + }, + fakeTimers: { + toFake: ["setTimeout", "Date"], + }, + watch: false, + include: ["dist-test/browser/**/*.spec.js"], + coverage: { + include: ["dist-test/browser/**/*.spec.js"], + provider: "istanbul", + reporter: ["text", "json", "html"], + reportsDirectory: "coverage-browser", + }, + testTimeout: 1200000, + hookTimeout: 1200000, + }, +}); diff --git a/sdk/chaos/xxxx/vitest.config.ts b/sdk/chaos/xxxx/vitest.config.ts new file mode 100644 index 000000000000..2cf5d0e02c2e --- /dev/null +++ b/sdk/chaos/xxxx/vitest.config.ts @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig } from "vitest/config"; +import { relativeRecordingsPath } from "@azure-tools/test-recorder"; + +export default defineConfig({ + test: { + reporters: ["basic", "junit"], + outputFile: { + junit: "test-results.browser.xml", + }, + fakeTimers: { + toFake: ["setTimeout", "Date"], + }, + watch: false, + include: ["test/**/*.spec.ts"], + exclude: ["test/**/browser/*.spec.ts"], + coverage: { + include: ["src/**/*.ts"], + exclude: [ + "src/**/*-browser.mts", + "src/**/*-react-native.mts", + "vitest*.config.ts", + "samples-dev/**/*.ts", + ], + provider: "istanbul", + reporter: ["text", "json", "html"], + reportsDirectory: "coverage", + }, + testTimeout: 1200000, + hookTimeout: 1200000, + }, +});