diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 768928da9376..d1d36b8fbf7a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -22999,18 +22999,21 @@ importers: sdk/policy/arm-policy: dependencies: + '@azure-rest/core-client': + specifier: ^2.3.1 + version: link:../../core/core-client-rest '@azure/core-auth': specifier: ^1.9.0 version: link:../../core/core-auth - '@azure/core-client': - specifier: ^1.9.2 - version: link:../../core/core-client - '@azure/core-paging': - specifier: ^1.6.2 - version: link:../../core/core-paging '@azure/core-rest-pipeline': - specifier: ^1.19.0 + specifier: ^1.20.0 version: link:../../core/core-rest-pipeline + '@azure/core-util': + specifier: ^1.12.0 + version: link:../../core/core-util + '@azure/logger': + specifier: ^1.2.0 + version: link:../../core/logger tslib: specifier: ^2.8.1 version: 2.8.1 @@ -23024,18 +23027,15 @@ importers: '@azure-tools/test-utils-vitest': specifier: workspace:^ version: link:../../test-utils/test-utils-vitest - '@azure/arm-managementgroups': - specifier: ^2.0.1 - version: link:../../managementgroups/arm-managementgroups '@azure/dev-tool': specifier: workspace:^ version: link:../../../common/tools/dev-tool + '@azure/eslint-plugin-azure-sdk': + specifier: workspace:^ + version: link:../../../common/tools/eslint-plugin-azure-sdk '@azure/identity': specifier: catalog:internal version: 4.13.0 - '@azure/logger': - specifier: ^1.1.4 - version: link:../../core/logger '@types/node': specifier: 'catalog:' version: 20.19.30 @@ -23051,6 +23051,9 @@ importers: dotenv: specifier: catalog:testing version: 16.6.1 + eslint: + specifier: 'catalog:' + version: 9.39.2 playwright: specifier: catalog:testing version: 1.58.1 diff --git a/sdk/policy/arm-policy/CHANGELOG.md b/sdk/policy/arm-policy/CHANGELOG.md index 73df4c62eee8..0159fa600afc 100644 --- a/sdk/policy/arm-policy/CHANGELOG.md +++ b/sdk/policy/arm-policy/CHANGELOG.md @@ -1,4 +1,60 @@ # Release History + +## 7.0.0 (2026-02-05) + +### Features Added + - Added operation group PolicyTokensOperations + - Added Interface ErrorDetail + - Added Interface ExtensionResource + - Added Interface ExternalEvaluationEndpointInvocationResult + - Added Interface ExternalEvaluationEndpointSettings + - Added Interface ExternalEvaluationEnforcementSettings + - Added Interface PagedAsyncIterableIterator + - Added Interface PageSettings + - Added Interface PolicyAssignmentProperties + - Added Interface PolicyAssignmentUpdateProperties + - Added Interface PolicyDefinitionProperties + - Added Interface PolicyDefinitionVersionProperties + - Added Interface PolicyLogInfo + - Added Interface PolicySetDefinitionProperties + - Added Interface PolicySetDefinitionVersionProperties + - Added Interface PolicyTokenOperation + - Added Interface PolicyTokenRequest + - Added Interface PolicyTokenResponse + - Added Interface PolicyTokensAcquireAtManagementGroupOptionalParams + - Added Interface PolicyTokensAcquireOptionalParams + - Added Interface ProxyResource + - Added Interface Resource + - Interface ErrorResponse has a new optional parameter error + - Interface ParameterDefinitionsValueMetadata has a new optional parameter additionalProperties + - Interface PolicyAssignment has a new optional parameter instanceId + - Interface PolicyDefinition has a new optional parameter externalEvaluationEnforcementSettings + - Interface PolicyDefinitionVersion has a new optional parameter externalEvaluationEnforcementSettings + - Added Type Alias AzureSupportedClouds + - Added Type Alias ExternalEndpointResult + - Added Type Alias PolicyTokenResult + - Added Enum AzureClouds + - Added Enum KnownExternalEndpointResult + - Added Enum KnownPolicyTokenResult + - Added Enum KnownVersions + - Enum KnownEnforcementMode has a new value Enroll + +### Breaking Changes + - Removed operation PolicyAssignments.createById + - Removed operation PolicyAssignments.deleteById + - Removed operation PolicyAssignments.getById + - Removed operation PolicyAssignments.updateById + - Removed Interface CloudError + - Removed Interface PolicyAssignmentsCreateByIdOptionalParams + - Removed Interface PolicyAssignmentsDeleteByIdOptionalParams + - Removed Interface PolicyAssignmentsGetByIdOptionalParams + - Removed Interface PolicyAssignmentsUpdateByIdOptionalParams + - Interface ErrorResponse no longer has parameter additionalInfo + - Interface ErrorResponse no longer has parameter code + - Interface ErrorResponse no longer has parameter details + - Interface ErrorResponse no longer has parameter message + - Interface ErrorResponse no longer has parameter target + ## 6.0.0 (2025-03-28) diff --git a/sdk/policy/arm-policy/README.md b/sdk/policy/arm-policy/README.md index 8e619d4eaf82..81fae2c0fc17 100644 --- a/sdk/policy/arm-policy/README.md +++ b/sdk/policy/arm-policy/README.md @@ -4,10 +4,12 @@ This package contains an isomorphic SDK (runs both in Node.js and in browsers) f To manage and control access to your resources, you can define customized policies and assign them at a scope. -[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/policy/arm-policy) | -[Package (NPM)](https://www.npmjs.com/package/@azure/arm-policy) | -[API reference documentation](https://learn.microsoft.com/javascript/api/@azure/arm-policy?view=azure-node-preview) | -[Samples](https://github.com/Azure-Samples/azure-samples-js-management) +Key links: + +- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/policy/arm-policy) +- [Package (NPM)](https://www.npmjs.com/package/@azure/arm-policy) +- [API reference documentation](https://learn.microsoft.com/javascript/api/@azure/arm-policy) +- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/policy/arm-policy/samples) ## Getting started @@ -35,7 +37,7 @@ npm install @azure/arm-policy To create a client object to access the Azure Policy API, you will need the `endpoint` of your Azure Policy resource and a `credential`. The Azure Policy client can use Azure Active Directory credentials to authenticate. You can find the endpoint for your Azure Policy 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). +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/main/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: @@ -63,14 +65,15 @@ For browser environments, use the `InteractiveBrowserCredential` from the `@azur import { InteractiveBrowserCredential } from "@azure/identity"; import { PolicyClient } from "@azure/arm-policy"; -const subscriptionId = "00000000-0000-0000-0000-000000000000"; const credential = new InteractiveBrowserCredential({ tenantId: "", clientId: "", }); +const subscriptionId = "00000000-0000-0000-0000-000000000000"; const client = new PolicyClient(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). @@ -96,7 +99,7 @@ For more detailed instructions on how to enable logs, you can look at the [@azur ## Next steps -Please take a look at the [samples](https://github.com/Azure-Samples/azure-samples-js-management) directory for detailed examples on how to use this library. +Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/policy/arm-policy/samples) directory for detailed examples on how to use this library. ## Contributing @@ -106,9 +109,6 @@ If you'd like to contribute to this library, please read the [contributing guide - [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js) - -[azure_cli]: https://learn.microsoft.com/cli/azure -[azure_sub]: https://azure.microsoft.com/free/ [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 diff --git a/sdk/policy/arm-policy/_meta.json b/sdk/policy/arm-policy/_meta.json deleted file mode 100644 index 97bc9b6c900b..000000000000 --- a/sdk/policy/arm-policy/_meta.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "commit": "f7e7494f92af4f4a0699a143ca899bb614f241e4", - "readme": "specification/resources/resource-manager/readme.md", - "autorest_command": "autorest --version=3.9.7 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\Git\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\resources\\resource-manager\\readme.md --use=@autorest/typescript@6.0.36 --generate-sample=true", - "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "release_tool": "@azure-tools/js-sdk-release-tools@2.7.21", - "use": "@autorest/typescript@6.0.36" -} diff --git a/sdk/policy/arm-policy/api-extractor.json b/sdk/policy/arm-policy/api-extractor.json index 16d81e2eb512..870d6d399477 100644 --- a/sdk/policy/arm-policy/api-extractor.json +++ b/sdk/policy/arm-policy/api-extractor.json @@ -1,3 +1 @@ -{ - "extends": "../../../api-extractor-base.json" -} +{ "extends": "../../../api-extractor-base.json" } diff --git a/sdk/policy/arm-policy/eslint.config.mjs b/sdk/policy/arm-policy/eslint.config.mjs new file mode 100644 index 000000000000..6d2f8a5914c3 --- /dev/null +++ b/sdk/policy/arm-policy/eslint.config.mjs @@ -0,0 +1,14 @@ +import azsdkEslint from "@azure/eslint-plugin-azure-sdk"; + +export default azsdkEslint.config([ + { + rules: { + "@azure/azure-sdk/ts-modules-only-named": "warn", + "@azure/azure-sdk/ts-package-json-types": "warn", + "@azure/azure-sdk/ts-package-json-engine-is-present": "warn", + "@azure/azure-sdk/ts-package-json-files-required": "off", + "@azure/azure-sdk/ts-package-json-main-is-cjs": "off", + "tsdoc/syntax": "warn", + }, + }, +]); diff --git a/sdk/policy/arm-policy/metadata.json b/sdk/policy/arm-policy/metadata.json new file mode 100644 index 000000000000..a8f8ea47c4d3 --- /dev/null +++ b/sdk/policy/arm-policy/metadata.json @@ -0,0 +1,118 @@ +{ + "apiVersion": "2025-03-01", + "emitterVersion": "0.49.0", + "crossLanguageDefinitions": { + "CrossLanguagePackageId": "Microsoft.Authorization", + "CrossLanguageDefinitionId": { + "@azure/arm-policy!PolicyAssignment:interface": "Microsoft.Authorization.PolicyAssignment", + "@azure/arm-policy!PolicyAssignmentProperties:interface": "Microsoft.Authorization.PolicyAssignmentProperties", + "@azure/arm-policy!ParameterValuesValue:interface": "Microsoft.Authorization.ParameterValuesValue", + "@azure/arm-policy!NonComplianceMessage:interface": "Microsoft.Authorization.NonComplianceMessage", + "@azure/arm-policy!ResourceSelector:interface": "Microsoft.Authorization.ResourceSelector", + "@azure/arm-policy!Selector:interface": "Microsoft.Authorization.Selector", + "@azure/arm-policy!Override:interface": "Microsoft.Authorization.Override", + "@azure/arm-policy!Identity:interface": "Microsoft.Authorization.Identity", + "@azure/arm-policy!UserAssignedIdentitiesValue:interface": "Microsoft.Authorization.UserAssignedIdentitiesValue", + "@azure/arm-policy!ExtensionResource:interface": "Azure.ResourceManager.CommonTypes.ExtensionResource", + "@azure/arm-policy!Resource:interface": "Azure.ResourceManager.CommonTypes.Resource", + "@azure/arm-policy!SystemData:interface": "Azure.ResourceManager.CommonTypes.SystemData", + "@azure/arm-policy!ErrorResponse:interface": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "@azure/arm-policy!ErrorDetail:interface": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "@azure/arm-policy!ErrorAdditionalInfo:interface": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "@azure/arm-policy!PolicyAssignmentUpdate:interface": "Microsoft.Authorization.PolicyAssignmentUpdate", + "@azure/arm-policy!PolicyAssignmentUpdateProperties:interface": "Microsoft.Authorization.PolicyAssignmentUpdateProperties", + "@azure/arm-policy!PolicyAssignmentListResult:interface": "Azure.ResourceManager.ResourceListResult", + "@azure/arm-policy!PolicyDefinition:interface": "Microsoft.Authorization.PolicyDefinition", + "@azure/arm-policy!PolicyDefinitionProperties:interface": "Microsoft.Authorization.PolicyDefinitionProperties", + "@azure/arm-policy!ParameterDefinitionsValue:interface": "Microsoft.Authorization.ParameterDefinitionsValue", + "@azure/arm-policy!ParameterDefinitionsValueMetadata:interface": "Microsoft.Authorization.ParameterDefinitionsValueMetadata", + "@azure/arm-policy!ExternalEvaluationEnforcementSettings:interface": "Microsoft.Authorization.ExternalEvaluationEnforcementSettings", + "@azure/arm-policy!ExternalEvaluationEndpointSettings:interface": "Microsoft.Authorization.ExternalEvaluationEndpointSettings", + "@azure/arm-policy!ProxyResource:interface": "Azure.ResourceManager.CommonTypes.ProxyResource", + "@azure/arm-policy!PolicyDefinitionListResult:interface": "Azure.ResourceManager.ResourceListResult", + "@azure/arm-policy!PolicyDefinitionVersion:interface": "Microsoft.Authorization.PolicyDefinitionVersion", + "@azure/arm-policy!PolicyDefinitionVersionProperties:interface": "Microsoft.Authorization.PolicyDefinitionVersionProperties", + "@azure/arm-policy!PolicyDefinitionVersionListResult:interface": "Azure.ResourceManager.ResourceListResult", + "@azure/arm-policy!PolicySetDefinition:interface": "Microsoft.Authorization.PolicySetDefinition", + "@azure/arm-policy!PolicySetDefinitionProperties:interface": "Microsoft.Authorization.PolicySetDefinitionProperties", + "@azure/arm-policy!PolicyDefinitionReference:interface": "Microsoft.Authorization.PolicyDefinitionReference", + "@azure/arm-policy!PolicyDefinitionGroup:interface": "Microsoft.Authorization.PolicyDefinitionGroup", + "@azure/arm-policy!PolicySetDefinitionListResult:interface": "Azure.ResourceManager.ResourceListResult", + "@azure/arm-policy!PolicySetDefinitionVersion:interface": "Microsoft.Authorization.PolicySetDefinitionVersion", + "@azure/arm-policy!PolicySetDefinitionVersionProperties:interface": "Microsoft.Authorization.PolicySetDefinitionVersionProperties", + "@azure/arm-policy!PolicySetDefinitionVersionListResult:interface": "Azure.ResourceManager.ResourceListResult", + "@azure/arm-policy!PolicyTokenRequest:interface": "Microsoft.Authorization.PolicyTokenRequest", + "@azure/arm-policy!PolicyTokenOperation:interface": "Microsoft.Authorization.PolicyTokenOperation", + "@azure/arm-policy!PolicyTokenResponse:interface": "Microsoft.Authorization.PolicyTokenResponse", + "@azure/arm-policy!ExternalEvaluationEndpointInvocationResult:interface": "Microsoft.Authorization.ExternalEvaluationEndpointInvocationResult", + "@azure/arm-policy!PolicyLogInfo:interface": "Microsoft.Authorization.PolicyLogInfo", + "@azure/arm-policy!KnownEnforcementMode:enum": "Microsoft.Authorization.EnforcementMode", + "@azure/arm-policy!KnownSelectorKind:enum": "Microsoft.Authorization.SelectorKind", + "@azure/arm-policy!KnownOverrideKind:enum": "Microsoft.Authorization.OverrideKind", + "@azure/arm-policy!KnownAssignmentType:enum": "Microsoft.Authorization.AssignmentType", + "@azure/arm-policy!KnownResourceIdentityType:enum": "Microsoft.Authorization.ResourceIdentityType", + "@azure/arm-policy!KnowncreatedByType:enum": "Azure.ResourceManager.CommonTypes.createdByType", + "@azure/arm-policy!KnownPolicyType:enum": "Microsoft.Authorization.PolicyType", + "@azure/arm-policy!KnownParameterType:enum": "Microsoft.Authorization.ParameterType", + "@azure/arm-policy!KnownPolicyTokenResult:enum": "Microsoft.Authorization.PolicyTokenResult", + "@azure/arm-policy!KnownExternalEndpointResult:enum": "Microsoft.Authorization.ExternalEndpointResult", + "@azure/arm-policy!KnownVersions:enum": "Microsoft.Authorization.Versions", + "@azure/arm-policy!PolicyTokensOperations#acquireAtManagementGroup:member": "Microsoft.Authorization.PolicyTokensOperationGroup.acquireAtManagementGroup", + "@azure/arm-policy!PolicyTokensOperations#acquire:member": "Microsoft.Authorization.PolicyTokensOperationGroup.acquire", + "@azure/arm-policy!PolicySetDefinitionVersionsOperations#listAll:member": "Microsoft.Authorization.PolicySetDefinitionVersionsOperationGroup.listAll", + "@azure/arm-policy!PolicySetDefinitionVersionsOperations#listAllAtManagementGroup:member": "Microsoft.Authorization.PolicySetDefinitionVersionsOperationGroup.listAllAtManagementGroup", + "@azure/arm-policy!PolicySetDefinitionVersionsOperations#listAllBuiltins:member": "Microsoft.Authorization.PolicySetDefinitionVersionsOperationGroup.listAllBuiltins", + "@azure/arm-policy!PolicySetDefinitionVersionsOperations#listByManagementGroup:member": "Microsoft.Authorization.PolicySetDefinitionVersions.listByManagementGroup", + "@azure/arm-policy!PolicySetDefinitionVersionsOperations#deleteAtManagementGroup:member": "Microsoft.Authorization.PolicySetDefinitionVersions.deleteAtManagementGroup", + "@azure/arm-policy!PolicySetDefinitionVersionsOperations#createOrUpdateAtManagementGroup:member": "Microsoft.Authorization.PolicySetDefinitionVersions.createOrUpdateAtManagementGroup", + "@azure/arm-policy!PolicySetDefinitionVersionsOperations#getAtManagementGroup:member": "Microsoft.Authorization.PolicySetDefinitionVersions.getAtManagementGroup", + "@azure/arm-policy!PolicySetDefinitionVersionsOperations#listBuiltIn:member": "Microsoft.Authorization.PolicySetDefinitionVersions.listBuiltIn", + "@azure/arm-policy!PolicySetDefinitionVersionsOperations#getBuiltIn:member": "Microsoft.Authorization.PolicySetDefinitionVersions.getBuiltIn", + "@azure/arm-policy!PolicySetDefinitionVersionsOperations#list:member": "Microsoft.Authorization.PolicySetDefinitionVersions.list", + "@azure/arm-policy!PolicySetDefinitionVersionsOperations#delete:member": "Microsoft.Authorization.PolicySetDefinitionVersions.delete", + "@azure/arm-policy!PolicySetDefinitionVersionsOperations#createOrUpdate:member": "Microsoft.Authorization.PolicySetDefinitionVersions.createOrUpdate", + "@azure/arm-policy!PolicySetDefinitionVersionsOperations#get:member": "Microsoft.Authorization.PolicySetDefinitionVersions.get", + "@azure/arm-policy!PolicySetDefinitionsOperations#listByManagementGroup:member": "Microsoft.Authorization.PolicySetDefinitions.listByManagementGroup", + "@azure/arm-policy!PolicySetDefinitionsOperations#deleteAtManagementGroup:member": "Microsoft.Authorization.PolicySetDefinitions.deleteAtManagementGroup", + "@azure/arm-policy!PolicySetDefinitionsOperations#createOrUpdateAtManagementGroup:member": "Microsoft.Authorization.PolicySetDefinitions.createOrUpdateAtManagementGroup", + "@azure/arm-policy!PolicySetDefinitionsOperations#getAtManagementGroup:member": "Microsoft.Authorization.PolicySetDefinitions.getAtManagementGroup", + "@azure/arm-policy!PolicySetDefinitionsOperations#listBuiltIn:member": "Microsoft.Authorization.PolicySetDefinitions.listBuiltIn", + "@azure/arm-policy!PolicySetDefinitionsOperations#getBuiltIn:member": "Microsoft.Authorization.PolicySetDefinitions.getBuiltIn", + "@azure/arm-policy!PolicySetDefinitionsOperations#list:member": "Microsoft.Authorization.PolicySetDefinitions.list", + "@azure/arm-policy!PolicySetDefinitionsOperations#delete:member": "Microsoft.Authorization.PolicySetDefinitions.delete", + "@azure/arm-policy!PolicySetDefinitionsOperations#createOrUpdate:member": "Microsoft.Authorization.PolicySetDefinitions.createOrUpdate", + "@azure/arm-policy!PolicySetDefinitionsOperations#get:member": "Microsoft.Authorization.PolicySetDefinitions.get", + "@azure/arm-policy!PolicyDefinitionVersionsOperations#listAll:member": "Microsoft.Authorization.PolicyDefinitionVersionsOperationGroup.listAll", + "@azure/arm-policy!PolicyDefinitionVersionsOperations#listAllAtManagementGroup:member": "Microsoft.Authorization.PolicyDefinitionVersionsOperationGroup.listAllAtManagementGroup", + "@azure/arm-policy!PolicyDefinitionVersionsOperations#listAllBuiltins:member": "Microsoft.Authorization.PolicyDefinitionVersionsOperationGroup.listAllBuiltins", + "@azure/arm-policy!PolicyDefinitionVersionsOperations#listByManagementGroup:member": "Microsoft.Authorization.PolicyDefinitionVersions.listByManagementGroup", + "@azure/arm-policy!PolicyDefinitionVersionsOperations#deleteAtManagementGroup:member": "Microsoft.Authorization.PolicyDefinitionVersions.deleteAtManagementGroup", + "@azure/arm-policy!PolicyDefinitionVersionsOperations#createOrUpdateAtManagementGroup:member": "Microsoft.Authorization.PolicyDefinitionVersions.createOrUpdateAtManagementGroup", + "@azure/arm-policy!PolicyDefinitionVersionsOperations#getAtManagementGroup:member": "Microsoft.Authorization.PolicyDefinitionVersions.getAtManagementGroup", + "@azure/arm-policy!PolicyDefinitionVersionsOperations#listBuiltIn:member": "Microsoft.Authorization.PolicyDefinitionVersions.listBuiltIn", + "@azure/arm-policy!PolicyDefinitionVersionsOperations#getBuiltIn:member": "Microsoft.Authorization.PolicyDefinitionVersions.getBuiltIn", + "@azure/arm-policy!PolicyDefinitionVersionsOperations#list:member": "Microsoft.Authorization.PolicyDefinitionVersions.list", + "@azure/arm-policy!PolicyDefinitionVersionsOperations#delete:member": "Microsoft.Authorization.PolicyDefinitionVersions.delete", + "@azure/arm-policy!PolicyDefinitionVersionsOperations#createOrUpdate:member": "Microsoft.Authorization.PolicyDefinitionVersions.createOrUpdate", + "@azure/arm-policy!PolicyDefinitionVersionsOperations#get:member": "Microsoft.Authorization.PolicyDefinitionVersions.get", + "@azure/arm-policy!PolicyDefinitionsOperations#listByManagementGroup:member": "Microsoft.Authorization.PolicyDefinitions.listByManagementGroup", + "@azure/arm-policy!PolicyDefinitionsOperations#deleteAtManagementGroup:member": "Microsoft.Authorization.PolicyDefinitions.deleteAtManagementGroup", + "@azure/arm-policy!PolicyDefinitionsOperations#createOrUpdateAtManagementGroup:member": "Microsoft.Authorization.PolicyDefinitions.createOrUpdateAtManagementGroup", + "@azure/arm-policy!PolicyDefinitionsOperations#getAtManagementGroup:member": "Microsoft.Authorization.PolicyDefinitions.getAtManagementGroup", + "@azure/arm-policy!PolicyDefinitionsOperations#listBuiltIn:member": "Microsoft.Authorization.PolicyDefinitions.listBuiltIn", + "@azure/arm-policy!PolicyDefinitionsOperations#getBuiltIn:member": "Microsoft.Authorization.PolicyDefinitions.getBuiltIn", + "@azure/arm-policy!PolicyDefinitionsOperations#list:member": "Microsoft.Authorization.PolicyDefinitions.list", + "@azure/arm-policy!PolicyDefinitionsOperations#delete:member": "Microsoft.Authorization.PolicyDefinitions.delete", + "@azure/arm-policy!PolicyDefinitionsOperations#createOrUpdate:member": "Microsoft.Authorization.PolicyDefinitions.createOrUpdate", + "@azure/arm-policy!PolicyDefinitionsOperations#get:member": "Microsoft.Authorization.PolicyDefinitions.get", + "@azure/arm-policy!PolicyAssignmentsOperations#listForResource:member": "Microsoft.Authorization.PolicyAssignments.listForResource", + "@azure/arm-policy!PolicyAssignmentsOperations#list:member": "Microsoft.Authorization.PolicyAssignments.list", + "@azure/arm-policy!PolicyAssignmentsOperations#listForManagementGroup:member": "Microsoft.Authorization.PolicyAssignments.listForManagementGroup", + "@azure/arm-policy!PolicyAssignmentsOperations#listForResourceGroup:member": "Microsoft.Authorization.PolicyAssignments.listForResourceGroup", + "@azure/arm-policy!PolicyAssignmentsOperations#delete:member": "Microsoft.Authorization.PolicyAssignments.delete", + "@azure/arm-policy!PolicyAssignmentsOperations#update:member": "Microsoft.Authorization.PolicyAssignments.update", + "@azure/arm-policy!PolicyAssignmentsOperations#create:member": "Microsoft.Authorization.PolicyAssignments.create", + "@azure/arm-policy!PolicyAssignmentsOperations#get:member": "Microsoft.Authorization.PolicyAssignments.get" + } + } +} diff --git a/sdk/policy/arm-policy/package.json b/sdk/policy/arm-policy/package.json index 3bf6d21a5d98..addbd38ba4d8 100644 --- a/sdk/policy/arm-policy/package.json +++ b/sdk/policy/arm-policy/package.json @@ -1,109 +1,118 @@ { "name": "@azure/arm-policy", - "sdk-type": "mgmt", - "author": "Microsoft Corporation", + "version": "7.0.0", "description": "A generated SDK for PolicyClient.", - "version": "6.0.0", "engines": { "node": ">=20.0.0" }, - "dependencies": { - "@azure/core-auth": "^1.9.0", - "@azure/core-client": "^1.9.2", - "@azure/core-paging": "^1.6.2", - "@azure/core-rest-pipeline": "^1.19.0", - "tslib": "^2.8.1" + "sideEffects": false, + "autoPublish": false, + "tshy": { + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./api": "./src/api/index.ts", + "./api/policyTokens": "./src/api/policyTokens/index.ts", + "./api/policySetDefinitionVersions": "./src/api/policySetDefinitionVersions/index.ts", + "./api/policySetDefinitions": "./src/api/policySetDefinitions/index.ts", + "./api/policyDefinitionVersions": "./src/api/policyDefinitionVersions/index.ts", + "./api/policyDefinitions": "./src/api/policyDefinitions/index.ts", + "./api/policyAssignments": "./src/api/policyAssignments/index.ts", + "./models": "./src/models/index.ts" + }, + "dialects": [ + "esm", + "commonjs" + ], + "esmDialects": [ + "browser", + "react-native" + ], + "selfLink": false, + "project": "../../../tsconfig.src.build.json" }, + "type": "module", + "browser": "./dist/browser/index.js", + "react-native": "./dist/react-native/index.js", "keywords": [ "node", "azure", + "cloud", "typescript", "browser", - "isomorphic", - "cloud" + "isomorphic" ], + "author": "Microsoft Corporation", "license": "MIT", - "main": "./dist/commonjs/index.js", - "module": "./dist/esm/index.js", - "types": "./dist/commonjs/index.d.ts", + "files": [ + "dist/", + "!dist/**/*.d.*ts.map", + "README.md", + "LICENSE" + ], + "sdk-type": "mgmt", + "repository": "github:Azure/azure-sdk-for-js", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/policy/arm-policy/README.md", + "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", + "//metadata": { + "constantPaths": [ + { + "path": "src/api/policyContext.ts", + "prefix": "userAgentInfo" + } + ] + }, + "dependencies": { + "@azure/core-util": "^1.12.0", + "@azure-rest/core-client": "^2.3.1", + "@azure/core-auth": "^1.9.0", + "@azure/core-rest-pipeline": "^1.20.0", + "@azure/logger": "^1.2.0", + "tslib": "^2.8.1" + }, "devDependencies": { "@azure-tools/test-credential": "workspace:^", "@azure-tools/test-recorder": "workspace:^", "@azure-tools/test-utils-vitest": "workspace:^", - "@azure/arm-managementgroups": "^2.0.1", "@azure/dev-tool": "workspace:^", + "tshy": "catalog:", + "@azure/eslint-plugin-azure-sdk": "workspace:^", "@azure/identity": "catalog:internal", - "@azure/logger": "^1.1.4", "@types/node": "catalog:", + "cross-env": "catalog:", + "eslint": "catalog:", + "prettier": "catalog:", + "rimraf": "catalog:", "@vitest/browser-playwright": "catalog:testing", "@vitest/coverage-istanbul": "catalog:testing", - "cross-env": "catalog:", "dotenv": "catalog:testing", "playwright": "catalog:testing", - "prettier": "catalog:", - "rimraf": "catalog:", - "tshy": "catalog:", "typescript": "catalog:", "vitest": "catalog:testing" }, - "repository": "github:Azure/azure-sdk-for-js", - "bugs": { - "url": "https://github.com/Azure/azure-sdk-for-js/issues" - }, - "files": [ - "dist/", - "README.md", - "LICENSE", - "review/*", - "CHANGELOG.md" - ], "scripts": { - "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api", - "build:samples": "tsc -p tsconfig.samples.json && dev-tool samples publish -f", - "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" ", "clean": "rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", - "execute:samples": "echo skipped", - "extract-api": "dev-tool run extract-api", - "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" ", - "lint": "echo skipped", + "extract-api": "rimraf review && dev-tool run extract-api", "pack": "pnpm pack 2>&1", + "lint": "echo skipped", + "lint:fix": "echo skipped", + "build:samples": "tsc -p tsconfig.samples.json && dev-tool samples publish -f", + "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" \"samples-dev/*.ts\"", + "execute:samples": "dev-tool samples run samples-dev", + "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" \"samples-dev/*.ts\"", + "generate:client": "echo skipped", + "test:browser": "dev-tool run build-test && dev-tool run test:vitest --browser", + "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api", + "test:node": "dev-tool run test:vitest", + "test:node:esm": "dev-tool run test:vitest --esm", "test": "npm run test:node && npm run test:browser", - "test:browser": "echo skipped", - "test:node": "dev-tool run build-test --no-browser-test && dev-tool run test:vitest", "update-snippets": "dev-tool run update-snippets" }, - "sideEffects": false, - "//metadata": { - "constantPaths": [ - { - "path": "src/policyClient.ts", - "prefix": "packageDetails" - } - ] - }, - "autoPublish": true, - "type": "module", - "tshy": { - "project": "../../../tsconfig.src.build.json", - "exports": { - "./package.json": "./package.json", - ".": "./src/index.ts" - }, - "dialects": [ - "esm", - "commonjs" - ], - "esmDialects": [ - "browser", - "react-native" - ], - "selfLink": false - }, - "browser": "./dist/browser/index.js", - "react-native": "./dist/react-native/index.js", - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/policy/arm-policy", "//sampleConfiguration": { - "productName": "", + "productName": "@azure/arm-policy", "productSlugs": [ "azure" ], @@ -129,6 +138,153 @@ "types": "./dist/commonjs/index.d.ts", "default": "./dist/commonjs/index.js" } + }, + "./api": { + "browser": { + "types": "./dist/browser/api/index.d.ts", + "default": "./dist/browser/api/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/index.d.ts", + "default": "./dist/react-native/api/index.js" + }, + "import": { + "types": "./dist/esm/api/index.d.ts", + "default": "./dist/esm/api/index.js" + }, + "require": { + "types": "./dist/commonjs/api/index.d.ts", + "default": "./dist/commonjs/api/index.js" + } + }, + "./api/policyTokens": { + "browser": { + "types": "./dist/browser/api/policyTokens/index.d.ts", + "default": "./dist/browser/api/policyTokens/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/policyTokens/index.d.ts", + "default": "./dist/react-native/api/policyTokens/index.js" + }, + "import": { + "types": "./dist/esm/api/policyTokens/index.d.ts", + "default": "./dist/esm/api/policyTokens/index.js" + }, + "require": { + "types": "./dist/commonjs/api/policyTokens/index.d.ts", + "default": "./dist/commonjs/api/policyTokens/index.js" + } + }, + "./api/policySetDefinitionVersions": { + "browser": { + "types": "./dist/browser/api/policySetDefinitionVersions/index.d.ts", + "default": "./dist/browser/api/policySetDefinitionVersions/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/policySetDefinitionVersions/index.d.ts", + "default": "./dist/react-native/api/policySetDefinitionVersions/index.js" + }, + "import": { + "types": "./dist/esm/api/policySetDefinitionVersions/index.d.ts", + "default": "./dist/esm/api/policySetDefinitionVersions/index.js" + }, + "require": { + "types": "./dist/commonjs/api/policySetDefinitionVersions/index.d.ts", + "default": "./dist/commonjs/api/policySetDefinitionVersions/index.js" + } + }, + "./api/policySetDefinitions": { + "browser": { + "types": "./dist/browser/api/policySetDefinitions/index.d.ts", + "default": "./dist/browser/api/policySetDefinitions/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/policySetDefinitions/index.d.ts", + "default": "./dist/react-native/api/policySetDefinitions/index.js" + }, + "import": { + "types": "./dist/esm/api/policySetDefinitions/index.d.ts", + "default": "./dist/esm/api/policySetDefinitions/index.js" + }, + "require": { + "types": "./dist/commonjs/api/policySetDefinitions/index.d.ts", + "default": "./dist/commonjs/api/policySetDefinitions/index.js" + } + }, + "./api/policyDefinitionVersions": { + "browser": { + "types": "./dist/browser/api/policyDefinitionVersions/index.d.ts", + "default": "./dist/browser/api/policyDefinitionVersions/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/policyDefinitionVersions/index.d.ts", + "default": "./dist/react-native/api/policyDefinitionVersions/index.js" + }, + "import": { + "types": "./dist/esm/api/policyDefinitionVersions/index.d.ts", + "default": "./dist/esm/api/policyDefinitionVersions/index.js" + }, + "require": { + "types": "./dist/commonjs/api/policyDefinitionVersions/index.d.ts", + "default": "./dist/commonjs/api/policyDefinitionVersions/index.js" + } + }, + "./api/policyDefinitions": { + "browser": { + "types": "./dist/browser/api/policyDefinitions/index.d.ts", + "default": "./dist/browser/api/policyDefinitions/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/policyDefinitions/index.d.ts", + "default": "./dist/react-native/api/policyDefinitions/index.js" + }, + "import": { + "types": "./dist/esm/api/policyDefinitions/index.d.ts", + "default": "./dist/esm/api/policyDefinitions/index.js" + }, + "require": { + "types": "./dist/commonjs/api/policyDefinitions/index.d.ts", + "default": "./dist/commonjs/api/policyDefinitions/index.js" + } + }, + "./api/policyAssignments": { + "browser": { + "types": "./dist/browser/api/policyAssignments/index.d.ts", + "default": "./dist/browser/api/policyAssignments/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/policyAssignments/index.d.ts", + "default": "./dist/react-native/api/policyAssignments/index.js" + }, + "import": { + "types": "./dist/esm/api/policyAssignments/index.d.ts", + "default": "./dist/esm/api/policyAssignments/index.js" + }, + "require": { + "types": "./dist/commonjs/api/policyAssignments/index.d.ts", + "default": "./dist/commonjs/api/policyAssignments/index.js" + } + }, + "./models": { + "browser": { + "types": "./dist/browser/models/index.d.ts", + "default": "./dist/browser/models/index.js" + }, + "react-native": { + "types": "./dist/react-native/models/index.d.ts", + "default": "./dist/react-native/models/index.js" + }, + "import": { + "types": "./dist/esm/models/index.d.ts", + "default": "./dist/esm/models/index.js" + }, + "require": { + "types": "./dist/commonjs/models/index.d.ts", + "default": "./dist/commonjs/models/index.js" + } } - } + }, + "main": "./dist/commonjs/index.js", + "types": "./dist/commonjs/index.d.ts", + "module": "./dist/esm/index.js" } diff --git a/sdk/policy/arm-policy/review/arm-policy-api-node.api.md b/sdk/policy/arm-policy/review/arm-policy-api-node.api.md new file mode 100644 index 000000000000..59212b56a0c3 --- /dev/null +++ b/sdk/policy/arm-policy/review/arm-policy-api-node.api.md @@ -0,0 +1,28 @@ +## API Report File for "@azure/arm-policy" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { Client } from '@azure-rest/core-client'; +import type { ClientOptions } from '@azure-rest/core-client'; +import type { TokenCredential } from '@azure/core-auth'; + +// @public +export function createPolicy(credential: TokenCredential, subscriptionId: string, options?: PolicyClientOptionalParams): PolicyContext; + +// @public +export interface PolicyClientOptionalParams extends ClientOptions { + apiVersion?: string; + cloudSetting?: AzureSupportedClouds; +} + +// @public +export interface PolicyContext extends Client { + apiVersion?: string; + subscriptionId: string; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/policy/arm-policy/review/arm-policy-api-policyAssignments-node.api.md b/sdk/policy/arm-policy/review/arm-policy-api-policyAssignments-node.api.md new file mode 100644 index 000000000000..fada5507629a --- /dev/null +++ b/sdk/policy/arm-policy/review/arm-policy-api-policyAssignments-node.api.md @@ -0,0 +1,81 @@ +## API Report File for "@azure/arm-policy" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { Client } from '@azure-rest/core-client'; +import type { OperationOptions } from '@azure-rest/core-client'; + +// @public +export function $delete(context: PolicyContext, scope: string, policyAssignmentName: string, options?: PolicyAssignmentsDeleteOptionalParams): Promise; + +// @public +export function create(context: PolicyContext, scope: string, policyAssignmentName: string, parameters: PolicyAssignment, options?: PolicyAssignmentsCreateOptionalParams): Promise; + +// @public +export function get(context: PolicyContext, scope: string, policyAssignmentName: string, options?: PolicyAssignmentsGetOptionalParams): Promise; + +// @public +export function list(context: PolicyContext, options?: PolicyAssignmentsListOptionalParams): PagedAsyncIterableIterator; + +// @public +export function listForManagementGroup(context: PolicyContext, managementGroupId: string, options?: PolicyAssignmentsListForManagementGroupOptionalParams): PagedAsyncIterableIterator; + +// @public +export function listForResource(context: PolicyContext, resourceGroupName: string, resourceProviderNamespace: string, parentResourcePath: string, resourceType: string, resourceName: string, options?: PolicyAssignmentsListForResourceOptionalParams): PagedAsyncIterableIterator; + +// @public +export function listForResourceGroup(context: PolicyContext, resourceGroupName: string, options?: PolicyAssignmentsListForResourceGroupOptionalParams): PagedAsyncIterableIterator; + +// @public +export interface PolicyAssignmentsCreateOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyAssignmentsDeleteOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyAssignmentsGetOptionalParams extends OperationOptions { + expand?: string; +} + +// @public +export interface PolicyAssignmentsListForManagementGroupOptionalParams extends OperationOptions { + expand?: string; + filter?: string; + top?: number; +} + +// @public +export interface PolicyAssignmentsListForResourceGroupOptionalParams extends OperationOptions { + expand?: string; + filter?: string; + top?: number; +} + +// @public +export interface PolicyAssignmentsListForResourceOptionalParams extends OperationOptions { + expand?: string; + filter?: string; + top?: number; +} + +// @public +export interface PolicyAssignmentsListOptionalParams extends OperationOptions { + expand?: string; + filter?: string; + top?: number; +} + +// @public +export interface PolicyAssignmentsUpdateOptionalParams extends OperationOptions { +} + +// @public +export function update(context: PolicyContext, scope: string, policyAssignmentName: string, parameters: PolicyAssignmentUpdate, options?: PolicyAssignmentsUpdateOptionalParams): Promise; + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/policy/arm-policy/review/arm-policy-api-policyDefinitionVersions-node.api.md b/sdk/policy/arm-policy/review/arm-policy-api-policyDefinitionVersions-node.api.md new file mode 100644 index 000000000000..dbf8311fea37 --- /dev/null +++ b/sdk/policy/arm-policy/review/arm-policy-api-policyDefinitionVersions-node.api.md @@ -0,0 +1,106 @@ +## API Report File for "@azure/arm-policy" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { Client } from '@azure-rest/core-client'; +import type { OperationOptions } from '@azure-rest/core-client'; + +// @public +export function $delete(context: PolicyContext, policyDefinitionName: string, policyDefinitionVersion: string, options?: PolicyDefinitionVersionsDeleteOptionalParams): Promise; + +// @public +export function createOrUpdate(context: PolicyContext, policyDefinitionName: string, policyDefinitionVersion: string, parameters: PolicyDefinitionVersion, options?: PolicyDefinitionVersionsCreateOrUpdateOptionalParams): Promise; + +// @public +export function createOrUpdateAtManagementGroup(context: PolicyContext, managementGroupName: string, policyDefinitionName: string, policyDefinitionVersion: string, parameters: PolicyDefinitionVersion, options?: PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams): Promise; + +// @public +export function deleteAtManagementGroup(context: PolicyContext, managementGroupName: string, policyDefinitionName: string, policyDefinitionVersion: string, options?: PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams): Promise; + +// @public +export function get(context: PolicyContext, policyDefinitionName: string, policyDefinitionVersion: string, options?: PolicyDefinitionVersionsGetOptionalParams): Promise; + +// @public +export function getAtManagementGroup(context: PolicyContext, managementGroupName: string, policyDefinitionName: string, policyDefinitionVersion: string, options?: PolicyDefinitionVersionsGetAtManagementGroupOptionalParams): Promise; + +// @public +export function getBuiltIn(context: PolicyContext, policyDefinitionName: string, policyDefinitionVersion: string, options?: PolicyDefinitionVersionsGetBuiltInOptionalParams): Promise; + +// @public +export function list(context: PolicyContext, policyDefinitionName: string, options?: PolicyDefinitionVersionsListOptionalParams): PagedAsyncIterableIterator; + +// @public +export function listAll(context: PolicyContext, options?: PolicyDefinitionVersionsListAllOptionalParams): Promise<_PolicyDefinitionVersionListResult>; + +// @public +export function listAllAtManagementGroup(context: PolicyContext, managementGroupName: string, options?: PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams): Promise<_PolicyDefinitionVersionListResult>; + +// @public +export function listAllBuiltins(context: PolicyContext, options?: PolicyDefinitionVersionsListAllBuiltinsOptionalParams): Promise<_PolicyDefinitionVersionListResult>; + +// @public +export function listBuiltIn(context: PolicyContext, policyDefinitionName: string, options?: PolicyDefinitionVersionsListBuiltInOptionalParams): PagedAsyncIterableIterator; + +// @public +export function listByManagementGroup(context: PolicyContext, managementGroupName: string, policyDefinitionName: string, options?: PolicyDefinitionVersionsListByManagementGroupOptionalParams): PagedAsyncIterableIterator; + +// @public +export interface PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyDefinitionVersionsCreateOrUpdateOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyDefinitionVersionsDeleteOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyDefinitionVersionsGetAtManagementGroupOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyDefinitionVersionsGetBuiltInOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyDefinitionVersionsGetOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyDefinitionVersionsListAllBuiltinsOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyDefinitionVersionsListAllOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyDefinitionVersionsListBuiltInOptionalParams extends OperationOptions { + top?: number; +} + +// @public +export interface PolicyDefinitionVersionsListByManagementGroupOptionalParams extends OperationOptions { + top?: number; +} + +// @public +export interface PolicyDefinitionVersionsListOptionalParams extends OperationOptions { + top?: number; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/policy/arm-policy/review/arm-policy-api-policyDefinitions-node.api.md b/sdk/policy/arm-policy/review/arm-policy-api-policyDefinitions-node.api.md new file mode 100644 index 000000000000..61752b959ea2 --- /dev/null +++ b/sdk/policy/arm-policy/review/arm-policy-api-policyDefinitions-node.api.md @@ -0,0 +1,88 @@ +## API Report File for "@azure/arm-policy" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { Client } from '@azure-rest/core-client'; +import type { OperationOptions } from '@azure-rest/core-client'; + +// @public +export function $delete(context: PolicyContext, policyDefinitionName: string, options?: PolicyDefinitionsDeleteOptionalParams): Promise; + +// @public +export function createOrUpdate(context: PolicyContext, policyDefinitionName: string, parameters: PolicyDefinition, options?: PolicyDefinitionsCreateOrUpdateOptionalParams): Promise; + +// @public +export function createOrUpdateAtManagementGroup(context: PolicyContext, managementGroupId: string, policyDefinitionName: string, parameters: PolicyDefinition, options?: PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams): Promise; + +// @public +export function deleteAtManagementGroup(context: PolicyContext, managementGroupId: string, policyDefinitionName: string, options?: PolicyDefinitionsDeleteAtManagementGroupOptionalParams): Promise; + +// @public +export function get(context: PolicyContext, policyDefinitionName: string, options?: PolicyDefinitionsGetOptionalParams): Promise; + +// @public +export function getAtManagementGroup(context: PolicyContext, managementGroupId: string, policyDefinitionName: string, options?: PolicyDefinitionsGetAtManagementGroupOptionalParams): Promise; + +// @public +export function getBuiltIn(context: PolicyContext, policyDefinitionName: string, options?: PolicyDefinitionsGetBuiltInOptionalParams): Promise; + +// @public +export function list(context: PolicyContext, options?: PolicyDefinitionsListOptionalParams): PagedAsyncIterableIterator; + +// @public +export function listBuiltIn(context: PolicyContext, options?: PolicyDefinitionsListBuiltInOptionalParams): PagedAsyncIterableIterator; + +// @public +export function listByManagementGroup(context: PolicyContext, managementGroupId: string, options?: PolicyDefinitionsListByManagementGroupOptionalParams): PagedAsyncIterableIterator; + +// @public +export interface PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyDefinitionsCreateOrUpdateOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyDefinitionsDeleteAtManagementGroupOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyDefinitionsDeleteOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyDefinitionsGetAtManagementGroupOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyDefinitionsGetBuiltInOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyDefinitionsGetOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyDefinitionsListBuiltInOptionalParams extends OperationOptions { + filter?: string; + top?: number; +} + +// @public +export interface PolicyDefinitionsListByManagementGroupOptionalParams extends OperationOptions { + filter?: string; + top?: number; +} + +// @public +export interface PolicyDefinitionsListOptionalParams extends OperationOptions { + filter?: string; + top?: number; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/policy/arm-policy/review/arm-policy-api-policySetDefinitionVersions-node.api.md b/sdk/policy/arm-policy/review/arm-policy-api-policySetDefinitionVersions-node.api.md new file mode 100644 index 000000000000..87798d023716 --- /dev/null +++ b/sdk/policy/arm-policy/review/arm-policy-api-policySetDefinitionVersions-node.api.md @@ -0,0 +1,112 @@ +## API Report File for "@azure/arm-policy" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { Client } from '@azure-rest/core-client'; +import type { OperationOptions } from '@azure-rest/core-client'; + +// @public +export function $delete(context: PolicyContext, policySetDefinitionName: string, policyDefinitionVersion: string, options?: PolicySetDefinitionVersionsDeleteOptionalParams): Promise; + +// @public +export function createOrUpdate(context: PolicyContext, policySetDefinitionName: string, policyDefinitionVersion: string, parameters: PolicySetDefinitionVersion, options?: PolicySetDefinitionVersionsCreateOrUpdateOptionalParams): Promise; + +// @public +export function createOrUpdateAtManagementGroup(context: PolicyContext, managementGroupName: string, policySetDefinitionName: string, policyDefinitionVersion: string, parameters: PolicySetDefinitionVersion, options?: PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams): Promise; + +// @public +export function deleteAtManagementGroup(context: PolicyContext, managementGroupName: string, policySetDefinitionName: string, policyDefinitionVersion: string, options?: PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams): Promise; + +// @public +export function get(context: PolicyContext, policySetDefinitionName: string, policyDefinitionVersion: string, options?: PolicySetDefinitionVersionsGetOptionalParams): Promise; + +// @public +export function getAtManagementGroup(context: PolicyContext, managementGroupName: string, policySetDefinitionName: string, policyDefinitionVersion: string, options?: PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams): Promise; + +// @public +export function getBuiltIn(context: PolicyContext, policySetDefinitionName: string, policyDefinitionVersion: string, options?: PolicySetDefinitionVersionsGetBuiltInOptionalParams): Promise; + +// @public +export function list(context: PolicyContext, policySetDefinitionName: string, options?: PolicySetDefinitionVersionsListOptionalParams): PagedAsyncIterableIterator; + +// @public +export function listAll(context: PolicyContext, options?: PolicySetDefinitionVersionsListAllOptionalParams): Promise<_PolicySetDefinitionVersionListResult>; + +// @public +export function listAllAtManagementGroup(context: PolicyContext, managementGroupName: string, options?: PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams): Promise<_PolicySetDefinitionVersionListResult>; + +// @public +export function listAllBuiltins(context: PolicyContext, options?: PolicySetDefinitionVersionsListAllBuiltinsOptionalParams): Promise<_PolicySetDefinitionVersionListResult>; + +// @public +export function listBuiltIn(context: PolicyContext, policySetDefinitionName: string, options?: PolicySetDefinitionVersionsListBuiltInOptionalParams): PagedAsyncIterableIterator; + +// @public +export function listByManagementGroup(context: PolicyContext, managementGroupName: string, policySetDefinitionName: string, options?: PolicySetDefinitionVersionsListByManagementGroupOptionalParams): PagedAsyncIterableIterator; + +// @public +export interface PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams extends OperationOptions { +} + +// @public +export interface PolicySetDefinitionVersionsCreateOrUpdateOptionalParams extends OperationOptions { +} + +// @public +export interface PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams extends OperationOptions { +} + +// @public +export interface PolicySetDefinitionVersionsDeleteOptionalParams extends OperationOptions { +} + +// @public +export interface PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams extends OperationOptions { + expand?: string; +} + +// @public +export interface PolicySetDefinitionVersionsGetBuiltInOptionalParams extends OperationOptions { + expand?: string; +} + +// @public +export interface PolicySetDefinitionVersionsGetOptionalParams extends OperationOptions { + expand?: string; +} + +// @public +export interface PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams extends OperationOptions { +} + +// @public +export interface PolicySetDefinitionVersionsListAllBuiltinsOptionalParams extends OperationOptions { +} + +// @public +export interface PolicySetDefinitionVersionsListAllOptionalParams extends OperationOptions { +} + +// @public +export interface PolicySetDefinitionVersionsListBuiltInOptionalParams extends OperationOptions { + expand?: string; + top?: number; +} + +// @public +export interface PolicySetDefinitionVersionsListByManagementGroupOptionalParams extends OperationOptions { + expand?: string; + top?: number; +} + +// @public +export interface PolicySetDefinitionVersionsListOptionalParams extends OperationOptions { + expand?: string; + top?: number; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/policy/arm-policy/review/arm-policy-api-policySetDefinitions-node.api.md b/sdk/policy/arm-policy/review/arm-policy-api-policySetDefinitions-node.api.md new file mode 100644 index 000000000000..409348db1da9 --- /dev/null +++ b/sdk/policy/arm-policy/review/arm-policy-api-policySetDefinitions-node.api.md @@ -0,0 +1,94 @@ +## API Report File for "@azure/arm-policy" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { Client } from '@azure-rest/core-client'; +import type { OperationOptions } from '@azure-rest/core-client'; + +// @public +export function $delete(context: PolicyContext, policySetDefinitionName: string, options?: PolicySetDefinitionsDeleteOptionalParams): Promise; + +// @public +export function createOrUpdate(context: PolicyContext, policySetDefinitionName: string, parameters: PolicySetDefinition, options?: PolicySetDefinitionsCreateOrUpdateOptionalParams): Promise; + +// @public +export function createOrUpdateAtManagementGroup(context: PolicyContext, managementGroupId: string, policySetDefinitionName: string, parameters: PolicySetDefinition, options?: PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams): Promise; + +// @public +export function deleteAtManagementGroup(context: PolicyContext, managementGroupId: string, policySetDefinitionName: string, options?: PolicySetDefinitionsDeleteAtManagementGroupOptionalParams): Promise; + +// @public +export function get(context: PolicyContext, policySetDefinitionName: string, options?: PolicySetDefinitionsGetOptionalParams): Promise; + +// @public +export function getAtManagementGroup(context: PolicyContext, managementGroupId: string, policySetDefinitionName: string, options?: PolicySetDefinitionsGetAtManagementGroupOptionalParams): Promise; + +// @public +export function getBuiltIn(context: PolicyContext, policySetDefinitionName: string, options?: PolicySetDefinitionsGetBuiltInOptionalParams): Promise; + +// @public +export function list(context: PolicyContext, options?: PolicySetDefinitionsListOptionalParams): PagedAsyncIterableIterator; + +// @public +export function listBuiltIn(context: PolicyContext, options?: PolicySetDefinitionsListBuiltInOptionalParams): PagedAsyncIterableIterator; + +// @public +export function listByManagementGroup(context: PolicyContext, managementGroupId: string, options?: PolicySetDefinitionsListByManagementGroupOptionalParams): PagedAsyncIterableIterator; + +// @public +export interface PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams extends OperationOptions { +} + +// @public +export interface PolicySetDefinitionsCreateOrUpdateOptionalParams extends OperationOptions { +} + +// @public +export interface PolicySetDefinitionsDeleteAtManagementGroupOptionalParams extends OperationOptions { +} + +// @public +export interface PolicySetDefinitionsDeleteOptionalParams extends OperationOptions { +} + +// @public +export interface PolicySetDefinitionsGetAtManagementGroupOptionalParams extends OperationOptions { + expand?: string; +} + +// @public +export interface PolicySetDefinitionsGetBuiltInOptionalParams extends OperationOptions { + expand?: string; +} + +// @public +export interface PolicySetDefinitionsGetOptionalParams extends OperationOptions { + expand?: string; +} + +// @public +export interface PolicySetDefinitionsListBuiltInOptionalParams extends OperationOptions { + expand?: string; + filter?: string; + top?: number; +} + +// @public +export interface PolicySetDefinitionsListByManagementGroupOptionalParams extends OperationOptions { + expand?: string; + filter?: string; + top?: number; +} + +// @public +export interface PolicySetDefinitionsListOptionalParams extends OperationOptions { + expand?: string; + filter?: string; + top?: number; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/policy/arm-policy/review/arm-policy-api-policyTokens-node.api.md b/sdk/policy/arm-policy/review/arm-policy-api-policyTokens-node.api.md new file mode 100644 index 000000000000..45c3b6227b2d --- /dev/null +++ b/sdk/policy/arm-policy/review/arm-policy-api-policyTokens-node.api.md @@ -0,0 +1,26 @@ +## API Report File for "@azure/arm-policy" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { Client } from '@azure-rest/core-client'; +import type { OperationOptions } from '@azure-rest/core-client'; + +// @public +export function acquire(context: PolicyContext, parameters: PolicyTokenRequest, options?: PolicyTokensAcquireOptionalParams): Promise; + +// @public +export function acquireAtManagementGroup(context: PolicyContext, managementGroupName: string, parameters: PolicyTokenRequest, options?: PolicyTokensAcquireAtManagementGroupOptionalParams): Promise; + +// @public +export interface PolicyTokensAcquireAtManagementGroupOptionalParams extends OperationOptions { +} + +// @public +export interface PolicyTokensAcquireOptionalParams extends OperationOptions { +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/policy/arm-policy/review/arm-policy-models-node.api.md b/sdk/policy/arm-policy/review/arm-policy-models-node.api.md new file mode 100644 index 000000000000..5298c705094f --- /dev/null +++ b/sdk/policy/arm-policy/review/arm-policy-models-node.api.md @@ -0,0 +1,475 @@ +## API Report File for "@azure/arm-policy" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +// @public +export type AssignmentType = string; + +// @public +export type CreatedByType = string; + +// @public +export type EnforcementMode = string; + +// @public +export interface ErrorAdditionalInfo { + readonly info?: any; + readonly type?: string; +} + +// @public +export interface ErrorDetail { + readonly additionalInfo?: ErrorAdditionalInfo[]; + readonly code?: string; + readonly details?: ErrorDetail[]; + readonly message?: string; + readonly target?: string; +} + +// @public +export interface ErrorResponse { + error?: ErrorDetail; +} + +// @public +export interface ExtensionResource extends Resource { +} + +// @public +export type ExternalEndpointResult = string; + +// @public +export interface ExternalEvaluationEndpointInvocationResult { + claims?: any; + expiration?: Date; + message?: string; + policyInfo?: PolicyLogInfo; + result?: ExternalEndpointResult; + retryAfter?: Date; +} + +// @public +export interface ExternalEvaluationEndpointSettings { + details?: any; + kind?: string; +} + +// @public +export interface ExternalEvaluationEnforcementSettings { + endpointSettings?: ExternalEvaluationEndpointSettings; + missingTokenAction?: string; + resultLifespan?: string; + roleDefinitionIds?: string[]; +} + +// @public +export interface Identity { + readonly principalId?: string; + readonly tenantId?: string; + type?: ResourceIdentityType; + userAssignedIdentities?: Record; +} + +// @public +export enum KnownAssignmentType { + Custom = "Custom", + NotSpecified = "NotSpecified", + System = "System", + SystemHidden = "SystemHidden" +} + +// @public +export enum KnownCreatedByType { + Application = "Application", + Key = "Key", + ManagedIdentity = "ManagedIdentity", + User = "User" +} + +// @public +export enum KnownEnforcementMode { + Default = "Default", + DoNotEnforce = "DoNotEnforce", + Enroll = "Enroll" +} + +// @public +export enum KnownExternalEndpointResult { + Failed = "Failed", + Succeeded = "Succeeded" +} + +// @public +export enum KnownOverrideKind { + DefinitionVersion = "definitionVersion", + PolicyEffect = "policyEffect" +} + +// @public +export enum KnownParameterType { + Array = "Array", + Boolean = "Boolean", + DateTime = "DateTime", + Float = "Float", + Integer = "Integer", + Object = "Object", + String = "String" +} + +// @public +export enum KnownPolicyTokenResult { + Failed = "Failed", + Succeeded = "Succeeded" +} + +// @public +export enum KnownPolicyType { + BuiltIn = "BuiltIn", + Custom = "Custom", + NotSpecified = "NotSpecified", + Static = "Static" +} + +// @public +export enum KnownSelectorKind { + PolicyDefinitionReferenceId = "policyDefinitionReferenceId", + ResourceLocation = "resourceLocation", + ResourceType = "resourceType", + ResourceWithoutLocation = "resourceWithoutLocation" +} + +// @public +export enum KnownVersions { + V20250301 = "2025-03-01" +} + +// @public +export interface NonComplianceMessage { + message: string; + policyDefinitionReferenceId?: string; +} + +// @public +export interface Override { + kind?: OverrideKind; + selectors?: Selector[]; + value?: string; +} + +// @public +export type OverrideKind = string; + +// @public +export interface ParameterDefinitionsValue { + allowedValues?: any[]; + defaultValue?: any; + metadata?: ParameterDefinitionsValueMetadata; + schema?: any; + type?: ParameterType; +} + +// @public +export interface ParameterDefinitionsValueMetadata { + additionalProperties?: Record; + assignPermissions?: boolean; + description?: string; + displayName?: string; + strongType?: string; +} + +// @public +export type ParameterType = string; + +// @public +export interface ParameterValuesValue { + value?: any; +} + +// @public +export interface PolicyAssignment extends ExtensionResource { + assignmentType?: AssignmentType; + definitionVersion?: string; + description?: string; + displayName?: string; + readonly effectiveDefinitionVersion?: string; + enforcementMode?: EnforcementMode; + identity?: Identity; + readonly instanceId?: string; + readonly latestDefinitionVersion?: string; + location?: string; + metadata?: any; + nonComplianceMessages?: NonComplianceMessage[]; + notScopes?: string[]; + overrides?: Override[]; + parameters?: Record; + policyDefinitionId?: string; + resourceSelectors?: ResourceSelector[]; + readonly scope?: string; +} + +// @public +export interface PolicyAssignmentProperties { + assignmentType?: AssignmentType; + definitionVersion?: string; + description?: string; + displayName?: string; + readonly effectiveDefinitionVersion?: string; + enforcementMode?: EnforcementMode; + readonly instanceId?: string; + readonly latestDefinitionVersion?: string; + metadata?: any; + nonComplianceMessages?: NonComplianceMessage[]; + notScopes?: string[]; + overrides?: Override[]; + parameters?: Record; + policyDefinitionId?: string; + resourceSelectors?: ResourceSelector[]; + readonly scope?: string; +} + +// @public +export interface PolicyAssignmentUpdate { + identity?: Identity; + location?: string; + overrides?: Override[]; + resourceSelectors?: ResourceSelector[]; +} + +// @public +export interface PolicyAssignmentUpdateProperties { + overrides?: Override[]; + resourceSelectors?: ResourceSelector[]; +} + +// @public +export interface PolicyDefinition extends ProxyResource { + description?: string; + displayName?: string; + externalEvaluationEnforcementSettings?: ExternalEvaluationEnforcementSettings; + metadata?: any; + mode?: string; + parameters?: Record; + policyRule?: any; + policyType?: PolicyType; + version?: string; + versions?: string[]; +} + +// @public +export interface PolicyDefinitionGroup { + additionalMetadataId?: string; + category?: string; + description?: string; + displayName?: string; + name: string; +} + +// @public +export interface PolicyDefinitionProperties { + description?: string; + displayName?: string; + externalEvaluationEnforcementSettings?: ExternalEvaluationEnforcementSettings; + metadata?: any; + mode?: string; + parameters?: Record; + policyRule?: any; + policyType?: PolicyType; + version?: string; + versions?: string[]; +} + +// @public +export interface PolicyDefinitionReference { + definitionVersion?: string; + readonly effectiveDefinitionVersion?: string; + groupNames?: string[]; + readonly latestDefinitionVersion?: string; + parameters?: Record; + policyDefinitionId: string; + policyDefinitionReferenceId?: string; +} + +// @public +export interface PolicyDefinitionVersion extends ProxyResource { + description?: string; + displayName?: string; + externalEvaluationEnforcementSettings?: ExternalEvaluationEnforcementSettings; + metadata?: any; + mode?: string; + parameters?: Record; + policyRule?: any; + policyType?: PolicyType; + version?: string; +} + +// @public +export interface PolicyDefinitionVersionProperties { + description?: string; + displayName?: string; + externalEvaluationEnforcementSettings?: ExternalEvaluationEnforcementSettings; + metadata?: any; + mode?: string; + parameters?: Record; + policyRule?: any; + policyType?: PolicyType; + version?: string; +} + +// @public +export interface PolicyLogInfo { + ancestors?: string; + complianceReasonCode?: string; + policyAssignmentDisplayName?: string; + policyAssignmentId?: string; + policyAssignmentName?: string; + policyAssignmentScope?: string; + policyAssignmentVersion?: string; + policyDefinitionDisplayName?: string; + policyDefinitionEffect?: string; + policyDefinitionGroupNames?: string[]; + policyDefinitionId?: string; + policyDefinitionName?: string; + policyDefinitionReferenceId?: string; + policyDefinitionVersion?: string; + policyExemptionIds?: string[]; + policySetDefinitionCategory?: string; + policySetDefinitionDisplayName?: string; + policySetDefinitionId?: string; + policySetDefinitionName?: string; + policySetDefinitionVersion?: string; + resourceLocation?: string; +} + +// @public +export interface PolicySetDefinition extends ProxyResource { + description?: string; + displayName?: string; + metadata?: any; + parameters?: Record; + policyDefinitionGroups?: PolicyDefinitionGroup[]; + policyDefinitions?: PolicyDefinitionReference[]; + policyType?: PolicyType; + version?: string; + versions?: string[]; +} + +// @public +export interface PolicySetDefinitionProperties { + description?: string; + displayName?: string; + metadata?: any; + parameters?: Record; + policyDefinitionGroups?: PolicyDefinitionGroup[]; + policyDefinitions: PolicyDefinitionReference[]; + policyType?: PolicyType; + version?: string; + versions?: string[]; +} + +// @public +export interface PolicySetDefinitionVersion extends ProxyResource { + description?: string; + displayName?: string; + metadata?: any; + parameters?: Record; + policyDefinitionGroups?: PolicyDefinitionGroup[]; + policyDefinitions?: PolicyDefinitionReference[]; + policyType?: PolicyType; + version?: string; +} + +// @public +export interface PolicySetDefinitionVersionProperties { + description?: string; + displayName?: string; + metadata?: any; + parameters?: Record; + policyDefinitionGroups?: PolicyDefinitionGroup[]; + policyDefinitions: PolicyDefinitionReference[]; + policyType?: PolicyType; + version?: string; +} + +// @public +export interface PolicyTokenOperation { + content?: any; + httpMethod: string; + uri: string; +} + +// @public +export interface PolicyTokenRequest { + changeReference?: string; + operation: PolicyTokenOperation; +} + +// @public +export interface PolicyTokenResponse { + changeReference?: string; + expiration?: Date; + message?: string; + result?: PolicyTokenResult; + results?: ExternalEvaluationEndpointInvocationResult[]; + retryAfter?: Date; + token?: string; + tokenId?: string; +} + +// @public +export type PolicyTokenResult = string; + +// @public +export type PolicyType = string; + +// @public +export interface ProxyResource extends Resource { +} + +// @public +export interface Resource { + readonly id?: string; + readonly name?: string; + readonly systemData?: SystemData; + readonly type?: string; +} + +// @public +export type ResourceIdentityType = "SystemAssigned" | "UserAssigned" | "None"; + +// @public +export interface ResourceSelector { + name?: string; + selectors?: Selector[]; +} + +// @public +export interface Selector { + in?: string[]; + kind?: SelectorKind; + notIn?: string[]; +} + +// @public +export type SelectorKind = string; + +// @public +export interface SystemData { + createdAt?: Date; + createdBy?: string; + createdByType?: CreatedByType; + lastModifiedAt?: Date; + lastModifiedBy?: string; + lastModifiedByType?: CreatedByType; +} + +// @public +export interface UserAssignedIdentitiesValue { + readonly clientId?: string; + readonly principalId?: string; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/policy/arm-policy/review/arm-policy-node.api.md b/sdk/policy/arm-policy/review/arm-policy-node.api.md index 5b02cdea5da1..c52306c470fd 100644 --- a/sdk/policy/arm-policy/review/arm-policy-node.api.md +++ b/sdk/policy/arm-policy/review/arm-policy-node.api.md @@ -4,18 +4,29 @@ ```ts -import type * as coreAuth from '@azure/core-auth'; -import * as coreClient from '@azure/core-client'; -import type { PagedAsyncIterableIterator } from '@azure/core-paging'; +import type { ClientOptions } from '@azure-rest/core-client'; +import type { OperationOptions } from '@azure-rest/core-client'; +import type { Pipeline } from '@azure/core-rest-pipeline'; +import type { TokenCredential } from '@azure/core-auth'; // @public export type AssignmentType = string; // @public -export interface CloudError { - error?: ErrorResponse; +export enum AzureClouds { + AZURE_CHINA_CLOUD = "AZURE_CHINA_CLOUD", + AZURE_PUBLIC_CLOUD = "AZURE_PUBLIC_CLOUD", + AZURE_US_GOVERNMENT = "AZURE_US_GOVERNMENT" } +// @public +export type AzureSupportedClouds = `${AzureClouds}`; + +// @public +export type ContinuablePage = TPage & { + continuationToken?: string; +}; + // @public export type CreatedByType = string; @@ -29,25 +40,56 @@ export interface ErrorAdditionalInfo { } // @public -export interface ErrorResponse { +export interface ErrorDetail { readonly additionalInfo?: ErrorAdditionalInfo[]; readonly code?: string; - readonly details?: ErrorResponse[]; + readonly details?: ErrorDetail[]; readonly message?: string; readonly target?: string; } // @public -export function getContinuationToken(page: unknown): string | undefined; +export interface ErrorResponse { + error?: ErrorDetail; +} + +// @public +export interface ExtensionResource extends Resource { +} + +// @public +export type ExternalEndpointResult = string; + +// @public +export interface ExternalEvaluationEndpointInvocationResult { + claims?: any; + expiration?: Date; + message?: string; + policyInfo?: PolicyLogInfo; + result?: ExternalEndpointResult; + retryAfter?: Date; +} + +// @public +export interface ExternalEvaluationEndpointSettings { + details?: any; + kind?: string; +} + +// @public +export interface ExternalEvaluationEnforcementSettings { + endpointSettings?: ExternalEvaluationEndpointSettings; + missingTokenAction?: string; + resultLifespan?: string; + roleDefinitionIds?: string[]; +} // @public export interface Identity { readonly principalId?: string; readonly tenantId?: string; type?: ResourceIdentityType; - userAssignedIdentities?: { - [propertyName: string]: UserAssignedIdentitiesValue; - }; + userAssignedIdentities?: Record; } // @public @@ -69,7 +111,14 @@ export enum KnownCreatedByType { // @public export enum KnownEnforcementMode { Default = "Default", - DoNotEnforce = "DoNotEnforce" + DoNotEnforce = "DoNotEnforce", + Enroll = "Enroll" +} + +// @public +export enum KnownExternalEndpointResult { + Failed = "Failed", + Succeeded = "Succeeded" } // @public @@ -89,6 +138,12 @@ export enum KnownParameterType { String = "String" } +// @public +export enum KnownPolicyTokenResult { + Failed = "Failed", + Succeeded = "Succeeded" +} + // @public export enum KnownPolicyType { BuiltIn = "BuiltIn", @@ -105,6 +160,11 @@ export enum KnownSelectorKind { ResourceWithoutLocation = "resourceWithoutLocation" } +// @public +export enum KnownVersions { + V20250301 = "2025-03-01" +} + // @public export interface NonComplianceMessage { message: string; @@ -121,6 +181,18 @@ export interface Override { // @public export type OverrideKind = string; +// @public +export interface PagedAsyncIterableIterator { + [Symbol.asyncIterator](): PagedAsyncIterableIterator; + byPage: (settings?: TPageSettings) => AsyncIterableIterator>; + next(): Promise>; +} + +// @public +export interface PageSettings { + continuationToken?: string; +} + // @public export interface ParameterDefinitionsValue { allowedValues?: any[]; @@ -132,7 +204,7 @@ export interface ParameterDefinitionsValue { // @public export interface ParameterDefinitionsValueMetadata { - [property: string]: any; + additionalProperties?: Record; assignPermissions?: boolean; description?: string; displayName?: string; @@ -148,180 +220,104 @@ export interface ParameterValuesValue { } // @public -export interface PolicyAssignment { +export interface PolicyAssignment extends ExtensionResource { assignmentType?: AssignmentType; definitionVersion?: string; description?: string; displayName?: string; readonly effectiveDefinitionVersion?: string; enforcementMode?: EnforcementMode; - readonly id?: string; identity?: Identity; + readonly instanceId?: string; readonly latestDefinitionVersion?: string; location?: string; metadata?: any; - readonly name?: string; nonComplianceMessages?: NonComplianceMessage[]; notScopes?: string[]; overrides?: Override[]; - parameters?: { - [propertyName: string]: ParameterValuesValue; - }; + parameters?: Record; policyDefinitionId?: string; resourceSelectors?: ResourceSelector[]; readonly scope?: string; - readonly systemData?: SystemData; - readonly type?: string; } // @public -export interface PolicyAssignmentListResult { - nextLink?: string; - value?: PolicyAssignment[]; -} - -// @public -export interface PolicyAssignments { - create(scope: string, policyAssignmentName: string, parameters: PolicyAssignment, options?: PolicyAssignmentsCreateOptionalParams): Promise; - createById(policyAssignmentId: string, parameters: PolicyAssignment, options?: PolicyAssignmentsCreateByIdOptionalParams): Promise; - delete(scope: string, policyAssignmentName: string, options?: PolicyAssignmentsDeleteOptionalParams): Promise; - deleteById(policyAssignmentId: string, options?: PolicyAssignmentsDeleteByIdOptionalParams): Promise; - get(scope: string, policyAssignmentName: string, options?: PolicyAssignmentsGetOptionalParams): Promise; - getById(policyAssignmentId: string, options?: PolicyAssignmentsGetByIdOptionalParams): Promise; - list(options?: PolicyAssignmentsListOptionalParams): PagedAsyncIterableIterator; - listForManagementGroup(managementGroupId: string, options?: PolicyAssignmentsListForManagementGroupOptionalParams): PagedAsyncIterableIterator; - listForResource(resourceGroupName: string, resourceProviderNamespace: string, parentResourcePath: string, resourceType: string, resourceName: string, options?: PolicyAssignmentsListForResourceOptionalParams): PagedAsyncIterableIterator; - listForResourceGroup(resourceGroupName: string, options?: PolicyAssignmentsListForResourceGroupOptionalParams): PagedAsyncIterableIterator; - update(scope: string, policyAssignmentName: string, parameters: PolicyAssignmentUpdate, options?: PolicyAssignmentsUpdateOptionalParams): Promise; - updateById(policyAssignmentId: string, parameters: PolicyAssignmentUpdate, options?: PolicyAssignmentsUpdateByIdOptionalParams): Promise; -} - -// @public -export interface PolicyAssignmentsCreateByIdOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type PolicyAssignmentsCreateByIdResponse = PolicyAssignment; - -// @public -export interface PolicyAssignmentsCreateOptionalParams extends coreClient.OperationOptions { +export interface PolicyAssignmentProperties { + assignmentType?: AssignmentType; + definitionVersion?: string; + description?: string; + displayName?: string; + readonly effectiveDefinitionVersion?: string; + enforcementMode?: EnforcementMode; + readonly instanceId?: string; + readonly latestDefinitionVersion?: string; + metadata?: any; + nonComplianceMessages?: NonComplianceMessage[]; + notScopes?: string[]; + overrides?: Override[]; + parameters?: Record; + policyDefinitionId?: string; + resourceSelectors?: ResourceSelector[]; + readonly scope?: string; } // @public -export type PolicyAssignmentsCreateResponse = PolicyAssignment; - -// @public -export interface PolicyAssignmentsDeleteByIdOptionalParams extends coreClient.OperationOptions { +export interface PolicyAssignmentsCreateOptionalParams extends OperationOptions { } // @public -export type PolicyAssignmentsDeleteByIdResponse = PolicyAssignment; - -// @public -export interface PolicyAssignmentsDeleteOptionalParams extends coreClient.OperationOptions { +export interface PolicyAssignmentsDeleteOptionalParams extends OperationOptions { } // @public -export type PolicyAssignmentsDeleteResponse = PolicyAssignment; - -// @public -export interface PolicyAssignmentsGetByIdOptionalParams extends coreClient.OperationOptions { +export interface PolicyAssignmentsGetOptionalParams extends OperationOptions { expand?: string; } // @public -export type PolicyAssignmentsGetByIdResponse = PolicyAssignment; - -// @public -export interface PolicyAssignmentsGetOptionalParams extends coreClient.OperationOptions { - expand?: string; -} - -// @public -export type PolicyAssignmentsGetResponse = PolicyAssignment; - -// @public -export interface PolicyAssignmentsListForManagementGroupNextOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type PolicyAssignmentsListForManagementGroupNextResponse = PolicyAssignmentListResult; - -// @public -export interface PolicyAssignmentsListForManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicyAssignmentsListForManagementGroupOptionalParams extends OperationOptions { expand?: string; filter?: string; top?: number; } // @public -export type PolicyAssignmentsListForManagementGroupResponse = PolicyAssignmentListResult; - -// @public -export interface PolicyAssignmentsListForResourceGroupNextOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type PolicyAssignmentsListForResourceGroupNextResponse = PolicyAssignmentListResult; - -// @public -export interface PolicyAssignmentsListForResourceGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicyAssignmentsListForResourceGroupOptionalParams extends OperationOptions { expand?: string; filter?: string; top?: number; } // @public -export type PolicyAssignmentsListForResourceGroupResponse = PolicyAssignmentListResult; - -// @public -export interface PolicyAssignmentsListForResourceNextOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type PolicyAssignmentsListForResourceNextResponse = PolicyAssignmentListResult; - -// @public -export interface PolicyAssignmentsListForResourceOptionalParams extends coreClient.OperationOptions { +export interface PolicyAssignmentsListForResourceOptionalParams extends OperationOptions { expand?: string; filter?: string; top?: number; } // @public -export type PolicyAssignmentsListForResourceResponse = PolicyAssignmentListResult; - -// @public -export interface PolicyAssignmentsListNextOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type PolicyAssignmentsListNextResponse = PolicyAssignmentListResult; - -// @public -export interface PolicyAssignmentsListOptionalParams extends coreClient.OperationOptions { +export interface PolicyAssignmentsListOptionalParams extends OperationOptions { expand?: string; filter?: string; top?: number; } // @public -export type PolicyAssignmentsListResponse = PolicyAssignmentListResult; - -// @public -export interface PolicyAssignmentsUpdateByIdOptionalParams extends coreClient.OperationOptions { +export interface PolicyAssignmentsOperations { + create: (scope: string, policyAssignmentName: string, parameters: PolicyAssignment, options?: PolicyAssignmentsCreateOptionalParams) => Promise; + delete: (scope: string, policyAssignmentName: string, options?: PolicyAssignmentsDeleteOptionalParams) => Promise; + get: (scope: string, policyAssignmentName: string, options?: PolicyAssignmentsGetOptionalParams) => Promise; + list: (options?: PolicyAssignmentsListOptionalParams) => PagedAsyncIterableIterator; + listForManagementGroup: (managementGroupId: string, options?: PolicyAssignmentsListForManagementGroupOptionalParams) => PagedAsyncIterableIterator; + listForResource: (resourceGroupName: string, resourceProviderNamespace: string, parentResourcePath: string, resourceType: string, resourceName: string, options?: PolicyAssignmentsListForResourceOptionalParams) => PagedAsyncIterableIterator; + listForResourceGroup: (resourceGroupName: string, options?: PolicyAssignmentsListForResourceGroupOptionalParams) => PagedAsyncIterableIterator; + update: (scope: string, policyAssignmentName: string, parameters: PolicyAssignmentUpdate, options?: PolicyAssignmentsUpdateOptionalParams) => Promise; } // @public -export type PolicyAssignmentsUpdateByIdResponse = PolicyAssignment; - -// @public -export interface PolicyAssignmentsUpdateOptionalParams extends coreClient.OperationOptions { +export interface PolicyAssignmentsUpdateOptionalParams extends OperationOptions { } -// @public -export type PolicyAssignmentsUpdateResponse = PolicyAssignment; - // @public export interface PolicyAssignmentUpdate { identity?: Identity; @@ -330,50 +326,41 @@ export interface PolicyAssignmentUpdate { resourceSelectors?: ResourceSelector[]; } +// @public +export interface PolicyAssignmentUpdateProperties { + overrides?: Override[]; + resourceSelectors?: ResourceSelector[]; +} + // @public (undocumented) -export class PolicyClient extends coreClient.ServiceClient { - // (undocumented) - $host: string; - constructor(credentials: coreAuth.TokenCredential, subscriptionId: string, options?: PolicyClientOptionalParams); - constructor(credentials: coreAuth.TokenCredential, options?: PolicyClientOptionalParams); - // (undocumented) - apiVersion: string; - // (undocumented) - policyAssignments: PolicyAssignments; - // (undocumented) - policyDefinitions: PolicyDefinitions; - // (undocumented) - policyDefinitionVersions: PolicyDefinitionVersions; - // (undocumented) - policySetDefinitions: PolicySetDefinitions; - // (undocumented) - policySetDefinitionVersions: PolicySetDefinitionVersions; - // (undocumented) - subscriptionId?: string; -} - -// @public -export interface PolicyClientOptionalParams extends coreClient.ServiceClientOptions { - $host?: string; +export class PolicyClient { + constructor(credential: TokenCredential, options?: PolicyClientOptionalParams); + constructor(credential: TokenCredential, subscriptionId: string, options?: PolicyClientOptionalParams); + readonly pipeline: Pipeline; + readonly policyAssignments: PolicyAssignmentsOperations; + readonly policyDefinitions: PolicyDefinitionsOperations; + readonly policyDefinitionVersions: PolicyDefinitionVersionsOperations; + readonly policySetDefinitions: PolicySetDefinitionsOperations; + readonly policySetDefinitionVersions: PolicySetDefinitionVersionsOperations; + readonly policyTokens: PolicyTokensOperations; +} + +// @public +export interface PolicyClientOptionalParams extends ClientOptions { apiVersion?: string; - endpoint?: string; + cloudSetting?: AzureSupportedClouds; } // @public -export interface PolicyDefinition { +export interface PolicyDefinition extends ProxyResource { description?: string; displayName?: string; - readonly id?: string; + externalEvaluationEnforcementSettings?: ExternalEvaluationEnforcementSettings; metadata?: any; mode?: string; - readonly name?: string; - parameters?: { - [propertyName: string]: ParameterDefinitionsValue; - }; + parameters?: Record; policyRule?: any; policyType?: PolicyType; - readonly systemData?: SystemData; - readonly type?: string; version?: string; versions?: string[]; } @@ -388,9 +375,17 @@ export interface PolicyDefinitionGroup { } // @public -export interface PolicyDefinitionListResult { - nextLink?: string; - value?: PolicyDefinition[]; +export interface PolicyDefinitionProperties { + description?: string; + displayName?: string; + externalEvaluationEnforcementSettings?: ExternalEvaluationEnforcementSettings; + metadata?: any; + mode?: string; + parameters?: Record; + policyRule?: any; + policyType?: PolicyType; + version?: string; + versions?: string[]; } // @public @@ -399,562 +394,446 @@ export interface PolicyDefinitionReference { readonly effectiveDefinitionVersion?: string; groupNames?: string[]; readonly latestDefinitionVersion?: string; - parameters?: { - [propertyName: string]: ParameterValuesValue; - }; + parameters?: Record; policyDefinitionId: string; policyDefinitionReferenceId?: string; } // @public -export interface PolicyDefinitions { - createOrUpdate(policyDefinitionName: string, parameters: PolicyDefinition, options?: PolicyDefinitionsCreateOrUpdateOptionalParams): Promise; - createOrUpdateAtManagementGroup(managementGroupId: string, policyDefinitionName: string, parameters: PolicyDefinition, options?: PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams): Promise; - delete(policyDefinitionName: string, options?: PolicyDefinitionsDeleteOptionalParams): Promise; - deleteAtManagementGroup(managementGroupId: string, policyDefinitionName: string, options?: PolicyDefinitionsDeleteAtManagementGroupOptionalParams): Promise; - get(policyDefinitionName: string, options?: PolicyDefinitionsGetOptionalParams): Promise; - getAtManagementGroup(managementGroupId: string, policyDefinitionName: string, options?: PolicyDefinitionsGetAtManagementGroupOptionalParams): Promise; - getBuiltIn(policyDefinitionName: string, options?: PolicyDefinitionsGetBuiltInOptionalParams): Promise; - list(options?: PolicyDefinitionsListOptionalParams): PagedAsyncIterableIterator; - listBuiltIn(options?: PolicyDefinitionsListBuiltInOptionalParams): PagedAsyncIterableIterator; - listByManagementGroup(managementGroupId: string, options?: PolicyDefinitionsListByManagementGroupOptionalParams): PagedAsyncIterableIterator; +export interface PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams extends OperationOptions { } // @public -export interface PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionsCreateOrUpdateOptionalParams extends OperationOptions { } // @public -export type PolicyDefinitionsCreateOrUpdateAtManagementGroupResponse = PolicyDefinition; - -// @public -export interface PolicyDefinitionsCreateOrUpdateOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionsDeleteAtManagementGroupOptionalParams extends OperationOptions { } // @public -export type PolicyDefinitionsCreateOrUpdateResponse = PolicyDefinition; - -// @public -export interface PolicyDefinitionsDeleteAtManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionsDeleteOptionalParams extends OperationOptions { } // @public -export interface PolicyDefinitionsDeleteOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionsGetAtManagementGroupOptionalParams extends OperationOptions { } // @public -export interface PolicyDefinitionsGetAtManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionsGetBuiltInOptionalParams extends OperationOptions { } // @public -export type PolicyDefinitionsGetAtManagementGroupResponse = PolicyDefinition; - -// @public -export interface PolicyDefinitionsGetBuiltInOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionsGetOptionalParams extends OperationOptions { } // @public -export type PolicyDefinitionsGetBuiltInResponse = PolicyDefinition; - -// @public -export interface PolicyDefinitionsGetOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type PolicyDefinitionsGetResponse = PolicyDefinition; - -// @public -export interface PolicyDefinitionsListBuiltInNextOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type PolicyDefinitionsListBuiltInNextResponse = PolicyDefinitionListResult; - -// @public -export interface PolicyDefinitionsListBuiltInOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionsListBuiltInOptionalParams extends OperationOptions { filter?: string; top?: number; } // @public -export type PolicyDefinitionsListBuiltInResponse = PolicyDefinitionListResult; - -// @public -export interface PolicyDefinitionsListByManagementGroupNextOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type PolicyDefinitionsListByManagementGroupNextResponse = PolicyDefinitionListResult; - -// @public -export interface PolicyDefinitionsListByManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionsListByManagementGroupOptionalParams extends OperationOptions { filter?: string; top?: number; } // @public -export type PolicyDefinitionsListByManagementGroupResponse = PolicyDefinitionListResult; - -// @public -export interface PolicyDefinitionsListNextOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type PolicyDefinitionsListNextResponse = PolicyDefinitionListResult; - -// @public -export interface PolicyDefinitionsListOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionsListOptionalParams extends OperationOptions { filter?: string; top?: number; } // @public -export type PolicyDefinitionsListResponse = PolicyDefinitionListResult; +export interface PolicyDefinitionsOperations { + createOrUpdate: (policyDefinitionName: string, parameters: PolicyDefinition, options?: PolicyDefinitionsCreateOrUpdateOptionalParams) => Promise; + createOrUpdateAtManagementGroup: (managementGroupId: string, policyDefinitionName: string, parameters: PolicyDefinition, options?: PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams) => Promise; + delete: (policyDefinitionName: string, options?: PolicyDefinitionsDeleteOptionalParams) => Promise; + deleteAtManagementGroup: (managementGroupId: string, policyDefinitionName: string, options?: PolicyDefinitionsDeleteAtManagementGroupOptionalParams) => Promise; + get: (policyDefinitionName: string, options?: PolicyDefinitionsGetOptionalParams) => Promise; + getAtManagementGroup: (managementGroupId: string, policyDefinitionName: string, options?: PolicyDefinitionsGetAtManagementGroupOptionalParams) => Promise; + getBuiltIn: (policyDefinitionName: string, options?: PolicyDefinitionsGetBuiltInOptionalParams) => Promise; + list: (options?: PolicyDefinitionsListOptionalParams) => PagedAsyncIterableIterator; + listBuiltIn: (options?: PolicyDefinitionsListBuiltInOptionalParams) => PagedAsyncIterableIterator; + listByManagementGroup: (managementGroupId: string, options?: PolicyDefinitionsListByManagementGroupOptionalParams) => PagedAsyncIterableIterator; +} // @public -export interface PolicyDefinitionVersion { +export interface PolicyDefinitionVersion extends ProxyResource { description?: string; displayName?: string; - readonly id?: string; + externalEvaluationEnforcementSettings?: ExternalEvaluationEnforcementSettings; metadata?: any; mode?: string; - readonly name?: string; - parameters?: { - [propertyName: string]: ParameterDefinitionsValue; - }; + parameters?: Record; policyRule?: any; policyType?: PolicyType; - readonly systemData?: SystemData; - readonly type?: string; version?: string; } // @public -export interface PolicyDefinitionVersionListResult { - nextLink?: string; - value?: PolicyDefinitionVersion[]; -} - -// @public -export interface PolicyDefinitionVersions { - createOrUpdate(policyDefinitionName: string, policyDefinitionVersion: string, parameters: PolicyDefinitionVersion, options?: PolicyDefinitionVersionsCreateOrUpdateOptionalParams): Promise; - createOrUpdateAtManagementGroup(managementGroupName: string, policyDefinitionName: string, policyDefinitionVersion: string, parameters: PolicyDefinitionVersion, options?: PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams): Promise; - delete(policyDefinitionName: string, policyDefinitionVersion: string, options?: PolicyDefinitionVersionsDeleteOptionalParams): Promise; - deleteAtManagementGroup(managementGroupName: string, policyDefinitionName: string, policyDefinitionVersion: string, options?: PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams): Promise; - get(policyDefinitionName: string, policyDefinitionVersion: string, options?: PolicyDefinitionVersionsGetOptionalParams): Promise; - getAtManagementGroup(managementGroupName: string, policyDefinitionName: string, policyDefinitionVersion: string, options?: PolicyDefinitionVersionsGetAtManagementGroupOptionalParams): Promise; - getBuiltIn(policyDefinitionName: string, policyDefinitionVersion: string, options?: PolicyDefinitionVersionsGetBuiltInOptionalParams): Promise; - list(policyDefinitionName: string, options?: PolicyDefinitionVersionsListOptionalParams): PagedAsyncIterableIterator; - listAll(options?: PolicyDefinitionVersionsListAllOptionalParams): Promise; - listAllAtManagementGroup(managementGroupName: string, options?: PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams): Promise; - listAllBuiltins(options?: PolicyDefinitionVersionsListAllBuiltinsOptionalParams): Promise; - listBuiltIn(policyDefinitionName: string, options?: PolicyDefinitionVersionsListBuiltInOptionalParams): PagedAsyncIterableIterator; - listByManagementGroup(managementGroupName: string, policyDefinitionName: string, options?: PolicyDefinitionVersionsListByManagementGroupOptionalParams): PagedAsyncIterableIterator; -} - -// @public -export interface PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionVersionProperties { + description?: string; + displayName?: string; + externalEvaluationEnforcementSettings?: ExternalEvaluationEnforcementSettings; + metadata?: any; + mode?: string; + parameters?: Record; + policyRule?: any; + policyType?: PolicyType; + version?: string; } // @public -export type PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupResponse = PolicyDefinitionVersion; - -// @public -export interface PolicyDefinitionVersionsCreateOrUpdateOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams extends OperationOptions { } // @public -export type PolicyDefinitionVersionsCreateOrUpdateResponse = PolicyDefinitionVersion; - -// @public -export interface PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionVersionsCreateOrUpdateOptionalParams extends OperationOptions { } // @public -export interface PolicyDefinitionVersionsDeleteOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams extends OperationOptions { } // @public -export interface PolicyDefinitionVersionsGetAtManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionVersionsDeleteOptionalParams extends OperationOptions { } // @public -export type PolicyDefinitionVersionsGetAtManagementGroupResponse = PolicyDefinitionVersion; - -// @public -export interface PolicyDefinitionVersionsGetBuiltInOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionVersionsGetAtManagementGroupOptionalParams extends OperationOptions { } // @public -export type PolicyDefinitionVersionsGetBuiltInResponse = PolicyDefinitionVersion; - -// @public -export interface PolicyDefinitionVersionsGetOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionVersionsGetBuiltInOptionalParams extends OperationOptions { } // @public -export type PolicyDefinitionVersionsGetResponse = PolicyDefinitionVersion; - -// @public -export interface PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionVersionsGetOptionalParams extends OperationOptions { } // @public -export type PolicyDefinitionVersionsListAllAtManagementGroupResponse = PolicyDefinitionVersionListResult; - -// @public -export interface PolicyDefinitionVersionsListAllBuiltinsOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams extends OperationOptions { } // @public -export type PolicyDefinitionVersionsListAllBuiltinsResponse = PolicyDefinitionVersionListResult; - -// @public -export interface PolicyDefinitionVersionsListAllOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionVersionsListAllBuiltinsOptionalParams extends OperationOptions { } // @public -export type PolicyDefinitionVersionsListAllResponse = PolicyDefinitionVersionListResult; - -// @public -export interface PolicyDefinitionVersionsListBuiltInNextOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionVersionsListAllOptionalParams extends OperationOptions { } // @public -export type PolicyDefinitionVersionsListBuiltInNextResponse = PolicyDefinitionVersionListResult; - -// @public -export interface PolicyDefinitionVersionsListBuiltInOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionVersionsListBuiltInOptionalParams extends OperationOptions { top?: number; } // @public -export type PolicyDefinitionVersionsListBuiltInResponse = PolicyDefinitionVersionListResult; - -// @public -export interface PolicyDefinitionVersionsListByManagementGroupNextOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type PolicyDefinitionVersionsListByManagementGroupNextResponse = PolicyDefinitionVersionListResult; - -// @public -export interface PolicyDefinitionVersionsListByManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionVersionsListByManagementGroupOptionalParams extends OperationOptions { top?: number; } // @public -export type PolicyDefinitionVersionsListByManagementGroupResponse = PolicyDefinitionVersionListResult; - -// @public -export interface PolicyDefinitionVersionsListNextOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type PolicyDefinitionVersionsListNextResponse = PolicyDefinitionVersionListResult; - -// @public -export interface PolicyDefinitionVersionsListOptionalParams extends coreClient.OperationOptions { +export interface PolicyDefinitionVersionsListOptionalParams extends OperationOptions { top?: number; } // @public -export type PolicyDefinitionVersionsListResponse = PolicyDefinitionVersionListResult; +export interface PolicyDefinitionVersionsOperations { + createOrUpdate: (policyDefinitionName: string, policyDefinitionVersion: string, parameters: PolicyDefinitionVersion, options?: PolicyDefinitionVersionsCreateOrUpdateOptionalParams) => Promise; + createOrUpdateAtManagementGroup: (managementGroupName: string, policyDefinitionName: string, policyDefinitionVersion: string, parameters: PolicyDefinitionVersion, options?: PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams) => Promise; + delete: (policyDefinitionName: string, policyDefinitionVersion: string, options?: PolicyDefinitionVersionsDeleteOptionalParams) => Promise; + deleteAtManagementGroup: (managementGroupName: string, policyDefinitionName: string, policyDefinitionVersion: string, options?: PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams) => Promise; + get: (policyDefinitionName: string, policyDefinitionVersion: string, options?: PolicyDefinitionVersionsGetOptionalParams) => Promise; + getAtManagementGroup: (managementGroupName: string, policyDefinitionName: string, policyDefinitionVersion: string, options?: PolicyDefinitionVersionsGetAtManagementGroupOptionalParams) => Promise; + getBuiltIn: (policyDefinitionName: string, policyDefinitionVersion: string, options?: PolicyDefinitionVersionsGetBuiltInOptionalParams) => Promise; + list: (policyDefinitionName: string, options?: PolicyDefinitionVersionsListOptionalParams) => PagedAsyncIterableIterator; + // Warning: (ae-forgotten-export) The symbol "_PolicyDefinitionVersionListResult" needs to be exported by the entry point index.d.ts + listAll: (options?: PolicyDefinitionVersionsListAllOptionalParams) => Promise<_PolicyDefinitionVersionListResult>; + listAllAtManagementGroup: (managementGroupName: string, options?: PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams) => Promise<_PolicyDefinitionVersionListResult>; + listAllBuiltins: (options?: PolicyDefinitionVersionsListAllBuiltinsOptionalParams) => Promise<_PolicyDefinitionVersionListResult>; + listBuiltIn: (policyDefinitionName: string, options?: PolicyDefinitionVersionsListBuiltInOptionalParams) => PagedAsyncIterableIterator; + listByManagementGroup: (managementGroupName: string, policyDefinitionName: string, options?: PolicyDefinitionVersionsListByManagementGroupOptionalParams) => PagedAsyncIterableIterator; +} + +// @public +export interface PolicyLogInfo { + ancestors?: string; + complianceReasonCode?: string; + policyAssignmentDisplayName?: string; + policyAssignmentId?: string; + policyAssignmentName?: string; + policyAssignmentScope?: string; + policyAssignmentVersion?: string; + policyDefinitionDisplayName?: string; + policyDefinitionEffect?: string; + policyDefinitionGroupNames?: string[]; + policyDefinitionId?: string; + policyDefinitionName?: string; + policyDefinitionReferenceId?: string; + policyDefinitionVersion?: string; + policyExemptionIds?: string[]; + policySetDefinitionCategory?: string; + policySetDefinitionDisplayName?: string; + policySetDefinitionId?: string; + policySetDefinitionName?: string; + policySetDefinitionVersion?: string; + resourceLocation?: string; +} // @public -export interface PolicySetDefinition { +export interface PolicySetDefinition extends ProxyResource { description?: string; displayName?: string; - readonly id?: string; metadata?: any; - readonly name?: string; - parameters?: { - [propertyName: string]: ParameterDefinitionsValue; - }; + parameters?: Record; policyDefinitionGroups?: PolicyDefinitionGroup[]; policyDefinitions?: PolicyDefinitionReference[]; policyType?: PolicyType; - readonly systemData?: SystemData; - readonly type?: string; version?: string; versions?: string[]; } // @public -export interface PolicySetDefinitionListResult { - nextLink?: string; - value?: PolicySetDefinition[]; -} - -// @public -export interface PolicySetDefinitions { - createOrUpdate(policySetDefinitionName: string, parameters: PolicySetDefinition, options?: PolicySetDefinitionsCreateOrUpdateOptionalParams): Promise; - createOrUpdateAtManagementGroup(managementGroupId: string, policySetDefinitionName: string, parameters: PolicySetDefinition, options?: PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams): Promise; - delete(policySetDefinitionName: string, options?: PolicySetDefinitionsDeleteOptionalParams): Promise; - deleteAtManagementGroup(managementGroupId: string, policySetDefinitionName: string, options?: PolicySetDefinitionsDeleteAtManagementGroupOptionalParams): Promise; - get(policySetDefinitionName: string, options?: PolicySetDefinitionsGetOptionalParams): Promise; - getAtManagementGroup(managementGroupId: string, policySetDefinitionName: string, options?: PolicySetDefinitionsGetAtManagementGroupOptionalParams): Promise; - getBuiltIn(policySetDefinitionName: string, options?: PolicySetDefinitionsGetBuiltInOptionalParams): Promise; - list(options?: PolicySetDefinitionsListOptionalParams): PagedAsyncIterableIterator; - listBuiltIn(options?: PolicySetDefinitionsListBuiltInOptionalParams): PagedAsyncIterableIterator; - listByManagementGroup(managementGroupId: string, options?: PolicySetDefinitionsListByManagementGroupOptionalParams): PagedAsyncIterableIterator; +export interface PolicySetDefinitionProperties { + description?: string; + displayName?: string; + metadata?: any; + parameters?: Record; + policyDefinitionGroups?: PolicyDefinitionGroup[]; + policyDefinitions: PolicyDefinitionReference[]; + policyType?: PolicyType; + version?: string; + versions?: string[]; } // @public -export interface PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams extends OperationOptions { } // @public -export type PolicySetDefinitionsCreateOrUpdateAtManagementGroupResponse = PolicySetDefinition; - -// @public -export interface PolicySetDefinitionsCreateOrUpdateOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionsCreateOrUpdateOptionalParams extends OperationOptions { } // @public -export type PolicySetDefinitionsCreateOrUpdateResponse = PolicySetDefinition; - -// @public -export interface PolicySetDefinitionsDeleteAtManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionsDeleteAtManagementGroupOptionalParams extends OperationOptions { } // @public -export interface PolicySetDefinitionsDeleteOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionsDeleteOptionalParams extends OperationOptions { } // @public -export interface PolicySetDefinitionsGetAtManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionsGetAtManagementGroupOptionalParams extends OperationOptions { expand?: string; } // @public -export type PolicySetDefinitionsGetAtManagementGroupResponse = PolicySetDefinition; - -// @public -export interface PolicySetDefinitionsGetBuiltInOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionsGetBuiltInOptionalParams extends OperationOptions { expand?: string; } // @public -export type PolicySetDefinitionsGetBuiltInResponse = PolicySetDefinition; - -// @public -export interface PolicySetDefinitionsGetOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionsGetOptionalParams extends OperationOptions { expand?: string; } // @public -export type PolicySetDefinitionsGetResponse = PolicySetDefinition; - -// @public -export interface PolicySetDefinitionsListBuiltInNextOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type PolicySetDefinitionsListBuiltInNextResponse = PolicySetDefinitionListResult; - -// @public -export interface PolicySetDefinitionsListBuiltInOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionsListBuiltInOptionalParams extends OperationOptions { expand?: string; filter?: string; top?: number; } // @public -export type PolicySetDefinitionsListBuiltInResponse = PolicySetDefinitionListResult; - -// @public -export interface PolicySetDefinitionsListByManagementGroupNextOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type PolicySetDefinitionsListByManagementGroupNextResponse = PolicySetDefinitionListResult; - -// @public -export interface PolicySetDefinitionsListByManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionsListByManagementGroupOptionalParams extends OperationOptions { expand?: string; filter?: string; top?: number; } // @public -export type PolicySetDefinitionsListByManagementGroupResponse = PolicySetDefinitionListResult; - -// @public -export interface PolicySetDefinitionsListNextOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type PolicySetDefinitionsListNextResponse = PolicySetDefinitionListResult; - -// @public -export interface PolicySetDefinitionsListOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionsListOptionalParams extends OperationOptions { expand?: string; filter?: string; top?: number; } // @public -export type PolicySetDefinitionsListResponse = PolicySetDefinitionListResult; +export interface PolicySetDefinitionsOperations { + createOrUpdate: (policySetDefinitionName: string, parameters: PolicySetDefinition, options?: PolicySetDefinitionsCreateOrUpdateOptionalParams) => Promise; + createOrUpdateAtManagementGroup: (managementGroupId: string, policySetDefinitionName: string, parameters: PolicySetDefinition, options?: PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams) => Promise; + delete: (policySetDefinitionName: string, options?: PolicySetDefinitionsDeleteOptionalParams) => Promise; + deleteAtManagementGroup: (managementGroupId: string, policySetDefinitionName: string, options?: PolicySetDefinitionsDeleteAtManagementGroupOptionalParams) => Promise; + get: (policySetDefinitionName: string, options?: PolicySetDefinitionsGetOptionalParams) => Promise; + getAtManagementGroup: (managementGroupId: string, policySetDefinitionName: string, options?: PolicySetDefinitionsGetAtManagementGroupOptionalParams) => Promise; + getBuiltIn: (policySetDefinitionName: string, options?: PolicySetDefinitionsGetBuiltInOptionalParams) => Promise; + list: (options?: PolicySetDefinitionsListOptionalParams) => PagedAsyncIterableIterator; + listBuiltIn: (options?: PolicySetDefinitionsListBuiltInOptionalParams) => PagedAsyncIterableIterator; + listByManagementGroup: (managementGroupId: string, options?: PolicySetDefinitionsListByManagementGroupOptionalParams) => PagedAsyncIterableIterator; +} // @public -export interface PolicySetDefinitionVersion { +export interface PolicySetDefinitionVersion extends ProxyResource { description?: string; displayName?: string; - readonly id?: string; metadata?: any; - readonly name?: string; - parameters?: { - [propertyName: string]: ParameterDefinitionsValue; - }; + parameters?: Record; policyDefinitionGroups?: PolicyDefinitionGroup[]; policyDefinitions?: PolicyDefinitionReference[]; policyType?: PolicyType; - readonly systemData?: SystemData; - readonly type?: string; version?: string; } // @public -export interface PolicySetDefinitionVersionListResult { - nextLink?: string; - value?: PolicySetDefinitionVersion[]; -} - -// @public -export interface PolicySetDefinitionVersions { - createOrUpdate(policySetDefinitionName: string, policyDefinitionVersion: string, parameters: PolicySetDefinitionVersion, options?: PolicySetDefinitionVersionsCreateOrUpdateOptionalParams): Promise; - createOrUpdateAtManagementGroup(managementGroupName: string, policySetDefinitionName: string, policyDefinitionVersion: string, parameters: PolicySetDefinitionVersion, options?: PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams): Promise; - delete(policySetDefinitionName: string, policyDefinitionVersion: string, options?: PolicySetDefinitionVersionsDeleteOptionalParams): Promise; - deleteAtManagementGroup(managementGroupName: string, policySetDefinitionName: string, policyDefinitionVersion: string, options?: PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams): Promise; - get(policySetDefinitionName: string, policyDefinitionVersion: string, options?: PolicySetDefinitionVersionsGetOptionalParams): Promise; - getAtManagementGroup(managementGroupName: string, policySetDefinitionName: string, policyDefinitionVersion: string, options?: PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams): Promise; - getBuiltIn(policySetDefinitionName: string, policyDefinitionVersion: string, options?: PolicySetDefinitionVersionsGetBuiltInOptionalParams): Promise; - list(policySetDefinitionName: string, options?: PolicySetDefinitionVersionsListOptionalParams): PagedAsyncIterableIterator; - listAll(options?: PolicySetDefinitionVersionsListAllOptionalParams): Promise; - listAllAtManagementGroup(managementGroupName: string, options?: PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams): Promise; - listAllBuiltins(options?: PolicySetDefinitionVersionsListAllBuiltinsOptionalParams): Promise; - listBuiltIn(policySetDefinitionName: string, options?: PolicySetDefinitionVersionsListBuiltInOptionalParams): PagedAsyncIterableIterator; - listByManagementGroup(managementGroupName: string, policySetDefinitionName: string, options?: PolicySetDefinitionVersionsListByManagementGroupOptionalParams): PagedAsyncIterableIterator; +export interface PolicySetDefinitionVersionProperties { + description?: string; + displayName?: string; + metadata?: any; + parameters?: Record; + policyDefinitionGroups?: PolicyDefinitionGroup[]; + policyDefinitions: PolicyDefinitionReference[]; + policyType?: PolicyType; + version?: string; } // @public -export interface PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams extends OperationOptions { } // @public -export type PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupResponse = PolicySetDefinitionVersion; - -// @public -export interface PolicySetDefinitionVersionsCreateOrUpdateOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionVersionsCreateOrUpdateOptionalParams extends OperationOptions { } // @public -export type PolicySetDefinitionVersionsCreateOrUpdateResponse = PolicySetDefinitionVersion; - -// @public -export interface PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams extends OperationOptions { } // @public -export interface PolicySetDefinitionVersionsDeleteOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionVersionsDeleteOptionalParams extends OperationOptions { } // @public -export interface PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams extends OperationOptions { expand?: string; } // @public -export type PolicySetDefinitionVersionsGetAtManagementGroupResponse = PolicySetDefinitionVersion; - -// @public -export interface PolicySetDefinitionVersionsGetBuiltInOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionVersionsGetBuiltInOptionalParams extends OperationOptions { expand?: string; } // @public -export type PolicySetDefinitionVersionsGetBuiltInResponse = PolicySetDefinitionVersion; - -// @public -export interface PolicySetDefinitionVersionsGetOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionVersionsGetOptionalParams extends OperationOptions { expand?: string; } // @public -export type PolicySetDefinitionVersionsGetResponse = PolicySetDefinitionVersion; - -// @public -export interface PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams extends OperationOptions { } // @public -export type PolicySetDefinitionVersionsListAllAtManagementGroupResponse = PolicySetDefinitionVersionListResult; - -// @public -export interface PolicySetDefinitionVersionsListAllBuiltinsOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionVersionsListAllBuiltinsOptionalParams extends OperationOptions { } // @public -export type PolicySetDefinitionVersionsListAllBuiltinsResponse = PolicySetDefinitionVersionListResult; - -// @public -export interface PolicySetDefinitionVersionsListAllOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionVersionsListAllOptionalParams extends OperationOptions { } // @public -export type PolicySetDefinitionVersionsListAllResponse = PolicySetDefinitionVersionListResult; - -// @public -export interface PolicySetDefinitionVersionsListBuiltInNextOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionVersionsListBuiltInOptionalParams extends OperationOptions { + expand?: string; + top?: number; } // @public -export type PolicySetDefinitionVersionsListBuiltInNextResponse = PolicySetDefinitionVersionListResult; +export interface PolicySetDefinitionVersionsListByManagementGroupOptionalParams extends OperationOptions { + expand?: string; + top?: number; +} // @public -export interface PolicySetDefinitionVersionsListBuiltInOptionalParams extends coreClient.OperationOptions { +export interface PolicySetDefinitionVersionsListOptionalParams extends OperationOptions { expand?: string; top?: number; } // @public -export type PolicySetDefinitionVersionsListBuiltInResponse = PolicySetDefinitionVersionListResult; +export interface PolicySetDefinitionVersionsOperations { + createOrUpdate: (policySetDefinitionName: string, policyDefinitionVersion: string, parameters: PolicySetDefinitionVersion, options?: PolicySetDefinitionVersionsCreateOrUpdateOptionalParams) => Promise; + createOrUpdateAtManagementGroup: (managementGroupName: string, policySetDefinitionName: string, policyDefinitionVersion: string, parameters: PolicySetDefinitionVersion, options?: PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams) => Promise; + delete: (policySetDefinitionName: string, policyDefinitionVersion: string, options?: PolicySetDefinitionVersionsDeleteOptionalParams) => Promise; + deleteAtManagementGroup: (managementGroupName: string, policySetDefinitionName: string, policyDefinitionVersion: string, options?: PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams) => Promise; + get: (policySetDefinitionName: string, policyDefinitionVersion: string, options?: PolicySetDefinitionVersionsGetOptionalParams) => Promise; + getAtManagementGroup: (managementGroupName: string, policySetDefinitionName: string, policyDefinitionVersion: string, options?: PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams) => Promise; + getBuiltIn: (policySetDefinitionName: string, policyDefinitionVersion: string, options?: PolicySetDefinitionVersionsGetBuiltInOptionalParams) => Promise; + list: (policySetDefinitionName: string, options?: PolicySetDefinitionVersionsListOptionalParams) => PagedAsyncIterableIterator; + // Warning: (ae-forgotten-export) The symbol "_PolicySetDefinitionVersionListResult" needs to be exported by the entry point index.d.ts + listAll: (options?: PolicySetDefinitionVersionsListAllOptionalParams) => Promise<_PolicySetDefinitionVersionListResult>; + listAllAtManagementGroup: (managementGroupName: string, options?: PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams) => Promise<_PolicySetDefinitionVersionListResult>; + listAllBuiltins: (options?: PolicySetDefinitionVersionsListAllBuiltinsOptionalParams) => Promise<_PolicySetDefinitionVersionListResult>; + listBuiltIn: (policySetDefinitionName: string, options?: PolicySetDefinitionVersionsListBuiltInOptionalParams) => PagedAsyncIterableIterator; + listByManagementGroup: (managementGroupName: string, policySetDefinitionName: string, options?: PolicySetDefinitionVersionsListByManagementGroupOptionalParams) => PagedAsyncIterableIterator; +} // @public -export interface PolicySetDefinitionVersionsListByManagementGroupNextOptionalParams extends coreClient.OperationOptions { +export interface PolicyTokenOperation { + content?: any; + httpMethod: string; + uri: string; } // @public -export type PolicySetDefinitionVersionsListByManagementGroupNextResponse = PolicySetDefinitionVersionListResult; +export interface PolicyTokenRequest { + changeReference?: string; + operation: PolicyTokenOperation; +} // @public -export interface PolicySetDefinitionVersionsListByManagementGroupOptionalParams extends coreClient.OperationOptions { - expand?: string; - top?: number; +export interface PolicyTokenResponse { + changeReference?: string; + expiration?: Date; + message?: string; + result?: PolicyTokenResult; + results?: ExternalEvaluationEndpointInvocationResult[]; + retryAfter?: Date; + token?: string; + tokenId?: string; } // @public -export type PolicySetDefinitionVersionsListByManagementGroupResponse = PolicySetDefinitionVersionListResult; +export type PolicyTokenResult = string; // @public -export interface PolicySetDefinitionVersionsListNextOptionalParams extends coreClient.OperationOptions { +export interface PolicyTokensAcquireAtManagementGroupOptionalParams extends OperationOptions { } // @public -export type PolicySetDefinitionVersionsListNextResponse = PolicySetDefinitionVersionListResult; +export interface PolicyTokensAcquireOptionalParams extends OperationOptions { +} // @public -export interface PolicySetDefinitionVersionsListOptionalParams extends coreClient.OperationOptions { - expand?: string; - top?: number; +export interface PolicyTokensOperations { + acquire: (parameters: PolicyTokenRequest, options?: PolicyTokensAcquireOptionalParams) => Promise; + acquireAtManagementGroup: (managementGroupName: string, parameters: PolicyTokenRequest, options?: PolicyTokensAcquireAtManagementGroupOptionalParams) => Promise; } // @public -export type PolicySetDefinitionVersionsListResponse = PolicySetDefinitionVersionListResult; +export type PolicyType = string; // @public -export type PolicyType = string; +export interface ProxyResource extends Resource { +} + +// @public +export interface Resource { + readonly id?: string; + readonly name?: string; + readonly systemData?: SystemData; + readonly type?: string; +} // @public export type ResourceIdentityType = "SystemAssigned" | "UserAssigned" | "None"; @@ -985,7 +864,7 @@ export interface SystemData { lastModifiedByType?: CreatedByType; } -// @public (undocumented) +// @public export interface UserAssignedIdentitiesValue { readonly clientId?: string; readonly principalId?: string; diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsCreateByIdSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsCreateByIdSample.ts deleted file mode 100644 index a24614f9c8e5..000000000000 --- a/sdk/policy/arm-policy/samples-dev/policyAssignmentsCreateByIdSample.ts +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * - * @summary This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentById.json - */ - -import type { PolicyAssignment } from "@azure/arm-policy"; -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -async function createOrUpdatePolicyAssignmentById(): Promise { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const parameters: PolicyAssignment = { - description: - "Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created", - definitionVersion: "1.*.*", - displayName: "Enforce storage account SKU", - enforcementMode: "Default", - metadata: { assignedBy: "Cheapskate Boss" }, - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.createById( - policyAssignmentId, - parameters, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * - * @summary This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithIdentityById.json - */ -async function createOrUpdatePolicyAssignmentWithAManagedIdentityById(): Promise { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const parameters: PolicyAssignment = { - description: - "Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created", - definitionVersion: "1.*.*", - displayName: "Enforce storage account SKU", - enforcementMode: "Default", - identity: { type: "SystemAssigned" }, - location: "eastus", - metadata: { assignedBy: "Cheapskate Boss" }, - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.createById( - policyAssignmentId, - parameters, - ); - console.log(result); -} - -async function main(): Promise { - await createOrUpdatePolicyAssignmentById(); - await createOrUpdatePolicyAssignmentWithAManagedIdentityById(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsCreateSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsCreateSample.ts index a785fdacb5ce..daaf4fa8d2a7 100644 --- a/sdk/policy/arm-policy/samples-dev/policyAssignmentsCreateSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsCreateSample.ts @@ -1,265 +1,256 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignment.json - */ - -import type { PolicyAssignment } from "@azure/arm-policy"; import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignment.json + */ async function createOrUpdateAPolicyAssignment(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters: PolicyAssignment = { - description: - "Force resource names to begin with given DeptA and end with -LC", - displayName: "Enforce resource naming rules", - metadata: { assignedBy: "Special Someone" }, - nonComplianceMessages: [ - { message: "Resource names must start with 'DeptA' and end with '-LC'." }, - ], - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - }; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.create( - scope, - policyAssignmentName, - parameters, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + metadata: { assignedBy: "Special Someone" }, + nonComplianceMessages: [ + { message: "Resource names must start with 'DeptA' and end with '-LC'." }, + ], + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }, ); console.log(result); } /** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithIdentity.json + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentNonComplianceMessages.json */ -async function createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters: PolicyAssignment = { - description: - "Force resource names to begin with given DeptA and end with -LC", - displayName: "Enforce resource naming rules", - enforcementMode: "Default", - identity: { type: "SystemAssigned" }, - location: "eastus", - metadata: { assignedBy: "Foo Bar" }, - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - }; +async function createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages(): Promise { const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.create( - scope, - policyAssignmentName, - parameters, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "securityInitAssignment", + { + displayName: "Enforce security policies", + nonComplianceMessages: [ + { + message: + "Resources must comply with all internal security policies. See for more info.", + }, + { + message: "Resource names must start with 'DeptA' and end with '-LC'.", + policyDefinitionReferenceId: "10420126870854049575", + }, + { + message: "Storage accounts must have firewall rules configured.", + policyDefinitionReferenceId: "8572513655450389710", + }, + ], + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/securityInitiative", + }, ); console.log(result); } /** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithUserAssignedIdentity.json + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithEnrollEnforcement.json */ -async function createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters: PolicyAssignment = { - description: - "Force resource names to begin with given DeptA and end with -LC", - displayName: "Enforce resource naming rules", - enforcementMode: "Default", - identity: { - type: "UserAssigned", - userAssignedIdentities: { - "/subscriptions/ae640e6bBa3e42569d622993eecfa6f2/resourceGroups/testResourceGroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/testIdentity": - {}, - }, - }, - location: "eastus", - metadata: { assignedBy: "Foo Bar" }, - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - }; +async function createOrUpdateAPolicyAssignmentToEnforcePolicyEffectOnlyOnEnrolledResourcesDuringResourceCreationOrUpdate(): Promise { const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.create( - scope, - policyAssignmentName, - parameters, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNamingEnroll", + { + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "Enroll", + metadata: { assignedBy: "Special Someone" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }, ); console.log(result); } /** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentNonComplianceMessages.json + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithIdentity.json */ -async function createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "securityInitAssignment"; - const parameters: PolicyAssignment = { - displayName: "Enforce security policies", - nonComplianceMessages: [ - { - message: - "Resources must comply with all internal security policies. See for more info.", - }, - { - message: "Resource names must start with 'DeptA' and end with '-LC'.", - policyDefinitionReferenceId: "10420126870854049575", - }, - { - message: "Storage accounts must have firewall rules configured.", - policyDefinitionReferenceId: "8572513655450389710", - }, - ], - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/securityInitiative", - }; +async function createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity(): Promise { const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.create( - scope, - policyAssignmentName, - parameters, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { + identity: { type: "SystemAssigned" }, + location: "eastus", + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "Default", + metadata: { assignedBy: "Foo Bar" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }, ); console.log(result); } /** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithOverrides.json + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithOverrides.json */ async function createOrUpdateAPolicyAssignmentWithOverrides(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; - const parameters: PolicyAssignment = { - description: "Limit the resource location and resource SKU", - definitionVersion: "1.*.*", - displayName: "Limit the resource location and resource SKU", - metadata: { assignedBy: "Special Someone" }, - overrides: [ - { - kind: "policyEffect", - selectors: [ - { - in: ["Limit_Skus", "Limit_Locations"], - kind: "policyDefinitionReferenceId", - }, - ], - value: "Audit", - }, - { - kind: "definitionVersion", - selectors: [ - { in: ["eastUSEuap", "centralUSEuap"], kind: "resourceLocation" }, - ], - value: "2.*.*", - }, - ], - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", - }; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.create( - scope, - policyAssignmentName, - parameters, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", + { + description: "Limit the resource location and resource SKU", + definitionVersion: "1.*.*", + displayName: "Limit the resource location and resource SKU", + metadata: { assignedBy: "Special Someone" }, + overrides: [ + { + kind: "policyEffect", + selectors: [ + { in: ["Limit_Skus", "Limit_Locations"], kind: "policyDefinitionReferenceId" }, + ], + value: "Audit", + }, + { + kind: "definitionVersion", + selectors: [{ in: ["eastUSEuap", "centralUSEuap"], kind: "resourceLocation" }], + value: "2.*.*", + }, + ], + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", + }, ); console.log(result); } /** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithResourceSelectors.json + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithResourceSelectors.json */ async function createOrUpdateAPolicyAssignmentWithResourceSelectors(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; - const parameters: PolicyAssignment = { - description: "Limit the resource location and resource SKU", - displayName: "Limit the resource location and resource SKU", - metadata: { assignedBy: "Special Someone" }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", - resourceSelectors: [ - { - name: "SDPRegions", - selectors: [ - { in: ["eastus2euap", "centraluseuap"], kind: "resourceLocation" }, - ], - }, - ], - }; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.create( - scope, - policyAssignmentName, - parameters, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", + { + description: "Limit the resource location and resource SKU", + displayName: "Limit the resource location and resource SKU", + metadata: { assignedBy: "Special Someone" }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", + resourceSelectors: [ + { + name: "SDPRegions", + selectors: [{ in: ["eastus2euap", "centraluseuap"], kind: "resourceLocation" }], + }, + ], + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithUserAssignedIdentity.json + */ +async function createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.create( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { + identity: { + type: "UserAssigned", + userAssignedIdentities: { + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": + {}, + }, + }, + location: "eastus", + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "Default", + metadata: { assignedBy: "Foo Bar" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }, ); console.log(result); } /** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithoutEnforcement.json + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithoutEnforcement.json */ async function createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters: PolicyAssignment = { - description: - "Force resource names to begin with given DeptA and end with -LC", - displayName: "Enforce resource naming rules", - enforcementMode: "DoNotEnforce", - metadata: { assignedBy: "Special Someone" }, - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - }; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.create( - scope, - policyAssignmentName, - parameters, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "DoNotEnforce", + metadata: { assignedBy: "Special Someone" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }, ); console.log(result); } async function main(): Promise { await createOrUpdateAPolicyAssignment(); - await createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity(); - await createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity(); await createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages(); + await createOrUpdateAPolicyAssignmentToEnforcePolicyEffectOnlyOnEnrolledResourcesDuringResourceCreationOrUpdate(); + await createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity(); await createOrUpdateAPolicyAssignmentWithOverrides(); await createOrUpdateAPolicyAssignmentWithResourceSelectors(); + await createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity(); await createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate(); } diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsDeleteByIdSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsDeleteByIdSample.ts deleted file mode 100644 index 833f9415b43f..000000000000 --- a/sdk/policy/arm-policy/samples-dev/policyAssignmentsDeleteByIdSample.ts +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). - * - * @summary This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyAssignmentById.json - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -async function deleteAPolicyAssignmentById(): Promise { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.deleteById(policyAssignmentId); - console.log(result); -} - -async function main(): Promise { - await deleteAPolicyAssignmentById(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsDeleteSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsDeleteSample.ts index 50026351bbcd..219895eae42e 100644 --- a/sdk/policy/arm-policy/samples-dev/policyAssignmentsDeleteSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsDeleteSample.ts @@ -1,25 +1,21 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - * - * @summary This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyAssignment.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * + * @summary this operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * x-ms-original-file: 2025-03-01/deletePolicyAssignment.json + */ async function deleteAPolicyAssignment(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.delete( - scope, - policyAssignmentName, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", ); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsGetByIdSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsGetByIdSample.ts deleted file mode 100644 index cf8d32db6ac8..000000000000 --- a/sdk/policy/arm-policy/samples-dev/policyAssignmentsGetByIdSample.ts +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * - * @summary The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentById.json - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -async function retrieveAPolicyAssignmentById(): Promise { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.getById(policyAssignmentId); - console.log(result); -} - -/** - * This sample demonstrates how to The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * - * @summary The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentWithIdentityById.json - */ -async function retrieveAPolicyAssignmentWithAManagedIdentityById(): Promise { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.getById(policyAssignmentId); - console.log(result); -} - -async function main(): Promise { - await retrieveAPolicyAssignmentById(); - await retrieveAPolicyAssignmentWithAManagedIdentityById(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsGetSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsGetSample.ts index 5a112dceabd3..d7e0aa5da48e 100644 --- a/sdk/policy/arm-policy/samples-dev/policyAssignmentsGetSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsGetSample.ts @@ -1,97 +1,85 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. - * - * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignment.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary this operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: 2025-03-01/getPolicyAssignment.json + */ async function retrieveAPolicyAssignment(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.get( - scope, - policyAssignmentName, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", ); console.log(result); } /** - * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. + * This sample demonstrates how to this operation retrieves a single policy assignment, given its name and the scope it was created at. * - * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentWithIdentity.json + * @summary this operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: 2025-03-01/getPolicyAssignmentWithIdentity.json */ async function retrieveAPolicyAssignmentWithASystemAssignedIdentity(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.get( - scope, - policyAssignmentName, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", ); console.log(result); } /** - * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. + * This sample demonstrates how to this operation retrieves a single policy assignment, given its name and the scope it was created at. * - * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json + * @summary this operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: 2025-03-01/getPolicyAssignmentWithOverrides.json */ -async function retrieveAPolicyAssignmentWithAUserAssignedIdentity(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; +async function retrieveAPolicyAssignmentWithOverrides(): Promise { const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.get( - scope, - policyAssignmentName, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", ); console.log(result); } /** - * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. + * This sample demonstrates how to this operation retrieves a single policy assignment, given its name and the scope it was created at. * - * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentWithOverrides.json + * @summary this operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: 2025-03-01/getPolicyAssignmentWithResourceSelectors.json */ -async function retrieveAPolicyAssignmentWithOverrides(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; +async function retrieveAPolicyAssignmentWithResourceSelectors(): Promise { const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.get( - scope, - policyAssignmentName, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", ); console.log(result); } /** - * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. + * This sample demonstrates how to this operation retrieves a single policy assignment, given its name and the scope it was created at. * - * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentWithResourceSelectors.json + * @summary this operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: 2025-03-01/getPolicyAssignmentWithUserAssignedIdentity.json */ -async function retrieveAPolicyAssignmentWithResourceSelectors(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; +async function retrieveAPolicyAssignmentWithAUserAssignedIdentity(): Promise { const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.get( - scope, - policyAssignmentName, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", ); console.log(result); } @@ -99,9 +87,9 @@ async function retrieveAPolicyAssignmentWithResourceSelectors(): Promise { async function main(): Promise { await retrieveAPolicyAssignment(); await retrieveAPolicyAssignmentWithASystemAssignedIdentity(); - await retrieveAPolicyAssignmentWithAUserAssignedIdentity(); await retrieveAPolicyAssignmentWithOverrides(); await retrieveAPolicyAssignmentWithResourceSelectors(); + await retrieveAPolicyAssignmentWithAUserAssignedIdentity(); } main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForManagementGroupSample.ts index d1d3b17a787d..cc2da6480f35 100644 --- a/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForManagementGroupSample.ts @@ -1,35 +1,26 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. - * - * @summary This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignmentsForManagementGroup.json - */ - -import type { PolicyAssignmentsListForManagementGroupOptionalParams } from "@azure/arm-policy"; import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. + * + * @summary this operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. + * x-ms-original-file: 2025-03-01/listPolicyAssignmentsForManagementGroup.json + */ async function listPolicyAssignmentsThatApplyToAManagementGroup(): Promise { - const managementGroupId = "TestManagementGroup"; - const filter = "atScope()"; - const expand = "LatestDefinitionVersion, EffectiveDefinitionVersion"; - const options: PolicyAssignmentsListForManagementGroupOptionalParams = { - filter, - expand, - }; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); - for await (const item of client.policyAssignments.listForManagementGroup( - managementGroupId, - options, - )) { + for await (const item of client.policyAssignments.listForManagementGroup("TestManagementGroup", { + filter: "atScope()", + expand: "LatestDefinitionVersion, EffectiveDefinitionVersion", + })) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForResourceGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForResourceGroupSample.ts index 7b0826c26f72..ec42f7cb3aa6 100644 --- a/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForResourceGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForResourceGroupSample.ts @@ -1,39 +1,27 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. - * - * @summary This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignmentsForResourceGroup.json - */ - -import type { PolicyAssignmentsListForResourceGroupOptionalParams } from "@azure/arm-policy"; import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + * @summary this operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * x-ms-original-file: 2025-03-01/listPolicyAssignmentsForResourceGroup.json + */ async function listPolicyAssignmentsThatApplyToAResourceGroup(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const resourceGroupName = - process.env["POLICY_RESOURCE_GROUP"] || "TestResourceGroup"; - const filter = "atScope()"; - const expand = "LatestDefinitionVersion, EffectiveDefinitionVersion"; - const options: PolicyAssignmentsListForResourceGroupOptionalParams = { - filter, - expand, - }; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const resArray = new Array(); - for await (const item of client.policyAssignments.listForResourceGroup( - resourceGroupName, - options, - )) { + for await (const item of client.policyAssignments.listForResourceGroup("TestResourceGroup", { + filter: "atScope()", + expand: "LatestDefinitionVersion, EffectiveDefinitionVersion", + })) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForResourceSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForResourceSample.ts index 8f94d80a8aec..933483585a7c 100644 --- a/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForResourceSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForResourceSample.ts @@ -1,44 +1,35 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - * - * @summary This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignmentsForResource.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; -async function listAllPolicyAssignmentsThatApplyToAResource(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const resourceGroupName = - process.env["POLICY_RESOURCE_GROUP"] || "TestResourceGroup"; - const resourceProviderNamespace = "Microsoft.Compute"; - const parentResourcePath = "virtualMachines/MyTestVm"; - const resourceType = "domainNames"; - const resourceName = "MyTestComputer.cloudapp.net"; +/** + * This sample demonstrates how to this operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @summary this operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * x-ms-original-file: 2025-03-01/listPolicyAssignmentsForResource.json + */ +async function listPolicyAssignmentsThatApplyToAResourceGroup(): Promise { const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const resArray = new Array(); for await (const item of client.policyAssignments.listForResource( - resourceGroupName, - resourceProviderNamespace, - parentResourcePath, - resourceType, - resourceName, + "TestResourceGroup", + "Microsoft.Compute", + "virtualMachines/MyTestVm", + "domainNames", + "MyTestComputer.cloudapp.net", )) { resArray.push(item); } + console.log(resArray); } async function main(): Promise { - await listAllPolicyAssignmentsThatApplyToAResource(); + await listPolicyAssignmentsThatApplyToAResourceGroup(); } main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsListSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsListSample.ts index 27fd491024f6..a47d53147f64 100644 --- a/sdk/policy/arm-policy/samples-dev/policyAssignmentsListSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsListSample.ts @@ -1,31 +1,27 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. - * - * @summary This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignments.json - */ - -import type { PolicyAssignmentsListOptionalParams } from "@azure/arm-policy"; import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + * @summary this operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * x-ms-original-file: 2025-03-01/listPolicyAssignments.json + */ async function listPolicyAssignmentsThatApplyToASubscription(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const filter = "atScope()"; - const expand = "LatestDefinitionVersion, EffectiveDefinitionVersion"; - const options: PolicyAssignmentsListOptionalParams = { filter, expand }; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const resArray = new Array(); - for await (const item of client.policyAssignments.list(options)) { + for await (const item of client.policyAssignments.list({ + filter: "atScope()", + expand: "LatestDefinitionVersion, EffectiveDefinitionVersion", + })) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsUpdateByIdSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsUpdateByIdSample.ts deleted file mode 100644 index d2ae4d834f95..000000000000 --- a/sdk/policy/arm-policy/samples-dev/policyAssignmentsUpdateByIdSample.ts +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to This operation updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * - * @summary This operation updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithIdentityById.json - */ - -import type { PolicyAssignmentUpdate } from "@azure/arm-policy"; -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -async function updatePolicyAssignmentWithAManagedIdentityById(): Promise { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const parameters: PolicyAssignmentUpdate = { - identity: { type: "SystemAssigned" }, - location: "eastus", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.updateById( - policyAssignmentId, - parameters, - ); - console.log(result); -} - -async function main(): Promise { - await updatePolicyAssignmentWithAManagedIdentityById(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsUpdateSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsUpdateSample.ts index a3f7a4d359d9..7aded83b0917 100644 --- a/sdk/policy/arm-policy/samples-dev/policyAssignmentsUpdateSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsUpdateSample.ts @@ -1,131 +1,108 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithIdentity.json - */ - -import type { PolicyAssignmentUpdate } from "@azure/arm-policy"; import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/updatePolicyAssignmentWithIdentity.json + */ async function updateAPolicyAssignmentWithASystemAssignedIdentity(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters: PolicyAssignmentUpdate = { - identity: { type: "SystemAssigned" }, - location: "eastus", - }; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.update( - scope, - policyAssignmentName, - parameters, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { identity: { type: "SystemAssigned" }, location: "eastus" }, ); console.log(result); } /** - * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * This sample demonstrates how to this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. * - * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithUserAssignedIdentity.json + * @summary this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/updatePolicyAssignmentWithOverrides.json */ -async function updateAPolicyAssignmentWithAUserAssignedIdentity(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters: PolicyAssignmentUpdate = { - identity: { - type: "UserAssigned", - userAssignedIdentities: { - "/subscriptions/ae640e6bBa3e42569d622993eecfa6f2/resourceGroups/testResourceGroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/testIdentity": - {}, - }, - }, - location: "eastus", - }; +async function updateAPolicyAssignmentWithOverrides(): Promise { const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.update( - scope, - policyAssignmentName, - parameters, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", + { + overrides: [ + { + kind: "policyEffect", + selectors: [ + { in: ["Limit_Skus", "Limit_Locations"], kind: "policyDefinitionReferenceId" }, + ], + value: "Audit", + }, + ], + }, ); console.log(result); } /** - * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * This sample demonstrates how to this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. * - * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithOverrides.json + * @summary this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/updatePolicyAssignmentWithResourceSelectors.json */ -async function updateAPolicyAssignmentWithOverrides(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; - const parameters: PolicyAssignmentUpdate = { - overrides: [ - { - kind: "policyEffect", - selectors: [ - { - in: ["Limit_Skus", "Limit_Locations"], - kind: "policyDefinitionReferenceId", - }, - ], - value: "Audit", - }, - ], - }; +async function updateAPolicyAssignmentWithResourceSelectors(): Promise { const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.update( - scope, - policyAssignmentName, - parameters, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", + { + resourceSelectors: [ + { + name: "SDPRegions", + selectors: [{ in: ["eastus2euap", "centraluseuap"], kind: "resourceLocation" }], + }, + ], + }, ); console.log(result); } /** - * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * This sample demonstrates how to this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. * - * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithResourceSelectors.json + * @summary this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/updatePolicyAssignmentWithUserAssignedIdentity.json */ -async function updateAPolicyAssignmentWithResourceSelectors(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; - const parameters: PolicyAssignmentUpdate = { - resourceSelectors: [ - { - name: "SDPRegions", - selectors: [ - { in: ["eastus2euap", "centraluseuap"], kind: "resourceLocation" }, - ], - }, - ], - }; +async function updateAPolicyAssignmentWithAUserAssignedIdentity(): Promise { const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.update( - scope, - policyAssignmentName, - parameters, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { + identity: { + type: "UserAssigned", + userAssignedIdentities: { + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": + {}, + }, + }, + location: "eastus", + }, ); console.log(result); } async function main(): Promise { await updateAPolicyAssignmentWithASystemAssignedIdentity(); - await updateAPolicyAssignmentWithAUserAssignedIdentity(); await updateAPolicyAssignmentWithOverrides(); await updateAPolicyAssignmentWithResourceSelectors(); + await updateAPolicyAssignmentWithAUserAssignedIdentity(); } main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts index 11da7f39ebbc..534033b29963 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts @@ -1,64 +1,47 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation creates or updates a policy definition version in the given management group with the given name. - * - * @summary This operation creates or updates a policy definition version in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json - */ - -import type { PolicyDefinitionVersion } from "@azure/arm-policy"; import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation creates or updates a policy definition version in the given management group with the given name. + * + * @summary this operation creates or updates a policy definition version in the given management group with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json + */ async function createOrUpdateAPolicyDefinitionVersionAtManagementGroupLevel(): Promise { - const managementGroupName = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; - const parameters: PolicyDefinitionVersion = { - description: - "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - displayName: "Enforce resource naming convention", - metadata: { category: "Naming" }, - mode: "All", - parameters: { - prefix: { - type: "String", - metadata: { - description: "Resource name prefix", - displayName: "Prefix", + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyDefinitionVersions.createOrUpdateAtManagementGroup( + "MyManagementGroup", + "ResourceNaming", + "1.2.1", + { + description: + "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + displayName: "Enforce resource naming convention", + metadata: { category: "Naming" }, + mode: "All", + parameters: { + prefix: { + type: "String", + metadata: { description: "Resource name prefix", displayName: "Prefix" }, }, - }, - suffix: { - type: "String", - metadata: { - description: "Resource name suffix", - displayName: "Suffix", + suffix: { + type: "String", + metadata: { description: "Resource name suffix", displayName: "Suffix" }, }, }, - }, - policyRule: { - if: { - not: { - field: "name", - like: "[concat(parameters('prefix'), '*', parameters('suffix'))]", + policyRule: { + if: { + not: { field: "name", like: "[concat(parameters('prefix'), '*', parameters('suffix'))]" }, }, + then: { effect: "deny" }, }, - then: { effect: "deny" }, + version: "1.2.1", }, - version: "1.2.1", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = - await client.policyDefinitionVersions.createOrUpdateAtManagementGroup( - managementGroupName, - policyDefinitionName, - policyDefinitionVersion, - parameters, - ); + ); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsCreateOrUpdateSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsCreateOrUpdateSample.ts index c743d8afdb57..7a1dd0739adc 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsCreateOrUpdateSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsCreateOrUpdateSample.ts @@ -1,64 +1,42 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation creates or updates a policy definition in the given subscription with the given name. - * - * @summary This operation creates or updates a policy definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionVersion.json - */ - -import type { PolicyDefinitionVersion } from "@azure/arm-policy"; import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation creates or updates a policy definition in the given subscription with the given name. + * + * @summary this operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionVersion.json + */ async function createOrUpdateAPolicyDefinitionVersion(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; - const parameters: PolicyDefinitionVersion = { - description: - "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitionVersions.createOrUpdate("ResourceNaming", "1.2.1", { + description: "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", displayName: "Enforce resource naming convention", metadata: { category: "Naming" }, mode: "All", parameters: { prefix: { type: "String", - metadata: { - description: "Resource name prefix", - displayName: "Prefix", - }, + metadata: { description: "Resource name prefix", displayName: "Prefix" }, }, suffix: { type: "String", - metadata: { - description: "Resource name suffix", - displayName: "Suffix", - }, + metadata: { description: "Resource name suffix", displayName: "Suffix" }, }, }, policyRule: { if: { - not: { - field: "name", - like: "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, + not: { field: "name", like: "[concat(parameters('prefix'), '*', parameters('suffix'))]" }, }, then: { effect: "deny" }, }, version: "1.2.1", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitionVersions.createOrUpdate( - policyDefinitionName, - policyDefinitionVersion, - parameters, - ); + }); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsDeleteAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsDeleteAtManagementGroupSample.ts index 90caf07faf03..0e555cc5642c 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsDeleteAtManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsDeleteAtManagementGroupSample.ts @@ -1,29 +1,23 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation deletes the policy definition in the given management group with the given name. - * - * @summary This operation deletes the policy definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinitionVersionAtManagementGroup.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation deletes the policy definition in the given management group with the given name. + * + * @summary this operation deletes the policy definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/deletePolicyDefinitionVersionAtManagementGroup.json + */ async function deleteAPolicyDefinitionVersionAtManagementGroupLevel(): Promise { - const managementGroupName = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); - const result = await client.policyDefinitionVersions.deleteAtManagementGroup( - managementGroupName, - policyDefinitionName, - policyDefinitionVersion, + await client.policyDefinitionVersions.deleteAtManagementGroup( + "MyManagementGroup", + "ResourceNaming", + "1.2.1", ); - console.log(result); } async function main(): Promise { diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsDeleteSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsDeleteSample.ts index cc3ac100b913..65de8722fe7b 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsDeleteSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsDeleteSample.ts @@ -1,30 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation deletes the policy definition version in the given subscription with the given name. - * - * @summary This operation deletes the policy definition version in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinitionVersion.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation deletes the policy definition version in the given subscription with the given name. + * + * @summary this operation deletes the policy definition version in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/deletePolicyDefinitionVersion.json + */ async function deleteAPolicyDefinitionVersion(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitionVersions.delete( - policyDefinitionName, - policyDefinitionVersion, - ); - console.log(result); + await client.policyDefinitionVersions.delete("ResourceNaming", "1.2.1"); } async function main(): Promise { diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsGetAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsGetAtManagementGroupSample.ts index 7ad24d634ff2..15cdcf9367f0 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsGetAtManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsGetAtManagementGroupSample.ts @@ -1,27 +1,22 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves the policy definition version in the given management group with the given name. - * - * @summary This operation retrieves the policy definition version in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinitionVersionAtManagementGroup.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves the policy definition version in the given management group with the given name. + * + * @summary this operation retrieves the policy definition version in the given management group with the given name. + * x-ms-original-file: 2025-03-01/getPolicyDefinitionVersionAtManagementGroup.json + */ async function retrieveAPolicyDefinitionVersionAtManagementGroupLevel(): Promise { - const managementGroupName = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyDefinitionVersions.getAtManagementGroup( - managementGroupName, - policyDefinitionName, - policyDefinitionVersion, + "MyManagementGroup", + "ResourceNaming", + "1.2.1", ); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsGetBuiltInSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsGetBuiltInSample.ts index 030bcd6bd868..f0da17df22a2 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsGetBuiltInSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsGetBuiltInSample.ts @@ -1,25 +1,21 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves the built-in policy definition version with the given name. - * - * @summary This operation retrieves the built-in policy definition version with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltinPolicyDefinitionVersion.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves the built-in policy definition version with the given name. + * + * @summary this operation retrieves the built-in policy definition version with the given name. + * x-ms-original-file: 2025-03-01/getBuiltinPolicyDefinitionVersion.json + */ async function retrieveABuiltInPolicyDefinitionVersion(): Promise { - const policyDefinitionName = "7433c107-6db4-4ad1-b57a-a76dce0154a1"; - const policyDefinitionVersion = "1.2.1"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyDefinitionVersions.getBuiltIn( - policyDefinitionName, - policyDefinitionVersion, + "7433c107-6db4-4ad1-b57a-a76dce0154a1", + "1.2.1", ); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsGetSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsGetSample.ts index a58c0dd7e17b..2f186814a7b4 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsGetSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsGetSample.ts @@ -1,29 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves the policy definition version in the given subscription with the given name. - * - * @summary This operation retrieves the policy definition version in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinitionVersion.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves the policy definition version in the given subscription with the given name. + * + * @summary this operation retrieves the policy definition version in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/getPolicyDefinitionVersion.json + */ async function retrieveAPolicyDefinitionVersion(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitionVersions.get( - policyDefinitionName, - policyDefinitionVersion, - ); + const result = await client.policyDefinitionVersions.get("ResourceNaming", "1.2.1"); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListAllAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListAllAtManagementGroupSample.ts index 41105276ac53..44498235c26b 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListAllAtManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListAllAtManagementGroupSample.ts @@ -1,25 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation lists all the policy definition versions for all policy definitions at the management group scope. - * - * @summary This operation lists all the policy definition versions for all policy definitions at the management group scope. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicyDefinitionVersionsByManagementGroup.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation lists all the policy definition versions for all policy definitions at the management group scope. + * + * @summary this operation lists all the policy definition versions for all policy definitions at the management group scope. + * x-ms-original-file: 2025-03-01/listAllPolicyDefinitionVersionsByManagementGroup.json + */ async function listAllPolicyDefinitionVersionsAtManagementGroup(): Promise { - const managementGroupName = "MyManagementGroup"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = - await client.policyDefinitionVersions.listAllAtManagementGroup( - managementGroupName, - ); + await client.policyDefinitionVersions.listAllAtManagementGroup("MyManagementGroup"); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListAllBuiltinsSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListAllBuiltinsSample.ts index 61b3e30f4a21..194025a75d41 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListAllBuiltinsSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListAllBuiltinsSample.ts @@ -1,17 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation lists all the built-in policy definition versions for all built-in policy definitions. - * - * @summary This operation lists all the built-in policy definition versions for all built-in policy definitions. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllBuiltInPolicyDefinitionVersions.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation lists all the built-in policy definition versions for all built-in policy definitions. + * + * @summary this operation lists all the built-in policy definition versions for all built-in policy definitions. + * x-ms-original-file: 2025-03-01/listAllBuiltInPolicyDefinitionVersions.json + */ async function listAllBuiltInPolicyDefinitionVersions(): Promise { const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListAllSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListAllSample.ts index 7a906e55514e..4ea266b2b186 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListAllSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListAllSample.ts @@ -1,22 +1,18 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation lists all the policy definition versions for all policy definitions within a subscription. - * - * @summary This operation lists all the policy definition versions for all policy definitions within a subscription. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicyDefinitionVersions.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation lists all the policy definition versions for all policy definitions within a subscription. + * + * @summary this operation lists all the policy definition versions for all policy definitions within a subscription. + * x-ms-original-file: 2025-03-01/listAllPolicyDefinitionVersions.json + */ async function listAllPolicyDefinitionVersionsAtSubscription(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const result = await client.policyDefinitionVersions.listAll(); console.log(result); diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListBuiltInSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListBuiltInSample.ts index 12c4c686c86a..6a5cb9343a43 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListBuiltInSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListBuiltInSample.ts @@ -1,27 +1,25 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves a list of all the built-in policy definition versions for the given policy definition. - * - * @summary This operation retrieves a list of all the built-in policy definition versions for the given policy definition. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicyDefinitionVersions.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves a list of all the built-in policy definition versions for the given policy definition. + * + * @summary this operation retrieves a list of all the built-in policy definition versions for the given policy definition. + * x-ms-original-file: 2025-03-01/listBuiltInPolicyDefinitionVersions.json + */ async function listBuiltInPolicyDefinitionVersions(): Promise { - const policyDefinitionName = "06a78e20-9358-41c9-923c-fb736d382a12"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); for await (const item of client.policyDefinitionVersions.listBuiltIn( - policyDefinitionName, + "06a78e20-9358-41c9-923c-fb736d382a12", )) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListByManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListByManagementGroupSample.ts index 4f1ad6f2d821..9ff8880cb4c8 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListByManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListByManagementGroupSample.ts @@ -1,29 +1,26 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. - * - * @summary This operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitionVersionsByManagementGroup.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. + * + * @summary this operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. + * x-ms-original-file: 2025-03-01/listPolicyDefinitionVersionsByManagementGroup.json + */ async function listPolicyDefinitionVersionsByManagementGroup(): Promise { - const managementGroupName = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); for await (const item of client.policyDefinitionVersions.listByManagementGroup( - managementGroupName, - policyDefinitionName, + "MyManagementGroup", + "ResourceNaming", )) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListSample.ts index d3b1dd99d2b1..32259b308c31 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionVersionsListSample.ts @@ -1,30 +1,24 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves a list of all the policy definition versions for the given policy definition. - * - * @summary This operation retrieves a list of all the policy definition versions for the given policy definition. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitionVersions.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves a list of all the policy definition versions for the given policy definition. + * + * @summary this operation retrieves a list of all the policy definition versions for the given policy definition. + * x-ms-original-file: 2025-03-01/listPolicyDefinitionVersions.json + */ async function listPolicyDefinitionVersionsBySubscription(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const resArray = new Array(); - for await (const item of client.policyDefinitionVersions.list( - policyDefinitionName, - )) { + for await (const item of client.policyDefinitionVersions.list("ResourceNaming")) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts index 7d8becc54962..b4324503c59f 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts @@ -1,59 +1,44 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation creates or updates a policy definition in the given management group with the given name. - * - * @summary This operation creates or updates a policy definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json - */ - -import type { PolicyDefinition } from "@azure/arm-policy"; import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation creates or updates a policy definition in the given management group with the given name. + * + * @summary this operation creates or updates a policy definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionAtManagementGroup.json + */ async function createOrUpdateAPolicyDefinitionAtManagementGroupLevel(): Promise { - const managementGroupId = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; - const parameters: PolicyDefinition = { - description: - "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - displayName: "Enforce resource naming convention", - metadata: { category: "Naming" }, - mode: "All", - parameters: { - prefix: { - type: "String", - metadata: { - description: "Resource name prefix", - displayName: "Prefix", + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyDefinitions.createOrUpdateAtManagementGroup( + "MyManagementGroup", + "ResourceNaming", + { + description: + "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + displayName: "Enforce resource naming convention", + metadata: { category: "Naming" }, + mode: "All", + parameters: { + prefix: { + type: "String", + metadata: { description: "Resource name prefix", displayName: "Prefix" }, }, - }, - suffix: { - type: "String", - metadata: { - description: "Resource name suffix", - displayName: "Suffix", + suffix: { + type: "String", + metadata: { description: "Resource name suffix", displayName: "Suffix" }, }, }, - }, - policyRule: { - if: { - not: { - field: "name", - like: "[concat(parameters('prefix'), '*', parameters('suffix'))]", + policyRule: { + if: { + not: { field: "name", like: "[concat(parameters('prefix'), '*', parameters('suffix'))]" }, }, + then: { effect: "deny" }, }, - then: { effect: "deny" }, }, - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyDefinitions.createOrUpdateAtManagementGroup( - managementGroupId, - policyDefinitionName, - parameters, ); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsCreateOrUpdateSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsCreateOrUpdateSample.ts index 6485878e24bf..96da436e3632 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionsCreateOrUpdateSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsCreateOrUpdateSample.ts @@ -1,76 +1,55 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation creates or updates a policy definition in the given subscription with the given name. - * - * @summary This operation creates or updates a policy definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinition.json - */ - -import type { PolicyDefinition } from "@azure/arm-policy"; import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation creates or updates a policy definition in the given subscription with the given name. + * + * @summary this operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinition.json + */ async function createOrUpdateAPolicyDefinition(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const parameters: PolicyDefinition = { - description: - "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.createOrUpdate("ResourceNaming", { + description: "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", displayName: "Enforce resource naming convention", metadata: { category: "Naming" }, mode: "All", parameters: { prefix: { type: "String", - metadata: { - description: "Resource name prefix", - displayName: "Prefix", - }, + metadata: { description: "Resource name prefix", displayName: "Prefix" }, }, suffix: { type: "String", - metadata: { - description: "Resource name suffix", - displayName: "Suffix", - }, + metadata: { description: "Resource name suffix", displayName: "Suffix" }, }, }, policyRule: { if: { - not: { - field: "name", - like: "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, + not: { field: "name", like: "[concat(parameters('prefix'), '*', parameters('suffix'))]" }, }, then: { effect: "deny" }, }, - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitions.createOrUpdate( - policyDefinitionName, - parameters, - ); + }); console.log(result); } /** - * This sample demonstrates how to This operation creates or updates a policy definition in the given subscription with the given name. + * This sample demonstrates how to this operation creates or updates a policy definition in the given subscription with the given name. * - * @summary This operation creates or updates a policy definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionAdvancedParams.json + * @summary this operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionAdvancedParams.json */ async function createOrUpdateAPolicyDefinitionWithAdvancedParameters(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "EventHubDiagnosticLogs"; - const parameters: PolicyDefinition = { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.createOrUpdate("EventHubDiagnosticLogs", { description: "Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised", displayName: "Event Hubs should have diagnostic logging enabled", @@ -97,32 +76,62 @@ async function createOrUpdateAPolicyDefinitionWithAdvancedParameters(): Promise< allOf: [ { equals: "true", - field: - "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled", + field: "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled", }, { equals: "[parameters('requiredRetentionDays')]", - field: - "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days", + field: "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days", }, ], }, }, }, }, - }; + }); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy definition in the given subscription with the given name. + * + * @summary this operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionExternalEvaluationEnforcementSettings.json + */ +async function createOrUpdateAPolicyDefinitionWithExternalEvaluationEnforcementSettings(): Promise { const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitions.createOrUpdate( - policyDefinitionName, - parameters, - ); + const result = await client.policyDefinitions.createOrUpdate("RandomizeVMAllocation", { + description: + "Randomly disable VM allocation in eastus by having policy rule reference the outcome of invoking an external endpoint using the CoinFlip endpoint that returns random values.", + displayName: "Randomize VM Allocation", + externalEvaluationEnforcementSettings: { + endpointSettings: { kind: "CoinFlip", details: { successProbability: 0.5 } }, + missingTokenAction: "audit", + roleDefinitionIds: [ + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/roleDefinitions/f0cc2aea-b517-48f6-8f9e-0c01c687907b", + ], + }, + metadata: { category: "VM" }, + mode: "Indexed", + policyRule: { + if: { + allOf: [ + { equals: "Microsoft.Compute/virtualMachines", field: "type" }, + { equals: "eastus", field: "location" }, + { equals: "false", value: "[claims().isValid]" }, + ], + }, + then: { effect: "deny" }, + }, + }); console.log(result); } async function main(): Promise { await createOrUpdateAPolicyDefinition(); await createOrUpdateAPolicyDefinitionWithAdvancedParameters(); + await createOrUpdateAPolicyDefinitionWithExternalEvaluationEnforcementSettings(); } main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsDeleteAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsDeleteAtManagementGroupSample.ts index 71f98321b338..cfc182b535ac 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionsDeleteAtManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsDeleteAtManagementGroupSample.ts @@ -1,27 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation deletes the policy definition in the given management group with the given name. - * - * @summary This operation deletes the policy definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinitionAtManagementGroup.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation deletes the policy definition in the given management group with the given name. + * + * @summary this operation deletes the policy definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/deletePolicyDefinitionAtManagementGroup.json + */ async function deleteAPolicyDefinitionAtManagementGroupLevel(): Promise { - const managementGroupId = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); - const result = await client.policyDefinitions.deleteAtManagementGroup( - managementGroupId, - policyDefinitionName, - ); - console.log(result); + await client.policyDefinitions.deleteAtManagementGroup("MyManagementGroup", "ResourceNaming"); } async function main(): Promise { diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsDeleteSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsDeleteSample.ts index da48817a5a54..6ec2d0c1f9c5 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionsDeleteSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsDeleteSample.ts @@ -1,26 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation deletes the policy definition in the given subscription with the given name. - * - * @summary This operation deletes the policy definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinition.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation deletes the policy definition in the given subscription with the given name. + * + * @summary this operation deletes the policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/deletePolicyDefinition.json + */ async function deleteAPolicyDefinition(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitions.delete(policyDefinitionName); - console.log(result); + await client.policyDefinitions.delete("ResourceNaming"); } async function main(): Promise { diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetAtManagementGroupSample.ts index c457a2839f66..cdb278a96281 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetAtManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetAtManagementGroupSample.ts @@ -1,25 +1,21 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves the policy definition in the given management group with the given name. - * - * @summary This operation retrieves the policy definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinitionAtManagementGroup.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves the policy definition in the given management group with the given name. + * + * @summary this operation retrieves the policy definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/getPolicyDefinitionAtManagementGroup.json + */ async function retrieveAPolicyDefinitionAtManagementGroupLevel(): Promise { - const managementGroupId = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyDefinitions.getAtManagementGroup( - managementGroupId, - policyDefinitionName, + "MyManagementGroup", + "ResourceNaming", ); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetBuiltInSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetBuiltInSample.ts index 2cb60e0dece9..60032f58def0 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetBuiltInSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetBuiltInSample.ts @@ -1,23 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves the built-in policy definition with the given name. - * - * @summary This operation retrieves the built-in policy definition with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltinPolicyDefinition.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves the built-in policy definition with the given name. + * + * @summary this operation retrieves the built-in policy definition with the given name. + * x-ms-original-file: 2025-03-01/getBuiltinPolicyDefinition.json + */ async function retrieveABuiltInPolicyDefinition(): Promise { - const policyDefinitionName = "7433c107-6db4-4ad1-b57a-a76dce0154a1"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); - const result = - await client.policyDefinitions.getBuiltIn(policyDefinitionName); + const result = await client.policyDefinitions.getBuiltIn("7433c107-6db4-4ad1-b57a-a76dce0154a1"); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetSample.ts index 3dc23222ed02..a885e87bc1e6 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetSample.ts @@ -1,25 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves the policy definition in the given subscription with the given name. - * - * @summary This operation retrieves the policy definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinition.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves the policy definition in the given subscription with the given name. + * + * @summary this operation retrieves the policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/getPolicyDefinition.json + */ async function retrieveAPolicyDefinition(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitions.get(policyDefinitionName); + const result = await client.policyDefinitions.get("ResourceNaming"); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsListBuiltInSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsListBuiltInSample.ts index ebdbabaf631a..9a8522ad5378 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionsListBuiltInSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsListBuiltInSample.ts @@ -1,17 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. - * - * @summary This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicyDefinitions.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. + * + * @summary this operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listBuiltInPolicyDefinitions.json + */ async function listBuiltInPolicyDefinitions(): Promise { const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); @@ -19,6 +17,7 @@ async function listBuiltInPolicyDefinitions(): Promise { for await (const item of client.policyDefinitions.listBuiltIn()) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsListByManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsListByManagementGroupSample.ts index eaf202dc76de..497e020825de 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionsListByManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsListByManagementGroupSample.ts @@ -1,27 +1,23 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. - * - * @summary This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitionsByManagementGroup.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * + * @summary this operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listPolicyDefinitionsByManagementGroup.json + */ async function listPolicyDefinitionsByManagementGroup(): Promise { - const managementGroupId = "MyManagementGroup"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); - for await (const item of client.policyDefinitions.listByManagementGroup( - managementGroupId, - )) { + for await (const item of client.policyDefinitions.listByManagementGroup("MyManagementGroup")) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsListSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsListSample.ts index 2038d0ae2876..4c01baadb8e8 100644 --- a/sdk/policy/arm-policy/samples-dev/policyDefinitionsListSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsListSample.ts @@ -1,27 +1,24 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. - * - * @summary This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitions.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * + * @summary this operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listPolicyDefinitions.json + */ async function listPolicyDefinitionsBySubscription(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const resArray = new Array(); for await (const item of client.policyDefinitions.list()) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts index 82427f55a88f..2b361cf51a97 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts @@ -1,53 +1,43 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation creates or updates a policy set definition version in the given management group with the given name and version. - * - * @summary This operation creates or updates a policy set definition version in the given management group with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json - */ - -import type { PolicySetDefinitionVersion } from "@azure/arm-policy"; import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation creates or updates a policy set definition version in the given management group with the given name and version. + * + * @summary this operation creates or updates a policy set definition version in the given management group with the given name and version. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json + */ async function createOrUpdateAPolicySetDefinitionVersionAtManagementGroupLevel(): Promise { - const managementGroupName = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; - const parameters: PolicySetDefinitionVersion = { - description: "Policies to enforce low cost storage SKUs", - displayName: "Cost Management", - metadata: { category: "Cost Management" }, - policyDefinitions: [ - { - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - policyDefinitionReferenceId: "Limit_Skus", - }, - { - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - policyDefinitionReferenceId: "Resource_Naming", - }, - ], - version: "1.2.1", - }; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); - const result = - await client.policySetDefinitionVersions.createOrUpdateAtManagementGroup( - managementGroupName, - policySetDefinitionName, - policyDefinitionVersion, - parameters, - ); + const result = await client.policySetDefinitionVersions.createOrUpdateAtManagementGroup( + "MyManagementGroup", + "CostManagement", + "1.2.1", + { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitions: [ + { + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus", + }, + { + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming", + }, + ], + version: "1.2.1", + }, + ); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsCreateOrUpdateSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsCreateOrUpdateSample.ts index b94a91c96468..323af123d7cd 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsCreateOrUpdateSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsCreateOrUpdateSample.ts @@ -1,62 +1,49 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation creates or updates a policy set definition version in the given subscription with the given name and version. - * - * @summary This operation creates or updates a policy set definition version in the given subscription with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionVersion.json - */ - -import type { PolicySetDefinitionVersion } from "@azure/arm-policy"; import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation creates or updates a policy set definition version in the given subscription with the given name and version. + * + * @summary this operation creates or updates a policy set definition version in the given subscription with the given name and version. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionVersion.json + */ async function createOrUpdateAPolicySetDefinitionVersion(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; - const parameters: PolicySetDefinitionVersion = { - description: "Policies to enforce low cost storage SKUs", - displayName: "Cost Management", - metadata: { category: "Cost Management" }, - parameters: { - namePrefix: { - type: "String", - defaultValue: "myPrefix", - metadata: { displayName: "Prefix to enforce on resource names" }, - }, - }, - policyDefinitions: [ - { - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - policyDefinitionReferenceId: "Limit_Skus", - }, - { - parameters: { - prefix: { value: "[parameters('namePrefix')]" }, - suffix: { value: "-LC" }, - }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - policyDefinitionReferenceId: "Resource_Naming", - }, - ], - version: "1.2.1", - }; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const result = await client.policySetDefinitionVersions.createOrUpdate( - policySetDefinitionName, - policyDefinitionVersion, - parameters, + "CostManagement", + "1.2.1", + { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + parameters: { + namePrefix: { + type: "String", + defaultValue: "myPrefix", + metadata: { displayName: "Prefix to enforce on resource names" }, + }, + }, + policyDefinitions: [ + { + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus", + }, + { + parameters: { prefix: { value: "[parameters('namePrefix')]" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming", + }, + ], + version: "1.2.1", + }, ); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsDeleteAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsDeleteAtManagementGroupSample.ts index 9d3bc839f9c2..55ecf200efe8 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsDeleteAtManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsDeleteAtManagementGroupSample.ts @@ -1,30 +1,23 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation deletes the policy set definition version in the given management group with the given name and version. - * - * @summary This operation deletes the policy set definition version in the given management group with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinitionVersionAtManagementGroup.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation deletes the policy set definition version in the given management group with the given name and version. + * + * @summary this operation deletes the policy set definition version in the given management group with the given name and version. + * x-ms-original-file: 2025-03-01/deletePolicySetDefinitionVersionAtManagementGroup.json + */ async function deleteAPolicySetDefinitionVersionAtManagementGroupLevel(): Promise { - const managementGroupName = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); - const result = - await client.policySetDefinitionVersions.deleteAtManagementGroup( - managementGroupName, - policySetDefinitionName, - policyDefinitionVersion, - ); - console.log(result); + await client.policySetDefinitionVersions.deleteAtManagementGroup( + "MyManagementGroup", + "CostManagement", + "1.2.1", + ); } async function main(): Promise { diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsDeleteSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsDeleteSample.ts index 684fc7216c8b..5dd732b903d5 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsDeleteSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsDeleteSample.ts @@ -1,30 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation deletes the policy set definition version in the given subscription with the given name and version. - * - * @summary This operation deletes the policy set definition version in the given subscription with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinitionVersion.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation deletes the policy set definition version in the given subscription with the given name and version. + * + * @summary this operation deletes the policy set definition version in the given subscription with the given name and version. + * x-ms-original-file: 2025-03-01/deletePolicySetDefinitionVersion.json + */ async function deleteAPolicySetDefinitionVersion(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitionVersions.delete( - policySetDefinitionName, - policyDefinitionVersion, - ); - console.log(result); + await client.policySetDefinitionVersions.delete("CostManagement", "1.2.1"); } async function main(): Promise { diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsGetAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsGetAtManagementGroupSample.ts index 6017cc6f368d..552249177dab 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsGetAtManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsGetAtManagementGroupSample.ts @@ -1,27 +1,22 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves the policy set definition version in the given management group with the given name and version. - * - * @summary This operation retrieves the policy set definition version in the given management group with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinitionVersionAtManagementGroup.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves the policy set definition version in the given management group with the given name and version. + * + * @summary this operation retrieves the policy set definition version in the given management group with the given name and version. + * x-ms-original-file: 2025-03-01/getPolicySetDefinitionVersionAtManagementGroup.json + */ async function retrieveAPolicySetDefinitionVersionAtManagementGroupLevel(): Promise { - const managementGroupName = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policySetDefinitionVersions.getAtManagementGroup( - managementGroupName, - policySetDefinitionName, - policyDefinitionVersion, + "MyManagementGroup", + "CostManagement", + "1.2.1", ); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsGetBuiltInSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsGetBuiltInSample.ts index 2f90542d48cc..c7f8fe3ca57d 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsGetBuiltInSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsGetBuiltInSample.ts @@ -1,25 +1,21 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves the built-in policy set definition version with the given name and version. - * - * @summary This operation retrieves the built-in policy set definition version with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltInPolicySetDefinitionVersion.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves the built-in policy set definition version with the given name and version. + * + * @summary this operation retrieves the built-in policy set definition version with the given name and version. + * x-ms-original-file: 2025-03-01/getBuiltInPolicySetDefinitionVersion.json + */ async function retrieveABuiltInPolicySetDefinitionVersion(): Promise { - const policySetDefinitionName = "1f3afdf9-d0c9-4c3d-847f-89da613e70a8"; - const policyDefinitionVersion = "1.2.1"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policySetDefinitionVersions.getBuiltIn( - policySetDefinitionName, - policyDefinitionVersion, + "1f3afdf9-d0c9-4c3d-847f-89da613e70a8", + "1.2.1", ); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsGetSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsGetSample.ts index a7320986d3e9..133122f34bf3 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsGetSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsGetSample.ts @@ -1,29 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves the policy set definition version in the given subscription with the given name and version. - * - * @summary This operation retrieves the policy set definition version in the given subscription with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinitionVersion.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves the policy set definition version in the given subscription with the given name and version. + * + * @summary this operation retrieves the policy set definition version in the given subscription with the given name and version. + * x-ms-original-file: 2025-03-01/getPolicySetDefinitionVersion.json + */ async function retrieveAPolicySetDefinitionVersion(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitionVersions.get( - policySetDefinitionName, - policyDefinitionVersion, - ); + const result = await client.policySetDefinitionVersions.get("CostManagement", "1.2.1"); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListAllAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListAllAtManagementGroupSample.ts index dadad39ec9ea..0065e9f8a881 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListAllAtManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListAllAtManagementGroupSample.ts @@ -1,25 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation lists all the policy set definition versions for all policy set definitions at the management group scope. - * - * @summary This operation lists all the policy set definition versions for all policy set definitions at the management group scope. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicySetDefinitionVersionsByManagementGroup.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation lists all the policy set definition versions for all policy set definitions at the management group scope. + * + * @summary this operation lists all the policy set definition versions for all policy set definitions at the management group scope. + * x-ms-original-file: 2025-03-01/listAllPolicySetDefinitionVersionsByManagementGroup.json + */ async function listAllPolicyDefinitionVersionsAtManagementGroup(): Promise { - const managementGroupName = "MyManagementGroup"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = - await client.policySetDefinitionVersions.listAllAtManagementGroup( - managementGroupName, - ); + await client.policySetDefinitionVersions.listAllAtManagementGroup("MyManagementGroup"); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListAllBuiltinsSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListAllBuiltinsSample.ts index 94316f1b25a8..e4cc8dcc0b65 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListAllBuiltinsSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListAllBuiltinsSample.ts @@ -1,17 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation lists all the built-in policy set definition versions for all built-in policy set definitions. - * - * @summary This operation lists all the built-in policy set definition versions for all built-in policy set definitions. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllBuiltInPolicySetDefinitionVersions.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation lists all the built-in policy set definition versions for all built-in policy set definitions. + * + * @summary this operation lists all the built-in policy set definition versions for all built-in policy set definitions. + * x-ms-original-file: 2025-03-01/listAllBuiltInPolicySetDefinitionVersions.json + */ async function listAllBuiltInPolicyDefinitionVersions(): Promise { const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListAllSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListAllSample.ts index ea4d08248f62..ca229730124d 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListAllSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListAllSample.ts @@ -1,22 +1,18 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation lists all the policy set definition versions for all policy set definitions within a subscription. - * - * @summary This operation lists all the policy set definition versions for all policy set definitions within a subscription. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicySetDefinitionVersions.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation lists all the policy set definition versions for all policy set definitions within a subscription. + * + * @summary this operation lists all the policy set definition versions for all policy set definitions within a subscription. + * x-ms-original-file: 2025-03-01/listAllPolicySetDefinitionVersions.json + */ async function listAllPolicyDefinitionVersionsAtSubscription(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const result = await client.policySetDefinitionVersions.listAll(); console.log(result); diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListBuiltInSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListBuiltInSample.ts index 906501fa1e3a..5a8c71748997 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListBuiltInSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListBuiltInSample.ts @@ -1,27 +1,25 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. - * - * @summary This operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicySetDefinitionVersions.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. + * + * @summary this operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. + * x-ms-original-file: 2025-03-01/listBuiltInPolicySetDefinitionVersions.json + */ async function listBuiltInPolicySetDefinitions(): Promise { - const policySetDefinitionName = "1f3afdf9-d0c9-4c3d-847f-89da613e70a8"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); for await (const item of client.policySetDefinitionVersions.listBuiltIn( - policySetDefinitionName, + "1f3afdf9-d0c9-4c3d-847f-89da613e70a8", )) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListByManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListByManagementGroupSample.ts index d80f1a1e2989..81052b09bbfa 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListByManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListByManagementGroupSample.ts @@ -1,29 +1,26 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. - * - * @summary This operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitionVersionsByManagementGroup.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. + * + * @summary this operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. + * x-ms-original-file: 2025-03-01/listPolicySetDefinitionVersionsByManagementGroup.json + */ async function listPolicySetDefinitionsAtManagementGroupLevel(): Promise { - const managementGroupName = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); for await (const item of client.policySetDefinitionVersions.listByManagementGroup( - managementGroupName, - policySetDefinitionName, + "MyManagementGroup", + "CostManagement", )) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListSample.ts index 1b7da6291caf..84fafcfdd9fe 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionVersionsListSample.ts @@ -1,30 +1,24 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves a list of all the policy set definition versions for the given policy set definition. - * - * @summary This operation retrieves a list of all the policy set definition versions for the given policy set definition. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitionVersions.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves a list of all the policy set definition versions for the given policy set definition. + * + * @summary this operation retrieves a list of all the policy set definition versions for the given policy set definition. + * x-ms-original-file: 2025-03-01/listPolicySetDefinitionVersions.json + */ async function listPolicySetDefinitions(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const resArray = new Array(); - for await (const item of client.policySetDefinitionVersions.list( - policySetDefinitionName, - )) { + for await (const item of client.policySetDefinitionVersions.list("CostManagement")) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts index 6328ab3be3eb..ead47c9853e0 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts @@ -1,107 +1,91 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation creates or updates a policy set definition in the given management group with the given name. - * - * @summary This operation creates or updates a policy set definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json - */ - -import type { PolicySetDefinition } from "@azure/arm-policy"; import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation creates or updates a policy set definition in the given management group with the given name. + * + * @summary this operation creates or updates a policy set definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionAtManagementGroup.json + */ async function createOrUpdateAPolicySetDefinitionAtManagementGroupLevel(): Promise { - const managementGroupId = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const parameters: PolicySetDefinition = { - description: "Policies to enforce low cost storage SKUs", - displayName: "Cost Management", - metadata: { category: "Cost Management" }, - policyDefinitions: [ - { - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - policyDefinitionReferenceId: "Limit_Skus", - }, - { - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - policyDefinitionReferenceId: "Resource_Naming", - }, - ], - }; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); - const result = - await client.policySetDefinitions.createOrUpdateAtManagementGroup( - managementGroupId, - policySetDefinitionName, - parameters, - ); + const result = await client.policySetDefinitions.createOrUpdateAtManagementGroup( + "MyManagementGroup", + "CostManagement", + { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitions: [ + { + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus", + }, + { + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming", + }, + ], + }, + ); console.log(result); } /** - * This sample demonstrates how to This operation creates or updates a policy set definition in the given management group with the given name. + * This sample demonstrates how to this operation creates or updates a policy set definition in the given management group with the given name. * - * @summary This operation creates or updates a policy set definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json + * @summary this operation creates or updates a policy set definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json */ async function createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel(): Promise { - const managementGroupId = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const parameters: PolicySetDefinition = { - description: "Policies to enforce low cost storage SKUs", - displayName: "Cost Management", - metadata: { category: "Cost Management" }, - policyDefinitionGroups: [ - { - name: "CostSaving", - description: - "Policies designed to control spend within a subscription.", - displayName: "Cost Management Policies", - }, - { - name: "Organizational", - description: - "Policies that help enforce resource organization standards within a subscription.", - displayName: "Organizational Policies", - }, - ], - policyDefinitions: [ - { - groupNames: ["CostSaving"], - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - policyDefinitionReferenceId: "Limit_Skus", - }, - { - groupNames: ["Organizational"], - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - policyDefinitionReferenceId: "Resource_Naming", - }, - ], - }; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); - const result = - await client.policySetDefinitions.createOrUpdateAtManagementGroup( - managementGroupId, - policySetDefinitionName, - parameters, - ); + const result = await client.policySetDefinitions.createOrUpdateAtManagementGroup( + "MyManagementGroup", + "CostManagement", + { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitionGroups: [ + { + name: "CostSaving", + description: "Policies designed to control spend within a subscription.", + displayName: "Cost Management Policies", + }, + { + name: "Organizational", + description: + "Policies that help enforce resource organization standards within a subscription.", + displayName: "Organizational Policies", + }, + ], + policyDefinitions: [ + { + groupNames: ["CostSaving"], + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus", + }, + { + groupNames: ["Organizational"], + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming", + }, + ], + }, + ); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsCreateOrUpdateSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsCreateOrUpdateSample.ts index f92b755ddd22..8152bc9b50bf 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsCreateOrUpdateSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsCreateOrUpdateSample.ts @@ -1,24 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation creates or updates a policy set definition in the given subscription with the given name. - * - * @summary This operation creates or updates a policy set definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinition.json - */ - -import type { PolicySetDefinition } from "@azure/arm-policy"; import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation creates or updates a policy set definition in the given subscription with the given name. + * + * @summary this operation creates or updates a policy set definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinition.json + */ async function createOrUpdateAPolicySetDefinition(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const parameters: PolicySetDefinition = { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdate("CostManagement", { description: "Policies to enforce low cost storage SKUs", displayName: "Cost Management", metadata: { category: "Cost Management" }, @@ -31,53 +27,40 @@ async function createOrUpdateAPolicySetDefinition(): Promise { }, policyDefinitions: [ { - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, policyDefinitionId: "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", policyDefinitionReferenceId: "Limit_Skus", }, { - parameters: { - prefix: { value: "[parameters('namePrefix')]" }, - suffix: { value: "-LC" }, - }, + parameters: { prefix: { value: "[parameters('namePrefix')]" }, suffix: { value: "-LC" } }, policyDefinitionId: "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", policyDefinitionReferenceId: "Resource_Naming", }, ], - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitions.createOrUpdate( - policySetDefinitionName, - parameters, - ); + }); console.log(result); } /** - * This sample demonstrates how to This operation creates or updates a policy set definition in the given subscription with the given name. + * This sample demonstrates how to this operation creates or updates a policy set definition in the given subscription with the given name. * - * @summary This operation creates or updates a policy set definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionWithGroups.json + * @summary this operation creates or updates a policy set definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionWithGroups.json */ async function createOrUpdateAPolicySetDefinitionWithGroups(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const parameters: PolicySetDefinition = { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdate("CostManagement", { description: "Policies to enforce low cost storage SKUs", displayName: "Cost Management", metadata: { category: "Cost Management" }, policyDefinitionGroups: [ { name: "CostSaving", - description: - "Policies designed to control spend within a subscription.", + description: "Policies designed to control spend within a subscription.", displayName: "Cost Management Policies", }, { @@ -91,9 +74,7 @@ async function createOrUpdateAPolicySetDefinitionWithGroups(): Promise { { definitionVersion: "1.*.*", groupNames: ["CostSaving"], - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, policyDefinitionId: "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", policyDefinitionReferenceId: "Limit_Skus", @@ -107,13 +88,7 @@ async function createOrUpdateAPolicySetDefinitionWithGroups(): Promise { policyDefinitionReferenceId: "Resource_Naming", }, ], - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitions.createOrUpdate( - policySetDefinitionName, - parameters, - ); + }); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsDeleteAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsDeleteAtManagementGroupSample.ts index 17dca2cda786..697526eff8bc 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsDeleteAtManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsDeleteAtManagementGroupSample.ts @@ -1,27 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation deletes the policy set definition in the given management group with the given name. - * - * @summary This operation deletes the policy set definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinitionAtManagementGroup.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation deletes the policy set definition in the given management group with the given name. + * + * @summary this operation deletes the policy set definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/deletePolicySetDefinitionAtManagementGroup.json + */ async function deleteAPolicySetDefinitionAtManagementGroupLevel(): Promise { - const managementGroupId = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); - const result = await client.policySetDefinitions.deleteAtManagementGroup( - managementGroupId, - policySetDefinitionName, - ); - console.log(result); + await client.policySetDefinitions.deleteAtManagementGroup("MyManagementGroup", "CostManagement"); } async function main(): Promise { diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsDeleteSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsDeleteSample.ts index 844e6764e7eb..d2b7f4404b12 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsDeleteSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsDeleteSample.ts @@ -1,28 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation deletes the policy set definition in the given subscription with the given name. - * - * @summary This operation deletes the policy set definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinition.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation deletes the policy set definition in the given subscription with the given name. + * + * @summary this operation deletes the policy set definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/deletePolicySetDefinition.json + */ async function deleteAPolicySetDefinition(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitions.delete( - policySetDefinitionName, - ); - console.log(result); + await client.policySetDefinitions.delete("CostManagement"); } async function main(): Promise { diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetAtManagementGroupSample.ts index ce20d294cde9..c6253efa7831 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetAtManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetAtManagementGroupSample.ts @@ -1,25 +1,21 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves the policy set definition in the given management group with the given name. - * - * @summary This operation retrieves the policy set definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinitionAtManagementGroup.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves the policy set definition in the given management group with the given name. + * + * @summary this operation retrieves the policy set definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/getPolicySetDefinitionAtManagementGroup.json + */ async function retrieveAPolicySetDefinitionAtManagementGroupLevel(): Promise { - const managementGroupId = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policySetDefinitions.getAtManagementGroup( - managementGroupId, - policySetDefinitionName, + "MyManagementGroup", + "CostManagement", ); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetBuiltInSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetBuiltInSample.ts index e6390593e83d..0b65ac57e6ec 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetBuiltInSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetBuiltInSample.ts @@ -1,23 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves the built-in policy set definition with the given name. - * - * @summary This operation retrieves the built-in policy set definition with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltInPolicySetDefinition.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves the built-in policy set definition with the given name. + * + * @summary this operation retrieves the built-in policy set definition with the given name. + * x-ms-original-file: 2025-03-01/getBuiltInPolicySetDefinition.json + */ async function retrieveABuiltInPolicySetDefinition(): Promise { - const policySetDefinitionName = "1f3afdf9-d0c9-4c3d-847f-89da613e70a8"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policySetDefinitions.getBuiltIn( - policySetDefinitionName, + "1f3afdf9-d0c9-4c3d-847f-89da613e70a8", ); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetSample.ts index 80a8e1facdfe..d33322d1f3e2 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetSample.ts @@ -1,25 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves the policy set definition in the given subscription with the given name. - * - * @summary This operation retrieves the policy set definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinition.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves the policy set definition in the given subscription with the given name. + * + * @summary this operation retrieves the policy set definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/getPolicySetDefinition.json + */ async function retrieveAPolicySetDefinition(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitions.get(policySetDefinitionName); + const result = await client.policySetDefinitions.get("CostManagement"); console.log(result); } diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListBuiltInSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListBuiltInSample.ts index 825ae77baa3e..93c5f6d8a353 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListBuiltInSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListBuiltInSample.ts @@ -1,17 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. - * - * @summary This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicySetDefinitions.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. + * + * @summary this operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listBuiltInPolicySetDefinitions.json + */ async function listBuiltInPolicySetDefinitions(): Promise { const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); @@ -19,6 +17,7 @@ async function listBuiltInPolicySetDefinitions(): Promise { for await (const item of client.policySetDefinitions.listBuiltIn()) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListByManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListByManagementGroupSample.ts index d35869e67e4d..57ed2fbc508b 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListByManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListByManagementGroupSample.ts @@ -1,27 +1,23 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. - * - * @summary This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitionsByManagementGroup.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * + * @summary this operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listPolicySetDefinitionsByManagementGroup.json + */ async function listPolicySetDefinitionsAtManagementGroupLevel(): Promise { - const managementGroupId = "MyManagementGroup"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); - for await (const item of client.policySetDefinitions.listByManagementGroup( - managementGroupId, - )) { + for await (const item of client.policySetDefinitions.listByManagementGroup("MyManagementGroup")) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListSample.ts index a8596d44790c..0f071298db77 100644 --- a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListSample.ts +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListSample.ts @@ -1,27 +1,24 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. - * - * @summary This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitions.json - */ - import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to this operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * + * @summary this operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listPolicySetDefinitions.json + */ async function listPolicySetDefinitions(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const resArray = new Array(); for await (const item of client.policySetDefinitions.list()) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples-dev/policyTokensAcquireAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyTokensAcquireAtManagementGroupSample.ts new file mode 100644 index 000000000000..f57d218c94c3 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyTokensAcquireAtManagementGroupSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation acquires a policy token in the given management group for the given request body. + * + * @summary this operation acquires a policy token in the given management group for the given request body. + * x-ms-original-file: 2025-03-01/acquirePolicyTokenAtManagementGroup.json + */ +async function acquireAPolicyTokenAtManagementGroupLevel(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyTokens.acquireAtManagementGroup("MyManagementGroup", { + operation: { + httpMethod: "delete", + uri: "https://management.azure.com/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/roleAssignments/00000000-0000-0000-0000-000000000000?api-version=2022-04-01", + }, + }); + console.log(result); +} + +async function main(): Promise { + await acquireAPolicyTokenAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyTokensAcquireSample.ts b/sdk/policy/arm-policy/samples-dev/policyTokensAcquireSample.ts new file mode 100644 index 000000000000..79f57d13bec3 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyTokensAcquireSample.ts @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation acquires a policy token in the given subscription for the given request body. + * + * @summary this operation acquires a policy token in the given subscription for the given request body. + * x-ms-original-file: 2025-03-01/acquirePolicyToken.json + */ +async function acquireAPolicyToken(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyTokens.acquire({ + operation: { + httpMethod: "delete", + uri: "https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/testVM?api-version=2024-01-01", + }, + }); + console.log(result); +} + +async function main(): Promise { + await acquireAPolicyToken(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsCreateByIdSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsCreateByIdSample.js deleted file mode 100644 index 3f89d12f020a..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsCreateByIdSample.js +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * - * @summary This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentById.json - */ -async function createOrUpdatePolicyAssignmentById() { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const parameters = { - description: "Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created", - definitionVersion: "1.*.*", - displayName: "Enforce storage account SKU", - enforcementMode: "Default", - metadata: { assignedBy: "Cheapskate Boss" }, - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.createById(policyAssignmentId, parameters); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * - * @summary This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithIdentityById.json - */ -async function createOrUpdatePolicyAssignmentWithAManagedIdentityById() { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const parameters = { - description: "Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created", - definitionVersion: "1.*.*", - displayName: "Enforce storage account SKU", - enforcementMode: "Default", - identity: { type: "SystemAssigned" }, - location: "eastus", - metadata: { assignedBy: "Cheapskate Boss" }, - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.createById(policyAssignmentId, parameters); - console.log(result); -} - -async function main() { - await createOrUpdatePolicyAssignmentById(); - await createOrUpdatePolicyAssignmentWithAManagedIdentityById(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsCreateSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsCreateSample.js deleted file mode 100644 index d164d493af30..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsCreateSample.js +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignment.json - */ -async function createOrUpdateAPolicyAssignment() { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters = { - description: "Force resource names to begin with given DeptA and end with -LC", - displayName: "Enforce resource naming rules", - metadata: { assignedBy: "Special Someone" }, - nonComplianceMessages: [ - { message: "Resource names must start with 'DeptA' and end with '-LC'." }, - ], - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.create(scope, policyAssignmentName, parameters); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithIdentity.json - */ -async function createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity() { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters = { - description: "Force resource names to begin with given DeptA and end with -LC", - displayName: "Enforce resource naming rules", - enforcementMode: "Default", - identity: { type: "SystemAssigned" }, - location: "eastus", - metadata: { assignedBy: "Foo Bar" }, - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.create(scope, policyAssignmentName, parameters); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithUserAssignedIdentity.json - */ -async function createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity() { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters = { - description: "Force resource names to begin with given DeptA and end with -LC", - displayName: "Enforce resource naming rules", - enforcementMode: "Default", - identity: { - type: "UserAssigned", - userAssignedIdentities: { - "/subscriptions/ae640e6bBa3e42569d622993eecfa6f2/resourceGroups/testResourceGroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/testIdentity": - {}, - }, - }, - location: "eastus", - metadata: { assignedBy: "Foo Bar" }, - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.create(scope, policyAssignmentName, parameters); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentNonComplianceMessages.json - */ -async function createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages() { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "securityInitAssignment"; - const parameters = { - displayName: "Enforce security policies", - nonComplianceMessages: [ - { - message: - "Resources must comply with all internal security policies. See for more info.", - }, - { - message: "Resource names must start with 'DeptA' and end with '-LC'.", - policyDefinitionReferenceId: "10420126870854049575", - }, - { - message: "Storage accounts must have firewall rules configured.", - policyDefinitionReferenceId: "8572513655450389710", - }, - ], - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/securityInitiative", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.create(scope, policyAssignmentName, parameters); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithOverrides.json - */ -async function createOrUpdateAPolicyAssignmentWithOverrides() { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; - const parameters = { - description: "Limit the resource location and resource SKU", - definitionVersion: "1.*.*", - displayName: "Limit the resource location and resource SKU", - metadata: { assignedBy: "Special Someone" }, - overrides: [ - { - kind: "policyEffect", - selectors: [ - { - in: ["Limit_Skus", "Limit_Locations"], - kind: "policyDefinitionReferenceId", - }, - ], - value: "Audit", - }, - { - kind: "definitionVersion", - selectors: [{ in: ["eastUSEuap", "centralUSEuap"], kind: "resourceLocation" }], - value: "2.*.*", - }, - ], - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.create(scope, policyAssignmentName, parameters); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithResourceSelectors.json - */ -async function createOrUpdateAPolicyAssignmentWithResourceSelectors() { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; - const parameters = { - description: "Limit the resource location and resource SKU", - displayName: "Limit the resource location and resource SKU", - metadata: { assignedBy: "Special Someone" }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", - resourceSelectors: [ - { - name: "SDPRegions", - selectors: [{ in: ["eastus2euap", "centraluseuap"], kind: "resourceLocation" }], - }, - ], - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.create(scope, policyAssignmentName, parameters); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithoutEnforcement.json - */ -async function createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate() { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters = { - description: "Force resource names to begin with given DeptA and end with -LC", - displayName: "Enforce resource naming rules", - enforcementMode: "DoNotEnforce", - metadata: { assignedBy: "Special Someone" }, - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.create(scope, policyAssignmentName, parameters); - console.log(result); -} - -async function main() { - await createOrUpdateAPolicyAssignment(); - await createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity(); - await createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity(); - await createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages(); - await createOrUpdateAPolicyAssignmentWithOverrides(); - await createOrUpdateAPolicyAssignmentWithResourceSelectors(); - await createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsDeleteByIdSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsDeleteByIdSample.js deleted file mode 100644 index 97a66abd84e5..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsDeleteByIdSample.js +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). - * - * @summary This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyAssignmentById.json - */ -async function deleteAPolicyAssignmentById() { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.deleteById(policyAssignmentId); - console.log(result); -} - -async function main() { - await deleteAPolicyAssignmentById(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsGetByIdSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsGetByIdSample.js deleted file mode 100644 index ff2d4e172911..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsGetByIdSample.js +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * - * @summary The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentById.json - */ -async function retrieveAPolicyAssignmentById() { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.getById(policyAssignmentId); - console.log(result); -} - -/** - * This sample demonstrates how to The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * - * @summary The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentWithIdentityById.json - */ -async function retrieveAPolicyAssignmentWithAManagedIdentityById() { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.getById(policyAssignmentId); - console.log(result); -} - -async function main() { - await retrieveAPolicyAssignmentById(); - await retrieveAPolicyAssignmentWithAManagedIdentityById(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsGetSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsGetSample.js deleted file mode 100644 index b84fc16fc235..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsGetSample.js +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. - * - * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignment.json - */ -async function retrieveAPolicyAssignment() { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.get(scope, policyAssignmentName); - console.log(result); -} - -/** - * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. - * - * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentWithIdentity.json - */ -async function retrieveAPolicyAssignmentWithASystemAssignedIdentity() { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.get(scope, policyAssignmentName); - console.log(result); -} - -/** - * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. - * - * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json - */ -async function retrieveAPolicyAssignmentWithAUserAssignedIdentity() { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.get(scope, policyAssignmentName); - console.log(result); -} - -/** - * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. - * - * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentWithOverrides.json - */ -async function retrieveAPolicyAssignmentWithOverrides() { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.get(scope, policyAssignmentName); - console.log(result); -} - -/** - * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. - * - * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentWithResourceSelectors.json - */ -async function retrieveAPolicyAssignmentWithResourceSelectors() { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.get(scope, policyAssignmentName); - console.log(result); -} - -async function main() { - await retrieveAPolicyAssignment(); - await retrieveAPolicyAssignmentWithASystemAssignedIdentity(); - await retrieveAPolicyAssignmentWithAUserAssignedIdentity(); - await retrieveAPolicyAssignmentWithOverrides(); - await retrieveAPolicyAssignmentWithResourceSelectors(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsUpdateByIdSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsUpdateByIdSample.js deleted file mode 100644 index 69c31c2a203c..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsUpdateByIdSample.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * - * @summary This operation updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithIdentityById.json - */ -async function updatePolicyAssignmentWithAManagedIdentityById() { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const parameters = { - identity: { type: "SystemAssigned" }, - location: "eastus", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.updateById(policyAssignmentId, parameters); - console.log(result); -} - -async function main() { - await updatePolicyAssignmentWithAManagedIdentityById(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsUpdateSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsUpdateSample.js deleted file mode 100644 index fb2e4868bd64..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsUpdateSample.js +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithIdentity.json - */ -async function updateAPolicyAssignmentWithASystemAssignedIdentity() { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters = { - identity: { type: "SystemAssigned" }, - location: "eastus", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.update(scope, policyAssignmentName, parameters); - console.log(result); -} - -/** - * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithUserAssignedIdentity.json - */ -async function updateAPolicyAssignmentWithAUserAssignedIdentity() { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters = { - identity: { - type: "UserAssigned", - userAssignedIdentities: { - "/subscriptions/ae640e6bBa3e42569d622993eecfa6f2/resourceGroups/testResourceGroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/testIdentity": - {}, - }, - }, - location: "eastus", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.update(scope, policyAssignmentName, parameters); - console.log(result); -} - -/** - * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithOverrides.json - */ -async function updateAPolicyAssignmentWithOverrides() { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; - const parameters = { - overrides: [ - { - kind: "policyEffect", - selectors: [ - { - in: ["Limit_Skus", "Limit_Locations"], - kind: "policyDefinitionReferenceId", - }, - ], - value: "Audit", - }, - ], - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.update(scope, policyAssignmentName, parameters); - console.log(result); -} - -/** - * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithResourceSelectors.json - */ -async function updateAPolicyAssignmentWithResourceSelectors() { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; - const parameters = { - resourceSelectors: [ - { - name: "SDPRegions", - selectors: [{ in: ["eastus2euap", "centraluseuap"], kind: "resourceLocation" }], - }, - ], - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.update(scope, policyAssignmentName, parameters); - console.log(result); -} - -async function main() { - await updateAPolicyAssignmentWithASystemAssignedIdentity(); - await updateAPolicyAssignmentWithAUserAssignedIdentity(); - await updateAPolicyAssignmentWithOverrides(); - await updateAPolicyAssignmentWithResourceSelectors(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js deleted file mode 100644 index 115c9d0f407d..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation creates or updates a policy definition version in the given management group with the given name. - * - * @summary This operation creates or updates a policy definition version in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json - */ -async function createOrUpdateAPolicyDefinitionVersionAtManagementGroupLevel() { - const managementGroupName = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; - const parameters = { - description: "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - displayName: "Enforce resource naming convention", - metadata: { category: "Naming" }, - mode: "All", - parameters: { - prefix: { - type: "String", - metadata: { - description: "Resource name prefix", - displayName: "Prefix", - }, - }, - suffix: { - type: "String", - metadata: { - description: "Resource name suffix", - displayName: "Suffix", - }, - }, - }, - policyRule: { - if: { - not: { - field: "name", - like: "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - then: { effect: "deny" }, - }, - version: "1.2.1", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyDefinitionVersions.createOrUpdateAtManagementGroup( - managementGroupName, - policyDefinitionName, - policyDefinitionVersion, - parameters, - ); - console.log(result); -} - -async function main() { - await createOrUpdateAPolicyDefinitionVersionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsCreateOrUpdateSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsCreateOrUpdateSample.js deleted file mode 100644 index 49164b12dad3..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsCreateOrUpdateSample.js +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation creates or updates a policy definition in the given subscription with the given name. - * - * @summary This operation creates or updates a policy definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionVersion.json - */ -async function createOrUpdateAPolicyDefinitionVersion() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; - const parameters = { - description: "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - displayName: "Enforce resource naming convention", - metadata: { category: "Naming" }, - mode: "All", - parameters: { - prefix: { - type: "String", - metadata: { - description: "Resource name prefix", - displayName: "Prefix", - }, - }, - suffix: { - type: "String", - metadata: { - description: "Resource name suffix", - displayName: "Suffix", - }, - }, - }, - policyRule: { - if: { - not: { - field: "name", - like: "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - then: { effect: "deny" }, - }, - version: "1.2.1", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitionVersions.createOrUpdate( - policyDefinitionName, - policyDefinitionVersion, - parameters, - ); - console.log(result); -} - -async function main() { - await createOrUpdateAPolicyDefinitionVersion(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsDeleteAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsDeleteAtManagementGroupSample.js deleted file mode 100644 index 250a19cfd4ac..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsDeleteAtManagementGroupSample.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation deletes the policy definition in the given management group with the given name. - * - * @summary This operation deletes the policy definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinitionVersionAtManagementGroup.json - */ -async function deleteAPolicyDefinitionVersionAtManagementGroupLevel() { - const managementGroupName = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyDefinitionVersions.deleteAtManagementGroup( - managementGroupName, - policyDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main() { - await deleteAPolicyDefinitionVersionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsDeleteSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsDeleteSample.js deleted file mode 100644 index 21ecfcc0cecb..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsDeleteSample.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation deletes the policy definition version in the given subscription with the given name. - * - * @summary This operation deletes the policy definition version in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinitionVersion.json - */ -async function deleteAPolicyDefinitionVersion() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitionVersions.delete( - policyDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main() { - await deleteAPolicyDefinitionVersion(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsGetAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsGetAtManagementGroupSample.js deleted file mode 100644 index 16e1eadadf64..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsGetAtManagementGroupSample.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation retrieves the policy definition version in the given management group with the given name. - * - * @summary This operation retrieves the policy definition version in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinitionVersionAtManagementGroup.json - */ -async function retrieveAPolicyDefinitionVersionAtManagementGroupLevel() { - const managementGroupName = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyDefinitionVersions.getAtManagementGroup( - managementGroupName, - policyDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main() { - await retrieveAPolicyDefinitionVersionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsGetBuiltInSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsGetBuiltInSample.js deleted file mode 100644 index 03682a4fc6cb..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsGetBuiltInSample.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation retrieves the built-in policy definition version with the given name. - * - * @summary This operation retrieves the built-in policy definition version with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltinPolicyDefinitionVersion.json - */ -async function retrieveABuiltInPolicyDefinitionVersion() { - const policyDefinitionName = "7433c107-6db4-4ad1-b57a-a76dce0154a1"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyDefinitionVersions.getBuiltIn( - policyDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main() { - await retrieveABuiltInPolicyDefinitionVersion(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsGetSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsGetSample.js deleted file mode 100644 index fe2dd5cf453c..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsGetSample.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation retrieves the policy definition version in the given subscription with the given name. - * - * @summary This operation retrieves the policy definition version in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinitionVersion.json - */ -async function retrieveAPolicyDefinitionVersion() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitionVersions.get( - policyDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main() { - await retrieveAPolicyDefinitionVersion(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListSample.js deleted file mode 100644 index 314bef664525..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListSample.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation retrieves a list of all the policy definition versions for the given policy definition. - * - * @summary This operation retrieves a list of all the policy definition versions for the given policy definition. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitionVersions.json - */ -async function listPolicyDefinitionVersionsBySubscription() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const resArray = new Array(); - for await (const item of client.policyDefinitionVersions.list(policyDefinitionName)) { - resArray.push(item); - } - console.log(resArray); -} - -async function main() { - await listPolicyDefinitionVersionsBySubscription(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsCreateOrUpdateAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsCreateOrUpdateAtManagementGroupSample.js deleted file mode 100644 index 0f19ebe60fe1..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsCreateOrUpdateAtManagementGroupSample.js +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation creates or updates a policy definition in the given management group with the given name. - * - * @summary This operation creates or updates a policy definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json - */ -async function createOrUpdateAPolicyDefinitionAtManagementGroupLevel() { - const managementGroupId = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; - const parameters = { - description: "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - displayName: "Enforce resource naming convention", - metadata: { category: "Naming" }, - mode: "All", - parameters: { - prefix: { - type: "String", - metadata: { - description: "Resource name prefix", - displayName: "Prefix", - }, - }, - suffix: { - type: "String", - metadata: { - description: "Resource name suffix", - displayName: "Suffix", - }, - }, - }, - policyRule: { - if: { - not: { - field: "name", - like: "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - then: { effect: "deny" }, - }, - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyDefinitions.createOrUpdateAtManagementGroup( - managementGroupId, - policyDefinitionName, - parameters, - ); - console.log(result); -} - -async function main() { - await createOrUpdateAPolicyDefinitionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsCreateOrUpdateSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsCreateOrUpdateSample.js deleted file mode 100644 index b9fccab3e2e5..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsCreateOrUpdateSample.js +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation creates or updates a policy definition in the given subscription with the given name. - * - * @summary This operation creates or updates a policy definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinition.json - */ -async function createOrUpdateAPolicyDefinition() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const parameters = { - description: "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - displayName: "Enforce resource naming convention", - metadata: { category: "Naming" }, - mode: "All", - parameters: { - prefix: { - type: "String", - metadata: { - description: "Resource name prefix", - displayName: "Prefix", - }, - }, - suffix: { - type: "String", - metadata: { - description: "Resource name suffix", - displayName: "Suffix", - }, - }, - }, - policyRule: { - if: { - not: { - field: "name", - like: "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - then: { effect: "deny" }, - }, - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitions.createOrUpdate(policyDefinitionName, parameters); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates a policy definition in the given subscription with the given name. - * - * @summary This operation creates or updates a policy definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionAdvancedParams.json - */ -async function createOrUpdateAPolicyDefinitionWithAdvancedParameters() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "EventHubDiagnosticLogs"; - const parameters = { - description: - "Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised", - displayName: "Event Hubs should have diagnostic logging enabled", - metadata: { category: "Event Hub" }, - mode: "Indexed", - parameters: { - requiredRetentionDays: { - type: "Integer", - allowedValues: [0, 30, 90, 180, 365], - defaultValue: 365, - metadata: { - description: "The required diagnostic logs retention in days", - displayName: "Required retention (days)", - }, - }, - }, - policyRule: { - if: { equals: "Microsoft.EventHub/namespaces", field: "type" }, - then: { - effect: "AuditIfNotExists", - details: { - type: "Microsoft.Insights/diagnosticSettings", - existenceCondition: { - allOf: [ - { - equals: "true", - field: "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled", - }, - { - equals: "[parameters('requiredRetentionDays')]", - field: "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days", - }, - ], - }, - }, - }, - }, - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitions.createOrUpdate(policyDefinitionName, parameters); - console.log(result); -} - -async function main() { - await createOrUpdateAPolicyDefinition(); - await createOrUpdateAPolicyDefinitionWithAdvancedParameters(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsDeleteAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsDeleteAtManagementGroupSample.js deleted file mode 100644 index 635fa8b4a34e..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsDeleteAtManagementGroupSample.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation deletes the policy definition in the given management group with the given name. - * - * @summary This operation deletes the policy definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinitionAtManagementGroup.json - */ -async function deleteAPolicyDefinitionAtManagementGroupLevel() { - const managementGroupId = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyDefinitions.deleteAtManagementGroup( - managementGroupId, - policyDefinitionName, - ); - console.log(result); -} - -async function main() { - await deleteAPolicyDefinitionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsDeleteSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsDeleteSample.js deleted file mode 100644 index 32660b19f510..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsDeleteSample.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation deletes the policy definition in the given subscription with the given name. - * - * @summary This operation deletes the policy definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinition.json - */ -async function deleteAPolicyDefinition() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitions.delete(policyDefinitionName); - console.log(result); -} - -async function main() { - await deleteAPolicyDefinition(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsGetAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsGetAtManagementGroupSample.js deleted file mode 100644 index dea33b34be0d..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsGetAtManagementGroupSample.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation retrieves the policy definition in the given management group with the given name. - * - * @summary This operation retrieves the policy definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinitionAtManagementGroup.json - */ -async function retrieveAPolicyDefinitionAtManagementGroupLevel() { - const managementGroupId = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyDefinitions.getAtManagementGroup( - managementGroupId, - policyDefinitionName, - ); - console.log(result); -} - -async function main() { - await retrieveAPolicyDefinitionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsGetBuiltInSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsGetBuiltInSample.js deleted file mode 100644 index e1a9536d3cb0..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsGetBuiltInSample.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation retrieves the built-in policy definition with the given name. - * - * @summary This operation retrieves the built-in policy definition with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltinPolicyDefinition.json - */ -async function retrieveABuiltInPolicyDefinition() { - const policyDefinitionName = "7433c107-6db4-4ad1-b57a-a76dce0154a1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyDefinitions.getBuiltIn(policyDefinitionName); - console.log(result); -} - -async function main() { - await retrieveABuiltInPolicyDefinition(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsGetSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsGetSample.js deleted file mode 100644 index ac94e995116b..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsGetSample.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation retrieves the policy definition in the given subscription with the given name. - * - * @summary This operation retrieves the policy definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinition.json - */ -async function retrieveAPolicyDefinition() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitions.get(policyDefinitionName); - console.log(result); -} - -async function main() { - await retrieveAPolicyDefinition(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js deleted file mode 100644 index 16e436128a60..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation creates or updates a policy set definition version in the given management group with the given name and version. - * - * @summary This operation creates or updates a policy set definition version in the given management group with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json - */ -async function createOrUpdateAPolicySetDefinitionVersionAtManagementGroupLevel() { - const managementGroupName = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; - const parameters = { - description: "Policies to enforce low cost storage SKUs", - displayName: "Cost Management", - metadata: { category: "Cost Management" }, - policyDefinitions: [ - { - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - policyDefinitionReferenceId: "Limit_Skus", - }, - { - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - policyDefinitionReferenceId: "Resource_Naming", - }, - ], - version: "1.2.1", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policySetDefinitionVersions.createOrUpdateAtManagementGroup( - managementGroupName, - policySetDefinitionName, - policyDefinitionVersion, - parameters, - ); - console.log(result); -} - -async function main() { - await createOrUpdateAPolicySetDefinitionVersionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsCreateOrUpdateSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsCreateOrUpdateSample.js deleted file mode 100644 index c62c7e556a6c..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsCreateOrUpdateSample.js +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation creates or updates a policy set definition version in the given subscription with the given name and version. - * - * @summary This operation creates or updates a policy set definition version in the given subscription with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionVersion.json - */ -async function createOrUpdateAPolicySetDefinitionVersion() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; - const parameters = { - description: "Policies to enforce low cost storage SKUs", - displayName: "Cost Management", - metadata: { category: "Cost Management" }, - parameters: { - namePrefix: { - type: "String", - defaultValue: "myPrefix", - metadata: { displayName: "Prefix to enforce on resource names" }, - }, - }, - policyDefinitions: [ - { - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - policyDefinitionReferenceId: "Limit_Skus", - }, - { - parameters: { - prefix: { value: "[parameters('namePrefix')]" }, - suffix: { value: "-LC" }, - }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - policyDefinitionReferenceId: "Resource_Naming", - }, - ], - version: "1.2.1", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitionVersions.createOrUpdate( - policySetDefinitionName, - policyDefinitionVersion, - parameters, - ); - console.log(result); -} - -async function main() { - await createOrUpdateAPolicySetDefinitionVersion(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsDeleteAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsDeleteAtManagementGroupSample.js deleted file mode 100644 index 654aebbeaee3..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsDeleteAtManagementGroupSample.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation deletes the policy set definition version in the given management group with the given name and version. - * - * @summary This operation deletes the policy set definition version in the given management group with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinitionVersionAtManagementGroup.json - */ -async function deleteAPolicySetDefinitionVersionAtManagementGroupLevel() { - const managementGroupName = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policySetDefinitionVersions.deleteAtManagementGroup( - managementGroupName, - policySetDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main() { - await deleteAPolicySetDefinitionVersionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsDeleteSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsDeleteSample.js deleted file mode 100644 index 4a15a681166c..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsDeleteSample.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation deletes the policy set definition version in the given subscription with the given name and version. - * - * @summary This operation deletes the policy set definition version in the given subscription with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinitionVersion.json - */ -async function deleteAPolicySetDefinitionVersion() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitionVersions.delete( - policySetDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main() { - await deleteAPolicySetDefinitionVersion(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsGetAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsGetAtManagementGroupSample.js deleted file mode 100644 index c1f2775e6557..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsGetAtManagementGroupSample.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation retrieves the policy set definition version in the given management group with the given name and version. - * - * @summary This operation retrieves the policy set definition version in the given management group with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinitionVersionAtManagementGroup.json - */ -async function retrieveAPolicySetDefinitionVersionAtManagementGroupLevel() { - const managementGroupName = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policySetDefinitionVersions.getAtManagementGroup( - managementGroupName, - policySetDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main() { - await retrieveAPolicySetDefinitionVersionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsGetBuiltInSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsGetBuiltInSample.js deleted file mode 100644 index c9a1c7bbdd07..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsGetBuiltInSample.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation retrieves the built-in policy set definition version with the given name and version. - * - * @summary This operation retrieves the built-in policy set definition version with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltInPolicySetDefinitionVersion.json - */ -async function retrieveABuiltInPolicySetDefinitionVersion() { - const policySetDefinitionName = "1f3afdf9-d0c9-4c3d-847f-89da613e70a8"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policySetDefinitionVersions.getBuiltIn( - policySetDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main() { - await retrieveABuiltInPolicySetDefinitionVersion(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsGetSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsGetSample.js deleted file mode 100644 index 60e706ddf7fc..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsGetSample.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation retrieves the policy set definition version in the given subscription with the given name and version. - * - * @summary This operation retrieves the policy set definition version in the given subscription with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinitionVersion.json - */ -async function retrieveAPolicySetDefinitionVersion() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitionVersions.get( - policySetDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main() { - await retrieveAPolicySetDefinitionVersion(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListSample.js deleted file mode 100644 index bd7086ac5300..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListSample.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation retrieves a list of all the policy set definition versions for the given policy set definition. - * - * @summary This operation retrieves a list of all the policy set definition versions for the given policy set definition. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitionVersions.json - */ -async function listPolicySetDefinitions() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const resArray = new Array(); - for await (const item of client.policySetDefinitionVersions.list(policySetDefinitionName)) { - resArray.push(item); - } - console.log(resArray); -} - -async function main() { - await listPolicySetDefinitions(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.js deleted file mode 100644 index aaa18f0caec3..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.js +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation creates or updates a policy set definition in the given management group with the given name. - * - * @summary This operation creates or updates a policy set definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json - */ -async function createOrUpdateAPolicySetDefinitionAtManagementGroupLevel() { - const managementGroupId = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const parameters = { - description: "Policies to enforce low cost storage SKUs", - displayName: "Cost Management", - metadata: { category: "Cost Management" }, - policyDefinitions: [ - { - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - policyDefinitionReferenceId: "Limit_Skus", - }, - { - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - policyDefinitionReferenceId: "Resource_Naming", - }, - ], - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policySetDefinitions.createOrUpdateAtManagementGroup( - managementGroupId, - policySetDefinitionName, - parameters, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates a policy set definition in the given management group with the given name. - * - * @summary This operation creates or updates a policy set definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json - */ -async function createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel() { - const managementGroupId = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const parameters = { - description: "Policies to enforce low cost storage SKUs", - displayName: "Cost Management", - metadata: { category: "Cost Management" }, - policyDefinitionGroups: [ - { - name: "CostSaving", - description: "Policies designed to control spend within a subscription.", - displayName: "Cost Management Policies", - }, - { - name: "Organizational", - description: - "Policies that help enforce resource organization standards within a subscription.", - displayName: "Organizational Policies", - }, - ], - policyDefinitions: [ - { - groupNames: ["CostSaving"], - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - policyDefinitionReferenceId: "Limit_Skus", - }, - { - groupNames: ["Organizational"], - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - policyDefinitionReferenceId: "Resource_Naming", - }, - ], - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policySetDefinitions.createOrUpdateAtManagementGroup( - managementGroupId, - policySetDefinitionName, - parameters, - ); - console.log(result); -} - -async function main() { - await createOrUpdateAPolicySetDefinitionAtManagementGroupLevel(); - await createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsDeleteAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsDeleteAtManagementGroupSample.js deleted file mode 100644 index f80b6247d185..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsDeleteAtManagementGroupSample.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation deletes the policy set definition in the given management group with the given name. - * - * @summary This operation deletes the policy set definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinitionAtManagementGroup.json - */ -async function deleteAPolicySetDefinitionAtManagementGroupLevel() { - const managementGroupId = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policySetDefinitions.deleteAtManagementGroup( - managementGroupId, - policySetDefinitionName, - ); - console.log(result); -} - -async function main() { - await deleteAPolicySetDefinitionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsDeleteSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsDeleteSample.js deleted file mode 100644 index 5b70c0366ed2..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsDeleteSample.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation deletes the policy set definition in the given subscription with the given name. - * - * @summary This operation deletes the policy set definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinition.json - */ -async function deleteAPolicySetDefinition() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitions.delete(policySetDefinitionName); - console.log(result); -} - -async function main() { - await deleteAPolicySetDefinition(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsGetAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsGetAtManagementGroupSample.js deleted file mode 100644 index e1842e982cb5..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsGetAtManagementGroupSample.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation retrieves the policy set definition in the given management group with the given name. - * - * @summary This operation retrieves the policy set definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinitionAtManagementGroup.json - */ -async function retrieveAPolicySetDefinitionAtManagementGroupLevel() { - const managementGroupId = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policySetDefinitions.getAtManagementGroup( - managementGroupId, - policySetDefinitionName, - ); - console.log(result); -} - -async function main() { - await retrieveAPolicySetDefinitionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsGetBuiltInSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsGetBuiltInSample.js deleted file mode 100644 index e88ddd3a16d4..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsGetBuiltInSample.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation retrieves the built-in policy set definition with the given name. - * - * @summary This operation retrieves the built-in policy set definition with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltInPolicySetDefinition.json - */ -async function retrieveABuiltInPolicySetDefinition() { - const policySetDefinitionName = "1f3afdf9-d0c9-4c3d-847f-89da613e70a8"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policySetDefinitions.getBuiltIn(policySetDefinitionName); - console.log(result); -} - -async function main() { - await retrieveABuiltInPolicySetDefinition(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsGetSample.js b/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsGetSample.js deleted file mode 100644 index f36973d72ca9..000000000000 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsGetSample.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -const { PolicyClient } = require("@azure/arm-policy"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -/** - * This sample demonstrates how to This operation retrieves the policy set definition in the given subscription with the given name. - * - * @summary This operation retrieves the policy set definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinition.json - */ -async function retrieveAPolicySetDefinition() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitions.get(policySetDefinitionName); - console.log(result); -} - -async function main() { - await retrieveAPolicySetDefinition(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsCreateByIdSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsCreateByIdSample.ts deleted file mode 100644 index aaa0352c1823..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsCreateByIdSample.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PolicyAssignment } from "@azure/arm-policy"; -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * - * @summary This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentById.json - */ -async function createOrUpdatePolicyAssignmentById(): Promise { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const parameters: PolicyAssignment = { - description: - "Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created", - definitionVersion: "1.*.*", - displayName: "Enforce storage account SKU", - enforcementMode: "Default", - metadata: { assignedBy: "Cheapskate Boss" }, - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.createById( - policyAssignmentId, - parameters, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * - * @summary This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithIdentityById.json - */ -async function createOrUpdatePolicyAssignmentWithAManagedIdentityById(): Promise { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const parameters: PolicyAssignment = { - description: - "Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created", - definitionVersion: "1.*.*", - displayName: "Enforce storage account SKU", - enforcementMode: "Default", - identity: { type: "SystemAssigned" }, - location: "eastus", - metadata: { assignedBy: "Cheapskate Boss" }, - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.createById( - policyAssignmentId, - parameters, - ); - console.log(result); -} - -async function main(): Promise { - await createOrUpdatePolicyAssignmentById(); - await createOrUpdatePolicyAssignmentWithAManagedIdentityById(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsCreateSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsCreateSample.ts deleted file mode 100644 index 463dfd25d827..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsCreateSample.ts +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PolicyAssignment } from "@azure/arm-policy"; -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignment.json - */ -async function createOrUpdateAPolicyAssignment(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters: PolicyAssignment = { - description: - "Force resource names to begin with given DeptA and end with -LC", - displayName: "Enforce resource naming rules", - metadata: { assignedBy: "Special Someone" }, - nonComplianceMessages: [ - { message: "Resource names must start with 'DeptA' and end with '-LC'." }, - ], - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.create( - scope, - policyAssignmentName, - parameters, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithIdentity.json - */ -async function createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters: PolicyAssignment = { - description: - "Force resource names to begin with given DeptA and end with -LC", - displayName: "Enforce resource naming rules", - enforcementMode: "Default", - identity: { type: "SystemAssigned" }, - location: "eastus", - metadata: { assignedBy: "Foo Bar" }, - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.create( - scope, - policyAssignmentName, - parameters, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithUserAssignedIdentity.json - */ -async function createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters: PolicyAssignment = { - description: - "Force resource names to begin with given DeptA and end with -LC", - displayName: "Enforce resource naming rules", - enforcementMode: "Default", - identity: { - type: "UserAssigned", - userAssignedIdentities: { - "/subscriptions/ae640e6bBa3e42569d622993eecfa6f2/resourceGroups/testResourceGroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/testIdentity": - {}, - }, - }, - location: "eastus", - metadata: { assignedBy: "Foo Bar" }, - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.create( - scope, - policyAssignmentName, - parameters, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentNonComplianceMessages.json - */ -async function createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "securityInitAssignment"; - const parameters: PolicyAssignment = { - displayName: "Enforce security policies", - nonComplianceMessages: [ - { - message: - "Resources must comply with all internal security policies. See for more info.", - }, - { - message: "Resource names must start with 'DeptA' and end with '-LC'.", - policyDefinitionReferenceId: "10420126870854049575", - }, - { - message: "Storage accounts must have firewall rules configured.", - policyDefinitionReferenceId: "8572513655450389710", - }, - ], - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/securityInitiative", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.create( - scope, - policyAssignmentName, - parameters, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithOverrides.json - */ -async function createOrUpdateAPolicyAssignmentWithOverrides(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; - const parameters: PolicyAssignment = { - description: "Limit the resource location and resource SKU", - definitionVersion: "1.*.*", - displayName: "Limit the resource location and resource SKU", - metadata: { assignedBy: "Special Someone" }, - overrides: [ - { - kind: "policyEffect", - selectors: [ - { - in: ["Limit_Skus", "Limit_Locations"], - kind: "policyDefinitionReferenceId", - }, - ], - value: "Audit", - }, - { - kind: "definitionVersion", - selectors: [ - { in: ["eastUSEuap", "centralUSEuap"], kind: "resourceLocation" }, - ], - value: "2.*.*", - }, - ], - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.create( - scope, - policyAssignmentName, - parameters, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithResourceSelectors.json - */ -async function createOrUpdateAPolicyAssignmentWithResourceSelectors(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; - const parameters: PolicyAssignment = { - description: "Limit the resource location and resource SKU", - displayName: "Limit the resource location and resource SKU", - metadata: { assignedBy: "Special Someone" }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", - resourceSelectors: [ - { - name: "SDPRegions", - selectors: [ - { in: ["eastus2euap", "centraluseuap"], kind: "resourceLocation" }, - ], - }, - ], - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.create( - scope, - policyAssignmentName, - parameters, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentWithoutEnforcement.json - */ -async function createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters: PolicyAssignment = { - description: - "Force resource names to begin with given DeptA and end with -LC", - displayName: "Enforce resource naming rules", - enforcementMode: "DoNotEnforce", - metadata: { assignedBy: "Special Someone" }, - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.create( - scope, - policyAssignmentName, - parameters, - ); - console.log(result); -} - -async function main(): Promise { - await createOrUpdateAPolicyAssignment(); - await createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity(); - await createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity(); - await createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages(); - await createOrUpdateAPolicyAssignmentWithOverrides(); - await createOrUpdateAPolicyAssignmentWithResourceSelectors(); - await createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsDeleteByIdSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsDeleteByIdSample.ts deleted file mode 100644 index 20974aebe1d6..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsDeleteByIdSample.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). - * - * @summary This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyAssignmentById.json - */ -async function deleteAPolicyAssignmentById(): Promise { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.deleteById(policyAssignmentId); - console.log(result); -} - -async function main(): Promise { - await deleteAPolicyAssignmentById(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsGetByIdSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsGetByIdSample.ts deleted file mode 100644 index 7b00e2db85c3..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsGetByIdSample.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * - * @summary The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentById.json - */ -async function retrieveAPolicyAssignmentById(): Promise { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.getById(policyAssignmentId); - console.log(result); -} - -/** - * This sample demonstrates how to The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * - * @summary The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentWithIdentityById.json - */ -async function retrieveAPolicyAssignmentWithAManagedIdentityById(): Promise { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.getById(policyAssignmentId); - console.log(result); -} - -async function main(): Promise { - await retrieveAPolicyAssignmentById(); - await retrieveAPolicyAssignmentWithAManagedIdentityById(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsGetSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsGetSample.ts deleted file mode 100644 index a736a24c8597..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsGetSample.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. - * - * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignment.json - */ -async function retrieveAPolicyAssignment(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.get( - scope, - policyAssignmentName, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. - * - * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentWithIdentity.json - */ -async function retrieveAPolicyAssignmentWithASystemAssignedIdentity(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.get( - scope, - policyAssignmentName, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. - * - * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json - */ -async function retrieveAPolicyAssignmentWithAUserAssignedIdentity(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.get( - scope, - policyAssignmentName, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. - * - * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentWithOverrides.json - */ -async function retrieveAPolicyAssignmentWithOverrides(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.get( - scope, - policyAssignmentName, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. - * - * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentWithResourceSelectors.json - */ -async function retrieveAPolicyAssignmentWithResourceSelectors(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.get( - scope, - policyAssignmentName, - ); - console.log(result); -} - -async function main(): Promise { - await retrieveAPolicyAssignment(); - await retrieveAPolicyAssignmentWithASystemAssignedIdentity(); - await retrieveAPolicyAssignmentWithAUserAssignedIdentity(); - await retrieveAPolicyAssignmentWithOverrides(); - await retrieveAPolicyAssignmentWithResourceSelectors(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsUpdateByIdSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsUpdateByIdSample.ts deleted file mode 100644 index 7ce353beadb5..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsUpdateByIdSample.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PolicyAssignmentUpdate } from "@azure/arm-policy"; -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * - * @summary This operation updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithIdentityById.json - */ -async function updatePolicyAssignmentWithAManagedIdentityById(): Promise { - const policyAssignmentId = - "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; - const parameters: PolicyAssignmentUpdate = { - identity: { type: "SystemAssigned" }, - location: "eastus", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.updateById( - policyAssignmentId, - parameters, - ); - console.log(result); -} - -async function main(): Promise { - await updatePolicyAssignmentWithAManagedIdentityById(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsUpdateSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsUpdateSample.ts deleted file mode 100644 index 2777b8875d19..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsUpdateSample.ts +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PolicyAssignmentUpdate } from "@azure/arm-policy"; -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithIdentity.json - */ -async function updateAPolicyAssignmentWithASystemAssignedIdentity(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters: PolicyAssignmentUpdate = { - identity: { type: "SystemAssigned" }, - location: "eastus", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.update( - scope, - policyAssignmentName, - parameters, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithUserAssignedIdentity.json - */ -async function updateAPolicyAssignmentWithAUserAssignedIdentity(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; - const parameters: PolicyAssignmentUpdate = { - identity: { - type: "UserAssigned", - userAssignedIdentities: { - "/subscriptions/ae640e6bBa3e42569d622993eecfa6f2/resourceGroups/testResourceGroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/testIdentity": - {}, - }, - }, - location: "eastus", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.update( - scope, - policyAssignmentName, - parameters, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithOverrides.json - */ -async function updateAPolicyAssignmentWithOverrides(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; - const parameters: PolicyAssignmentUpdate = { - overrides: [ - { - kind: "policyEffect", - selectors: [ - { - in: ["Limit_Skus", "Limit_Locations"], - kind: "policyDefinitionReferenceId", - }, - ], - value: "Audit", - }, - ], - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.update( - scope, - policyAssignmentName, - parameters, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * - * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithResourceSelectors.json - */ -async function updateAPolicyAssignmentWithResourceSelectors(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "CostManagement"; - const parameters: PolicyAssignmentUpdate = { - resourceSelectors: [ - { - name: "SDPRegions", - selectors: [ - { in: ["eastus2euap", "centraluseuap"], kind: "resourceLocation" }, - ], - }, - ], - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyAssignments.update( - scope, - policyAssignmentName, - parameters, - ); - console.log(result); -} - -async function main(): Promise { - await updateAPolicyAssignmentWithASystemAssignedIdentity(); - await updateAPolicyAssignmentWithAUserAssignedIdentity(); - await updateAPolicyAssignmentWithOverrides(); - await updateAPolicyAssignmentWithResourceSelectors(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts deleted file mode 100644 index 92313a367e36..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PolicyDefinitionVersion } from "@azure/arm-policy"; -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation creates or updates a policy definition version in the given management group with the given name. - * - * @summary This operation creates or updates a policy definition version in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json - */ -async function createOrUpdateAPolicyDefinitionVersionAtManagementGroupLevel(): Promise { - const managementGroupName = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; - const parameters: PolicyDefinitionVersion = { - description: - "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - displayName: "Enforce resource naming convention", - metadata: { category: "Naming" }, - mode: "All", - parameters: { - prefix: { - type: "String", - metadata: { - description: "Resource name prefix", - displayName: "Prefix", - }, - }, - suffix: { - type: "String", - metadata: { - description: "Resource name suffix", - displayName: "Suffix", - }, - }, - }, - policyRule: { - if: { - not: { - field: "name", - like: "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - then: { effect: "deny" }, - }, - version: "1.2.1", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = - await client.policyDefinitionVersions.createOrUpdateAtManagementGroup( - managementGroupName, - policyDefinitionName, - policyDefinitionVersion, - parameters, - ); - console.log(result); -} - -async function main(): Promise { - await createOrUpdateAPolicyDefinitionVersionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsCreateOrUpdateSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsCreateOrUpdateSample.ts deleted file mode 100644 index d39b37e9e55d..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsCreateOrUpdateSample.ts +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PolicyDefinitionVersion } from "@azure/arm-policy"; -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation creates or updates a policy definition in the given subscription with the given name. - * - * @summary This operation creates or updates a policy definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionVersion.json - */ -async function createOrUpdateAPolicyDefinitionVersion(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; - const parameters: PolicyDefinitionVersion = { - description: - "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - displayName: "Enforce resource naming convention", - metadata: { category: "Naming" }, - mode: "All", - parameters: { - prefix: { - type: "String", - metadata: { - description: "Resource name prefix", - displayName: "Prefix", - }, - }, - suffix: { - type: "String", - metadata: { - description: "Resource name suffix", - displayName: "Suffix", - }, - }, - }, - policyRule: { - if: { - not: { - field: "name", - like: "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - then: { effect: "deny" }, - }, - version: "1.2.1", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitionVersions.createOrUpdate( - policyDefinitionName, - policyDefinitionVersion, - parameters, - ); - console.log(result); -} - -async function main(): Promise { - await createOrUpdateAPolicyDefinitionVersion(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsDeleteAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsDeleteAtManagementGroupSample.ts deleted file mode 100644 index f1d1defdfe7c..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsDeleteAtManagementGroupSample.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation deletes the policy definition in the given management group with the given name. - * - * @summary This operation deletes the policy definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinitionVersionAtManagementGroup.json - */ -async function deleteAPolicyDefinitionVersionAtManagementGroupLevel(): Promise { - const managementGroupName = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyDefinitionVersions.deleteAtManagementGroup( - managementGroupName, - policyDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main(): Promise { - await deleteAPolicyDefinitionVersionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsDeleteSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsDeleteSample.ts deleted file mode 100644 index dd7311798d44..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsDeleteSample.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation deletes the policy definition version in the given subscription with the given name. - * - * @summary This operation deletes the policy definition version in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinitionVersion.json - */ -async function deleteAPolicyDefinitionVersion(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitionVersions.delete( - policyDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main(): Promise { - await deleteAPolicyDefinitionVersion(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsGetAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsGetAtManagementGroupSample.ts deleted file mode 100644 index db1ab499788e..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsGetAtManagementGroupSample.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation retrieves the policy definition version in the given management group with the given name. - * - * @summary This operation retrieves the policy definition version in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinitionVersionAtManagementGroup.json - */ -async function retrieveAPolicyDefinitionVersionAtManagementGroupLevel(): Promise { - const managementGroupName = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyDefinitionVersions.getAtManagementGroup( - managementGroupName, - policyDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main(): Promise { - await retrieveAPolicyDefinitionVersionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsGetBuiltInSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsGetBuiltInSample.ts deleted file mode 100644 index 23348a3fa093..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsGetBuiltInSample.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation retrieves the built-in policy definition version with the given name. - * - * @summary This operation retrieves the built-in policy definition version with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltinPolicyDefinitionVersion.json - */ -async function retrieveABuiltInPolicyDefinitionVersion(): Promise { - const policyDefinitionName = "7433c107-6db4-4ad1-b57a-a76dce0154a1"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyDefinitionVersions.getBuiltIn( - policyDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main(): Promise { - await retrieveABuiltInPolicyDefinitionVersion(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsGetSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsGetSample.ts deleted file mode 100644 index c724ef4307db..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsGetSample.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation retrieves the policy definition version in the given subscription with the given name. - * - * @summary This operation retrieves the policy definition version in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinitionVersion.json - */ -async function retrieveAPolicyDefinitionVersion(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitionVersions.get( - policyDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main(): Promise { - await retrieveAPolicyDefinitionVersion(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListSample.ts deleted file mode 100644 index df4f0956382b..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListSample.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation retrieves a list of all the policy definition versions for the given policy definition. - * - * @summary This operation retrieves a list of all the policy definition versions for the given policy definition. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitionVersions.json - */ -async function listPolicyDefinitionVersionsBySubscription(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const resArray = new Array(); - for await (const item of client.policyDefinitionVersions.list( - policyDefinitionName, - )) { - resArray.push(item); - } - console.log(resArray); -} - -async function main(): Promise { - await listPolicyDefinitionVersionsBySubscription(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts deleted file mode 100644 index 4bedac868455..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PolicyDefinition } from "@azure/arm-policy"; -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation creates or updates a policy definition in the given management group with the given name. - * - * @summary This operation creates or updates a policy definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json - */ -async function createOrUpdateAPolicyDefinitionAtManagementGroupLevel(): Promise { - const managementGroupId = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; - const parameters: PolicyDefinition = { - description: - "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - displayName: "Enforce resource naming convention", - metadata: { category: "Naming" }, - mode: "All", - parameters: { - prefix: { - type: "String", - metadata: { - description: "Resource name prefix", - displayName: "Prefix", - }, - }, - suffix: { - type: "String", - metadata: { - description: "Resource name suffix", - displayName: "Suffix", - }, - }, - }, - policyRule: { - if: { - not: { - field: "name", - like: "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - then: { effect: "deny" }, - }, - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyDefinitions.createOrUpdateAtManagementGroup( - managementGroupId, - policyDefinitionName, - parameters, - ); - console.log(result); -} - -async function main(): Promise { - await createOrUpdateAPolicyDefinitionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsCreateOrUpdateSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsCreateOrUpdateSample.ts deleted file mode 100644 index 29dc1da6534f..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsCreateOrUpdateSample.ts +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PolicyDefinition } from "@azure/arm-policy"; -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation creates or updates a policy definition in the given subscription with the given name. - * - * @summary This operation creates or updates a policy definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinition.json - */ -async function createOrUpdateAPolicyDefinition(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const parameters: PolicyDefinition = { - description: - "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - displayName: "Enforce resource naming convention", - metadata: { category: "Naming" }, - mode: "All", - parameters: { - prefix: { - type: "String", - metadata: { - description: "Resource name prefix", - displayName: "Prefix", - }, - }, - suffix: { - type: "String", - metadata: { - description: "Resource name suffix", - displayName: "Suffix", - }, - }, - }, - policyRule: { - if: { - not: { - field: "name", - like: "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - then: { effect: "deny" }, - }, - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitions.createOrUpdate( - policyDefinitionName, - parameters, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates a policy definition in the given subscription with the given name. - * - * @summary This operation creates or updates a policy definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionAdvancedParams.json - */ -async function createOrUpdateAPolicyDefinitionWithAdvancedParameters(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "EventHubDiagnosticLogs"; - const parameters: PolicyDefinition = { - description: - "Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised", - displayName: "Event Hubs should have diagnostic logging enabled", - metadata: { category: "Event Hub" }, - mode: "Indexed", - parameters: { - requiredRetentionDays: { - type: "Integer", - allowedValues: [0, 30, 90, 180, 365], - defaultValue: 365, - metadata: { - description: "The required diagnostic logs retention in days", - displayName: "Required retention (days)", - }, - }, - }, - policyRule: { - if: { equals: "Microsoft.EventHub/namespaces", field: "type" }, - then: { - effect: "AuditIfNotExists", - details: { - type: "Microsoft.Insights/diagnosticSettings", - existenceCondition: { - allOf: [ - { - equals: "true", - field: - "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled", - }, - { - equals: "[parameters('requiredRetentionDays')]", - field: - "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days", - }, - ], - }, - }, - }, - }, - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitions.createOrUpdate( - policyDefinitionName, - parameters, - ); - console.log(result); -} - -async function main(): Promise { - await createOrUpdateAPolicyDefinition(); - await createOrUpdateAPolicyDefinitionWithAdvancedParameters(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsDeleteAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsDeleteAtManagementGroupSample.ts deleted file mode 100644 index f9fd733c18b0..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsDeleteAtManagementGroupSample.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation deletes the policy definition in the given management group with the given name. - * - * @summary This operation deletes the policy definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinitionAtManagementGroup.json - */ -async function deleteAPolicyDefinitionAtManagementGroupLevel(): Promise { - const managementGroupId = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyDefinitions.deleteAtManagementGroup( - managementGroupId, - policyDefinitionName, - ); - console.log(result); -} - -async function main(): Promise { - await deleteAPolicyDefinitionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsDeleteSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsDeleteSample.ts deleted file mode 100644 index 14d51eecdc7f..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsDeleteSample.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation deletes the policy definition in the given subscription with the given name. - * - * @summary This operation deletes the policy definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinition.json - */ -async function deleteAPolicyDefinition(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitions.delete(policyDefinitionName); - console.log(result); -} - -async function main(): Promise { - await deleteAPolicyDefinition(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsGetAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsGetAtManagementGroupSample.ts deleted file mode 100644 index 8874a94d1bbb..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsGetAtManagementGroupSample.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation retrieves the policy definition in the given management group with the given name. - * - * @summary This operation retrieves the policy definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinitionAtManagementGroup.json - */ -async function retrieveAPolicyDefinitionAtManagementGroupLevel(): Promise { - const managementGroupId = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policyDefinitions.getAtManagementGroup( - managementGroupId, - policyDefinitionName, - ); - console.log(result); -} - -async function main(): Promise { - await retrieveAPolicyDefinitionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsGetBuiltInSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsGetBuiltInSample.ts deleted file mode 100644 index 36bda22c4a9d..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsGetBuiltInSample.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation retrieves the built-in policy definition with the given name. - * - * @summary This operation retrieves the built-in policy definition with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltinPolicyDefinition.json - */ -async function retrieveABuiltInPolicyDefinition(): Promise { - const policyDefinitionName = "7433c107-6db4-4ad1-b57a-a76dce0154a1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = - await client.policyDefinitions.getBuiltIn(policyDefinitionName); - console.log(result); -} - -async function main(): Promise { - await retrieveABuiltInPolicyDefinition(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsGetSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsGetSample.ts deleted file mode 100644 index 6820a82ddeac..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsGetSample.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation retrieves the policy definition in the given subscription with the given name. - * - * @summary This operation retrieves the policy definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinition.json - */ -async function retrieveAPolicyDefinition(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyDefinitionName = "ResourceNaming"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policyDefinitions.get(policyDefinitionName); - console.log(result); -} - -async function main(): Promise { - await retrieveAPolicyDefinition(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts deleted file mode 100644 index 2f460f9b8b4e..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PolicySetDefinitionVersion } from "@azure/arm-policy"; -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation creates or updates a policy set definition version in the given management group with the given name and version. - * - * @summary This operation creates or updates a policy set definition version in the given management group with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json - */ -async function createOrUpdateAPolicySetDefinitionVersionAtManagementGroupLevel(): Promise { - const managementGroupName = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; - const parameters: PolicySetDefinitionVersion = { - description: "Policies to enforce low cost storage SKUs", - displayName: "Cost Management", - metadata: { category: "Cost Management" }, - policyDefinitions: [ - { - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - policyDefinitionReferenceId: "Limit_Skus", - }, - { - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - policyDefinitionReferenceId: "Resource_Naming", - }, - ], - version: "1.2.1", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = - await client.policySetDefinitionVersions.createOrUpdateAtManagementGroup( - managementGroupName, - policySetDefinitionName, - policyDefinitionVersion, - parameters, - ); - console.log(result); -} - -async function main(): Promise { - await createOrUpdateAPolicySetDefinitionVersionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsCreateOrUpdateSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsCreateOrUpdateSample.ts deleted file mode 100644 index 287cabcf61dd..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsCreateOrUpdateSample.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PolicySetDefinitionVersion } from "@azure/arm-policy"; -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation creates or updates a policy set definition version in the given subscription with the given name and version. - * - * @summary This operation creates or updates a policy set definition version in the given subscription with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionVersion.json - */ -async function createOrUpdateAPolicySetDefinitionVersion(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; - const parameters: PolicySetDefinitionVersion = { - description: "Policies to enforce low cost storage SKUs", - displayName: "Cost Management", - metadata: { category: "Cost Management" }, - parameters: { - namePrefix: { - type: "String", - defaultValue: "myPrefix", - metadata: { displayName: "Prefix to enforce on resource names" }, - }, - }, - policyDefinitions: [ - { - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - policyDefinitionReferenceId: "Limit_Skus", - }, - { - parameters: { - prefix: { value: "[parameters('namePrefix')]" }, - suffix: { value: "-LC" }, - }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - policyDefinitionReferenceId: "Resource_Naming", - }, - ], - version: "1.2.1", - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitionVersions.createOrUpdate( - policySetDefinitionName, - policyDefinitionVersion, - parameters, - ); - console.log(result); -} - -async function main(): Promise { - await createOrUpdateAPolicySetDefinitionVersion(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsDeleteAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsDeleteAtManagementGroupSample.ts deleted file mode 100644 index 5a9e29b2c8cf..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsDeleteAtManagementGroupSample.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation deletes the policy set definition version in the given management group with the given name and version. - * - * @summary This operation deletes the policy set definition version in the given management group with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinitionVersionAtManagementGroup.json - */ -async function deleteAPolicySetDefinitionVersionAtManagementGroupLevel(): Promise { - const managementGroupName = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = - await client.policySetDefinitionVersions.deleteAtManagementGroup( - managementGroupName, - policySetDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main(): Promise { - await deleteAPolicySetDefinitionVersionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsDeleteSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsDeleteSample.ts deleted file mode 100644 index 5715fae67891..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsDeleteSample.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation deletes the policy set definition version in the given subscription with the given name and version. - * - * @summary This operation deletes the policy set definition version in the given subscription with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinitionVersion.json - */ -async function deleteAPolicySetDefinitionVersion(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitionVersions.delete( - policySetDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main(): Promise { - await deleteAPolicySetDefinitionVersion(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsGetAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsGetAtManagementGroupSample.ts deleted file mode 100644 index b70de889b318..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsGetAtManagementGroupSample.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation retrieves the policy set definition version in the given management group with the given name and version. - * - * @summary This operation retrieves the policy set definition version in the given management group with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinitionVersionAtManagementGroup.json - */ -async function retrieveAPolicySetDefinitionVersionAtManagementGroupLevel(): Promise { - const managementGroupName = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policySetDefinitionVersions.getAtManagementGroup( - managementGroupName, - policySetDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main(): Promise { - await retrieveAPolicySetDefinitionVersionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsGetBuiltInSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsGetBuiltInSample.ts deleted file mode 100644 index ff2e60e65f82..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsGetBuiltInSample.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation retrieves the built-in policy set definition version with the given name and version. - * - * @summary This operation retrieves the built-in policy set definition version with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltInPolicySetDefinitionVersion.json - */ -async function retrieveABuiltInPolicySetDefinitionVersion(): Promise { - const policySetDefinitionName = "1f3afdf9-d0c9-4c3d-847f-89da613e70a8"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policySetDefinitionVersions.getBuiltIn( - policySetDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main(): Promise { - await retrieveABuiltInPolicySetDefinitionVersion(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsGetSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsGetSample.ts deleted file mode 100644 index 6bb3314ce408..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsGetSample.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation retrieves the policy set definition version in the given subscription with the given name and version. - * - * @summary This operation retrieves the policy set definition version in the given subscription with the given name and version. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinitionVersion.json - */ -async function retrieveAPolicySetDefinitionVersion(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const policyDefinitionVersion = "1.2.1"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitionVersions.get( - policySetDefinitionName, - policyDefinitionVersion, - ); - console.log(result); -} - -async function main(): Promise { - await retrieveAPolicySetDefinitionVersion(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListSample.ts deleted file mode 100644 index 7e64654c0709..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListSample.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation retrieves a list of all the policy set definition versions for the given policy set definition. - * - * @summary This operation retrieves a list of all the policy set definition versions for the given policy set definition. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitionVersions.json - */ -async function listPolicySetDefinitions(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const resArray = new Array(); - for await (const item of client.policySetDefinitionVersions.list( - policySetDefinitionName, - )) { - resArray.push(item); - } - console.log(resArray); -} - -async function main(): Promise { - await listPolicySetDefinitions(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts deleted file mode 100644 index 30be97120c23..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PolicySetDefinition } from "@azure/arm-policy"; -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation creates or updates a policy set definition in the given management group with the given name. - * - * @summary This operation creates or updates a policy set definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json - */ -async function createOrUpdateAPolicySetDefinitionAtManagementGroupLevel(): Promise { - const managementGroupId = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const parameters: PolicySetDefinition = { - description: "Policies to enforce low cost storage SKUs", - displayName: "Cost Management", - metadata: { category: "Cost Management" }, - policyDefinitions: [ - { - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - policyDefinitionReferenceId: "Limit_Skus", - }, - { - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - policyDefinitionReferenceId: "Resource_Naming", - }, - ], - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = - await client.policySetDefinitions.createOrUpdateAtManagementGroup( - managementGroupId, - policySetDefinitionName, - parameters, - ); - console.log(result); -} - -/** - * This sample demonstrates how to This operation creates or updates a policy set definition in the given management group with the given name. - * - * @summary This operation creates or updates a policy set definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json - */ -async function createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel(): Promise { - const managementGroupId = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const parameters: PolicySetDefinition = { - description: "Policies to enforce low cost storage SKUs", - displayName: "Cost Management", - metadata: { category: "Cost Management" }, - policyDefinitionGroups: [ - { - name: "CostSaving", - description: - "Policies designed to control spend within a subscription.", - displayName: "Cost Management Policies", - }, - { - name: "Organizational", - description: - "Policies that help enforce resource organization standards within a subscription.", - displayName: "Organizational Policies", - }, - ], - policyDefinitions: [ - { - groupNames: ["CostSaving"], - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - policyDefinitionReferenceId: "Limit_Skus", - }, - { - groupNames: ["Organizational"], - parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, - policyDefinitionId: - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", - policyDefinitionReferenceId: "Resource_Naming", - }, - ], - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = - await client.policySetDefinitions.createOrUpdateAtManagementGroup( - managementGroupId, - policySetDefinitionName, - parameters, - ); - console.log(result); -} - -async function main(): Promise { - await createOrUpdateAPolicySetDefinitionAtManagementGroupLevel(); - await createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsDeleteAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsDeleteAtManagementGroupSample.ts deleted file mode 100644 index cda63ac62e7d..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsDeleteAtManagementGroupSample.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation deletes the policy set definition in the given management group with the given name. - * - * @summary This operation deletes the policy set definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinitionAtManagementGroup.json - */ -async function deleteAPolicySetDefinitionAtManagementGroupLevel(): Promise { - const managementGroupId = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policySetDefinitions.deleteAtManagementGroup( - managementGroupId, - policySetDefinitionName, - ); - console.log(result); -} - -async function main(): Promise { - await deleteAPolicySetDefinitionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsDeleteSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsDeleteSample.ts deleted file mode 100644 index bdd4cc4834f1..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsDeleteSample.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation deletes the policy set definition in the given subscription with the given name. - * - * @summary This operation deletes the policy set definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinition.json - */ -async function deleteAPolicySetDefinition(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitions.delete( - policySetDefinitionName, - ); - console.log(result); -} - -async function main(): Promise { - await deleteAPolicySetDefinition(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsGetAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsGetAtManagementGroupSample.ts deleted file mode 100644 index d8387d923464..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsGetAtManagementGroupSample.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation retrieves the policy set definition in the given management group with the given name. - * - * @summary This operation retrieves the policy set definition in the given management group with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinitionAtManagementGroup.json - */ -async function retrieveAPolicySetDefinitionAtManagementGroupLevel(): Promise { - const managementGroupId = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policySetDefinitions.getAtManagementGroup( - managementGroupId, - policySetDefinitionName, - ); - console.log(result); -} - -async function main(): Promise { - await retrieveAPolicySetDefinitionAtManagementGroupLevel(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsGetBuiltInSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsGetBuiltInSample.ts deleted file mode 100644 index 3ad25b31f6c0..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsGetBuiltInSample.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation retrieves the built-in policy set definition with the given name. - * - * @summary This operation retrieves the built-in policy set definition with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltInPolicySetDefinition.json - */ -async function retrieveABuiltInPolicySetDefinition(): Promise { - const policySetDefinitionName = "1f3afdf9-d0c9-4c3d-847f-89da613e70a8"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential); - const result = await client.policySetDefinitions.getBuiltIn( - policySetDefinitionName, - ); - console.log(result); -} - -async function main(): Promise { - await retrieveABuiltInPolicySetDefinition(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsGetSample.ts b/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsGetSample.ts deleted file mode 100644 index 098d02d2a136..000000000000 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsGetSample.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PolicyClient } from "@azure/arm-policy"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to This operation retrieves the policy set definition in the given subscription with the given name. - * - * @summary This operation retrieves the policy set definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinition.json - */ -async function retrieveAPolicySetDefinition(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitions.get(policySetDefinitionName); - console.log(result); -} - -async function main(): Promise { - await retrieveAPolicySetDefinition(); -} - -main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/README.md b/sdk/policy/arm-policy/samples/v7/javascript/README.md similarity index 84% rename from sdk/policy/arm-policy/samples/v6/javascript/README.md rename to sdk/policy/arm-policy/samples/v7/javascript/README.md index e990edd5af4f..2271fcc129af 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/README.md +++ b/sdk/policy/arm-policy/samples/v7/javascript/README.md @@ -1,67 +1,65 @@ -# client library samples for JavaScript - -These sample programs show how to use the JavaScript client libraries for in some common scenarios. - -| **File Name** | **Description** | -| --------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [policyAssignmentsCreateByIdSample.js][policyassignmentscreatebyidsample] | This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentById.json | -| [policyAssignmentsCreateSample.js][policyassignmentscreatesample] | This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignment.json | -| [policyAssignmentsDeleteByIdSample.js][policyassignmentsdeletebyidsample] | This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyAssignmentById.json | -| [policyAssignmentsDeleteSample.js][policyassignmentsdeletesample] | This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyAssignment.json | -| [policyAssignmentsGetByIdSample.js][policyassignmentsgetbyidsample] | The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentById.json | -| [policyAssignmentsGetSample.js][policyassignmentsgetsample] | This operation retrieves a single policy assignment, given its name and the scope it was created at. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignment.json | -| [policyAssignmentsListForManagementGroupSample.js][policyassignmentslistformanagementgroupsample] | This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignmentsForManagementGroup.json | -| [policyAssignmentsListForResourceGroupSample.js][policyassignmentslistforresourcegroupsample] | This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignmentsForResourceGroup.json | -| [policyAssignmentsListForResourceSample.js][policyassignmentslistforresourcesample] | This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignmentsForResource.json | -| [policyAssignmentsListSample.js][policyassignmentslistsample] | This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignments.json | -| [policyAssignmentsUpdateByIdSample.js][policyassignmentsupdatebyidsample] | This operation updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithIdentityById.json | -| [policyAssignmentsUpdateSample.js][policyassignmentsupdatesample] | This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithIdentity.json | -| [policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js][policydefinitionversionscreateorupdateatmanagementgroupsample] | This operation creates or updates a policy definition version in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json | -| [policyDefinitionVersionsCreateOrUpdateSample.js][policydefinitionversionscreateorupdatesample] | This operation creates or updates a policy definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionVersion.json | -| [policyDefinitionVersionsDeleteAtManagementGroupSample.js][policydefinitionversionsdeleteatmanagementgroupsample] | This operation deletes the policy definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinitionVersionAtManagementGroup.json | -| [policyDefinitionVersionsDeleteSample.js][policydefinitionversionsdeletesample] | This operation deletes the policy definition version in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinitionVersion.json | -| [policyDefinitionVersionsGetAtManagementGroupSample.js][policydefinitionversionsgetatmanagementgroupsample] | This operation retrieves the policy definition version in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinitionVersionAtManagementGroup.json | -| [policyDefinitionVersionsGetBuiltInSample.js][policydefinitionversionsgetbuiltinsample] | This operation retrieves the built-in policy definition version with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltinPolicyDefinitionVersion.json | -| [policyDefinitionVersionsGetSample.js][policydefinitionversionsgetsample] | This operation retrieves the policy definition version in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinitionVersion.json | -| [policyDefinitionVersionsListAllAtManagementGroupSample.js][policydefinitionversionslistallatmanagementgroupsample] | This operation lists all the policy definition versions for all policy definitions at the management group scope. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicyDefinitionVersionsByManagementGroup.json | -| [policyDefinitionVersionsListAllBuiltinsSample.js][policydefinitionversionslistallbuiltinssample] | This operation lists all the built-in policy definition versions for all built-in policy definitions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllBuiltInPolicyDefinitionVersions.json | -| [policyDefinitionVersionsListAllSample.js][policydefinitionversionslistallsample] | This operation lists all the policy definition versions for all policy definitions within a subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicyDefinitionVersions.json | -| [policyDefinitionVersionsListBuiltInSample.js][policydefinitionversionslistbuiltinsample] | This operation retrieves a list of all the built-in policy definition versions for the given policy definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicyDefinitionVersions.json | -| [policyDefinitionVersionsListByManagementGroupSample.js][policydefinitionversionslistbymanagementgroupsample] | This operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitionVersionsByManagementGroup.json | -| [policyDefinitionVersionsListSample.js][policydefinitionversionslistsample] | This operation retrieves a list of all the policy definition versions for the given policy definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitionVersions.json | -| [policyDefinitionsCreateOrUpdateAtManagementGroupSample.js][policydefinitionscreateorupdateatmanagementgroupsample] | This operation creates or updates a policy definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json | -| [policyDefinitionsCreateOrUpdateSample.js][policydefinitionscreateorupdatesample] | This operation creates or updates a policy definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinition.json | -| [policyDefinitionsDeleteAtManagementGroupSample.js][policydefinitionsdeleteatmanagementgroupsample] | This operation deletes the policy definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinitionAtManagementGroup.json | -| [policyDefinitionsDeleteSample.js][policydefinitionsdeletesample] | This operation deletes the policy definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinition.json | -| [policyDefinitionsGetAtManagementGroupSample.js][policydefinitionsgetatmanagementgroupsample] | This operation retrieves the policy definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinitionAtManagementGroup.json | -| [policyDefinitionsGetBuiltInSample.js][policydefinitionsgetbuiltinsample] | This operation retrieves the built-in policy definition with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltinPolicyDefinition.json | -| [policyDefinitionsGetSample.js][policydefinitionsgetsample] | This operation retrieves the policy definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinition.json | -| [policyDefinitionsListBuiltInSample.js][policydefinitionslistbuiltinsample] | This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicyDefinitions.json | -| [policyDefinitionsListByManagementGroupSample.js][policydefinitionslistbymanagementgroupsample] | This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitionsByManagementGroup.json | -| [policyDefinitionsListSample.js][policydefinitionslistsample] | This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitions.json | -| [policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js][policysetdefinitionversionscreateorupdateatmanagementgroupsample] | This operation creates or updates a policy set definition version in the given management group with the given name and version. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json | -| [policySetDefinitionVersionsCreateOrUpdateSample.js][policysetdefinitionversionscreateorupdatesample] | This operation creates or updates a policy set definition version in the given subscription with the given name and version. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionVersion.json | -| [policySetDefinitionVersionsDeleteAtManagementGroupSample.js][policysetdefinitionversionsdeleteatmanagementgroupsample] | This operation deletes the policy set definition version in the given management group with the given name and version. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinitionVersionAtManagementGroup.json | -| [policySetDefinitionVersionsDeleteSample.js][policysetdefinitionversionsdeletesample] | This operation deletes the policy set definition version in the given subscription with the given name and version. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinitionVersion.json | -| [policySetDefinitionVersionsGetAtManagementGroupSample.js][policysetdefinitionversionsgetatmanagementgroupsample] | This operation retrieves the policy set definition version in the given management group with the given name and version. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinitionVersionAtManagementGroup.json | -| [policySetDefinitionVersionsGetBuiltInSample.js][policysetdefinitionversionsgetbuiltinsample] | This operation retrieves the built-in policy set definition version with the given name and version. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltInPolicySetDefinitionVersion.json | -| [policySetDefinitionVersionsGetSample.js][policysetdefinitionversionsgetsample] | This operation retrieves the policy set definition version in the given subscription with the given name and version. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinitionVersion.json | -| [policySetDefinitionVersionsListAllAtManagementGroupSample.js][policysetdefinitionversionslistallatmanagementgroupsample] | This operation lists all the policy set definition versions for all policy set definitions at the management group scope. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicySetDefinitionVersionsByManagementGroup.json | -| [policySetDefinitionVersionsListAllBuiltinsSample.js][policysetdefinitionversionslistallbuiltinssample] | This operation lists all the built-in policy set definition versions for all built-in policy set definitions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllBuiltInPolicySetDefinitionVersions.json | -| [policySetDefinitionVersionsListAllSample.js][policysetdefinitionversionslistallsample] | This operation lists all the policy set definition versions for all policy set definitions within a subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicySetDefinitionVersions.json | -| [policySetDefinitionVersionsListBuiltInSample.js][policysetdefinitionversionslistbuiltinsample] | This operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicySetDefinitionVersions.json | -| [policySetDefinitionVersionsListByManagementGroupSample.js][policysetdefinitionversionslistbymanagementgroupsample] | This operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitionVersionsByManagementGroup.json | -| [policySetDefinitionVersionsListSample.js][policysetdefinitionversionslistsample] | This operation retrieves a list of all the policy set definition versions for the given policy set definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitionVersions.json | -| [policySetDefinitionsCreateOrUpdateAtManagementGroupSample.js][policysetdefinitionscreateorupdateatmanagementgroupsample] | This operation creates or updates a policy set definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json | -| [policySetDefinitionsCreateOrUpdateSample.js][policysetdefinitionscreateorupdatesample] | This operation creates or updates a policy set definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinition.json | -| [policySetDefinitionsDeleteAtManagementGroupSample.js][policysetdefinitionsdeleteatmanagementgroupsample] | This operation deletes the policy set definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinitionAtManagementGroup.json | -| [policySetDefinitionsDeleteSample.js][policysetdefinitionsdeletesample] | This operation deletes the policy set definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinition.json | -| [policySetDefinitionsGetAtManagementGroupSample.js][policysetdefinitionsgetatmanagementgroupsample] | This operation retrieves the policy set definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinitionAtManagementGroup.json | -| [policySetDefinitionsGetBuiltInSample.js][policysetdefinitionsgetbuiltinsample] | This operation retrieves the built-in policy set definition with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltInPolicySetDefinition.json | -| [policySetDefinitionsGetSample.js][policysetdefinitionsgetsample] | This operation retrieves the policy set definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinition.json | -| [policySetDefinitionsListBuiltInSample.js][policysetdefinitionslistbuiltinsample] | This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicySetDefinitions.json | -| [policySetDefinitionsListByManagementGroupSample.js][policysetdefinitionslistbymanagementgroupsample] | This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitionsByManagementGroup.json | -| [policySetDefinitionsListSample.js][policysetdefinitionslistsample] | This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitions.json | +# @azure/arm-policy client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for @azure/arm-policy in some common scenarios. + +| **File Name** | **Description** | +| --------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [policyAssignmentsCreateSample.js][policyassignmentscreatesample] | this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. x-ms-original-file: 2025-03-01/createPolicyAssignment.json | +| [policyAssignmentsDeleteSample.js][policyassignmentsdeletesample] | this operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. x-ms-original-file: 2025-03-01/deletePolicyAssignment.json | +| [policyAssignmentsGetSample.js][policyassignmentsgetsample] | this operation retrieves a single policy assignment, given its name and the scope it was created at. x-ms-original-file: 2025-03-01/getPolicyAssignment.json | +| [policyAssignmentsListForManagementGroupSample.js][policyassignmentslistformanagementgroupsample] | this operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. x-ms-original-file: 2025-03-01/listPolicyAssignmentsForManagementGroup.json | +| [policyAssignmentsListForResourceGroupSample.js][policyassignmentslistforresourcegroupsample] | this operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. x-ms-original-file: 2025-03-01/listPolicyAssignmentsForResourceGroup.json | +| [policyAssignmentsListForResourceSample.js][policyassignmentslistforresourcesample] | this operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). x-ms-original-file: 2025-03-01/listPolicyAssignmentsForResource.json | +| [policyAssignmentsListSample.js][policyassignmentslistsample] | this operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. x-ms-original-file: 2025-03-01/listPolicyAssignments.json | +| [policyAssignmentsUpdateSample.js][policyassignmentsupdatesample] | this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. x-ms-original-file: 2025-03-01/updatePolicyAssignmentWithIdentity.json | +| [policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js][policydefinitionversionscreateorupdateatmanagementgroupsample] | this operation creates or updates a policy definition version in the given management group with the given name. x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json | +| [policyDefinitionVersionsCreateOrUpdateSample.js][policydefinitionversionscreateorupdatesample] | this operation creates or updates a policy definition in the given subscription with the given name. x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionVersion.json | +| [policyDefinitionVersionsDeleteAtManagementGroupSample.js][policydefinitionversionsdeleteatmanagementgroupsample] | this operation deletes the policy definition in the given management group with the given name. x-ms-original-file: 2025-03-01/deletePolicyDefinitionVersionAtManagementGroup.json | +| [policyDefinitionVersionsDeleteSample.js][policydefinitionversionsdeletesample] | this operation deletes the policy definition version in the given subscription with the given name. x-ms-original-file: 2025-03-01/deletePolicyDefinitionVersion.json | +| [policyDefinitionVersionsGetAtManagementGroupSample.js][policydefinitionversionsgetatmanagementgroupsample] | this operation retrieves the policy definition version in the given management group with the given name. x-ms-original-file: 2025-03-01/getPolicyDefinitionVersionAtManagementGroup.json | +| [policyDefinitionVersionsGetBuiltInSample.js][policydefinitionversionsgetbuiltinsample] | this operation retrieves the built-in policy definition version with the given name. x-ms-original-file: 2025-03-01/getBuiltinPolicyDefinitionVersion.json | +| [policyDefinitionVersionsGetSample.js][policydefinitionversionsgetsample] | this operation retrieves the policy definition version in the given subscription with the given name. x-ms-original-file: 2025-03-01/getPolicyDefinitionVersion.json | +| [policyDefinitionVersionsListAllAtManagementGroupSample.js][policydefinitionversionslistallatmanagementgroupsample] | this operation lists all the policy definition versions for all policy definitions at the management group scope. x-ms-original-file: 2025-03-01/listAllPolicyDefinitionVersionsByManagementGroup.json | +| [policyDefinitionVersionsListAllBuiltinsSample.js][policydefinitionversionslistallbuiltinssample] | this operation lists all the built-in policy definition versions for all built-in policy definitions. x-ms-original-file: 2025-03-01/listAllBuiltInPolicyDefinitionVersions.json | +| [policyDefinitionVersionsListAllSample.js][policydefinitionversionslistallsample] | this operation lists all the policy definition versions for all policy definitions within a subscription. x-ms-original-file: 2025-03-01/listAllPolicyDefinitionVersions.json | +| [policyDefinitionVersionsListBuiltInSample.js][policydefinitionversionslistbuiltinsample] | this operation retrieves a list of all the built-in policy definition versions for the given policy definition. x-ms-original-file: 2025-03-01/listBuiltInPolicyDefinitionVersions.json | +| [policyDefinitionVersionsListByManagementGroupSample.js][policydefinitionversionslistbymanagementgroupsample] | this operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. x-ms-original-file: 2025-03-01/listPolicyDefinitionVersionsByManagementGroup.json | +| [policyDefinitionVersionsListSample.js][policydefinitionversionslistsample] | this operation retrieves a list of all the policy definition versions for the given policy definition. x-ms-original-file: 2025-03-01/listPolicyDefinitionVersions.json | +| [policyDefinitionsCreateOrUpdateAtManagementGroupSample.js][policydefinitionscreateorupdateatmanagementgroupsample] | this operation creates or updates a policy definition in the given management group with the given name. x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionAtManagementGroup.json | +| [policyDefinitionsCreateOrUpdateSample.js][policydefinitionscreateorupdatesample] | this operation creates or updates a policy definition in the given subscription with the given name. x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinition.json | +| [policyDefinitionsDeleteAtManagementGroupSample.js][policydefinitionsdeleteatmanagementgroupsample] | this operation deletes the policy definition in the given management group with the given name. x-ms-original-file: 2025-03-01/deletePolicyDefinitionAtManagementGroup.json | +| [policyDefinitionsDeleteSample.js][policydefinitionsdeletesample] | this operation deletes the policy definition in the given subscription with the given name. x-ms-original-file: 2025-03-01/deletePolicyDefinition.json | +| [policyDefinitionsGetAtManagementGroupSample.js][policydefinitionsgetatmanagementgroupsample] | this operation retrieves the policy definition in the given management group with the given name. x-ms-original-file: 2025-03-01/getPolicyDefinitionAtManagementGroup.json | +| [policyDefinitionsGetBuiltInSample.js][policydefinitionsgetbuiltinsample] | this operation retrieves the built-in policy definition with the given name. x-ms-original-file: 2025-03-01/getBuiltinPolicyDefinition.json | +| [policyDefinitionsGetSample.js][policydefinitionsgetsample] | this operation retrieves the policy definition in the given subscription with the given name. x-ms-original-file: 2025-03-01/getPolicyDefinition.json | +| [policyDefinitionsListBuiltInSample.js][policydefinitionslistbuiltinsample] | this operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. x-ms-original-file: 2025-03-01/listBuiltInPolicyDefinitions.json | +| [policyDefinitionsListByManagementGroupSample.js][policydefinitionslistbymanagementgroupsample] | this operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. x-ms-original-file: 2025-03-01/listPolicyDefinitionsByManagementGroup.json | +| [policyDefinitionsListSample.js][policydefinitionslistsample] | this operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. x-ms-original-file: 2025-03-01/listPolicyDefinitions.json | +| [policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js][policysetdefinitionversionscreateorupdateatmanagementgroupsample] | this operation creates or updates a policy set definition version in the given management group with the given name and version. x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json | +| [policySetDefinitionVersionsCreateOrUpdateSample.js][policysetdefinitionversionscreateorupdatesample] | this operation creates or updates a policy set definition version in the given subscription with the given name and version. x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionVersion.json | +| [policySetDefinitionVersionsDeleteAtManagementGroupSample.js][policysetdefinitionversionsdeleteatmanagementgroupsample] | this operation deletes the policy set definition version in the given management group with the given name and version. x-ms-original-file: 2025-03-01/deletePolicySetDefinitionVersionAtManagementGroup.json | +| [policySetDefinitionVersionsDeleteSample.js][policysetdefinitionversionsdeletesample] | this operation deletes the policy set definition version in the given subscription with the given name and version. x-ms-original-file: 2025-03-01/deletePolicySetDefinitionVersion.json | +| [policySetDefinitionVersionsGetAtManagementGroupSample.js][policysetdefinitionversionsgetatmanagementgroupsample] | this operation retrieves the policy set definition version in the given management group with the given name and version. x-ms-original-file: 2025-03-01/getPolicySetDefinitionVersionAtManagementGroup.json | +| [policySetDefinitionVersionsGetBuiltInSample.js][policysetdefinitionversionsgetbuiltinsample] | this operation retrieves the built-in policy set definition version with the given name and version. x-ms-original-file: 2025-03-01/getBuiltInPolicySetDefinitionVersion.json | +| [policySetDefinitionVersionsGetSample.js][policysetdefinitionversionsgetsample] | this operation retrieves the policy set definition version in the given subscription with the given name and version. x-ms-original-file: 2025-03-01/getPolicySetDefinitionVersion.json | +| [policySetDefinitionVersionsListAllAtManagementGroupSample.js][policysetdefinitionversionslistallatmanagementgroupsample] | this operation lists all the policy set definition versions for all policy set definitions at the management group scope. x-ms-original-file: 2025-03-01/listAllPolicySetDefinitionVersionsByManagementGroup.json | +| [policySetDefinitionVersionsListAllBuiltinsSample.js][policysetdefinitionversionslistallbuiltinssample] | this operation lists all the built-in policy set definition versions for all built-in policy set definitions. x-ms-original-file: 2025-03-01/listAllBuiltInPolicySetDefinitionVersions.json | +| [policySetDefinitionVersionsListAllSample.js][policysetdefinitionversionslistallsample] | this operation lists all the policy set definition versions for all policy set definitions within a subscription. x-ms-original-file: 2025-03-01/listAllPolicySetDefinitionVersions.json | +| [policySetDefinitionVersionsListBuiltInSample.js][policysetdefinitionversionslistbuiltinsample] | this operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. x-ms-original-file: 2025-03-01/listBuiltInPolicySetDefinitionVersions.json | +| [policySetDefinitionVersionsListByManagementGroupSample.js][policysetdefinitionversionslistbymanagementgroupsample] | this operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. x-ms-original-file: 2025-03-01/listPolicySetDefinitionVersionsByManagementGroup.json | +| [policySetDefinitionVersionsListSample.js][policysetdefinitionversionslistsample] | this operation retrieves a list of all the policy set definition versions for the given policy set definition. x-ms-original-file: 2025-03-01/listPolicySetDefinitionVersions.json | +| [policySetDefinitionsCreateOrUpdateAtManagementGroupSample.js][policysetdefinitionscreateorupdateatmanagementgroupsample] | this operation creates or updates a policy set definition in the given management group with the given name. x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionAtManagementGroup.json | +| [policySetDefinitionsCreateOrUpdateSample.js][policysetdefinitionscreateorupdatesample] | this operation creates or updates a policy set definition in the given subscription with the given name. x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinition.json | +| [policySetDefinitionsDeleteAtManagementGroupSample.js][policysetdefinitionsdeleteatmanagementgroupsample] | this operation deletes the policy set definition in the given management group with the given name. x-ms-original-file: 2025-03-01/deletePolicySetDefinitionAtManagementGroup.json | +| [policySetDefinitionsDeleteSample.js][policysetdefinitionsdeletesample] | this operation deletes the policy set definition in the given subscription with the given name. x-ms-original-file: 2025-03-01/deletePolicySetDefinition.json | +| [policySetDefinitionsGetAtManagementGroupSample.js][policysetdefinitionsgetatmanagementgroupsample] | this operation retrieves the policy set definition in the given management group with the given name. x-ms-original-file: 2025-03-01/getPolicySetDefinitionAtManagementGroup.json | +| [policySetDefinitionsGetBuiltInSample.js][policysetdefinitionsgetbuiltinsample] | this operation retrieves the built-in policy set definition with the given name. x-ms-original-file: 2025-03-01/getBuiltInPolicySetDefinition.json | +| [policySetDefinitionsGetSample.js][policysetdefinitionsgetsample] | this operation retrieves the policy set definition in the given subscription with the given name. x-ms-original-file: 2025-03-01/getPolicySetDefinition.json | +| [policySetDefinitionsListBuiltInSample.js][policysetdefinitionslistbuiltinsample] | this operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. x-ms-original-file: 2025-03-01/listBuiltInPolicySetDefinitions.json | +| [policySetDefinitionsListByManagementGroupSample.js][policysetdefinitionslistbymanagementgroupsample] | this operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. x-ms-original-file: 2025-03-01/listPolicySetDefinitionsByManagementGroup.json | +| [policySetDefinitionsListSample.js][policysetdefinitionslistsample] | this operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. x-ms-original-file: 2025-03-01/listPolicySetDefinitions.json | +| [policyTokensAcquireAtManagementGroupSample.js][policytokensacquireatmanagementgroupsample] | this operation acquires a policy token in the given management group for the given request body. x-ms-original-file: 2025-03-01/acquirePolicyTokenAtManagementGroup.json | +| [policyTokensAcquireSample.js][policytokensacquiresample] | this operation acquires a policy token in the given subscription for the given request body. x-ms-original-file: 2025-03-01/acquirePolicyToken.json | ## Prerequisites @@ -88,77 +86,75 @@ npm install 3. Run whichever samples you like (note that some samples may require additional setup, see the table above): ```bash -node policyAssignmentsCreateByIdSample.js +node policyAssignmentsCreateSample.js ``` -Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): +Alternatively, run a single sample with the required environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): ```bash -cross-env node policyAssignmentsCreateByIdSample.js +node policyAssignmentsCreateSample.js ``` ## Next Steps Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. -[policyassignmentscreatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsCreateByIdSample.js -[policyassignmentscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsCreateSample.js -[policyassignmentsdeletebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsDeleteByIdSample.js -[policyassignmentsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsDeleteSample.js -[policyassignmentsgetbyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsGetByIdSample.js -[policyassignmentsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsGetSample.js -[policyassignmentslistformanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsListForManagementGroupSample.js -[policyassignmentslistforresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsListForResourceGroupSample.js -[policyassignmentslistforresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsListForResourceSample.js -[policyassignmentslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsListSample.js -[policyassignmentsupdatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsUpdateByIdSample.js -[policyassignmentsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsUpdateSample.js -[policydefinitionversionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js -[policydefinitionversionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsCreateOrUpdateSample.js -[policydefinitionversionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsDeleteAtManagementGroupSample.js -[policydefinitionversionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsDeleteSample.js -[policydefinitionversionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsGetAtManagementGroupSample.js -[policydefinitionversionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsGetBuiltInSample.js -[policydefinitionversionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsGetSample.js -[policydefinitionversionslistallatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListAllAtManagementGroupSample.js -[policydefinitionversionslistallbuiltinssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListAllBuiltinsSample.js -[policydefinitionversionslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListAllSample.js -[policydefinitionversionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListBuiltInSample.js -[policydefinitionversionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListByManagementGroupSample.js -[policydefinitionversionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListSample.js -[policydefinitionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsCreateOrUpdateAtManagementGroupSample.js -[policydefinitionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsCreateOrUpdateSample.js -[policydefinitionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsDeleteAtManagementGroupSample.js -[policydefinitionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsDeleteSample.js -[policydefinitionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsGetAtManagementGroupSample.js -[policydefinitionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsGetBuiltInSample.js -[policydefinitionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsGetSample.js -[policydefinitionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsListBuiltInSample.js -[policydefinitionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsListByManagementGroupSample.js -[policydefinitionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsListSample.js -[policysetdefinitionversionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js -[policysetdefinitionversionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsCreateOrUpdateSample.js -[policysetdefinitionversionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsDeleteAtManagementGroupSample.js -[policysetdefinitionversionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsDeleteSample.js -[policysetdefinitionversionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsGetAtManagementGroupSample.js -[policysetdefinitionversionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsGetBuiltInSample.js -[policysetdefinitionversionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsGetSample.js -[policysetdefinitionversionslistallatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListAllAtManagementGroupSample.js -[policysetdefinitionversionslistallbuiltinssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListAllBuiltinsSample.js -[policysetdefinitionversionslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListAllSample.js -[policysetdefinitionversionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListBuiltInSample.js -[policysetdefinitionversionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListByManagementGroupSample.js -[policysetdefinitionversionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListSample.js -[policysetdefinitionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.js -[policysetdefinitionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsCreateOrUpdateSample.js -[policysetdefinitionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsDeleteAtManagementGroupSample.js -[policysetdefinitionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsDeleteSample.js -[policysetdefinitionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsGetAtManagementGroupSample.js -[policysetdefinitionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsGetBuiltInSample.js -[policysetdefinitionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsGetSample.js -[policysetdefinitionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsListBuiltInSample.js -[policysetdefinitionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsListByManagementGroupSample.js -[policysetdefinitionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsListSample.js +[policyassignmentscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsCreateSample.js +[policyassignmentsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsDeleteSample.js +[policyassignmentsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsGetSample.js +[policyassignmentslistformanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsListForManagementGroupSample.js +[policyassignmentslistforresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsListForResourceGroupSample.js +[policyassignmentslistforresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsListForResourceSample.js +[policyassignmentslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsListSample.js +[policyassignmentsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsUpdateSample.js +[policydefinitionversionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js +[policydefinitionversionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsCreateOrUpdateSample.js +[policydefinitionversionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsDeleteAtManagementGroupSample.js +[policydefinitionversionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsDeleteSample.js +[policydefinitionversionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsGetAtManagementGroupSample.js +[policydefinitionversionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsGetBuiltInSample.js +[policydefinitionversionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsGetSample.js +[policydefinitionversionslistallatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListAllAtManagementGroupSample.js +[policydefinitionversionslistallbuiltinssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListAllBuiltinsSample.js +[policydefinitionversionslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListAllSample.js +[policydefinitionversionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListBuiltInSample.js +[policydefinitionversionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListByManagementGroupSample.js +[policydefinitionversionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListSample.js +[policydefinitionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsCreateOrUpdateAtManagementGroupSample.js +[policydefinitionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsCreateOrUpdateSample.js +[policydefinitionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsDeleteAtManagementGroupSample.js +[policydefinitionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsDeleteSample.js +[policydefinitionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsGetAtManagementGroupSample.js +[policydefinitionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsGetBuiltInSample.js +[policydefinitionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsGetSample.js +[policydefinitionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsListBuiltInSample.js +[policydefinitionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsListByManagementGroupSample.js +[policydefinitionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsListSample.js +[policysetdefinitionversionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js +[policysetdefinitionversionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsCreateOrUpdateSample.js +[policysetdefinitionversionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsDeleteAtManagementGroupSample.js +[policysetdefinitionversionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsDeleteSample.js +[policysetdefinitionversionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsGetAtManagementGroupSample.js +[policysetdefinitionversionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsGetBuiltInSample.js +[policysetdefinitionversionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsGetSample.js +[policysetdefinitionversionslistallatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListAllAtManagementGroupSample.js +[policysetdefinitionversionslistallbuiltinssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListAllBuiltinsSample.js +[policysetdefinitionversionslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListAllSample.js +[policysetdefinitionversionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListBuiltInSample.js +[policysetdefinitionversionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListByManagementGroupSample.js +[policysetdefinitionversionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListSample.js +[policysetdefinitionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.js +[policysetdefinitionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsCreateOrUpdateSample.js +[policysetdefinitionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsDeleteAtManagementGroupSample.js +[policysetdefinitionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsDeleteSample.js +[policysetdefinitionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsGetAtManagementGroupSample.js +[policysetdefinitionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsGetBuiltInSample.js +[policysetdefinitionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsGetSample.js +[policysetdefinitionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsListBuiltInSample.js +[policysetdefinitionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsListByManagementGroupSample.js +[policysetdefinitionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsListSample.js +[policytokensacquireatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyTokensAcquireAtManagementGroupSample.js +[policytokensacquiresample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/javascript/policyTokensAcquireSample.js [apiref]: https://learn.microsoft.com/javascript/api/@azure/arm-policy?view=azure-node-preview [freesub]: https://azure.microsoft.com/free/ [package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/policy/arm-policy/README.md diff --git a/sdk/policy/arm-policy/samples/v6/javascript/package.json b/sdk/policy/arm-policy/samples/v7/javascript/package.json similarity index 77% rename from sdk/policy/arm-policy/samples/v6/javascript/package.json rename to sdk/policy/arm-policy/samples/v7/javascript/package.json index fd2a3b0e7df5..63c9ae42f800 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/package.json +++ b/sdk/policy/arm-policy/samples/v7/javascript/package.json @@ -2,7 +2,7 @@ "name": "@azure-samples/arm-policy-js", "private": true, "version": "1.0.0", - "description": " client library samples for JavaScript", + "description": "@azure/arm-policy client library samples for JavaScript", "engines": { "node": ">=20.0.0" }, @@ -14,10 +14,10 @@ "keywords": [ "node", "azure", + "cloud", "typescript", "browser", - "isomorphic", - "cloud" + "isomorphic" ], "author": "Microsoft Corporation", "license": "MIT", @@ -28,6 +28,9 @@ "dependencies": { "@azure/arm-policy": "latest", "dotenv": "latest", - "@azure/identity": "^4.6.0" + "@azure/identity": "^4.13.0" + }, + "devDependencies": { + "cross-env": "latest" } } diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsCreateSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsCreateSample.js new file mode 100644 index 000000000000..4c94d2e11800 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsCreateSample.js @@ -0,0 +1,257 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignment.json + */ +async function createOrUpdateAPolicyAssignment() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.create( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + metadata: { assignedBy: "Special Someone" }, + nonComplianceMessages: [ + { message: "Resource names must start with 'DeptA' and end with '-LC'." }, + ], + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentNonComplianceMessages.json + */ +async function createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.create( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "securityInitAssignment", + { + displayName: "Enforce security policies", + nonComplianceMessages: [ + { + message: + "Resources must comply with all internal security policies. See for more info.", + }, + { + message: "Resource names must start with 'DeptA' and end with '-LC'.", + policyDefinitionReferenceId: "10420126870854049575", + }, + { + message: "Storage accounts must have firewall rules configured.", + policyDefinitionReferenceId: "8572513655450389710", + }, + ], + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/securityInitiative", + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithEnrollEnforcement.json + */ +async function createOrUpdateAPolicyAssignmentToEnforcePolicyEffectOnlyOnEnrolledResourcesDuringResourceCreationOrUpdate() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.create( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNamingEnroll", + { + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "Enroll", + metadata: { assignedBy: "Special Someone" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithIdentity.json + */ +async function createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.create( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { + identity: { type: "SystemAssigned" }, + location: "eastus", + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "Default", + metadata: { assignedBy: "Foo Bar" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithOverrides.json + */ +async function createOrUpdateAPolicyAssignmentWithOverrides() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.create( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", + { + description: "Limit the resource location and resource SKU", + definitionVersion: "1.*.*", + displayName: "Limit the resource location and resource SKU", + metadata: { assignedBy: "Special Someone" }, + overrides: [ + { + kind: "policyEffect", + selectors: [ + { in: ["Limit_Skus", "Limit_Locations"], kind: "policyDefinitionReferenceId" }, + ], + value: "Audit", + }, + { + kind: "definitionVersion", + selectors: [{ in: ["eastUSEuap", "centralUSEuap"], kind: "resourceLocation" }], + value: "2.*.*", + }, + ], + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithResourceSelectors.json + */ +async function createOrUpdateAPolicyAssignmentWithResourceSelectors() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.create( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", + { + description: "Limit the resource location and resource SKU", + displayName: "Limit the resource location and resource SKU", + metadata: { assignedBy: "Special Someone" }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", + resourceSelectors: [ + { + name: "SDPRegions", + selectors: [{ in: ["eastus2euap", "centraluseuap"], kind: "resourceLocation" }], + }, + ], + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithUserAssignedIdentity.json + */ +async function createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.create( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { + identity: { + type: "UserAssigned", + userAssignedIdentities: { + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": + {}, + }, + }, + location: "eastus", + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "Default", + metadata: { assignedBy: "Foo Bar" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithoutEnforcement.json + */ +async function createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.create( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "DoNotEnforce", + metadata: { assignedBy: "Special Someone" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }, + ); + console.log(result); +} + +async function main() { + await createOrUpdateAPolicyAssignment(); + await createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages(); + await createOrUpdateAPolicyAssignmentToEnforcePolicyEffectOnlyOnEnrolledResourcesDuringResourceCreationOrUpdate(); + await createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity(); + await createOrUpdateAPolicyAssignmentWithOverrides(); + await createOrUpdateAPolicyAssignmentWithResourceSelectors(); + await createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity(); + await createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsDeleteSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsDeleteSample.js similarity index 51% rename from sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsDeleteSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsDeleteSample.js index 21716b69a579..ebef24f649fd 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsDeleteSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsDeleteSample.js @@ -1,27 +1,22 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * This sample demonstrates how to this operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. * - * @summary This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyAssignment.json + * @summary this operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * x-ms-original-file: 2025-03-01/deletePolicyAssignment.json */ async function deleteAPolicyAssignment() { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); - const result = await client.policyAssignments.delete(scope, policyAssignmentName); + const result = await client.policyAssignments.delete( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + ); console.log(result); } diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsGetSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsGetSample.js new file mode 100644 index 000000000000..f7667cc837c5 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsGetSample.js @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary this operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: 2025-03-01/getPolicyAssignment.json + */ +async function retrieveAPolicyAssignment() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.get( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary this operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: 2025-03-01/getPolicyAssignmentWithIdentity.json + */ +async function retrieveAPolicyAssignmentWithASystemAssignedIdentity() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.get( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary this operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: 2025-03-01/getPolicyAssignmentWithOverrides.json + */ +async function retrieveAPolicyAssignmentWithOverrides() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.get( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary this operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: 2025-03-01/getPolicyAssignmentWithResourceSelectors.json + */ +async function retrieveAPolicyAssignmentWithResourceSelectors() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.get( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary this operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: 2025-03-01/getPolicyAssignmentWithUserAssignedIdentity.json + */ +async function retrieveAPolicyAssignmentWithAUserAssignedIdentity() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.get( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + ); + console.log(result); +} + +async function main() { + await retrieveAPolicyAssignment(); + await retrieveAPolicyAssignmentWithASystemAssignedIdentity(); + await retrieveAPolicyAssignmentWithOverrides(); + await retrieveAPolicyAssignmentWithResourceSelectors(); + await retrieveAPolicyAssignmentWithAUserAssignedIdentity(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsListForManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsListForManagementGroupSample.js similarity index 70% rename from sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsListForManagementGroupSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsListForManagementGroupSample.js index 756d3ac13ce7..58ba927eb822 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsListForManagementGroupSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsListForManagementGroupSample.js @@ -1,38 +1,26 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. + * This sample demonstrates how to this operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. * - * @summary This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignmentsForManagementGroup.json + * @summary this operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. + * x-ms-original-file: 2025-03-01/listPolicyAssignmentsForManagementGroup.json */ async function listPolicyAssignmentsThatApplyToAManagementGroup() { - const managementGroupId = "TestManagementGroup"; - const filter = "atScope()"; - const expand = "LatestDefinitionVersion, EffectiveDefinitionVersion"; - const options = { - filter, - expand, - }; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); - for await (const item of client.policyAssignments.listForManagementGroup( - managementGroupId, - options, - )) { + for await (const item of client.policyAssignments.listForManagementGroup("TestManagementGroup", { + filter: "atScope()", + expand: "LatestDefinitionVersion, EffectiveDefinitionVersion", + })) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsListForResourceGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsListForResourceGroupSample.js similarity index 73% rename from sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsListForResourceGroupSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsListForResourceGroupSample.js index 4bbdf41aaa03..bf648286efcb 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsListForResourceGroupSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsListForResourceGroupSample.js @@ -1,40 +1,27 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * This sample demonstrates how to this operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. * - * @summary This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignmentsForResourceGroup.json + * @summary this operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * x-ms-original-file: 2025-03-01/listPolicyAssignmentsForResourceGroup.json */ async function listPolicyAssignmentsThatApplyToAResourceGroup() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const resourceGroupName = process.env["POLICY_RESOURCE_GROUP"] || "TestResourceGroup"; - const filter = "atScope()"; - const expand = "LatestDefinitionVersion, EffectiveDefinitionVersion"; - const options = { - filter, - expand, - }; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const resArray = new Array(); - for await (const item of client.policyAssignments.listForResourceGroup( - resourceGroupName, - options, - )) { + for await (const item of client.policyAssignments.listForResourceGroup("TestResourceGroup", { + filter: "atScope()", + expand: "LatestDefinitionVersion, EffectiveDefinitionVersion", + })) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsListForResourceSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsListForResourceSample.js similarity index 79% rename from sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsListForResourceSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsListForResourceSample.js index cf70ee2e7135..ddae1fab3dd5 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsListForResourceSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsListForResourceSample.js @@ -1,46 +1,35 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * This sample demonstrates how to this operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). * - * @summary This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignmentsForResource.json + * @summary this operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * x-ms-original-file: 2025-03-01/listPolicyAssignmentsForResource.json */ -async function listAllPolicyAssignmentsThatApplyToAResource() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const resourceGroupName = process.env["POLICY_RESOURCE_GROUP"] || "TestResourceGroup"; - const resourceProviderNamespace = "Microsoft.Compute"; - const parentResourcePath = "virtualMachines/MyTestVm"; - const resourceType = "domainNames"; - const resourceName = "MyTestComputer.cloudapp.net"; +async function listPolicyAssignmentsThatApplyToAResourceGroup() { const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const resArray = new Array(); for await (const item of client.policyAssignments.listForResource( - resourceGroupName, - resourceProviderNamespace, - parentResourcePath, - resourceType, - resourceName, + "TestResourceGroup", + "Microsoft.Compute", + "virtualMachines/MyTestVm", + "domainNames", + "MyTestComputer.cloudapp.net", )) { resArray.push(item); } + console.log(resArray); } async function main() { - await listAllPolicyAssignmentsThatApplyToAResource(); + await listPolicyAssignmentsThatApplyToAResourceGroup(); } main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsListSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsListSample.js similarity index 74% rename from sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsListSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsListSample.js index 11c4f5d706de..6b32d1862147 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyAssignmentsListSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsListSample.js @@ -1,33 +1,27 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * This sample demonstrates how to this operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. * - * @summary This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignments.json + * @summary this operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * x-ms-original-file: 2025-03-01/listPolicyAssignments.json */ async function listPolicyAssignmentsThatApplyToASubscription() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const filter = "atScope()"; - const expand = "LatestDefinitionVersion, EffectiveDefinitionVersion"; - const options = { filter, expand }; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const resArray = new Array(); - for await (const item of client.policyAssignments.list(options)) { + for await (const item of client.policyAssignments.list({ + filter: "atScope()", + expand: "LatestDefinitionVersion, EffectiveDefinitionVersion", + })) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsUpdateSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsUpdateSample.js new file mode 100644 index 000000000000..f4a72be5ff2a --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyAssignmentsUpdateSample.js @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/updatePolicyAssignmentWithIdentity.json + */ +async function updateAPolicyAssignmentWithASystemAssignedIdentity() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.update( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { identity: { type: "SystemAssigned" }, location: "eastus" }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/updatePolicyAssignmentWithOverrides.json + */ +async function updateAPolicyAssignmentWithOverrides() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.update( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", + { + overrides: [ + { + kind: "policyEffect", + selectors: [ + { in: ["Limit_Skus", "Limit_Locations"], kind: "policyDefinitionReferenceId" }, + ], + value: "Audit", + }, + ], + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/updatePolicyAssignmentWithResourceSelectors.json + */ +async function updateAPolicyAssignmentWithResourceSelectors() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.update( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", + { + resourceSelectors: [ + { + name: "SDPRegions", + selectors: [{ in: ["eastus2euap", "centraluseuap"], kind: "resourceLocation" }], + }, + ], + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/updatePolicyAssignmentWithUserAssignedIdentity.json + */ +async function updateAPolicyAssignmentWithAUserAssignedIdentity() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.update( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { + identity: { + type: "UserAssigned", + userAssignedIdentities: { + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": + {}, + }, + }, + location: "eastus", + }, + ); + console.log(result); +} + +async function main() { + await updateAPolicyAssignmentWithASystemAssignedIdentity(); + await updateAPolicyAssignmentWithOverrides(); + await updateAPolicyAssignmentWithResourceSelectors(); + await updateAPolicyAssignmentWithAUserAssignedIdentity(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js new file mode 100644 index 000000000000..b3572b521b80 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation creates or updates a policy definition version in the given management group with the given name. + * + * @summary this operation creates or updates a policy definition version in the given management group with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json + */ +async function createOrUpdateAPolicyDefinitionVersionAtManagementGroupLevel() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyDefinitionVersions.createOrUpdateAtManagementGroup( + "MyManagementGroup", + "ResourceNaming", + "1.2.1", + { + description: + "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + displayName: "Enforce resource naming convention", + metadata: { category: "Naming" }, + mode: "All", + parameters: { + prefix: { + type: "String", + metadata: { description: "Resource name prefix", displayName: "Prefix" }, + }, + suffix: { + type: "String", + metadata: { description: "Resource name suffix", displayName: "Suffix" }, + }, + }, + policyRule: { + if: { + not: { field: "name", like: "[concat(parameters('prefix'), '*', parameters('suffix'))]" }, + }, + then: { effect: "deny" }, + }, + version: "1.2.1", + }, + ); + console.log(result); +} + +async function main() { + await createOrUpdateAPolicyDefinitionVersionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsCreateOrUpdateSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsCreateOrUpdateSample.js new file mode 100644 index 000000000000..422619312804 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsCreateOrUpdateSample.js @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation creates or updates a policy definition in the given subscription with the given name. + * + * @summary this operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionVersion.json + */ +async function createOrUpdateAPolicyDefinitionVersion() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitionVersions.createOrUpdate("ResourceNaming", "1.2.1", { + description: "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + displayName: "Enforce resource naming convention", + metadata: { category: "Naming" }, + mode: "All", + parameters: { + prefix: { + type: "String", + metadata: { description: "Resource name prefix", displayName: "Prefix" }, + }, + suffix: { + type: "String", + metadata: { description: "Resource name suffix", displayName: "Suffix" }, + }, + }, + policyRule: { + if: { + not: { field: "name", like: "[concat(parameters('prefix'), '*', parameters('suffix'))]" }, + }, + then: { effect: "deny" }, + }, + version: "1.2.1", + }); + console.log(result); +} + +async function main() { + await createOrUpdateAPolicyDefinitionVersion(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsDeleteAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsDeleteAtManagementGroupSample.js new file mode 100644 index 000000000000..f5b59db39360 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsDeleteAtManagementGroupSample.js @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation deletes the policy definition in the given management group with the given name. + * + * @summary this operation deletes the policy definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/deletePolicyDefinitionVersionAtManagementGroup.json + */ +async function deleteAPolicyDefinitionVersionAtManagementGroupLevel() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + await client.policyDefinitionVersions.deleteAtManagementGroup( + "MyManagementGroup", + "ResourceNaming", + "1.2.1", + ); +} + +async function main() { + await deleteAPolicyDefinitionVersionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsDeleteSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsDeleteSample.js new file mode 100644 index 000000000000..38030db273a9 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsDeleteSample.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation deletes the policy definition version in the given subscription with the given name. + * + * @summary this operation deletes the policy definition version in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/deletePolicyDefinitionVersion.json + */ +async function deleteAPolicyDefinitionVersion() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + await client.policyDefinitionVersions.delete("ResourceNaming", "1.2.1"); +} + +async function main() { + await deleteAPolicyDefinitionVersion(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsGetAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsGetAtManagementGroupSample.js new file mode 100644 index 000000000000..373f34f93080 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsGetAtManagementGroupSample.js @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation retrieves the policy definition version in the given management group with the given name. + * + * @summary this operation retrieves the policy definition version in the given management group with the given name. + * x-ms-original-file: 2025-03-01/getPolicyDefinitionVersionAtManagementGroup.json + */ +async function retrieveAPolicyDefinitionVersionAtManagementGroupLevel() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyDefinitionVersions.getAtManagementGroup( + "MyManagementGroup", + "ResourceNaming", + "1.2.1", + ); + console.log(result); +} + +async function main() { + await retrieveAPolicyDefinitionVersionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsGetBuiltInSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsGetBuiltInSample.js new file mode 100644 index 000000000000..00f0f8ae66d2 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsGetBuiltInSample.js @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation retrieves the built-in policy definition version with the given name. + * + * @summary this operation retrieves the built-in policy definition version with the given name. + * x-ms-original-file: 2025-03-01/getBuiltinPolicyDefinitionVersion.json + */ +async function retrieveABuiltInPolicyDefinitionVersion() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyDefinitionVersions.getBuiltIn( + "7433c107-6db4-4ad1-b57a-a76dce0154a1", + "1.2.1", + ); + console.log(result); +} + +async function main() { + await retrieveABuiltInPolicyDefinitionVersion(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsGetSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsGetSample.js new file mode 100644 index 000000000000..577ac583570c --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsGetSample.js @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation retrieves the policy definition version in the given subscription with the given name. + * + * @summary this operation retrieves the policy definition version in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/getPolicyDefinitionVersion.json + */ +async function retrieveAPolicyDefinitionVersion() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitionVersions.get("ResourceNaming", "1.2.1"); + console.log(result); +} + +async function main() { + await retrieveAPolicyDefinitionVersion(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListAllAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListAllAtManagementGroupSample.js similarity index 51% rename from sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListAllAtManagementGroupSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListAllAtManagementGroupSample.js index effc1dd18604..6ea5d492b6cb 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListAllAtManagementGroupSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListAllAtManagementGroupSample.js @@ -1,27 +1,20 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation lists all the policy definition versions for all policy definitions at the management group scope. + * This sample demonstrates how to this operation lists all the policy definition versions for all policy definitions at the management group scope. * - * @summary This operation lists all the policy definition versions for all policy definitions at the management group scope. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicyDefinitionVersionsByManagementGroup.json + * @summary this operation lists all the policy definition versions for all policy definitions at the management group scope. + * x-ms-original-file: 2025-03-01/listAllPolicyDefinitionVersionsByManagementGroup.json */ async function listAllPolicyDefinitionVersionsAtManagementGroup() { - const managementGroupName = "MyManagementGroup"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = - await client.policyDefinitionVersions.listAllAtManagementGroup(managementGroupName); + await client.policyDefinitionVersions.listAllAtManagementGroup("MyManagementGroup"); console.log(result); } diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListAllBuiltinsSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListAllBuiltinsSample.js similarity index 53% rename from sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListAllBuiltinsSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListAllBuiltinsSample.js index 04cd6dd704bf..909764f87ac9 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListAllBuiltinsSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListAllBuiltinsSample.js @@ -1,20 +1,14 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation lists all the built-in policy definition versions for all built-in policy definitions. + * This sample demonstrates how to this operation lists all the built-in policy definition versions for all built-in policy definitions. * - * @summary This operation lists all the built-in policy definition versions for all built-in policy definitions. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllBuiltInPolicyDefinitionVersions.json + * @summary this operation lists all the built-in policy definition versions for all built-in policy definitions. + * x-ms-original-file: 2025-03-01/listAllBuiltInPolicyDefinitionVersions.json */ async function listAllBuiltInPolicyDefinitionVersions() { const credential = new DefaultAzureCredential(); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListAllSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListAllSample.js similarity index 50% rename from sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListAllSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListAllSample.js index a7834f6ba388..96a511e0bd3c 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListAllSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListAllSample.js @@ -1,25 +1,18 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation lists all the policy definition versions for all policy definitions within a subscription. + * This sample demonstrates how to this operation lists all the policy definition versions for all policy definitions within a subscription. * - * @summary This operation lists all the policy definition versions for all policy definitions within a subscription. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicyDefinitionVersions.json + * @summary this operation lists all the policy definition versions for all policy definitions within a subscription. + * x-ms-original-file: 2025-03-01/listAllPolicyDefinitionVersions.json */ async function listAllPolicyDefinitionVersionsAtSubscription() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const result = await client.policyDefinitionVersions.listAll(); console.log(result); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListBuiltInSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListBuiltInSample.js similarity index 51% rename from sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListBuiltInSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListBuiltInSample.js index 1be70b370c1d..5881f54955b2 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListBuiltInSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListBuiltInSample.js @@ -1,29 +1,25 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation retrieves a list of all the built-in policy definition versions for the given policy definition. + * This sample demonstrates how to this operation retrieves a list of all the built-in policy definition versions for the given policy definition. * - * @summary This operation retrieves a list of all the built-in policy definition versions for the given policy definition. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicyDefinitionVersions.json + * @summary this operation retrieves a list of all the built-in policy definition versions for the given policy definition. + * x-ms-original-file: 2025-03-01/listBuiltInPolicyDefinitionVersions.json */ async function listBuiltInPolicyDefinitionVersions() { - const policyDefinitionName = "06a78e20-9358-41c9-923c-fb736d382a12"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); - for await (const item of client.policyDefinitionVersions.listBuiltIn(policyDefinitionName)) { + for await (const item of client.policyDefinitionVersions.listBuiltIn( + "06a78e20-9358-41c9-923c-fb736d382a12", + )) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListByManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListByManagementGroupSample.js similarity index 52% rename from sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListByManagementGroupSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListByManagementGroupSample.js index 4ee097548afe..ef385fdb3117 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionVersionsListByManagementGroupSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListByManagementGroupSample.js @@ -1,33 +1,26 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. + * This sample demonstrates how to this operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. * - * @summary This operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitionVersionsByManagementGroup.json + * @summary this operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. + * x-ms-original-file: 2025-03-01/listPolicyDefinitionVersionsByManagementGroup.json */ async function listPolicyDefinitionVersionsByManagementGroup() { - const managementGroupName = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); for await (const item of client.policyDefinitionVersions.listByManagementGroup( - managementGroupName, - policyDefinitionName, + "MyManagementGroup", + "ResourceNaming", )) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListSample.js new file mode 100644 index 000000000000..8f0a772d3b52 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionVersionsListSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation retrieves a list of all the policy definition versions for the given policy definition. + * + * @summary this operation retrieves a list of all the policy definition versions for the given policy definition. + * x-ms-original-file: 2025-03-01/listPolicyDefinitionVersions.json + */ +async function listPolicyDefinitionVersionsBySubscription() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.policyDefinitionVersions.list("ResourceNaming")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await listPolicyDefinitionVersionsBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsCreateOrUpdateAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsCreateOrUpdateAtManagementGroupSample.js new file mode 100644 index 000000000000..bcb34ff7dfea --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsCreateOrUpdateAtManagementGroupSample.js @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation creates or updates a policy definition in the given management group with the given name. + * + * @summary this operation creates or updates a policy definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionAtManagementGroup.json + */ +async function createOrUpdateAPolicyDefinitionAtManagementGroupLevel() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyDefinitions.createOrUpdateAtManagementGroup( + "MyManagementGroup", + "ResourceNaming", + { + description: + "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + displayName: "Enforce resource naming convention", + metadata: { category: "Naming" }, + mode: "All", + parameters: { + prefix: { + type: "String", + metadata: { description: "Resource name prefix", displayName: "Prefix" }, + }, + suffix: { + type: "String", + metadata: { description: "Resource name suffix", displayName: "Suffix" }, + }, + }, + policyRule: { + if: { + not: { field: "name", like: "[concat(parameters('prefix'), '*', parameters('suffix'))]" }, + }, + then: { effect: "deny" }, + }, + }, + ); + console.log(result); +} + +async function main() { + await createOrUpdateAPolicyDefinitionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsCreateOrUpdateSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsCreateOrUpdateSample.js new file mode 100644 index 000000000000..fa8ee700f1e4 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsCreateOrUpdateSample.js @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation creates or updates a policy definition in the given subscription with the given name. + * + * @summary this operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinition.json + */ +async function createOrUpdateAPolicyDefinition() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.createOrUpdate("ResourceNaming", { + description: "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + displayName: "Enforce resource naming convention", + metadata: { category: "Naming" }, + mode: "All", + parameters: { + prefix: { + type: "String", + metadata: { description: "Resource name prefix", displayName: "Prefix" }, + }, + suffix: { + type: "String", + metadata: { description: "Resource name suffix", displayName: "Suffix" }, + }, + }, + policyRule: { + if: { + not: { field: "name", like: "[concat(parameters('prefix'), '*', parameters('suffix'))]" }, + }, + then: { effect: "deny" }, + }, + }); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy definition in the given subscription with the given name. + * + * @summary this operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionAdvancedParams.json + */ +async function createOrUpdateAPolicyDefinitionWithAdvancedParameters() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.createOrUpdate("EventHubDiagnosticLogs", { + description: + "Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised", + displayName: "Event Hubs should have diagnostic logging enabled", + metadata: { category: "Event Hub" }, + mode: "Indexed", + parameters: { + requiredRetentionDays: { + type: "Integer", + allowedValues: [0, 30, 90, 180, 365], + defaultValue: 365, + metadata: { + description: "The required diagnostic logs retention in days", + displayName: "Required retention (days)", + }, + }, + }, + policyRule: { + if: { equals: "Microsoft.EventHub/namespaces", field: "type" }, + then: { + effect: "AuditIfNotExists", + details: { + type: "Microsoft.Insights/diagnosticSettings", + existenceCondition: { + allOf: [ + { + equals: "true", + field: "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled", + }, + { + equals: "[parameters('requiredRetentionDays')]", + field: "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days", + }, + ], + }, + }, + }, + }, + }); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy definition in the given subscription with the given name. + * + * @summary this operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionExternalEvaluationEnforcementSettings.json + */ +async function createOrUpdateAPolicyDefinitionWithExternalEvaluationEnforcementSettings() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.createOrUpdate("RandomizeVMAllocation", { + description: + "Randomly disable VM allocation in eastus by having policy rule reference the outcome of invoking an external endpoint using the CoinFlip endpoint that returns random values.", + displayName: "Randomize VM Allocation", + externalEvaluationEnforcementSettings: { + endpointSettings: { kind: "CoinFlip", details: { successProbability: 0.5 } }, + missingTokenAction: "audit", + roleDefinitionIds: [ + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/roleDefinitions/f0cc2aea-b517-48f6-8f9e-0c01c687907b", + ], + }, + metadata: { category: "VM" }, + mode: "Indexed", + policyRule: { + if: { + allOf: [ + { equals: "Microsoft.Compute/virtualMachines", field: "type" }, + { equals: "eastus", field: "location" }, + { equals: "false", value: "[claims().isValid]" }, + ], + }, + then: { effect: "deny" }, + }, + }); + console.log(result); +} + +async function main() { + await createOrUpdateAPolicyDefinition(); + await createOrUpdateAPolicyDefinitionWithAdvancedParameters(); + await createOrUpdateAPolicyDefinitionWithExternalEvaluationEnforcementSettings(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsDeleteAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsDeleteAtManagementGroupSample.js new file mode 100644 index 000000000000..66f9282fcb13 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsDeleteAtManagementGroupSample.js @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation deletes the policy definition in the given management group with the given name. + * + * @summary this operation deletes the policy definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/deletePolicyDefinitionAtManagementGroup.json + */ +async function deleteAPolicyDefinitionAtManagementGroupLevel() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + await client.policyDefinitions.deleteAtManagementGroup("MyManagementGroup", "ResourceNaming"); +} + +async function main() { + await deleteAPolicyDefinitionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsDeleteSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsDeleteSample.js new file mode 100644 index 000000000000..48fb106013f8 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsDeleteSample.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation deletes the policy definition in the given subscription with the given name. + * + * @summary this operation deletes the policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/deletePolicyDefinition.json + */ +async function deleteAPolicyDefinition() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + await client.policyDefinitions.delete("ResourceNaming"); +} + +async function main() { + await deleteAPolicyDefinition(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsGetAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsGetAtManagementGroupSample.js new file mode 100644 index 000000000000..c2ca78e47df5 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsGetAtManagementGroupSample.js @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation retrieves the policy definition in the given management group with the given name. + * + * @summary this operation retrieves the policy definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/getPolicyDefinitionAtManagementGroup.json + */ +async function retrieveAPolicyDefinitionAtManagementGroupLevel() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyDefinitions.getAtManagementGroup( + "MyManagementGroup", + "ResourceNaming", + ); + console.log(result); +} + +async function main() { + await retrieveAPolicyDefinitionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsGetBuiltInSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsGetBuiltInSample.js new file mode 100644 index 000000000000..d98b5f2c37c7 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsGetBuiltInSample.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation retrieves the built-in policy definition with the given name. + * + * @summary this operation retrieves the built-in policy definition with the given name. + * x-ms-original-file: 2025-03-01/getBuiltinPolicyDefinition.json + */ +async function retrieveABuiltInPolicyDefinition() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyDefinitions.getBuiltIn("7433c107-6db4-4ad1-b57a-a76dce0154a1"); + console.log(result); +} + +async function main() { + await retrieveABuiltInPolicyDefinition(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsGetSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsGetSample.js new file mode 100644 index 000000000000..61d75aa01cbb --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsGetSample.js @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation retrieves the policy definition in the given subscription with the given name. + * + * @summary this operation retrieves the policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/getPolicyDefinition.json + */ +async function retrieveAPolicyDefinition() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.get("ResourceNaming"); + console.log(result); +} + +async function main() { + await retrieveAPolicyDefinition(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsListBuiltInSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsListBuiltInSample.js similarity index 72% rename from sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsListBuiltInSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsListBuiltInSample.js index bc0aea328796..f1cf88116426 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsListBuiltInSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsListBuiltInSample.js @@ -1,20 +1,14 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. + * This sample demonstrates how to this operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. * - * @summary This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicyDefinitions.json + * @summary this operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listBuiltInPolicyDefinitions.json */ async function listBuiltInPolicyDefinitions() { const credential = new DefaultAzureCredential(); @@ -23,6 +17,7 @@ async function listBuiltInPolicyDefinitions() { for await (const item of client.policyDefinitions.listBuiltIn()) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsListByManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsListByManagementGroupSample.js similarity index 78% rename from sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsListByManagementGroupSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsListByManagementGroupSample.js index 3ad103402045..1e09043c4d4f 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsListByManagementGroupSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsListByManagementGroupSample.js @@ -1,29 +1,23 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * This sample demonstrates how to this operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. * - * @summary This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitionsByManagementGroup.json + * @summary this operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listPolicyDefinitionsByManagementGroup.json */ async function listPolicyDefinitionsByManagementGroup() { - const managementGroupId = "MyManagementGroup"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); - for await (const item of client.policyDefinitions.listByManagementGroup(managementGroupId)) { + for await (const item of client.policyDefinitions.listByManagementGroup("MyManagementGroup")) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsListSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsListSample.js similarity index 78% rename from sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsListSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsListSample.js index ba831f5dec82..384a28ec928b 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policyDefinitionsListSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyDefinitionsListSample.js @@ -1,30 +1,24 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * This sample demonstrates how to this operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. * - * @summary This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitions.json + * @summary this operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listPolicyDefinitions.json */ async function listPolicyDefinitionsBySubscription() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const resArray = new Array(); for await (const item of client.policyDefinitions.list()) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js new file mode 100644 index 000000000000..5d197c3b45cd --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.js @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation creates or updates a policy set definition version in the given management group with the given name and version. + * + * @summary this operation creates or updates a policy set definition version in the given management group with the given name and version. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json + */ +async function createOrUpdateAPolicySetDefinitionVersionAtManagementGroupLevel() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policySetDefinitionVersions.createOrUpdateAtManagementGroup( + "MyManagementGroup", + "CostManagement", + "1.2.1", + { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitions: [ + { + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus", + }, + { + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming", + }, + ], + version: "1.2.1", + }, + ); + console.log(result); +} + +async function main() { + await createOrUpdateAPolicySetDefinitionVersionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsCreateOrUpdateSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsCreateOrUpdateSample.js new file mode 100644 index 000000000000..e70cd7b3a864 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsCreateOrUpdateSample.js @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation creates or updates a policy set definition version in the given subscription with the given name and version. + * + * @summary this operation creates or updates a policy set definition version in the given subscription with the given name and version. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionVersion.json + */ +async function createOrUpdateAPolicySetDefinitionVersion() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitionVersions.createOrUpdate( + "CostManagement", + "1.2.1", + { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + parameters: { + namePrefix: { + type: "String", + defaultValue: "myPrefix", + metadata: { displayName: "Prefix to enforce on resource names" }, + }, + }, + policyDefinitions: [ + { + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus", + }, + { + parameters: { prefix: { value: "[parameters('namePrefix')]" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming", + }, + ], + version: "1.2.1", + }, + ); + console.log(result); +} + +async function main() { + await createOrUpdateAPolicySetDefinitionVersion(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsDeleteAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsDeleteAtManagementGroupSample.js new file mode 100644 index 000000000000..5370ddc33eea --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsDeleteAtManagementGroupSample.js @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation deletes the policy set definition version in the given management group with the given name and version. + * + * @summary this operation deletes the policy set definition version in the given management group with the given name and version. + * x-ms-original-file: 2025-03-01/deletePolicySetDefinitionVersionAtManagementGroup.json + */ +async function deleteAPolicySetDefinitionVersionAtManagementGroupLevel() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + await client.policySetDefinitionVersions.deleteAtManagementGroup( + "MyManagementGroup", + "CostManagement", + "1.2.1", + ); +} + +async function main() { + await deleteAPolicySetDefinitionVersionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsDeleteSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsDeleteSample.js new file mode 100644 index 000000000000..8b06620fd8ef --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsDeleteSample.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation deletes the policy set definition version in the given subscription with the given name and version. + * + * @summary this operation deletes the policy set definition version in the given subscription with the given name and version. + * x-ms-original-file: 2025-03-01/deletePolicySetDefinitionVersion.json + */ +async function deleteAPolicySetDefinitionVersion() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + await client.policySetDefinitionVersions.delete("CostManagement", "1.2.1"); +} + +async function main() { + await deleteAPolicySetDefinitionVersion(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsGetAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsGetAtManagementGroupSample.js new file mode 100644 index 000000000000..de3078c44517 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsGetAtManagementGroupSample.js @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation retrieves the policy set definition version in the given management group with the given name and version. + * + * @summary this operation retrieves the policy set definition version in the given management group with the given name and version. + * x-ms-original-file: 2025-03-01/getPolicySetDefinitionVersionAtManagementGroup.json + */ +async function retrieveAPolicySetDefinitionVersionAtManagementGroupLevel() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policySetDefinitionVersions.getAtManagementGroup( + "MyManagementGroup", + "CostManagement", + "1.2.1", + ); + console.log(result); +} + +async function main() { + await retrieveAPolicySetDefinitionVersionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsGetBuiltInSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsGetBuiltInSample.js new file mode 100644 index 000000000000..e7c6c42e794b --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsGetBuiltInSample.js @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation retrieves the built-in policy set definition version with the given name and version. + * + * @summary this operation retrieves the built-in policy set definition version with the given name and version. + * x-ms-original-file: 2025-03-01/getBuiltInPolicySetDefinitionVersion.json + */ +async function retrieveABuiltInPolicySetDefinitionVersion() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policySetDefinitionVersions.getBuiltIn( + "1f3afdf9-d0c9-4c3d-847f-89da613e70a8", + "1.2.1", + ); + console.log(result); +} + +async function main() { + await retrieveABuiltInPolicySetDefinitionVersion(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsGetSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsGetSample.js new file mode 100644 index 000000000000..ecdefe9493f2 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsGetSample.js @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation retrieves the policy set definition version in the given subscription with the given name and version. + * + * @summary this operation retrieves the policy set definition version in the given subscription with the given name and version. + * x-ms-original-file: 2025-03-01/getPolicySetDefinitionVersion.json + */ +async function retrieveAPolicySetDefinitionVersion() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitionVersions.get("CostManagement", "1.2.1"); + console.log(result); +} + +async function main() { + await retrieveAPolicySetDefinitionVersion(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListAllAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListAllAtManagementGroupSample.js similarity index 51% rename from sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListAllAtManagementGroupSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListAllAtManagementGroupSample.js index d1ec3c3bb8c2..914226da8508 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListAllAtManagementGroupSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListAllAtManagementGroupSample.js @@ -1,27 +1,20 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation lists all the policy set definition versions for all policy set definitions at the management group scope. + * This sample demonstrates how to this operation lists all the policy set definition versions for all policy set definitions at the management group scope. * - * @summary This operation lists all the policy set definition versions for all policy set definitions at the management group scope. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicySetDefinitionVersionsByManagementGroup.json + * @summary this operation lists all the policy set definition versions for all policy set definitions at the management group scope. + * x-ms-original-file: 2025-03-01/listAllPolicySetDefinitionVersionsByManagementGroup.json */ async function listAllPolicyDefinitionVersionsAtManagementGroup() { - const managementGroupName = "MyManagementGroup"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = - await client.policySetDefinitionVersions.listAllAtManagementGroup(managementGroupName); + await client.policySetDefinitionVersions.listAllAtManagementGroup("MyManagementGroup"); console.log(result); } diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListAllBuiltinsSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListAllBuiltinsSample.js similarity index 53% rename from sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListAllBuiltinsSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListAllBuiltinsSample.js index 2ecf2ed45360..2b73b5242704 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListAllBuiltinsSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListAllBuiltinsSample.js @@ -1,20 +1,14 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation lists all the built-in policy set definition versions for all built-in policy set definitions. + * This sample demonstrates how to this operation lists all the built-in policy set definition versions for all built-in policy set definitions. * - * @summary This operation lists all the built-in policy set definition versions for all built-in policy set definitions. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllBuiltInPolicySetDefinitionVersions.json + * @summary this operation lists all the built-in policy set definition versions for all built-in policy set definitions. + * x-ms-original-file: 2025-03-01/listAllBuiltInPolicySetDefinitionVersions.json */ async function listAllBuiltInPolicyDefinitionVersions() { const credential = new DefaultAzureCredential(); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListAllSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListAllSample.js similarity index 50% rename from sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListAllSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListAllSample.js index 1b79255c11ee..c8e9e7916478 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListAllSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListAllSample.js @@ -1,25 +1,18 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation lists all the policy set definition versions for all policy set definitions within a subscription. + * This sample demonstrates how to this operation lists all the policy set definition versions for all policy set definitions within a subscription. * - * @summary This operation lists all the policy set definition versions for all policy set definitions within a subscription. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicySetDefinitionVersions.json + * @summary this operation lists all the policy set definition versions for all policy set definitions within a subscription. + * x-ms-original-file: 2025-03-01/listAllPolicySetDefinitionVersions.json */ async function listAllPolicyDefinitionVersionsAtSubscription() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const result = await client.policySetDefinitionVersions.listAll(); console.log(result); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListBuiltInSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListBuiltInSample.js similarity index 52% rename from sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListBuiltInSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListBuiltInSample.js index 4cee2ba749be..8a2cc20287a8 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListBuiltInSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListBuiltInSample.js @@ -1,31 +1,25 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. + * This sample demonstrates how to this operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. * - * @summary This operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicySetDefinitionVersions.json + * @summary this operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. + * x-ms-original-file: 2025-03-01/listBuiltInPolicySetDefinitionVersions.json */ async function listBuiltInPolicySetDefinitions() { - const policySetDefinitionName = "1f3afdf9-d0c9-4c3d-847f-89da613e70a8"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); for await (const item of client.policySetDefinitionVersions.listBuiltIn( - policySetDefinitionName, + "1f3afdf9-d0c9-4c3d-847f-89da613e70a8", )) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListByManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListByManagementGroupSample.js similarity index 52% rename from sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListByManagementGroupSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListByManagementGroupSample.js index cda7a00699ab..bea54f847065 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionVersionsListByManagementGroupSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListByManagementGroupSample.js @@ -1,33 +1,26 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. + * This sample demonstrates how to this operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. * - * @summary This operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitionVersionsByManagementGroup.json + * @summary this operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. + * x-ms-original-file: 2025-03-01/listPolicySetDefinitionVersionsByManagementGroup.json */ async function listPolicySetDefinitionsAtManagementGroupLevel() { - const managementGroupName = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); for await (const item of client.policySetDefinitionVersions.listByManagementGroup( - managementGroupName, - policySetDefinitionName, + "MyManagementGroup", + "CostManagement", )) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListSample.js new file mode 100644 index 000000000000..bf10aa4887d4 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionVersionsListSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation retrieves a list of all the policy set definition versions for the given policy set definition. + * + * @summary this operation retrieves a list of all the policy set definition versions for the given policy set definition. + * x-ms-original-file: 2025-03-01/listPolicySetDefinitionVersions.json + */ +async function listPolicySetDefinitions() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.policySetDefinitionVersions.list("CostManagement")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await listPolicySetDefinitions(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.js new file mode 100644 index 000000000000..cbc37ec9d926 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.js @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation creates or updates a policy set definition in the given management group with the given name. + * + * @summary this operation creates or updates a policy set definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionAtManagementGroup.json + */ +async function createOrUpdateAPolicySetDefinitionAtManagementGroupLevel() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policySetDefinitions.createOrUpdateAtManagementGroup( + "MyManagementGroup", + "CostManagement", + { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitions: [ + { + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus", + }, + { + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming", + }, + ], + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy set definition in the given management group with the given name. + * + * @summary this operation creates or updates a policy set definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json + */ +async function createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policySetDefinitions.createOrUpdateAtManagementGroup( + "MyManagementGroup", + "CostManagement", + { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitionGroups: [ + { + name: "CostSaving", + description: "Policies designed to control spend within a subscription.", + displayName: "Cost Management Policies", + }, + { + name: "Organizational", + description: + "Policies that help enforce resource organization standards within a subscription.", + displayName: "Organizational Policies", + }, + ], + policyDefinitions: [ + { + groupNames: ["CostSaving"], + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus", + }, + { + groupNames: ["Organizational"], + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming", + }, + ], + }, + ); + console.log(result); +} + +async function main() { + await createOrUpdateAPolicySetDefinitionAtManagementGroupLevel(); + await createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsCreateOrUpdateSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsCreateOrUpdateSample.js similarity index 66% rename from sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsCreateOrUpdateSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsCreateOrUpdateSample.js index 72e9606b76cb..b84542c47704 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsCreateOrUpdateSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsCreateOrUpdateSample.js @@ -1,26 +1,20 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation creates or updates a policy set definition in the given subscription with the given name. + * This sample demonstrates how to this operation creates or updates a policy set definition in the given subscription with the given name. * - * @summary This operation creates or updates a policy set definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinition.json + * @summary this operation creates or updates a policy set definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinition.json */ async function createOrUpdateAPolicySetDefinition() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const parameters = { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdate("CostManagement", { description: "Policies to enforce low cost storage SKUs", displayName: "Cost Management", metadata: { category: "Cost Management" }, @@ -33,44 +27,33 @@ async function createOrUpdateAPolicySetDefinition() { }, policyDefinitions: [ { - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, policyDefinitionId: "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", policyDefinitionReferenceId: "Limit_Skus", }, { - parameters: { - prefix: { value: "[parameters('namePrefix')]" }, - suffix: { value: "-LC" }, - }, + parameters: { prefix: { value: "[parameters('namePrefix')]" }, suffix: { value: "-LC" } }, policyDefinitionId: "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", policyDefinitionReferenceId: "Resource_Naming", }, ], - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitions.createOrUpdate( - policySetDefinitionName, - parameters, - ); + }); console.log(result); } /** - * This sample demonstrates how to This operation creates or updates a policy set definition in the given subscription with the given name. + * This sample demonstrates how to this operation creates or updates a policy set definition in the given subscription with the given name. * - * @summary This operation creates or updates a policy set definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionWithGroups.json + * @summary this operation creates or updates a policy set definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionWithGroups.json */ async function createOrUpdateAPolicySetDefinitionWithGroups() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const parameters = { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdate("CostManagement", { description: "Policies to enforce low cost storage SKUs", displayName: "Cost Management", metadata: { category: "Cost Management" }, @@ -91,9 +74,7 @@ async function createOrUpdateAPolicySetDefinitionWithGroups() { { definitionVersion: "1.*.*", groupNames: ["CostSaving"], - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, policyDefinitionId: "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", policyDefinitionReferenceId: "Limit_Skus", @@ -107,13 +88,7 @@ async function createOrUpdateAPolicySetDefinitionWithGroups() { policyDefinitionReferenceId: "Resource_Naming", }, ], - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitions.createOrUpdate( - policySetDefinitionName, - parameters, - ); + }); console.log(result); } diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsDeleteAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsDeleteAtManagementGroupSample.js new file mode 100644 index 000000000000..d876c482ea41 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsDeleteAtManagementGroupSample.js @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation deletes the policy set definition in the given management group with the given name. + * + * @summary this operation deletes the policy set definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/deletePolicySetDefinitionAtManagementGroup.json + */ +async function deleteAPolicySetDefinitionAtManagementGroupLevel() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + await client.policySetDefinitions.deleteAtManagementGroup("MyManagementGroup", "CostManagement"); +} + +async function main() { + await deleteAPolicySetDefinitionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsDeleteSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsDeleteSample.js new file mode 100644 index 000000000000..bf6869f63de9 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsDeleteSample.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation deletes the policy set definition in the given subscription with the given name. + * + * @summary this operation deletes the policy set definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/deletePolicySetDefinition.json + */ +async function deleteAPolicySetDefinition() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + await client.policySetDefinitions.delete("CostManagement"); +} + +async function main() { + await deleteAPolicySetDefinition(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsGetAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsGetAtManagementGroupSample.js new file mode 100644 index 000000000000..a370fcaca4d5 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsGetAtManagementGroupSample.js @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation retrieves the policy set definition in the given management group with the given name. + * + * @summary this operation retrieves the policy set definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/getPolicySetDefinitionAtManagementGroup.json + */ +async function retrieveAPolicySetDefinitionAtManagementGroupLevel() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policySetDefinitions.getAtManagementGroup( + "MyManagementGroup", + "CostManagement", + ); + console.log(result); +} + +async function main() { + await retrieveAPolicySetDefinitionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsGetBuiltInSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsGetBuiltInSample.js new file mode 100644 index 000000000000..0d956c34ff4b --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsGetBuiltInSample.js @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation retrieves the built-in policy set definition with the given name. + * + * @summary this operation retrieves the built-in policy set definition with the given name. + * x-ms-original-file: 2025-03-01/getBuiltInPolicySetDefinition.json + */ +async function retrieveABuiltInPolicySetDefinition() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policySetDefinitions.getBuiltIn( + "1f3afdf9-d0c9-4c3d-847f-89da613e70a8", + ); + console.log(result); +} + +async function main() { + await retrieveABuiltInPolicySetDefinition(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsGetSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsGetSample.js new file mode 100644 index 000000000000..465ac2e7afd7 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsGetSample.js @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation retrieves the policy set definition in the given subscription with the given name. + * + * @summary this operation retrieves the policy set definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/getPolicySetDefinition.json + */ +async function retrieveAPolicySetDefinition() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.get("CostManagement"); + console.log(result); +} + +async function main() { + await retrieveAPolicySetDefinition(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsListBuiltInSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsListBuiltInSample.js similarity index 64% rename from sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsListBuiltInSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsListBuiltInSample.js index 97197f9833aa..1cceec0e8c52 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsListBuiltInSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsListBuiltInSample.js @@ -1,20 +1,14 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. + * This sample demonstrates how to this operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. * - * @summary This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicySetDefinitions.json + * @summary this operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listBuiltInPolicySetDefinitions.json */ async function listBuiltInPolicySetDefinitions() { const credential = new DefaultAzureCredential(); @@ -23,6 +17,7 @@ async function listBuiltInPolicySetDefinitions() { for await (const item of client.policySetDefinitions.listBuiltIn()) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsListByManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsListByManagementGroupSample.js similarity index 78% rename from sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsListByManagementGroupSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsListByManagementGroupSample.js index 6f51735cc979..b9911defb847 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsListByManagementGroupSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsListByManagementGroupSample.js @@ -1,29 +1,23 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * This sample demonstrates how to this operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. * - * @summary This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitionsByManagementGroup.json + * @summary this operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listPolicySetDefinitionsByManagementGroup.json */ async function listPolicySetDefinitionsAtManagementGroupLevel() { - const managementGroupId = "MyManagementGroup"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); - for await (const item of client.policySetDefinitions.listByManagementGroup(managementGroupId)) { + for await (const item of client.policySetDefinitions.listByManagementGroup("MyManagementGroup")) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsListSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsListSample.js similarity index 78% rename from sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsListSample.js rename to sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsListSample.js index f2eb55df6a5e..2f2130beffab 100644 --- a/sdk/policy/arm-policy/samples/v6/javascript/policySetDefinitionsListSample.js +++ b/sdk/policy/arm-policy/samples/v7/javascript/policySetDefinitionsListSample.js @@ -1,30 +1,24 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. const { PolicyClient } = require("@azure/arm-policy"); const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); /** - * This sample demonstrates how to This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * This sample demonstrates how to this operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. * - * @summary This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitions.json + * @summary this operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listPolicySetDefinitions.json */ async function listPolicySetDefinitions() { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const resArray = new Array(); for await (const item of client.policySetDefinitions.list()) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyTokensAcquireAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyTokensAcquireAtManagementGroupSample.js new file mode 100644 index 000000000000..941ac4603a1e --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyTokensAcquireAtManagementGroupSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation acquires a policy token in the given management group for the given request body. + * + * @summary this operation acquires a policy token in the given management group for the given request body. + * x-ms-original-file: 2025-03-01/acquirePolicyTokenAtManagementGroup.json + */ +async function acquireAPolicyTokenAtManagementGroupLevel() { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyTokens.acquireAtManagementGroup("MyManagementGroup", { + operation: { + httpMethod: "delete", + uri: "https://management.azure.com/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/roleAssignments/00000000-0000-0000-0000-000000000000?api-version=2022-04-01", + }, + }); + console.log(result); +} + +async function main() { + await acquireAPolicyTokenAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/javascript/policyTokensAcquireSample.js b/sdk/policy/arm-policy/samples/v7/javascript/policyTokensAcquireSample.js new file mode 100644 index 000000000000..2a16037f7f32 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/javascript/policyTokensAcquireSample.js @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to this operation acquires a policy token in the given subscription for the given request body. + * + * @summary this operation acquires a policy token in the given subscription for the given request body. + * x-ms-original-file: 2025-03-01/acquirePolicyToken.json + */ +async function acquireAPolicyToken() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyTokens.acquire({ + operation: { + httpMethod: "delete", + uri: "https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/testVM?api-version=2024-01-01", + }, + }); + console.log(result); +} + +async function main() { + await acquireAPolicyToken(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/javascript/sample.env b/sdk/policy/arm-policy/samples/v7/javascript/sample.env similarity index 100% rename from sdk/policy/arm-policy/samples/v6/javascript/sample.env rename to sdk/policy/arm-policy/samples/v7/javascript/sample.env diff --git a/sdk/policy/arm-policy/samples/v6/typescript/README.md b/sdk/policy/arm-policy/samples/v7/typescript/README.md similarity index 84% rename from sdk/policy/arm-policy/samples/v6/typescript/README.md rename to sdk/policy/arm-policy/samples/v7/typescript/README.md index bb02cc2d0e97..f2c8d0dd6da7 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/README.md +++ b/sdk/policy/arm-policy/samples/v7/typescript/README.md @@ -1,67 +1,65 @@ -# client library samples for TypeScript - -These sample programs show how to use the TypeScript client libraries for in some common scenarios. - -| **File Name** | **Description** | -| --------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [policyAssignmentsCreateByIdSample.ts][policyassignmentscreatebyidsample] | This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignmentById.json | -| [policyAssignmentsCreateSample.ts][policyassignmentscreatesample] | This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createPolicyAssignment.json | -| [policyAssignmentsDeleteByIdSample.ts][policyassignmentsdeletebyidsample] | This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyAssignmentById.json | -| [policyAssignmentsDeleteSample.ts][policyassignmentsdeletesample] | This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyAssignment.json | -| [policyAssignmentsGetByIdSample.ts][policyassignmentsgetbyidsample] | The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignmentById.json | -| [policyAssignmentsGetSample.ts][policyassignmentsgetsample] | This operation retrieves a single policy assignment, given its name and the scope it was created at. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyAssignment.json | -| [policyAssignmentsListForManagementGroupSample.ts][policyassignmentslistformanagementgroupsample] | This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignmentsForManagementGroup.json | -| [policyAssignmentsListForResourceGroupSample.ts][policyassignmentslistforresourcegroupsample] | This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignmentsForResourceGroup.json | -| [policyAssignmentsListForResourceSample.ts][policyassignmentslistforresourcesample] | This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignmentsForResource.json | -| [policyAssignmentsListSample.ts][policyassignmentslistsample] | This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignments.json | -| [policyAssignmentsUpdateByIdSample.ts][policyassignmentsupdatebyidsample] | This operation updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithIdentityById.json | -| [policyAssignmentsUpdateSample.ts][policyassignmentsupdatesample] | This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/updatePolicyAssignmentWithIdentity.json | -| [policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts][policydefinitionversionscreateorupdateatmanagementgroupsample] | This operation creates or updates a policy definition version in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json | -| [policyDefinitionVersionsCreateOrUpdateSample.ts][policydefinitionversionscreateorupdatesample] | This operation creates or updates a policy definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionVersion.json | -| [policyDefinitionVersionsDeleteAtManagementGroupSample.ts][policydefinitionversionsdeleteatmanagementgroupsample] | This operation deletes the policy definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinitionVersionAtManagementGroup.json | -| [policyDefinitionVersionsDeleteSample.ts][policydefinitionversionsdeletesample] | This operation deletes the policy definition version in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinitionVersion.json | -| [policyDefinitionVersionsGetAtManagementGroupSample.ts][policydefinitionversionsgetatmanagementgroupsample] | This operation retrieves the policy definition version in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinitionVersionAtManagementGroup.json | -| [policyDefinitionVersionsGetBuiltInSample.ts][policydefinitionversionsgetbuiltinsample] | This operation retrieves the built-in policy definition version with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltinPolicyDefinitionVersion.json | -| [policyDefinitionVersionsGetSample.ts][policydefinitionversionsgetsample] | This operation retrieves the policy definition version in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinitionVersion.json | -| [policyDefinitionVersionsListAllAtManagementGroupSample.ts][policydefinitionversionslistallatmanagementgroupsample] | This operation lists all the policy definition versions for all policy definitions at the management group scope. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicyDefinitionVersionsByManagementGroup.json | -| [policyDefinitionVersionsListAllBuiltinsSample.ts][policydefinitionversionslistallbuiltinssample] | This operation lists all the built-in policy definition versions for all built-in policy definitions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllBuiltInPolicyDefinitionVersions.json | -| [policyDefinitionVersionsListAllSample.ts][policydefinitionversionslistallsample] | This operation lists all the policy definition versions for all policy definitions within a subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicyDefinitionVersions.json | -| [policyDefinitionVersionsListBuiltInSample.ts][policydefinitionversionslistbuiltinsample] | This operation retrieves a list of all the built-in policy definition versions for the given policy definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicyDefinitionVersions.json | -| [policyDefinitionVersionsListByManagementGroupSample.ts][policydefinitionversionslistbymanagementgroupsample] | This operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitionVersionsByManagementGroup.json | -| [policyDefinitionVersionsListSample.ts][policydefinitionversionslistsample] | This operation retrieves a list of all the policy definition versions for the given policy definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitionVersions.json | -| [policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts][policydefinitionscreateorupdateatmanagementgroupsample] | This operation creates or updates a policy definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json | -| [policyDefinitionsCreateOrUpdateSample.ts][policydefinitionscreateorupdatesample] | This operation creates or updates a policy definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicyDefinition.json | -| [policyDefinitionsDeleteAtManagementGroupSample.ts][policydefinitionsdeleteatmanagementgroupsample] | This operation deletes the policy definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinitionAtManagementGroup.json | -| [policyDefinitionsDeleteSample.ts][policydefinitionsdeletesample] | This operation deletes the policy definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyDefinition.json | -| [policyDefinitionsGetAtManagementGroupSample.ts][policydefinitionsgetatmanagementgroupsample] | This operation retrieves the policy definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinitionAtManagementGroup.json | -| [policyDefinitionsGetBuiltInSample.ts][policydefinitionsgetbuiltinsample] | This operation retrieves the built-in policy definition with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltinPolicyDefinition.json | -| [policyDefinitionsGetSample.ts][policydefinitionsgetsample] | This operation retrieves the policy definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicyDefinition.json | -| [policyDefinitionsListBuiltInSample.ts][policydefinitionslistbuiltinsample] | This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicyDefinitions.json | -| [policyDefinitionsListByManagementGroupSample.ts][policydefinitionslistbymanagementgroupsample] | This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitionsByManagementGroup.json | -| [policyDefinitionsListSample.ts][policydefinitionslistsample] | This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitions.json | -| [policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts][policysetdefinitionversionscreateorupdateatmanagementgroupsample] | This operation creates or updates a policy set definition version in the given management group with the given name and version. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json | -| [policySetDefinitionVersionsCreateOrUpdateSample.ts][policysetdefinitionversionscreateorupdatesample] | This operation creates or updates a policy set definition version in the given subscription with the given name and version. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionVersion.json | -| [policySetDefinitionVersionsDeleteAtManagementGroupSample.ts][policysetdefinitionversionsdeleteatmanagementgroupsample] | This operation deletes the policy set definition version in the given management group with the given name and version. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinitionVersionAtManagementGroup.json | -| [policySetDefinitionVersionsDeleteSample.ts][policysetdefinitionversionsdeletesample] | This operation deletes the policy set definition version in the given subscription with the given name and version. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinitionVersion.json | -| [policySetDefinitionVersionsGetAtManagementGroupSample.ts][policysetdefinitionversionsgetatmanagementgroupsample] | This operation retrieves the policy set definition version in the given management group with the given name and version. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinitionVersionAtManagementGroup.json | -| [policySetDefinitionVersionsGetBuiltInSample.ts][policysetdefinitionversionsgetbuiltinsample] | This operation retrieves the built-in policy set definition version with the given name and version. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltInPolicySetDefinitionVersion.json | -| [policySetDefinitionVersionsGetSample.ts][policysetdefinitionversionsgetsample] | This operation retrieves the policy set definition version in the given subscription with the given name and version. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinitionVersion.json | -| [policySetDefinitionVersionsListAllAtManagementGroupSample.ts][policysetdefinitionversionslistallatmanagementgroupsample] | This operation lists all the policy set definition versions for all policy set definitions at the management group scope. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicySetDefinitionVersionsByManagementGroup.json | -| [policySetDefinitionVersionsListAllBuiltinsSample.ts][policysetdefinitionversionslistallbuiltinssample] | This operation lists all the built-in policy set definition versions for all built-in policy set definitions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllBuiltInPolicySetDefinitionVersions.json | -| [policySetDefinitionVersionsListAllSample.ts][policysetdefinitionversionslistallsample] | This operation lists all the policy set definition versions for all policy set definitions within a subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicySetDefinitionVersions.json | -| [policySetDefinitionVersionsListBuiltInSample.ts][policysetdefinitionversionslistbuiltinsample] | This operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicySetDefinitionVersions.json | -| [policySetDefinitionVersionsListByManagementGroupSample.ts][policysetdefinitionversionslistbymanagementgroupsample] | This operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitionVersionsByManagementGroup.json | -| [policySetDefinitionVersionsListSample.ts][policysetdefinitionversionslistsample] | This operation retrieves a list of all the policy set definition versions for the given policy set definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitionVersions.json | -| [policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts][policysetdefinitionscreateorupdateatmanagementgroupsample] | This operation creates or updates a policy set definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json | -| [policySetDefinitionsCreateOrUpdateSample.ts][policysetdefinitionscreateorupdatesample] | This operation creates or updates a policy set definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinition.json | -| [policySetDefinitionsDeleteAtManagementGroupSample.ts][policysetdefinitionsdeleteatmanagementgroupsample] | This operation deletes the policy set definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinitionAtManagementGroup.json | -| [policySetDefinitionsDeleteSample.ts][policysetdefinitionsdeletesample] | This operation deletes the policy set definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicySetDefinition.json | -| [policySetDefinitionsGetAtManagementGroupSample.ts][policysetdefinitionsgetatmanagementgroupsample] | This operation retrieves the policy set definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinitionAtManagementGroup.json | -| [policySetDefinitionsGetBuiltInSample.ts][policysetdefinitionsgetbuiltinsample] | This operation retrieves the built-in policy set definition with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getBuiltInPolicySetDefinition.json | -| [policySetDefinitionsGetSample.ts][policysetdefinitionsgetsample] | This operation retrieves the policy set definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/getPolicySetDefinition.json | -| [policySetDefinitionsListBuiltInSample.ts][policysetdefinitionslistbuiltinsample] | This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicySetDefinitions.json | -| [policySetDefinitionsListByManagementGroupSample.ts][policysetdefinitionslistbymanagementgroupsample] | This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitionsByManagementGroup.json | -| [policySetDefinitionsListSample.ts][policysetdefinitionslistsample] | This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitions.json | +# @azure/arm-policy client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for @azure/arm-policy in some common scenarios. + +| **File Name** | **Description** | +| --------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [policyAssignmentsCreateSample.ts][policyassignmentscreatesample] | this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. x-ms-original-file: 2025-03-01/createPolicyAssignment.json | +| [policyAssignmentsDeleteSample.ts][policyassignmentsdeletesample] | this operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. x-ms-original-file: 2025-03-01/deletePolicyAssignment.json | +| [policyAssignmentsGetSample.ts][policyassignmentsgetsample] | this operation retrieves a single policy assignment, given its name and the scope it was created at. x-ms-original-file: 2025-03-01/getPolicyAssignment.json | +| [policyAssignmentsListForManagementGroupSample.ts][policyassignmentslistformanagementgroupsample] | this operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. x-ms-original-file: 2025-03-01/listPolicyAssignmentsForManagementGroup.json | +| [policyAssignmentsListForResourceGroupSample.ts][policyassignmentslistforresourcegroupsample] | this operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. x-ms-original-file: 2025-03-01/listPolicyAssignmentsForResourceGroup.json | +| [policyAssignmentsListForResourceSample.ts][policyassignmentslistforresourcesample] | this operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). x-ms-original-file: 2025-03-01/listPolicyAssignmentsForResource.json | +| [policyAssignmentsListSample.ts][policyassignmentslistsample] | this operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. x-ms-original-file: 2025-03-01/listPolicyAssignments.json | +| [policyAssignmentsUpdateSample.ts][policyassignmentsupdatesample] | this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. x-ms-original-file: 2025-03-01/updatePolicyAssignmentWithIdentity.json | +| [policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts][policydefinitionversionscreateorupdateatmanagementgroupsample] | this operation creates or updates a policy definition version in the given management group with the given name. x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json | +| [policyDefinitionVersionsCreateOrUpdateSample.ts][policydefinitionversionscreateorupdatesample] | this operation creates or updates a policy definition in the given subscription with the given name. x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionVersion.json | +| [policyDefinitionVersionsDeleteAtManagementGroupSample.ts][policydefinitionversionsdeleteatmanagementgroupsample] | this operation deletes the policy definition in the given management group with the given name. x-ms-original-file: 2025-03-01/deletePolicyDefinitionVersionAtManagementGroup.json | +| [policyDefinitionVersionsDeleteSample.ts][policydefinitionversionsdeletesample] | this operation deletes the policy definition version in the given subscription with the given name. x-ms-original-file: 2025-03-01/deletePolicyDefinitionVersion.json | +| [policyDefinitionVersionsGetAtManagementGroupSample.ts][policydefinitionversionsgetatmanagementgroupsample] | this operation retrieves the policy definition version in the given management group with the given name. x-ms-original-file: 2025-03-01/getPolicyDefinitionVersionAtManagementGroup.json | +| [policyDefinitionVersionsGetBuiltInSample.ts][policydefinitionversionsgetbuiltinsample] | this operation retrieves the built-in policy definition version with the given name. x-ms-original-file: 2025-03-01/getBuiltinPolicyDefinitionVersion.json | +| [policyDefinitionVersionsGetSample.ts][policydefinitionversionsgetsample] | this operation retrieves the policy definition version in the given subscription with the given name. x-ms-original-file: 2025-03-01/getPolicyDefinitionVersion.json | +| [policyDefinitionVersionsListAllAtManagementGroupSample.ts][policydefinitionversionslistallatmanagementgroupsample] | this operation lists all the policy definition versions for all policy definitions at the management group scope. x-ms-original-file: 2025-03-01/listAllPolicyDefinitionVersionsByManagementGroup.json | +| [policyDefinitionVersionsListAllBuiltinsSample.ts][policydefinitionversionslistallbuiltinssample] | this operation lists all the built-in policy definition versions for all built-in policy definitions. x-ms-original-file: 2025-03-01/listAllBuiltInPolicyDefinitionVersions.json | +| [policyDefinitionVersionsListAllSample.ts][policydefinitionversionslistallsample] | this operation lists all the policy definition versions for all policy definitions within a subscription. x-ms-original-file: 2025-03-01/listAllPolicyDefinitionVersions.json | +| [policyDefinitionVersionsListBuiltInSample.ts][policydefinitionversionslistbuiltinsample] | this operation retrieves a list of all the built-in policy definition versions for the given policy definition. x-ms-original-file: 2025-03-01/listBuiltInPolicyDefinitionVersions.json | +| [policyDefinitionVersionsListByManagementGroupSample.ts][policydefinitionversionslistbymanagementgroupsample] | this operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. x-ms-original-file: 2025-03-01/listPolicyDefinitionVersionsByManagementGroup.json | +| [policyDefinitionVersionsListSample.ts][policydefinitionversionslistsample] | this operation retrieves a list of all the policy definition versions for the given policy definition. x-ms-original-file: 2025-03-01/listPolicyDefinitionVersions.json | +| [policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts][policydefinitionscreateorupdateatmanagementgroupsample] | this operation creates or updates a policy definition in the given management group with the given name. x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionAtManagementGroup.json | +| [policyDefinitionsCreateOrUpdateSample.ts][policydefinitionscreateorupdatesample] | this operation creates or updates a policy definition in the given subscription with the given name. x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinition.json | +| [policyDefinitionsDeleteAtManagementGroupSample.ts][policydefinitionsdeleteatmanagementgroupsample] | this operation deletes the policy definition in the given management group with the given name. x-ms-original-file: 2025-03-01/deletePolicyDefinitionAtManagementGroup.json | +| [policyDefinitionsDeleteSample.ts][policydefinitionsdeletesample] | this operation deletes the policy definition in the given subscription with the given name. x-ms-original-file: 2025-03-01/deletePolicyDefinition.json | +| [policyDefinitionsGetAtManagementGroupSample.ts][policydefinitionsgetatmanagementgroupsample] | this operation retrieves the policy definition in the given management group with the given name. x-ms-original-file: 2025-03-01/getPolicyDefinitionAtManagementGroup.json | +| [policyDefinitionsGetBuiltInSample.ts][policydefinitionsgetbuiltinsample] | this operation retrieves the built-in policy definition with the given name. x-ms-original-file: 2025-03-01/getBuiltinPolicyDefinition.json | +| [policyDefinitionsGetSample.ts][policydefinitionsgetsample] | this operation retrieves the policy definition in the given subscription with the given name. x-ms-original-file: 2025-03-01/getPolicyDefinition.json | +| [policyDefinitionsListBuiltInSample.ts][policydefinitionslistbuiltinsample] | this operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. x-ms-original-file: 2025-03-01/listBuiltInPolicyDefinitions.json | +| [policyDefinitionsListByManagementGroupSample.ts][policydefinitionslistbymanagementgroupsample] | this operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. x-ms-original-file: 2025-03-01/listPolicyDefinitionsByManagementGroup.json | +| [policyDefinitionsListSample.ts][policydefinitionslistsample] | this operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. x-ms-original-file: 2025-03-01/listPolicyDefinitions.json | +| [policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts][policysetdefinitionversionscreateorupdateatmanagementgroupsample] | this operation creates or updates a policy set definition version in the given management group with the given name and version. x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json | +| [policySetDefinitionVersionsCreateOrUpdateSample.ts][policysetdefinitionversionscreateorupdatesample] | this operation creates or updates a policy set definition version in the given subscription with the given name and version. x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionVersion.json | +| [policySetDefinitionVersionsDeleteAtManagementGroupSample.ts][policysetdefinitionversionsdeleteatmanagementgroupsample] | this operation deletes the policy set definition version in the given management group with the given name and version. x-ms-original-file: 2025-03-01/deletePolicySetDefinitionVersionAtManagementGroup.json | +| [policySetDefinitionVersionsDeleteSample.ts][policysetdefinitionversionsdeletesample] | this operation deletes the policy set definition version in the given subscription with the given name and version. x-ms-original-file: 2025-03-01/deletePolicySetDefinitionVersion.json | +| [policySetDefinitionVersionsGetAtManagementGroupSample.ts][policysetdefinitionversionsgetatmanagementgroupsample] | this operation retrieves the policy set definition version in the given management group with the given name and version. x-ms-original-file: 2025-03-01/getPolicySetDefinitionVersionAtManagementGroup.json | +| [policySetDefinitionVersionsGetBuiltInSample.ts][policysetdefinitionversionsgetbuiltinsample] | this operation retrieves the built-in policy set definition version with the given name and version. x-ms-original-file: 2025-03-01/getBuiltInPolicySetDefinitionVersion.json | +| [policySetDefinitionVersionsGetSample.ts][policysetdefinitionversionsgetsample] | this operation retrieves the policy set definition version in the given subscription with the given name and version. x-ms-original-file: 2025-03-01/getPolicySetDefinitionVersion.json | +| [policySetDefinitionVersionsListAllAtManagementGroupSample.ts][policysetdefinitionversionslistallatmanagementgroupsample] | this operation lists all the policy set definition versions for all policy set definitions at the management group scope. x-ms-original-file: 2025-03-01/listAllPolicySetDefinitionVersionsByManagementGroup.json | +| [policySetDefinitionVersionsListAllBuiltinsSample.ts][policysetdefinitionversionslistallbuiltinssample] | this operation lists all the built-in policy set definition versions for all built-in policy set definitions. x-ms-original-file: 2025-03-01/listAllBuiltInPolicySetDefinitionVersions.json | +| [policySetDefinitionVersionsListAllSample.ts][policysetdefinitionversionslistallsample] | this operation lists all the policy set definition versions for all policy set definitions within a subscription. x-ms-original-file: 2025-03-01/listAllPolicySetDefinitionVersions.json | +| [policySetDefinitionVersionsListBuiltInSample.ts][policysetdefinitionversionslistbuiltinsample] | this operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. x-ms-original-file: 2025-03-01/listBuiltInPolicySetDefinitionVersions.json | +| [policySetDefinitionVersionsListByManagementGroupSample.ts][policysetdefinitionversionslistbymanagementgroupsample] | this operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. x-ms-original-file: 2025-03-01/listPolicySetDefinitionVersionsByManagementGroup.json | +| [policySetDefinitionVersionsListSample.ts][policysetdefinitionversionslistsample] | this operation retrieves a list of all the policy set definition versions for the given policy set definition. x-ms-original-file: 2025-03-01/listPolicySetDefinitionVersions.json | +| [policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts][policysetdefinitionscreateorupdateatmanagementgroupsample] | this operation creates or updates a policy set definition in the given management group with the given name. x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionAtManagementGroup.json | +| [policySetDefinitionsCreateOrUpdateSample.ts][policysetdefinitionscreateorupdatesample] | this operation creates or updates a policy set definition in the given subscription with the given name. x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinition.json | +| [policySetDefinitionsDeleteAtManagementGroupSample.ts][policysetdefinitionsdeleteatmanagementgroupsample] | this operation deletes the policy set definition in the given management group with the given name. x-ms-original-file: 2025-03-01/deletePolicySetDefinitionAtManagementGroup.json | +| [policySetDefinitionsDeleteSample.ts][policysetdefinitionsdeletesample] | this operation deletes the policy set definition in the given subscription with the given name. x-ms-original-file: 2025-03-01/deletePolicySetDefinition.json | +| [policySetDefinitionsGetAtManagementGroupSample.ts][policysetdefinitionsgetatmanagementgroupsample] | this operation retrieves the policy set definition in the given management group with the given name. x-ms-original-file: 2025-03-01/getPolicySetDefinitionAtManagementGroup.json | +| [policySetDefinitionsGetBuiltInSample.ts][policysetdefinitionsgetbuiltinsample] | this operation retrieves the built-in policy set definition with the given name. x-ms-original-file: 2025-03-01/getBuiltInPolicySetDefinition.json | +| [policySetDefinitionsGetSample.ts][policysetdefinitionsgetsample] | this operation retrieves the policy set definition in the given subscription with the given name. x-ms-original-file: 2025-03-01/getPolicySetDefinition.json | +| [policySetDefinitionsListBuiltInSample.ts][policysetdefinitionslistbuiltinsample] | this operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. x-ms-original-file: 2025-03-01/listBuiltInPolicySetDefinitions.json | +| [policySetDefinitionsListByManagementGroupSample.ts][policysetdefinitionslistbymanagementgroupsample] | this operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. x-ms-original-file: 2025-03-01/listPolicySetDefinitionsByManagementGroup.json | +| [policySetDefinitionsListSample.ts][policysetdefinitionslistsample] | this operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. x-ms-original-file: 2025-03-01/listPolicySetDefinitions.json | +| [policyTokensAcquireAtManagementGroupSample.ts][policytokensacquireatmanagementgroupsample] | this operation acquires a policy token in the given management group for the given request body. x-ms-original-file: 2025-03-01/acquirePolicyTokenAtManagementGroup.json | +| [policyTokensAcquireSample.ts][policytokensacquiresample] | this operation acquires a policy token in the given subscription for the given request body. x-ms-original-file: 2025-03-01/acquirePolicyToken.json | ## Prerequisites @@ -100,77 +98,75 @@ npm run build 4. Run whichever samples you like (note that some samples may require additional setup, see the table above): ```bash -node dist/policyAssignmentsCreateByIdSample.js +node dist/policyAssignmentsCreateSample.js ``` -Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): +Alternatively, run a single sample with the required environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): ```bash -cross-env node dist/policyAssignmentsCreateByIdSample.js +node dist/policyAssignmentsCreateSample.js ``` ## Next Steps Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. -[policyassignmentscreatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsCreateByIdSample.ts -[policyassignmentscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsCreateSample.ts -[policyassignmentsdeletebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsDeleteByIdSample.ts -[policyassignmentsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsDeleteSample.ts -[policyassignmentsgetbyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsGetByIdSample.ts -[policyassignmentsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsGetSample.ts -[policyassignmentslistformanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsListForManagementGroupSample.ts -[policyassignmentslistforresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsListForResourceGroupSample.ts -[policyassignmentslistforresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsListForResourceSample.ts -[policyassignmentslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsListSample.ts -[policyassignmentsupdatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsUpdateByIdSample.ts -[policyassignmentsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsUpdateSample.ts -[policydefinitionversionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts -[policydefinitionversionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsCreateOrUpdateSample.ts -[policydefinitionversionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsDeleteAtManagementGroupSample.ts -[policydefinitionversionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsDeleteSample.ts -[policydefinitionversionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsGetAtManagementGroupSample.ts -[policydefinitionversionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsGetBuiltInSample.ts -[policydefinitionversionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsGetSample.ts -[policydefinitionversionslistallatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListAllAtManagementGroupSample.ts -[policydefinitionversionslistallbuiltinssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListAllBuiltinsSample.ts -[policydefinitionversionslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListAllSample.ts -[policydefinitionversionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListBuiltInSample.ts -[policydefinitionversionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListByManagementGroupSample.ts -[policydefinitionversionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListSample.ts -[policydefinitionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts -[policydefinitionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsCreateOrUpdateSample.ts -[policydefinitionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsDeleteAtManagementGroupSample.ts -[policydefinitionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsDeleteSample.ts -[policydefinitionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsGetAtManagementGroupSample.ts -[policydefinitionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsGetBuiltInSample.ts -[policydefinitionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsGetSample.ts -[policydefinitionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsListBuiltInSample.ts -[policydefinitionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsListByManagementGroupSample.ts -[policydefinitionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsListSample.ts -[policysetdefinitionversionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts -[policysetdefinitionversionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsCreateOrUpdateSample.ts -[policysetdefinitionversionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsDeleteAtManagementGroupSample.ts -[policysetdefinitionversionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsDeleteSample.ts -[policysetdefinitionversionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsGetAtManagementGroupSample.ts -[policysetdefinitionversionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsGetBuiltInSample.ts -[policysetdefinitionversionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsGetSample.ts -[policysetdefinitionversionslistallatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListAllAtManagementGroupSample.ts -[policysetdefinitionversionslistallbuiltinssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListAllBuiltinsSample.ts -[policysetdefinitionversionslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListAllSample.ts -[policysetdefinitionversionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListBuiltInSample.ts -[policysetdefinitionversionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListByManagementGroupSample.ts -[policysetdefinitionversionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListSample.ts -[policysetdefinitionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts -[policysetdefinitionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsCreateOrUpdateSample.ts -[policysetdefinitionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsDeleteAtManagementGroupSample.ts -[policysetdefinitionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsDeleteSample.ts -[policysetdefinitionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsGetAtManagementGroupSample.ts -[policysetdefinitionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsGetBuiltInSample.ts -[policysetdefinitionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsGetSample.ts -[policysetdefinitionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsListBuiltInSample.ts -[policysetdefinitionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsListByManagementGroupSample.ts -[policysetdefinitionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsListSample.ts +[policyassignmentscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsCreateSample.ts +[policyassignmentsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsDeleteSample.ts +[policyassignmentsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsGetSample.ts +[policyassignmentslistformanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsListForManagementGroupSample.ts +[policyassignmentslistforresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsListForResourceGroupSample.ts +[policyassignmentslistforresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsListForResourceSample.ts +[policyassignmentslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsListSample.ts +[policyassignmentsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsUpdateSample.ts +[policydefinitionversionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts +[policydefinitionversionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsCreateOrUpdateSample.ts +[policydefinitionversionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsDeleteAtManagementGroupSample.ts +[policydefinitionversionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsDeleteSample.ts +[policydefinitionversionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsGetAtManagementGroupSample.ts +[policydefinitionversionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsGetBuiltInSample.ts +[policydefinitionversionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsGetSample.ts +[policydefinitionversionslistallatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListAllAtManagementGroupSample.ts +[policydefinitionversionslistallbuiltinssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListAllBuiltinsSample.ts +[policydefinitionversionslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListAllSample.ts +[policydefinitionversionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListBuiltInSample.ts +[policydefinitionversionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListByManagementGroupSample.ts +[policydefinitionversionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListSample.ts +[policydefinitionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts +[policydefinitionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsCreateOrUpdateSample.ts +[policydefinitionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsDeleteAtManagementGroupSample.ts +[policydefinitionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsDeleteSample.ts +[policydefinitionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsGetAtManagementGroupSample.ts +[policydefinitionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsGetBuiltInSample.ts +[policydefinitionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsGetSample.ts +[policydefinitionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsListBuiltInSample.ts +[policydefinitionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsListByManagementGroupSample.ts +[policydefinitionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsListSample.ts +[policysetdefinitionversionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts +[policysetdefinitionversionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsCreateOrUpdateSample.ts +[policysetdefinitionversionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsDeleteAtManagementGroupSample.ts +[policysetdefinitionversionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsDeleteSample.ts +[policysetdefinitionversionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsGetAtManagementGroupSample.ts +[policysetdefinitionversionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsGetBuiltInSample.ts +[policysetdefinitionversionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsGetSample.ts +[policysetdefinitionversionslistallatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListAllAtManagementGroupSample.ts +[policysetdefinitionversionslistallbuiltinssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListAllBuiltinsSample.ts +[policysetdefinitionversionslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListAllSample.ts +[policysetdefinitionversionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListBuiltInSample.ts +[policysetdefinitionversionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListByManagementGroupSample.ts +[policysetdefinitionversionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListSample.ts +[policysetdefinitionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts +[policysetdefinitionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsCreateOrUpdateSample.ts +[policysetdefinitionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsDeleteAtManagementGroupSample.ts +[policysetdefinitionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsDeleteSample.ts +[policysetdefinitionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsGetAtManagementGroupSample.ts +[policysetdefinitionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsGetBuiltInSample.ts +[policysetdefinitionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsGetSample.ts +[policysetdefinitionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsListBuiltInSample.ts +[policysetdefinitionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsListByManagementGroupSample.ts +[policysetdefinitionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsListSample.ts +[policytokensacquireatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyTokensAcquireAtManagementGroupSample.ts +[policytokensacquiresample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v7/typescript/src/policyTokensAcquireSample.ts [apiref]: https://learn.microsoft.com/javascript/api/@azure/arm-policy?view=azure-node-preview [freesub]: https://azure.microsoft.com/free/ [package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/policy/arm-policy/README.md diff --git a/sdk/policy/arm-policy/samples/v6/typescript/package.json b/sdk/policy/arm-policy/samples/v7/typescript/package.json similarity index 78% rename from sdk/policy/arm-policy/samples/v6/typescript/package.json rename to sdk/policy/arm-policy/samples/v7/typescript/package.json index eac2b4376857..49b156899763 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/package.json +++ b/sdk/policy/arm-policy/samples/v7/typescript/package.json @@ -2,7 +2,7 @@ "name": "@azure-samples/arm-policy-ts", "private": true, "version": "1.0.0", - "description": " client library samples for TypeScript", + "description": "@azure/arm-policy client library samples for TypeScript", "engines": { "node": ">=20.0.0" }, @@ -18,10 +18,10 @@ "keywords": [ "node", "azure", + "cloud", "typescript", "browser", - "isomorphic", - "cloud" + "isomorphic" ], "author": "Microsoft Corporation", "license": "MIT", @@ -32,11 +32,12 @@ "dependencies": { "@azure/arm-policy": "latest", "dotenv": "latest", - "@azure/identity": "^4.6.0" + "@azure/identity": "^4.13.0" }, "devDependencies": { "@types/node": "^20.0.0", - "typescript": "~5.8.2", - "rimraf": "latest" + "cross-env": "latest", + "rimraf": "latest", + "typescript": "~5.9.3" } } diff --git a/sdk/policy/arm-policy/samples/v6/typescript/sample.env b/sdk/policy/arm-policy/samples/v7/typescript/sample.env similarity index 100% rename from sdk/policy/arm-policy/samples/v6/typescript/sample.env rename to sdk/policy/arm-policy/samples/v7/typescript/sample.env diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsCreateSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsCreateSample.ts new file mode 100644 index 000000000000..daaf4fa8d2a7 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsCreateSample.ts @@ -0,0 +1,257 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignment.json + */ +async function createOrUpdateAPolicyAssignment(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.create( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + metadata: { assignedBy: "Special Someone" }, + nonComplianceMessages: [ + { message: "Resource names must start with 'DeptA' and end with '-LC'." }, + ], + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentNonComplianceMessages.json + */ +async function createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.create( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "securityInitAssignment", + { + displayName: "Enforce security policies", + nonComplianceMessages: [ + { + message: + "Resources must comply with all internal security policies. See for more info.", + }, + { + message: "Resource names must start with 'DeptA' and end with '-LC'.", + policyDefinitionReferenceId: "10420126870854049575", + }, + { + message: "Storage accounts must have firewall rules configured.", + policyDefinitionReferenceId: "8572513655450389710", + }, + ], + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/securityInitiative", + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithEnrollEnforcement.json + */ +async function createOrUpdateAPolicyAssignmentToEnforcePolicyEffectOnlyOnEnrolledResourcesDuringResourceCreationOrUpdate(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.create( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNamingEnroll", + { + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "Enroll", + metadata: { assignedBy: "Special Someone" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithIdentity.json + */ +async function createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.create( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { + identity: { type: "SystemAssigned" }, + location: "eastus", + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "Default", + metadata: { assignedBy: "Foo Bar" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithOverrides.json + */ +async function createOrUpdateAPolicyAssignmentWithOverrides(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.create( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", + { + description: "Limit the resource location and resource SKU", + definitionVersion: "1.*.*", + displayName: "Limit the resource location and resource SKU", + metadata: { assignedBy: "Special Someone" }, + overrides: [ + { + kind: "policyEffect", + selectors: [ + { in: ["Limit_Skus", "Limit_Locations"], kind: "policyDefinitionReferenceId" }, + ], + value: "Audit", + }, + { + kind: "definitionVersion", + selectors: [{ in: ["eastUSEuap", "centralUSEuap"], kind: "resourceLocation" }], + value: "2.*.*", + }, + ], + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithResourceSelectors.json + */ +async function createOrUpdateAPolicyAssignmentWithResourceSelectors(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.create( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", + { + description: "Limit the resource location and resource SKU", + displayName: "Limit the resource location and resource SKU", + metadata: { assignedBy: "Special Someone" }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", + resourceSelectors: [ + { + name: "SDPRegions", + selectors: [{ in: ["eastus2euap", "centraluseuap"], kind: "resourceLocation" }], + }, + ], + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithUserAssignedIdentity.json + */ +async function createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.create( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { + identity: { + type: "UserAssigned", + userAssignedIdentities: { + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": + {}, + }, + }, + location: "eastus", + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "Default", + metadata: { assignedBy: "Foo Bar" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/createPolicyAssignmentWithoutEnforcement.json + */ +async function createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.create( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "DoNotEnforce", + metadata: { assignedBy: "Special Someone" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }, + ); + console.log(result); +} + +async function main(): Promise { + await createOrUpdateAPolicyAssignment(); + await createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages(); + await createOrUpdateAPolicyAssignmentToEnforcePolicyEffectOnlyOnEnrolledResourcesDuringResourceCreationOrUpdate(); + await createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity(); + await createOrUpdateAPolicyAssignmentWithOverrides(); + await createOrUpdateAPolicyAssignmentWithResourceSelectors(); + await createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity(); + await createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsDeleteSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsDeleteSample.ts similarity index 55% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsDeleteSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsDeleteSample.ts index ed7c25a4ebab..219895eae42e 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsDeleteSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsDeleteSample.ts @@ -1,29 +1,21 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * This sample demonstrates how to this operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. * - * @summary This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/deletePolicyAssignment.json + * @summary this operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * x-ms-original-file: 2025-03-01/deletePolicyAssignment.json */ async function deleteAPolicyAssignment(): Promise { - const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policyAssignmentName = "EnforceNaming"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = await client.policyAssignments.delete( - scope, - policyAssignmentName, + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", ); console.log(result); } diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsGetSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsGetSample.ts new file mode 100644 index 000000000000..d7e0aa5da48e --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsGetSample.ts @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary this operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: 2025-03-01/getPolicyAssignment.json + */ +async function retrieveAPolicyAssignment(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.get( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary this operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: 2025-03-01/getPolicyAssignmentWithIdentity.json + */ +async function retrieveAPolicyAssignmentWithASystemAssignedIdentity(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.get( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary this operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: 2025-03-01/getPolicyAssignmentWithOverrides.json + */ +async function retrieveAPolicyAssignmentWithOverrides(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.get( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary this operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: 2025-03-01/getPolicyAssignmentWithResourceSelectors.json + */ +async function retrieveAPolicyAssignmentWithResourceSelectors(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.get( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary this operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: 2025-03-01/getPolicyAssignmentWithUserAssignedIdentity.json + */ +async function retrieveAPolicyAssignmentWithAUserAssignedIdentity(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.get( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + ); + console.log(result); +} + +async function main(): Promise { + await retrieveAPolicyAssignment(); + await retrieveAPolicyAssignmentWithASystemAssignedIdentity(); + await retrieveAPolicyAssignmentWithOverrides(); + await retrieveAPolicyAssignmentWithResourceSelectors(); + await retrieveAPolicyAssignmentWithAUserAssignedIdentity(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsListForManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsListForManagementGroupSample.ts similarity index 66% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsListForManagementGroupSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsListForManagementGroupSample.ts index 3984d95cd3ac..cc2da6480f35 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsListForManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsListForManagementGroupSample.ts @@ -1,39 +1,26 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. -import type { PolicyAssignmentsListForManagementGroupOptionalParams } from "@azure/arm-policy"; import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. + * This sample demonstrates how to this operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. * - * @summary This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignmentsForManagementGroup.json + * @summary this operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. + * x-ms-original-file: 2025-03-01/listPolicyAssignmentsForManagementGroup.json */ async function listPolicyAssignmentsThatApplyToAManagementGroup(): Promise { - const managementGroupId = "TestManagementGroup"; - const filter = "atScope()"; - const expand = "LatestDefinitionVersion, EffectiveDefinitionVersion"; - const options: PolicyAssignmentsListForManagementGroupOptionalParams = { - filter, - expand, - }; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); - for await (const item of client.policyAssignments.listForManagementGroup( - managementGroupId, - options, - )) { + for await (const item of client.policyAssignments.listForManagementGroup("TestManagementGroup", { + filter: "atScope()", + expand: "LatestDefinitionVersion, EffectiveDefinitionVersion", + })) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsListForResourceGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsListForResourceGroupSample.ts similarity index 70% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsListForResourceGroupSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsListForResourceGroupSample.ts index 5371b499bc1d..ec42f7cb3aa6 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsListForResourceGroupSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsListForResourceGroupSample.ts @@ -1,43 +1,27 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. -import type { PolicyAssignmentsListForResourceGroupOptionalParams } from "@azure/arm-policy"; import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * This sample demonstrates how to this operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. * - * @summary This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignmentsForResourceGroup.json + * @summary this operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * x-ms-original-file: 2025-03-01/listPolicyAssignmentsForResourceGroup.json */ async function listPolicyAssignmentsThatApplyToAResourceGroup(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const resourceGroupName = - process.env["POLICY_RESOURCE_GROUP"] || "TestResourceGroup"; - const filter = "atScope()"; - const expand = "LatestDefinitionVersion, EffectiveDefinitionVersion"; - const options: PolicyAssignmentsListForResourceGroupOptionalParams = { - filter, - expand, - }; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const resArray = new Array(); - for await (const item of client.policyAssignments.listForResourceGroup( - resourceGroupName, - options, - )) { + for await (const item of client.policyAssignments.listForResourceGroup("TestResourceGroup", { + filter: "atScope()", + expand: "LatestDefinitionVersion, EffectiveDefinitionVersion", + })) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsListForResourceSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsListForResourceSample.ts similarity index 78% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsListForResourceSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsListForResourceSample.ts index 0b627150f741..933483585a7c 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsListForResourceSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsListForResourceSample.ts @@ -1,48 +1,35 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * This sample demonstrates how to this operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). * - * @summary This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignmentsForResource.json + * @summary this operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * x-ms-original-file: 2025-03-01/listPolicyAssignmentsForResource.json */ -async function listAllPolicyAssignmentsThatApplyToAResource(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const resourceGroupName = - process.env["POLICY_RESOURCE_GROUP"] || "TestResourceGroup"; - const resourceProviderNamespace = "Microsoft.Compute"; - const parentResourcePath = "virtualMachines/MyTestVm"; - const resourceType = "domainNames"; - const resourceName = "MyTestComputer.cloudapp.net"; +async function listPolicyAssignmentsThatApplyToAResourceGroup(): Promise { const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const resArray = new Array(); for await (const item of client.policyAssignments.listForResource( - resourceGroupName, - resourceProviderNamespace, - parentResourcePath, - resourceType, - resourceName, + "TestResourceGroup", + "Microsoft.Compute", + "virtualMachines/MyTestVm", + "domainNames", + "MyTestComputer.cloudapp.net", )) { resArray.push(item); } + console.log(resArray); } async function main(): Promise { - await listAllPolicyAssignmentsThatApplyToAResource(); + await listPolicyAssignmentsThatApplyToAResourceGroup(); } main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsListSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsListSample.ts similarity index 72% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsListSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsListSample.ts index 04b9413d4210..a47d53147f64 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyAssignmentsListSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsListSample.ts @@ -1,35 +1,27 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. -import type { PolicyAssignmentsListOptionalParams } from "@azure/arm-policy"; import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * This sample demonstrates how to this operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. * - * @summary This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyAssignments.json + * @summary this operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * x-ms-original-file: 2025-03-01/listPolicyAssignments.json */ async function listPolicyAssignmentsThatApplyToASubscription(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const filter = "atScope()"; - const expand = "LatestDefinitionVersion, EffectiveDefinitionVersion"; - const options: PolicyAssignmentsListOptionalParams = { filter, expand }; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const resArray = new Array(); - for await (const item of client.policyAssignments.list(options)) { + for await (const item of client.policyAssignments.list({ + filter: "atScope()", + expand: "LatestDefinitionVersion, EffectiveDefinitionVersion", + })) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsUpdateSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsUpdateSample.ts new file mode 100644 index 000000000000..7aded83b0917 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyAssignmentsUpdateSample.ts @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/updatePolicyAssignmentWithIdentity.json + */ +async function updateAPolicyAssignmentWithASystemAssignedIdentity(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.update( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { identity: { type: "SystemAssigned" }, location: "eastus" }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/updatePolicyAssignmentWithOverrides.json + */ +async function updateAPolicyAssignmentWithOverrides(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.update( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", + { + overrides: [ + { + kind: "policyEffect", + selectors: [ + { in: ["Limit_Skus", "Limit_Locations"], kind: "policyDefinitionReferenceId" }, + ], + value: "Audit", + }, + ], + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/updatePolicyAssignmentWithResourceSelectors.json + */ +async function updateAPolicyAssignmentWithResourceSelectors(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.update( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "CostManagement", + { + resourceSelectors: [ + { + name: "SDPRegions", + selectors: [{ in: ["eastus2euap", "centraluseuap"], kind: "resourceLocation" }], + }, + ], + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary this operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: 2025-03-01/updatePolicyAssignmentWithUserAssignedIdentity.json + */ +async function updateAPolicyAssignmentWithAUserAssignedIdentity(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyAssignments.update( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + "EnforceNaming", + { + identity: { + type: "UserAssigned", + userAssignedIdentities: { + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": + {}, + }, + }, + location: "eastus", + }, + ); + console.log(result); +} + +async function main(): Promise { + await updateAPolicyAssignmentWithASystemAssignedIdentity(); + await updateAPolicyAssignmentWithOverrides(); + await updateAPolicyAssignmentWithResourceSelectors(); + await updateAPolicyAssignmentWithAUserAssignedIdentity(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts new file mode 100644 index 000000000000..534033b29963 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation creates or updates a policy definition version in the given management group with the given name. + * + * @summary this operation creates or updates a policy definition version in the given management group with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json + */ +async function createOrUpdateAPolicyDefinitionVersionAtManagementGroupLevel(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyDefinitionVersions.createOrUpdateAtManagementGroup( + "MyManagementGroup", + "ResourceNaming", + "1.2.1", + { + description: + "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + displayName: "Enforce resource naming convention", + metadata: { category: "Naming" }, + mode: "All", + parameters: { + prefix: { + type: "String", + metadata: { description: "Resource name prefix", displayName: "Prefix" }, + }, + suffix: { + type: "String", + metadata: { description: "Resource name suffix", displayName: "Suffix" }, + }, + }, + policyRule: { + if: { + not: { field: "name", like: "[concat(parameters('prefix'), '*', parameters('suffix'))]" }, + }, + then: { effect: "deny" }, + }, + version: "1.2.1", + }, + ); + console.log(result); +} + +async function main(): Promise { + await createOrUpdateAPolicyDefinitionVersionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsCreateOrUpdateSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..7a1dd0739adc --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsCreateOrUpdateSample.ts @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation creates or updates a policy definition in the given subscription with the given name. + * + * @summary this operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionVersion.json + */ +async function createOrUpdateAPolicyDefinitionVersion(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitionVersions.createOrUpdate("ResourceNaming", "1.2.1", { + description: "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + displayName: "Enforce resource naming convention", + metadata: { category: "Naming" }, + mode: "All", + parameters: { + prefix: { + type: "String", + metadata: { description: "Resource name prefix", displayName: "Prefix" }, + }, + suffix: { + type: "String", + metadata: { description: "Resource name suffix", displayName: "Suffix" }, + }, + }, + policyRule: { + if: { + not: { field: "name", like: "[concat(parameters('prefix'), '*', parameters('suffix'))]" }, + }, + then: { effect: "deny" }, + }, + version: "1.2.1", + }); + console.log(result); +} + +async function main(): Promise { + await createOrUpdateAPolicyDefinitionVersion(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsDeleteAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsDeleteAtManagementGroupSample.ts new file mode 100644 index 000000000000..0e555cc5642c --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsDeleteAtManagementGroupSample.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation deletes the policy definition in the given management group with the given name. + * + * @summary this operation deletes the policy definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/deletePolicyDefinitionVersionAtManagementGroup.json + */ +async function deleteAPolicyDefinitionVersionAtManagementGroupLevel(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + await client.policyDefinitionVersions.deleteAtManagementGroup( + "MyManagementGroup", + "ResourceNaming", + "1.2.1", + ); +} + +async function main(): Promise { + await deleteAPolicyDefinitionVersionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsDeleteSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsDeleteSample.ts new file mode 100644 index 000000000000..65de8722fe7b --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsDeleteSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation deletes the policy definition version in the given subscription with the given name. + * + * @summary this operation deletes the policy definition version in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/deletePolicyDefinitionVersion.json + */ +async function deleteAPolicyDefinitionVersion(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + await client.policyDefinitionVersions.delete("ResourceNaming", "1.2.1"); +} + +async function main(): Promise { + await deleteAPolicyDefinitionVersion(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsGetAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsGetAtManagementGroupSample.ts new file mode 100644 index 000000000000..15cdcf9367f0 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsGetAtManagementGroupSample.ts @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation retrieves the policy definition version in the given management group with the given name. + * + * @summary this operation retrieves the policy definition version in the given management group with the given name. + * x-ms-original-file: 2025-03-01/getPolicyDefinitionVersionAtManagementGroup.json + */ +async function retrieveAPolicyDefinitionVersionAtManagementGroupLevel(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyDefinitionVersions.getAtManagementGroup( + "MyManagementGroup", + "ResourceNaming", + "1.2.1", + ); + console.log(result); +} + +async function main(): Promise { + await retrieveAPolicyDefinitionVersionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsGetBuiltInSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsGetBuiltInSample.ts new file mode 100644 index 000000000000..f0da17df22a2 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsGetBuiltInSample.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation retrieves the built-in policy definition version with the given name. + * + * @summary this operation retrieves the built-in policy definition version with the given name. + * x-ms-original-file: 2025-03-01/getBuiltinPolicyDefinitionVersion.json + */ +async function retrieveABuiltInPolicyDefinitionVersion(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyDefinitionVersions.getBuiltIn( + "7433c107-6db4-4ad1-b57a-a76dce0154a1", + "1.2.1", + ); + console.log(result); +} + +async function main(): Promise { + await retrieveABuiltInPolicyDefinitionVersion(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsGetSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsGetSample.ts new file mode 100644 index 000000000000..2f186814a7b4 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsGetSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation retrieves the policy definition version in the given subscription with the given name. + * + * @summary this operation retrieves the policy definition version in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/getPolicyDefinitionVersion.json + */ +async function retrieveAPolicyDefinitionVersion(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitionVersions.get("ResourceNaming", "1.2.1"); + console.log(result); +} + +async function main(): Promise { + await retrieveAPolicyDefinitionVersion(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListAllAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListAllAtManagementGroupSample.ts similarity index 51% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListAllAtManagementGroupSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListAllAtManagementGroupSample.ts index 6c35965e3695..44498235c26b 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListAllAtManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListAllAtManagementGroupSample.ts @@ -1,29 +1,20 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation lists all the policy definition versions for all policy definitions at the management group scope. + * This sample demonstrates how to this operation lists all the policy definition versions for all policy definitions at the management group scope. * - * @summary This operation lists all the policy definition versions for all policy definitions at the management group scope. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicyDefinitionVersionsByManagementGroup.json + * @summary this operation lists all the policy definition versions for all policy definitions at the management group scope. + * x-ms-original-file: 2025-03-01/listAllPolicyDefinitionVersionsByManagementGroup.json */ async function listAllPolicyDefinitionVersionsAtManagementGroup(): Promise { - const managementGroupName = "MyManagementGroup"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = - await client.policyDefinitionVersions.listAllAtManagementGroup( - managementGroupName, - ); + await client.policyDefinitionVersions.listAllAtManagementGroup("MyManagementGroup"); console.log(result); } diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListAllBuiltinsSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListAllBuiltinsSample.ts similarity index 54% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListAllBuiltinsSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListAllBuiltinsSample.ts index 6add7c6973e0..194025a75d41 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListAllBuiltinsSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListAllBuiltinsSample.ts @@ -1,20 +1,14 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation lists all the built-in policy definition versions for all built-in policy definitions. + * This sample demonstrates how to this operation lists all the built-in policy definition versions for all built-in policy definitions. * - * @summary This operation lists all the built-in policy definition versions for all built-in policy definitions. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllBuiltInPolicyDefinitionVersions.json + * @summary this operation lists all the built-in policy definition versions for all built-in policy definitions. + * x-ms-original-file: 2025-03-01/listAllBuiltInPolicyDefinitionVersions.json */ async function listAllBuiltInPolicyDefinitionVersions(): Promise { const credential = new DefaultAzureCredential(); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListAllSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListAllSample.ts similarity index 50% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListAllSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListAllSample.ts index 3c515e33eca7..4ea266b2b186 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListAllSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListAllSample.ts @@ -1,26 +1,18 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation lists all the policy definition versions for all policy definitions within a subscription. + * This sample demonstrates how to this operation lists all the policy definition versions for all policy definitions within a subscription. * - * @summary This operation lists all the policy definition versions for all policy definitions within a subscription. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicyDefinitionVersions.json + * @summary this operation lists all the policy definition versions for all policy definitions within a subscription. + * x-ms-original-file: 2025-03-01/listAllPolicyDefinitionVersions.json */ async function listAllPolicyDefinitionVersionsAtSubscription(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const result = await client.policyDefinitionVersions.listAll(); console.log(result); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListBuiltInSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListBuiltInSample.ts similarity index 53% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListBuiltInSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListBuiltInSample.ts index 22fbc8bb0590..6a5cb9343a43 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListBuiltInSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListBuiltInSample.ts @@ -1,31 +1,25 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation retrieves a list of all the built-in policy definition versions for the given policy definition. + * This sample demonstrates how to this operation retrieves a list of all the built-in policy definition versions for the given policy definition. * - * @summary This operation retrieves a list of all the built-in policy definition versions for the given policy definition. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicyDefinitionVersions.json + * @summary this operation retrieves a list of all the built-in policy definition versions for the given policy definition. + * x-ms-original-file: 2025-03-01/listBuiltInPolicyDefinitionVersions.json */ async function listBuiltInPolicyDefinitionVersions(): Promise { - const policyDefinitionName = "06a78e20-9358-41c9-923c-fb736d382a12"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); for await (const item of client.policyDefinitionVersions.listBuiltIn( - policyDefinitionName, + "06a78e20-9358-41c9-923c-fb736d382a12", )) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListByManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListByManagementGroupSample.ts similarity index 53% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListByManagementGroupSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListByManagementGroupSample.ts index 908d2a1418be..9ff8880cb4c8 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionVersionsListByManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListByManagementGroupSample.ts @@ -1,33 +1,26 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. + * This sample demonstrates how to this operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. * - * @summary This operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitionVersionsByManagementGroup.json + * @summary this operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. + * x-ms-original-file: 2025-03-01/listPolicyDefinitionVersionsByManagementGroup.json */ async function listPolicyDefinitionVersionsByManagementGroup(): Promise { - const managementGroupName = "MyManagementGroup"; - const policyDefinitionName = "ResourceNaming"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); for await (const item of client.policyDefinitionVersions.listByManagementGroup( - managementGroupName, - policyDefinitionName, + "MyManagementGroup", + "ResourceNaming", )) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListSample.ts new file mode 100644 index 000000000000..32259b308c31 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionVersionsListSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation retrieves a list of all the policy definition versions for the given policy definition. + * + * @summary this operation retrieves a list of all the policy definition versions for the given policy definition. + * x-ms-original-file: 2025-03-01/listPolicyDefinitionVersions.json + */ +async function listPolicyDefinitionVersionsBySubscription(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.policyDefinitionVersions.list("ResourceNaming")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await listPolicyDefinitionVersionsBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts new file mode 100644 index 000000000000..b4324503c59f --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation creates or updates a policy definition in the given management group with the given name. + * + * @summary this operation creates or updates a policy definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionAtManagementGroup.json + */ +async function createOrUpdateAPolicyDefinitionAtManagementGroupLevel(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyDefinitions.createOrUpdateAtManagementGroup( + "MyManagementGroup", + "ResourceNaming", + { + description: + "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + displayName: "Enforce resource naming convention", + metadata: { category: "Naming" }, + mode: "All", + parameters: { + prefix: { + type: "String", + metadata: { description: "Resource name prefix", displayName: "Prefix" }, + }, + suffix: { + type: "String", + metadata: { description: "Resource name suffix", displayName: "Suffix" }, + }, + }, + policyRule: { + if: { + not: { field: "name", like: "[concat(parameters('prefix'), '*', parameters('suffix'))]" }, + }, + then: { effect: "deny" }, + }, + }, + ); + console.log(result); +} + +async function main(): Promise { + await createOrUpdateAPolicyDefinitionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsCreateOrUpdateSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..96da436e3632 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsCreateOrUpdateSample.ts @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation creates or updates a policy definition in the given subscription with the given name. + * + * @summary this operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinition.json + */ +async function createOrUpdateAPolicyDefinition(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.createOrUpdate("ResourceNaming", { + description: "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + displayName: "Enforce resource naming convention", + metadata: { category: "Naming" }, + mode: "All", + parameters: { + prefix: { + type: "String", + metadata: { description: "Resource name prefix", displayName: "Prefix" }, + }, + suffix: { + type: "String", + metadata: { description: "Resource name suffix", displayName: "Suffix" }, + }, + }, + policyRule: { + if: { + not: { field: "name", like: "[concat(parameters('prefix'), '*', parameters('suffix'))]" }, + }, + then: { effect: "deny" }, + }, + }); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy definition in the given subscription with the given name. + * + * @summary this operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionAdvancedParams.json + */ +async function createOrUpdateAPolicyDefinitionWithAdvancedParameters(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.createOrUpdate("EventHubDiagnosticLogs", { + description: + "Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised", + displayName: "Event Hubs should have diagnostic logging enabled", + metadata: { category: "Event Hub" }, + mode: "Indexed", + parameters: { + requiredRetentionDays: { + type: "Integer", + allowedValues: [0, 30, 90, 180, 365], + defaultValue: 365, + metadata: { + description: "The required diagnostic logs retention in days", + displayName: "Required retention (days)", + }, + }, + }, + policyRule: { + if: { equals: "Microsoft.EventHub/namespaces", field: "type" }, + then: { + effect: "AuditIfNotExists", + details: { + type: "Microsoft.Insights/diagnosticSettings", + existenceCondition: { + allOf: [ + { + equals: "true", + field: "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled", + }, + { + equals: "[parameters('requiredRetentionDays')]", + field: "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days", + }, + ], + }, + }, + }, + }, + }); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy definition in the given subscription with the given name. + * + * @summary this operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicyDefinitionExternalEvaluationEnforcementSettings.json + */ +async function createOrUpdateAPolicyDefinitionWithExternalEvaluationEnforcementSettings(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.createOrUpdate("RandomizeVMAllocation", { + description: + "Randomly disable VM allocation in eastus by having policy rule reference the outcome of invoking an external endpoint using the CoinFlip endpoint that returns random values.", + displayName: "Randomize VM Allocation", + externalEvaluationEnforcementSettings: { + endpointSettings: { kind: "CoinFlip", details: { successProbability: 0.5 } }, + missingTokenAction: "audit", + roleDefinitionIds: [ + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/roleDefinitions/f0cc2aea-b517-48f6-8f9e-0c01c687907b", + ], + }, + metadata: { category: "VM" }, + mode: "Indexed", + policyRule: { + if: { + allOf: [ + { equals: "Microsoft.Compute/virtualMachines", field: "type" }, + { equals: "eastus", field: "location" }, + { equals: "false", value: "[claims().isValid]" }, + ], + }, + then: { effect: "deny" }, + }, + }); + console.log(result); +} + +async function main(): Promise { + await createOrUpdateAPolicyDefinition(); + await createOrUpdateAPolicyDefinitionWithAdvancedParameters(); + await createOrUpdateAPolicyDefinitionWithExternalEvaluationEnforcementSettings(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsDeleteAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsDeleteAtManagementGroupSample.ts new file mode 100644 index 000000000000..cfc182b535ac --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsDeleteAtManagementGroupSample.ts @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation deletes the policy definition in the given management group with the given name. + * + * @summary this operation deletes the policy definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/deletePolicyDefinitionAtManagementGroup.json + */ +async function deleteAPolicyDefinitionAtManagementGroupLevel(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + await client.policyDefinitions.deleteAtManagementGroup("MyManagementGroup", "ResourceNaming"); +} + +async function main(): Promise { + await deleteAPolicyDefinitionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsDeleteSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsDeleteSample.ts new file mode 100644 index 000000000000..6ec2d0c1f9c5 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsDeleteSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation deletes the policy definition in the given subscription with the given name. + * + * @summary this operation deletes the policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/deletePolicyDefinition.json + */ +async function deleteAPolicyDefinition(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + await client.policyDefinitions.delete("ResourceNaming"); +} + +async function main(): Promise { + await deleteAPolicyDefinition(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsGetAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsGetAtManagementGroupSample.ts new file mode 100644 index 000000000000..cdb278a96281 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsGetAtManagementGroupSample.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation retrieves the policy definition in the given management group with the given name. + * + * @summary this operation retrieves the policy definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/getPolicyDefinitionAtManagementGroup.json + */ +async function retrieveAPolicyDefinitionAtManagementGroupLevel(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyDefinitions.getAtManagementGroup( + "MyManagementGroup", + "ResourceNaming", + ); + console.log(result); +} + +async function main(): Promise { + await retrieveAPolicyDefinitionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsGetBuiltInSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsGetBuiltInSample.ts new file mode 100644 index 000000000000..60032f58def0 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsGetBuiltInSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation retrieves the built-in policy definition with the given name. + * + * @summary this operation retrieves the built-in policy definition with the given name. + * x-ms-original-file: 2025-03-01/getBuiltinPolicyDefinition.json + */ +async function retrieveABuiltInPolicyDefinition(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyDefinitions.getBuiltIn("7433c107-6db4-4ad1-b57a-a76dce0154a1"); + console.log(result); +} + +async function main(): Promise { + await retrieveABuiltInPolicyDefinition(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsGetSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsGetSample.ts new file mode 100644 index 000000000000..a885e87bc1e6 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsGetSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation retrieves the policy definition in the given subscription with the given name. + * + * @summary this operation retrieves the policy definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/getPolicyDefinition.json + */ +async function retrieveAPolicyDefinition(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.get("ResourceNaming"); + console.log(result); +} + +async function main(): Promise { + await retrieveAPolicyDefinition(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsListBuiltInSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsListBuiltInSample.ts similarity index 72% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsListBuiltInSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsListBuiltInSample.ts index 7c2eeddb79e4..9a8522ad5378 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsListBuiltInSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsListBuiltInSample.ts @@ -1,20 +1,14 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. + * This sample demonstrates how to this operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. * - * @summary This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicyDefinitions.json + * @summary this operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listBuiltInPolicyDefinitions.json */ async function listBuiltInPolicyDefinitions(): Promise { const credential = new DefaultAzureCredential(); @@ -23,6 +17,7 @@ async function listBuiltInPolicyDefinitions(): Promise { for await (const item of client.policyDefinitions.listBuiltIn()) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsListByManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsListByManagementGroupSample.ts similarity index 78% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsListByManagementGroupSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsListByManagementGroupSample.ts index 683adb32e375..497e020825de 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsListByManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsListByManagementGroupSample.ts @@ -1,31 +1,23 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * This sample demonstrates how to this operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. * - * @summary This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitionsByManagementGroup.json + * @summary this operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listPolicyDefinitionsByManagementGroup.json */ async function listPolicyDefinitionsByManagementGroup(): Promise { - const managementGroupId = "MyManagementGroup"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); - for await (const item of client.policyDefinitions.listByManagementGroup( - managementGroupId, - )) { + for await (const item of client.policyDefinitions.listByManagementGroup("MyManagementGroup")) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsListSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsListSample.ts similarity index 78% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsListSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsListSample.ts index 49f7d3413111..4c01baadb8e8 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policyDefinitionsListSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyDefinitionsListSample.ts @@ -1,31 +1,24 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * This sample demonstrates how to this operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. * - * @summary This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicyDefinitions.json + * @summary this operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listPolicyDefinitions.json */ async function listPolicyDefinitionsBySubscription(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const resArray = new Array(); for await (const item of client.policyDefinitions.list()) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts new file mode 100644 index 000000000000..2b361cf51a97 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsCreateOrUpdateAtManagementGroupSample.ts @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation creates or updates a policy set definition version in the given management group with the given name and version. + * + * @summary this operation creates or updates a policy set definition version in the given management group with the given name and version. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json + */ +async function createOrUpdateAPolicySetDefinitionVersionAtManagementGroupLevel(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policySetDefinitionVersions.createOrUpdateAtManagementGroup( + "MyManagementGroup", + "CostManagement", + "1.2.1", + { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitions: [ + { + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus", + }, + { + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming", + }, + ], + version: "1.2.1", + }, + ); + console.log(result); +} + +async function main(): Promise { + await createOrUpdateAPolicySetDefinitionVersionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsCreateOrUpdateSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..323af123d7cd --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsCreateOrUpdateSample.ts @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation creates or updates a policy set definition version in the given subscription with the given name and version. + * + * @summary this operation creates or updates a policy set definition version in the given subscription with the given name and version. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionVersion.json + */ +async function createOrUpdateAPolicySetDefinitionVersion(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitionVersions.createOrUpdate( + "CostManagement", + "1.2.1", + { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + parameters: { + namePrefix: { + type: "String", + defaultValue: "myPrefix", + metadata: { displayName: "Prefix to enforce on resource names" }, + }, + }, + policyDefinitions: [ + { + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus", + }, + { + parameters: { prefix: { value: "[parameters('namePrefix')]" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming", + }, + ], + version: "1.2.1", + }, + ); + console.log(result); +} + +async function main(): Promise { + await createOrUpdateAPolicySetDefinitionVersion(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsDeleteAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsDeleteAtManagementGroupSample.ts new file mode 100644 index 000000000000..55ecf200efe8 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsDeleteAtManagementGroupSample.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation deletes the policy set definition version in the given management group with the given name and version. + * + * @summary this operation deletes the policy set definition version in the given management group with the given name and version. + * x-ms-original-file: 2025-03-01/deletePolicySetDefinitionVersionAtManagementGroup.json + */ +async function deleteAPolicySetDefinitionVersionAtManagementGroupLevel(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + await client.policySetDefinitionVersions.deleteAtManagementGroup( + "MyManagementGroup", + "CostManagement", + "1.2.1", + ); +} + +async function main(): Promise { + await deleteAPolicySetDefinitionVersionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsDeleteSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsDeleteSample.ts new file mode 100644 index 000000000000..5dd732b903d5 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsDeleteSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation deletes the policy set definition version in the given subscription with the given name and version. + * + * @summary this operation deletes the policy set definition version in the given subscription with the given name and version. + * x-ms-original-file: 2025-03-01/deletePolicySetDefinitionVersion.json + */ +async function deleteAPolicySetDefinitionVersion(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + await client.policySetDefinitionVersions.delete("CostManagement", "1.2.1"); +} + +async function main(): Promise { + await deleteAPolicySetDefinitionVersion(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsGetAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsGetAtManagementGroupSample.ts new file mode 100644 index 000000000000..552249177dab --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsGetAtManagementGroupSample.ts @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation retrieves the policy set definition version in the given management group with the given name and version. + * + * @summary this operation retrieves the policy set definition version in the given management group with the given name and version. + * x-ms-original-file: 2025-03-01/getPolicySetDefinitionVersionAtManagementGroup.json + */ +async function retrieveAPolicySetDefinitionVersionAtManagementGroupLevel(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policySetDefinitionVersions.getAtManagementGroup( + "MyManagementGroup", + "CostManagement", + "1.2.1", + ); + console.log(result); +} + +async function main(): Promise { + await retrieveAPolicySetDefinitionVersionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsGetBuiltInSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsGetBuiltInSample.ts new file mode 100644 index 000000000000..c7f8fe3ca57d --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsGetBuiltInSample.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation retrieves the built-in policy set definition version with the given name and version. + * + * @summary this operation retrieves the built-in policy set definition version with the given name and version. + * x-ms-original-file: 2025-03-01/getBuiltInPolicySetDefinitionVersion.json + */ +async function retrieveABuiltInPolicySetDefinitionVersion(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policySetDefinitionVersions.getBuiltIn( + "1f3afdf9-d0c9-4c3d-847f-89da613e70a8", + "1.2.1", + ); + console.log(result); +} + +async function main(): Promise { + await retrieveABuiltInPolicySetDefinitionVersion(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsGetSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsGetSample.ts new file mode 100644 index 000000000000..133122f34bf3 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsGetSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation retrieves the policy set definition version in the given subscription with the given name and version. + * + * @summary this operation retrieves the policy set definition version in the given subscription with the given name and version. + * x-ms-original-file: 2025-03-01/getPolicySetDefinitionVersion.json + */ +async function retrieveAPolicySetDefinitionVersion(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitionVersions.get("CostManagement", "1.2.1"); + console.log(result); +} + +async function main(): Promise { + await retrieveAPolicySetDefinitionVersion(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListAllAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListAllAtManagementGroupSample.ts similarity index 52% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListAllAtManagementGroupSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListAllAtManagementGroupSample.ts index 56ddb7624ca0..0065e9f8a881 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListAllAtManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListAllAtManagementGroupSample.ts @@ -1,29 +1,20 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation lists all the policy set definition versions for all policy set definitions at the management group scope. + * This sample demonstrates how to this operation lists all the policy set definition versions for all policy set definitions at the management group scope. * - * @summary This operation lists all the policy set definition versions for all policy set definitions at the management group scope. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicySetDefinitionVersionsByManagementGroup.json + * @summary this operation lists all the policy set definition versions for all policy set definitions at the management group scope. + * x-ms-original-file: 2025-03-01/listAllPolicySetDefinitionVersionsByManagementGroup.json */ async function listAllPolicyDefinitionVersionsAtManagementGroup(): Promise { - const managementGroupName = "MyManagementGroup"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const result = - await client.policySetDefinitionVersions.listAllAtManagementGroup( - managementGroupName, - ); + await client.policySetDefinitionVersions.listAllAtManagementGroup("MyManagementGroup"); console.log(result); } diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListAllBuiltinsSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListAllBuiltinsSample.ts similarity index 54% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListAllBuiltinsSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListAllBuiltinsSample.ts index 695885e3bbcc..e4cc8dcc0b65 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListAllBuiltinsSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListAllBuiltinsSample.ts @@ -1,20 +1,14 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation lists all the built-in policy set definition versions for all built-in policy set definitions. + * This sample demonstrates how to this operation lists all the built-in policy set definition versions for all built-in policy set definitions. * - * @summary This operation lists all the built-in policy set definition versions for all built-in policy set definitions. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllBuiltInPolicySetDefinitionVersions.json + * @summary this operation lists all the built-in policy set definition versions for all built-in policy set definitions. + * x-ms-original-file: 2025-03-01/listAllBuiltInPolicySetDefinitionVersions.json */ async function listAllBuiltInPolicyDefinitionVersions(): Promise { const credential = new DefaultAzureCredential(); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListAllSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListAllSample.ts similarity index 51% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListAllSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListAllSample.ts index 58e667fd8e84..ca229730124d 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListAllSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListAllSample.ts @@ -1,26 +1,18 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation lists all the policy set definition versions for all policy set definitions within a subscription. + * This sample demonstrates how to this operation lists all the policy set definition versions for all policy set definitions within a subscription. * - * @summary This operation lists all the policy set definition versions for all policy set definitions within a subscription. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listAllPolicySetDefinitionVersions.json + * @summary this operation lists all the policy set definition versions for all policy set definitions within a subscription. + * x-ms-original-file: 2025-03-01/listAllPolicySetDefinitionVersions.json */ async function listAllPolicyDefinitionVersionsAtSubscription(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const result = await client.policySetDefinitionVersions.listAll(); console.log(result); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListBuiltInSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListBuiltInSample.ts similarity index 53% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListBuiltInSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListBuiltInSample.ts index 86c67ca5b252..5a8c71748997 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListBuiltInSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListBuiltInSample.ts @@ -1,31 +1,25 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. + * This sample demonstrates how to this operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. * - * @summary This operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicySetDefinitionVersions.json + * @summary this operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. + * x-ms-original-file: 2025-03-01/listBuiltInPolicySetDefinitionVersions.json */ async function listBuiltInPolicySetDefinitions(): Promise { - const policySetDefinitionName = "1f3afdf9-d0c9-4c3d-847f-89da613e70a8"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); for await (const item of client.policySetDefinitionVersions.listBuiltIn( - policySetDefinitionName, + "1f3afdf9-d0c9-4c3d-847f-89da613e70a8", )) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListByManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListByManagementGroupSample.ts similarity index 53% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListByManagementGroupSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListByManagementGroupSample.ts index 73efd56175b9..81052b09bbfa 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionVersionsListByManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListByManagementGroupSample.ts @@ -1,33 +1,26 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. + * This sample demonstrates how to this operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. * - * @summary This operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitionVersionsByManagementGroup.json + * @summary this operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. + * x-ms-original-file: 2025-03-01/listPolicySetDefinitionVersionsByManagementGroup.json */ async function listPolicySetDefinitionsAtManagementGroupLevel(): Promise { - const managementGroupName = "MyManagementGroup"; - const policySetDefinitionName = "CostManagement"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); for await (const item of client.policySetDefinitionVersions.listByManagementGroup( - managementGroupName, - policySetDefinitionName, + "MyManagementGroup", + "CostManagement", )) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListSample.ts new file mode 100644 index 000000000000..84fafcfdd9fe --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionVersionsListSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation retrieves a list of all the policy set definition versions for the given policy set definition. + * + * @summary this operation retrieves a list of all the policy set definition versions for the given policy set definition. + * x-ms-original-file: 2025-03-01/listPolicySetDefinitionVersions.json + */ +async function listPolicySetDefinitions(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.policySetDefinitionVersions.list("CostManagement")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await listPolicySetDefinitions(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts new file mode 100644 index 000000000000..ead47c9853e0 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation creates or updates a policy set definition in the given management group with the given name. + * + * @summary this operation creates or updates a policy set definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionAtManagementGroup.json + */ +async function createOrUpdateAPolicySetDefinitionAtManagementGroupLevel(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policySetDefinitions.createOrUpdateAtManagementGroup( + "MyManagementGroup", + "CostManagement", + { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitions: [ + { + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus", + }, + { + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming", + }, + ], + }, + ); + console.log(result); +} + +/** + * This sample demonstrates how to this operation creates or updates a policy set definition in the given management group with the given name. + * + * @summary this operation creates or updates a policy set definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json + */ +async function createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policySetDefinitions.createOrUpdateAtManagementGroup( + "MyManagementGroup", + "CostManagement", + { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitionGroups: [ + { + name: "CostSaving", + description: "Policies designed to control spend within a subscription.", + displayName: "Cost Management Policies", + }, + { + name: "Organizational", + description: + "Policies that help enforce resource organization standards within a subscription.", + displayName: "Organizational Policies", + }, + ], + policyDefinitions: [ + { + groupNames: ["CostSaving"], + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus", + }, + { + groupNames: ["Organizational"], + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming", + }, + ], + }, + ); + console.log(result); +} + +async function main(): Promise { + await createOrUpdateAPolicySetDefinitionAtManagementGroupLevel(); + await createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsCreateOrUpdateSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsCreateOrUpdateSample.ts similarity index 63% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsCreateOrUpdateSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsCreateOrUpdateSample.ts index 5b9b59933471..8152bc9b50bf 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsCreateOrUpdateSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsCreateOrUpdateSample.ts @@ -1,28 +1,20 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. -import type { PolicySetDefinition } from "@azure/arm-policy"; import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation creates or updates a policy set definition in the given subscription with the given name. + * This sample demonstrates how to this operation creates or updates a policy set definition in the given subscription with the given name. * - * @summary This operation creates or updates a policy set definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinition.json + * @summary this operation creates or updates a policy set definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinition.json */ async function createOrUpdateAPolicySetDefinition(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const parameters: PolicySetDefinition = { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdate("CostManagement", { description: "Policies to enforce low cost storage SKUs", displayName: "Cost Management", metadata: { category: "Cost Management" }, @@ -35,53 +27,40 @@ async function createOrUpdateAPolicySetDefinition(): Promise { }, policyDefinitions: [ { - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, policyDefinitionId: "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", policyDefinitionReferenceId: "Limit_Skus", }, { - parameters: { - prefix: { value: "[parameters('namePrefix')]" }, - suffix: { value: "-LC" }, - }, + parameters: { prefix: { value: "[parameters('namePrefix')]" }, suffix: { value: "-LC" } }, policyDefinitionId: "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", policyDefinitionReferenceId: "Resource_Naming", }, ], - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitions.createOrUpdate( - policySetDefinitionName, - parameters, - ); + }); console.log(result); } /** - * This sample demonstrates how to This operation creates or updates a policy set definition in the given subscription with the given name. + * This sample demonstrates how to this operation creates or updates a policy set definition in the given subscription with the given name. * - * @summary This operation creates or updates a policy set definition in the given subscription with the given name. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/createOrUpdatePolicySetDefinitionWithGroups.json + * @summary this operation creates or updates a policy set definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/createOrUpdatePolicySetDefinitionWithGroups.json */ async function createOrUpdateAPolicySetDefinitionWithGroups(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - const policySetDefinitionName = "CostManagement"; - const parameters: PolicySetDefinition = { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdate("CostManagement", { description: "Policies to enforce low cost storage SKUs", displayName: "Cost Management", metadata: { category: "Cost Management" }, policyDefinitionGroups: [ { name: "CostSaving", - description: - "Policies designed to control spend within a subscription.", + description: "Policies designed to control spend within a subscription.", displayName: "Cost Management Policies", }, { @@ -95,9 +74,7 @@ async function createOrUpdateAPolicySetDefinitionWithGroups(): Promise { { definitionVersion: "1.*.*", groupNames: ["CostSaving"], - parameters: { - listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, - }, + parameters: { listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } }, policyDefinitionId: "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", policyDefinitionReferenceId: "Limit_Skus", @@ -111,13 +88,7 @@ async function createOrUpdateAPolicySetDefinitionWithGroups(): Promise { policyDefinitionReferenceId: "Resource_Naming", }, ], - }; - const credential = new DefaultAzureCredential(); - const client = new PolicyClient(credential, subscriptionId); - const result = await client.policySetDefinitions.createOrUpdate( - policySetDefinitionName, - parameters, - ); + }); console.log(result); } diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsDeleteAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsDeleteAtManagementGroupSample.ts new file mode 100644 index 000000000000..697526eff8bc --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsDeleteAtManagementGroupSample.ts @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation deletes the policy set definition in the given management group with the given name. + * + * @summary this operation deletes the policy set definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/deletePolicySetDefinitionAtManagementGroup.json + */ +async function deleteAPolicySetDefinitionAtManagementGroupLevel(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + await client.policySetDefinitions.deleteAtManagementGroup("MyManagementGroup", "CostManagement"); +} + +async function main(): Promise { + await deleteAPolicySetDefinitionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsDeleteSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsDeleteSample.ts new file mode 100644 index 000000000000..d2b7f4404b12 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsDeleteSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation deletes the policy set definition in the given subscription with the given name. + * + * @summary this operation deletes the policy set definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/deletePolicySetDefinition.json + */ +async function deleteAPolicySetDefinition(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + await client.policySetDefinitions.delete("CostManagement"); +} + +async function main(): Promise { + await deleteAPolicySetDefinition(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsGetAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsGetAtManagementGroupSample.ts new file mode 100644 index 000000000000..c6253efa7831 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsGetAtManagementGroupSample.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation retrieves the policy set definition in the given management group with the given name. + * + * @summary this operation retrieves the policy set definition in the given management group with the given name. + * x-ms-original-file: 2025-03-01/getPolicySetDefinitionAtManagementGroup.json + */ +async function retrieveAPolicySetDefinitionAtManagementGroupLevel(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policySetDefinitions.getAtManagementGroup( + "MyManagementGroup", + "CostManagement", + ); + console.log(result); +} + +async function main(): Promise { + await retrieveAPolicySetDefinitionAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsGetBuiltInSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsGetBuiltInSample.ts new file mode 100644 index 000000000000..0b65ac57e6ec --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsGetBuiltInSample.ts @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation retrieves the built-in policy set definition with the given name. + * + * @summary this operation retrieves the built-in policy set definition with the given name. + * x-ms-original-file: 2025-03-01/getBuiltInPolicySetDefinition.json + */ +async function retrieveABuiltInPolicySetDefinition(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policySetDefinitions.getBuiltIn( + "1f3afdf9-d0c9-4c3d-847f-89da613e70a8", + ); + console.log(result); +} + +async function main(): Promise { + await retrieveABuiltInPolicySetDefinition(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsGetSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsGetSample.ts new file mode 100644 index 000000000000..d33322d1f3e2 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsGetSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation retrieves the policy set definition in the given subscription with the given name. + * + * @summary this operation retrieves the policy set definition in the given subscription with the given name. + * x-ms-original-file: 2025-03-01/getPolicySetDefinition.json + */ +async function retrieveAPolicySetDefinition(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.get("CostManagement"); + console.log(result); +} + +async function main(): Promise { + await retrieveAPolicySetDefinition(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsListBuiltInSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsListBuiltInSample.ts similarity index 65% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsListBuiltInSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsListBuiltInSample.ts index a1fe1fcfd8fd..93c5f6d8a353 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsListBuiltInSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsListBuiltInSample.ts @@ -1,20 +1,14 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. + * This sample demonstrates how to this operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. * - * @summary This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listBuiltInPolicySetDefinitions.json + * @summary this operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listBuiltInPolicySetDefinitions.json */ async function listBuiltInPolicySetDefinitions(): Promise { const credential = new DefaultAzureCredential(); @@ -23,6 +17,7 @@ async function listBuiltInPolicySetDefinitions(): Promise { for await (const item of client.policySetDefinitions.listBuiltIn()) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsListByManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsListByManagementGroupSample.ts similarity index 78% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsListByManagementGroupSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsListByManagementGroupSample.ts index 4d421dbdde4e..57ed2fbc508b 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsListByManagementGroupSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsListByManagementGroupSample.ts @@ -1,31 +1,23 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * This sample demonstrates how to this operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. * - * @summary This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitionsByManagementGroup.json + * @summary this operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listPolicySetDefinitionsByManagementGroup.json */ async function listPolicySetDefinitionsAtManagementGroupLevel(): Promise { - const managementGroupId = "MyManagementGroup"; const credential = new DefaultAzureCredential(); const client = new PolicyClient(credential); const resArray = new Array(); - for await (const item of client.policySetDefinitions.listByManagementGroup( - managementGroupId, - )) { + for await (const item of client.policySetDefinitions.listByManagementGroup("MyManagementGroup")) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsListSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsListSample.ts similarity index 78% rename from sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsListSample.ts rename to sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsListSample.ts index 04db4eb70c3e..0f071298db77 100644 --- a/sdk/policy/arm-policy/samples/v6/typescript/src/policySetDefinitionsListSample.ts +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policySetDefinitionsListSample.ts @@ -1,31 +1,24 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "@azure/arm-policy"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; /** - * This sample demonstrates how to This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * This sample demonstrates how to this operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. * - * @summary This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2024-05-01/examples/listPolicySetDefinitions.json + * @summary this operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * x-ms-original-file: 2025-03-01/listPolicySetDefinitions.json */ async function listPolicySetDefinitions(): Promise { - const subscriptionId = - process.env["POLICY_SUBSCRIPTION_ID"] || - "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; const client = new PolicyClient(credential, subscriptionId); const resArray = new Array(); for await (const item of client.policySetDefinitions.list()) { resArray.push(item); } + console.log(resArray); } diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyTokensAcquireAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyTokensAcquireAtManagementGroupSample.ts new file mode 100644 index 000000000000..f57d218c94c3 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyTokensAcquireAtManagementGroupSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation acquires a policy token in the given management group for the given request body. + * + * @summary this operation acquires a policy token in the given management group for the given request body. + * x-ms-original-file: 2025-03-01/acquirePolicyTokenAtManagementGroup.json + */ +async function acquireAPolicyTokenAtManagementGroupLevel(): Promise { + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential); + const result = await client.policyTokens.acquireAtManagementGroup("MyManagementGroup", { + operation: { + httpMethod: "delete", + uri: "https://management.azure.com/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/roleAssignments/00000000-0000-0000-0000-000000000000?api-version=2022-04-01", + }, + }); + console.log(result); +} + +async function main(): Promise { + await acquireAPolicyTokenAtManagementGroupLevel(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v7/typescript/src/policyTokensAcquireSample.ts b/sdk/policy/arm-policy/samples/v7/typescript/src/policyTokensAcquireSample.ts new file mode 100644 index 000000000000..79f57d13bec3 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v7/typescript/src/policyTokensAcquireSample.ts @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to this operation acquires a policy token in the given subscription for the given request body. + * + * @summary this operation acquires a policy token in the given subscription for the given request body. + * x-ms-original-file: 2025-03-01/acquirePolicyToken.json + */ +async function acquireAPolicyToken(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyTokens.acquire({ + operation: { + httpMethod: "delete", + uri: "https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/testVM?api-version=2024-01-01", + }, + }); + console.log(result); +} + +async function main(): Promise { + await acquireAPolicyToken(); +} + +main().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v6/typescript/tsconfig.json b/sdk/policy/arm-policy/samples/v7/typescript/tsconfig.json similarity index 100% rename from sdk/policy/arm-policy/samples/v6/typescript/tsconfig.json rename to sdk/policy/arm-policy/samples/v7/typescript/tsconfig.json diff --git a/sdk/policy/arm-policy/src/api/index.ts b/sdk/policy/arm-policy/src/api/index.ts new file mode 100644 index 000000000000..240685a69e7c --- /dev/null +++ b/sdk/policy/arm-policy/src/api/index.ts @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { createPolicy, PolicyContext, PolicyClientOptionalParams } from "./policyContext.js"; diff --git a/sdk/policy/arm-policy/src/api/policyAssignments/index.ts b/sdk/policy/arm-policy/src/api/policyAssignments/index.ts new file mode 100644 index 000000000000..e2eb15e30cb8 --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policyAssignments/index.ts @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + listForResource, + list, + listForManagementGroup, + listForResourceGroup, + $delete, + update, + create, + get, +} from "./operations.js"; +export { + PolicyAssignmentsListForResourceOptionalParams, + PolicyAssignmentsListOptionalParams, + PolicyAssignmentsListForManagementGroupOptionalParams, + PolicyAssignmentsListForResourceGroupOptionalParams, + PolicyAssignmentsDeleteOptionalParams, + PolicyAssignmentsUpdateOptionalParams, + PolicyAssignmentsCreateOptionalParams, + PolicyAssignmentsGetOptionalParams, +} from "./options.js"; diff --git a/sdk/policy/arm-policy/src/api/policyAssignments/operations.ts b/sdk/policy/arm-policy/src/api/policyAssignments/operations.ts new file mode 100644 index 000000000000..49891ef10502 --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policyAssignments/operations.ts @@ -0,0 +1,456 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { PolicyContext as Client } from "../index.js"; +import type { + PolicyAssignment, + PolicyAssignmentUpdate, + _PolicyAssignmentListResult, +} from "../../models/models.js"; +import { + policyAssignmentSerializer, + policyAssignmentDeserializer, + errorResponseDeserializer, + policyAssignmentUpdateSerializer, + _policyAssignmentListResultDeserializer, +} from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { buildPagedAsyncIterator } from "../../static-helpers/pagingHelpers.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import type { + PolicyAssignmentsListForResourceOptionalParams, + PolicyAssignmentsListOptionalParams, + PolicyAssignmentsListForManagementGroupOptionalParams, + PolicyAssignmentsListForResourceGroupOptionalParams, + PolicyAssignmentsDeleteOptionalParams, + PolicyAssignmentsUpdateOptionalParams, + PolicyAssignmentsCreateOptionalParams, + PolicyAssignmentsGetOptionalParams, +} from "./options.js"; +import type { StreamableMethod, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError, operationOptionsToRequestParameters } from "@azure-rest/core-client"; + +export function _listForResourceSend( + context: Client, + resourceGroupName: string, + resourceProviderNamespace: string, + parentResourcePath: string, + resourceType: string, + resourceName: string, + options: PolicyAssignmentsListForResourceOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{+parentResourcePath}/{+resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments{?api%2Dversion,%24filter,%24expand,%24top}", + { + subscriptionId: context.subscriptionId, + resourceGroupName: resourceGroupName, + resourceProviderNamespace: resourceProviderNamespace, + parentResourcePath: parentResourcePath, + resourceType: resourceType, + resourceName: resourceName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24filter": options?.filter, + "%24expand": options?.expand, + "%24top": options?.top, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listForResourceDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicyAssignmentListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policyAssignmentListResultDeserializer(result.body); +} + +/** This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). */ +export function listForResource( + context: Client, + resourceGroupName: string, + resourceProviderNamespace: string, + parentResourcePath: string, + resourceType: string, + resourceName: string, + options: PolicyAssignmentsListForResourceOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => + _listForResourceSend( + context, + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName, + options, + ), + _listForResourceDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2025-03-01" }, + ); +} + +export function _listSend( + context: Client, + options: PolicyAssignmentsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments{?api%2Dversion,%24filter,%24expand,%24top}", + { + subscriptionId: context.subscriptionId, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24filter": options?.filter, + "%24expand": options?.expand, + "%24top": options?.top, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicyAssignmentListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policyAssignmentListResultDeserializer(result.body); +} + +/** This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. */ +export function list( + context: Client, + options: PolicyAssignmentsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listSend(context, options), + _listDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2025-03-01" }, + ); +} + +export function _listForManagementGroupSend( + context: Client, + managementGroupId: string, + options: PolicyAssignmentsListForManagementGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments{?api%2Dversion,%24filter,%24expand,%24top}", + { + managementGroupId: managementGroupId, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24filter": options?.filter, + "%24expand": options?.expand, + "%24top": options?.top, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listForManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicyAssignmentListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policyAssignmentListResultDeserializer(result.body); +} + +/** This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. */ +export function listForManagementGroup( + context: Client, + managementGroupId: string, + options: PolicyAssignmentsListForManagementGroupOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listForManagementGroupSend(context, managementGroupId, options), + _listForManagementGroupDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2025-03-01" }, + ); +} + +export function _listForResourceGroupSend( + context: Client, + resourceGroupName: string, + options: PolicyAssignmentsListForResourceGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments{?api%2Dversion,%24filter,%24expand,%24top}", + { + subscriptionId: context.subscriptionId, + resourceGroupName: resourceGroupName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24filter": options?.filter, + "%24expand": options?.expand, + "%24top": options?.top, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listForResourceGroupDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicyAssignmentListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policyAssignmentListResultDeserializer(result.body); +} + +/** This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. */ +export function listForResourceGroup( + context: Client, + resourceGroupName: string, + options: PolicyAssignmentsListForResourceGroupOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listForResourceGroupSend(context, resourceGroupName, options), + _listForResourceGroupDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2025-03-01" }, + ); +} + +export function _$deleteSend( + context: Client, + scope: string, + policyAssignmentName: string, + options: PolicyAssignmentsDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/{+scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}{?api%2Dversion}", + { + scope: scope, + policyAssignmentName: policyAssignmentName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).delete({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _$deleteDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "204"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policyAssignmentDeserializer(result.body); +} + +/** This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. */ +/** + * @fixme delete is a reserved word that cannot be used as an operation name. + * Please add @clientName("clientName") or @clientName("", "javascript") + * to the operation to override the generated name. + */ +export async function $delete( + context: Client, + scope: string, + policyAssignmentName: string, + options: PolicyAssignmentsDeleteOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _$deleteSend(context, scope, policyAssignmentName, options); + return _$deleteDeserialize(result); +} + +export function _updateSend( + context: Client, + scope: string, + policyAssignmentName: string, + parameters: PolicyAssignmentUpdate, + options: PolicyAssignmentsUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/{+scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}{?api%2Dversion}", + { + scope: scope, + policyAssignmentName: policyAssignmentName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).patch({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: policyAssignmentUpdateSerializer(parameters), + }); +} + +export async function _updateDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policyAssignmentDeserializer(result.body); +} + +/** This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. */ +export async function update( + context: Client, + scope: string, + policyAssignmentName: string, + parameters: PolicyAssignmentUpdate, + options: PolicyAssignmentsUpdateOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _updateSend(context, scope, policyAssignmentName, parameters, options); + return _updateDeserialize(result); +} + +export function _createSend( + context: Client, + scope: string, + policyAssignmentName: string, + parameters: PolicyAssignment, + options: PolicyAssignmentsCreateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/{+scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}{?api%2Dversion}", + { + scope: scope, + policyAssignmentName: policyAssignmentName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: policyAssignmentSerializer(parameters), + }); +} + +export async function _createDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policyAssignmentDeserializer(result.body); +} + +/** This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. */ +export async function create( + context: Client, + scope: string, + policyAssignmentName: string, + parameters: PolicyAssignment, + options: PolicyAssignmentsCreateOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _createSend(context, scope, policyAssignmentName, parameters, options); + return _createDeserialize(result); +} + +export function _getSend( + context: Client, + scope: string, + policyAssignmentName: string, + options: PolicyAssignmentsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/{+scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}{?api%2Dversion,%24expand}", + { + scope: scope, + policyAssignmentName: policyAssignmentName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24expand": options?.expand, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policyAssignmentDeserializer(result.body); +} + +/** This operation retrieves a single policy assignment, given its name and the scope it was created at. */ +export async function get( + context: Client, + scope: string, + policyAssignmentName: string, + options: PolicyAssignmentsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getSend(context, scope, policyAssignmentName, options); + return _getDeserialize(result); +} diff --git a/sdk/policy/arm-policy/src/api/policyAssignments/options.ts b/sdk/policy/arm-policy/src/api/policyAssignments/options.ts new file mode 100644 index 000000000000..6b3a24f477ea --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policyAssignments/options.ts @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface PolicyAssignmentsListForResourceOptionalParams extends OperationOptions { + /** The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is everything in the unfiltered list except those applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. */ + filter?: string; + /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ + expand?: string; + /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ + top?: number; +} + +/** Optional parameters. */ +export interface PolicyAssignmentsListOptionalParams extends OperationOptions { + /** The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is everything in the unfiltered list except those applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. */ + filter?: string; + /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ + expand?: string; + /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ + top?: number; +} + +/** Optional parameters. */ +export interface PolicyAssignmentsListForManagementGroupOptionalParams extends OperationOptions { + /** The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is everything in the unfiltered list except those applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. */ + filter?: string; + /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ + expand?: string; + /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ + top?: number; +} + +/** Optional parameters. */ +export interface PolicyAssignmentsListForResourceGroupOptionalParams extends OperationOptions { + /** The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is everything in the unfiltered list except those applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. */ + filter?: string; + /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ + expand?: string; + /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ + top?: number; +} + +/** Optional parameters. */ +export interface PolicyAssignmentsDeleteOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyAssignmentsUpdateOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyAssignmentsCreateOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyAssignmentsGetOptionalParams extends OperationOptions { + /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ + expand?: string; +} diff --git a/sdk/policy/arm-policy/src/api/policyContext.ts b/sdk/policy/arm-policy/src/api/policyContext.ts new file mode 100644 index 000000000000..62e5d06a74f7 --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policyContext.ts @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { logger } from "../logger.js"; +import { KnownVersions } from "../models/models.js"; +import type { AzureSupportedClouds } from "../static-helpers/cloudSettingHelpers.js"; +import { getArmEndpoint } from "../static-helpers/cloudSettingHelpers.js"; +import type { Client, ClientOptions } from "@azure-rest/core-client"; +import { getClient } from "@azure-rest/core-client"; +import type { TokenCredential } from "@azure/core-auth"; + +/** To manage and control access to your resources, you can define customized policies and assign them at a scope. */ +export interface PolicyContext extends Client { + /** The ID of the target subscription. The value must be an UUID. */ + subscriptionId: string; + /** The API version to use for this operation. */ + /** Known values of {@link KnownVersions} that the service accepts. */ + apiVersion?: string; +} + +/** Optional parameters for the client. */ +export interface PolicyClientOptionalParams extends ClientOptions { + /** The API version to use for this operation. */ + /** Known values of {@link KnownVersions} that the service accepts. */ + apiVersion?: string; + /** Specifies the Azure cloud environment for the client. */ + cloudSetting?: AzureSupportedClouds; +} + +/** To manage and control access to your resources, you can define customized policies and assign them at a scope. */ +export function createPolicy( + credential: TokenCredential, + subscriptionId: string, + options: PolicyClientOptionalParams = {}, +): PolicyContext { + const endpointUrl = + options.endpoint ?? getArmEndpoint(options.cloudSetting) ?? "https://management.azure.com"; + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentInfo = `azsdk-js-arm-policy/7.0.0`; + 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); + const apiVersion = options.apiVersion; + return { ...clientContext, apiVersion, subscriptionId } as PolicyContext; +} diff --git a/sdk/policy/arm-policy/src/api/policyDefinitionVersions/index.ts b/sdk/policy/arm-policy/src/api/policyDefinitionVersions/index.ts new file mode 100644 index 000000000000..73253f6ea50e --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policyDefinitionVersions/index.ts @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + listAll, + listAllAtManagementGroup, + listAllBuiltins, + listByManagementGroup, + deleteAtManagementGroup, + createOrUpdateAtManagementGroup, + getAtManagementGroup, + listBuiltIn, + getBuiltIn, + list, + $delete, + createOrUpdate, + get, +} from "./operations.js"; +export { + PolicyDefinitionVersionsListAllOptionalParams, + PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams, + PolicyDefinitionVersionsListAllBuiltinsOptionalParams, + PolicyDefinitionVersionsListByManagementGroupOptionalParams, + PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams, + PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, + PolicyDefinitionVersionsGetAtManagementGroupOptionalParams, + PolicyDefinitionVersionsListBuiltInOptionalParams, + PolicyDefinitionVersionsGetBuiltInOptionalParams, + PolicyDefinitionVersionsListOptionalParams, + PolicyDefinitionVersionsDeleteOptionalParams, + PolicyDefinitionVersionsCreateOrUpdateOptionalParams, + PolicyDefinitionVersionsGetOptionalParams, +} from "./options.js"; diff --git a/sdk/policy/arm-policy/src/api/policyDefinitionVersions/operations.ts b/sdk/policy/arm-policy/src/api/policyDefinitionVersions/operations.ts new file mode 100644 index 000000000000..cb936cdf9ebc --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policyDefinitionVersions/operations.ts @@ -0,0 +1,700 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { PolicyContext as Client } from "../index.js"; +import type { + PolicyDefinitionVersion, + _PolicyDefinitionVersionListResult, +} from "../../models/models.js"; +import { + errorResponseDeserializer, + policyDefinitionVersionSerializer, + policyDefinitionVersionDeserializer, + _policyDefinitionVersionListResultDeserializer, +} from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { buildPagedAsyncIterator } from "../../static-helpers/pagingHelpers.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import type { + PolicyDefinitionVersionsListAllOptionalParams, + PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams, + PolicyDefinitionVersionsListAllBuiltinsOptionalParams, + PolicyDefinitionVersionsListByManagementGroupOptionalParams, + PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams, + PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, + PolicyDefinitionVersionsGetAtManagementGroupOptionalParams, + PolicyDefinitionVersionsListBuiltInOptionalParams, + PolicyDefinitionVersionsGetBuiltInOptionalParams, + PolicyDefinitionVersionsListOptionalParams, + PolicyDefinitionVersionsDeleteOptionalParams, + PolicyDefinitionVersionsCreateOrUpdateOptionalParams, + PolicyDefinitionVersionsGetOptionalParams, +} from "./options.js"; +import type { StreamableMethod, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError, operationOptionsToRequestParameters } from "@azure-rest/core-client"; + +export function _listAllSend( + context: Client, + options: PolicyDefinitionVersionsListAllOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/listPolicyDefinitionVersions{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listAllDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicyDefinitionVersionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policyDefinitionVersionListResultDeserializer(result.body); +} + +/** This operation lists all the policy definition versions for all policy definitions within a subscription. */ +export async function listAll( + context: Client, + options: PolicyDefinitionVersionsListAllOptionalParams = { requestOptions: {} }, +): Promise<_PolicyDefinitionVersionListResult> { + const result = await _listAllSend(context, options); + return _listAllDeserialize(result); +} + +export function _listAllAtManagementGroupSend( + context: Client, + managementGroupName: string, + options: PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/listPolicyDefinitionVersions{?api%2Dversion}", + { + managementGroupName: managementGroupName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listAllAtManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicyDefinitionVersionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policyDefinitionVersionListResultDeserializer(result.body); +} + +/** This operation lists all the policy definition versions for all policy definitions at the management group scope. */ +export async function listAllAtManagementGroup( + context: Client, + managementGroupName: string, + options: PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams = { requestOptions: {} }, +): Promise<_PolicyDefinitionVersionListResult> { + const result = await _listAllAtManagementGroupSend(context, managementGroupName, options); + return _listAllAtManagementGroupDeserialize(result); +} + +export function _listAllBuiltinsSend( + context: Client, + options: PolicyDefinitionVersionsListAllBuiltinsOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Authorization/listPolicyDefinitionVersions{?api%2Dversion}", + { + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listAllBuiltinsDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicyDefinitionVersionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policyDefinitionVersionListResultDeserializer(result.body); +} + +/** This operation lists all the built-in policy definition versions for all built-in policy definitions. */ +export async function listAllBuiltins( + context: Client, + options: PolicyDefinitionVersionsListAllBuiltinsOptionalParams = { requestOptions: {} }, +): Promise<_PolicyDefinitionVersionListResult> { + const result = await _listAllBuiltinsSend(context, options); + return _listAllBuiltinsDeserialize(result); +} + +export function _listByManagementGroupSend( + context: Client, + managementGroupName: string, + policyDefinitionName: string, + options: PolicyDefinitionVersionsListByManagementGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions{?api%2Dversion,%24top}", + { + managementGroupName: managementGroupName, + policyDefinitionName: policyDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24top": options?.top, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listByManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicyDefinitionVersionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policyDefinitionVersionListResultDeserializer(result.body); +} + +/** This operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. */ +export function listByManagementGroup( + context: Client, + managementGroupName: string, + policyDefinitionName: string, + options: PolicyDefinitionVersionsListByManagementGroupOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listByManagementGroupSend(context, managementGroupName, policyDefinitionName, options), + _listByManagementGroupDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2025-03-01" }, + ); +} + +export function _deleteAtManagementGroupSend( + context: Client, + managementGroupName: string, + policyDefinitionName: string, + policyDefinitionVersion: string, + options: PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}{?api%2Dversion}", + { + managementGroupName: managementGroupName, + policyDefinitionName: policyDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).delete({ ...operationOptionsToRequestParameters(options) }); +} + +export async function _deleteAtManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "204"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** This operation deletes the policy definition in the given management group with the given name. */ +export async function deleteAtManagementGroup( + context: Client, + managementGroupName: string, + policyDefinitionName: string, + policyDefinitionVersion: string, + options: PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _deleteAtManagementGroupSend( + context, + managementGroupName, + policyDefinitionName, + policyDefinitionVersion, + options, + ); + return _deleteAtManagementGroupDeserialize(result); +} + +export function _createOrUpdateAtManagementGroupSend( + context: Client, + managementGroupName: string, + policyDefinitionName: string, + policyDefinitionVersion: string, + parameters: PolicyDefinitionVersion, + options: PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}{?api%2Dversion}", + { + managementGroupName: managementGroupName, + policyDefinitionName: policyDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: policyDefinitionVersionSerializer(parameters), + }); +} + +export async function _createOrUpdateAtManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policyDefinitionVersionDeserializer(result.body); +} + +/** This operation creates or updates a policy definition version in the given management group with the given name. */ +export async function createOrUpdateAtManagementGroup( + context: Client, + managementGroupName: string, + policyDefinitionName: string, + policyDefinitionVersion: string, + parameters: PolicyDefinitionVersion, + options: PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams = { + requestOptions: {}, + }, +): Promise { + const result = await _createOrUpdateAtManagementGroupSend( + context, + managementGroupName, + policyDefinitionName, + policyDefinitionVersion, + parameters, + options, + ); + return _createOrUpdateAtManagementGroupDeserialize(result); +} + +export function _getAtManagementGroupSend( + context: Client, + managementGroupName: string, + policyDefinitionName: string, + policyDefinitionVersion: string, + options: PolicyDefinitionVersionsGetAtManagementGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}{?api%2Dversion}", + { + managementGroupName: managementGroupName, + policyDefinitionName: policyDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getAtManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policyDefinitionVersionDeserializer(result.body); +} + +/** This operation retrieves the policy definition version in the given management group with the given name. */ +export async function getAtManagementGroup( + context: Client, + managementGroupName: string, + policyDefinitionName: string, + policyDefinitionVersion: string, + options: PolicyDefinitionVersionsGetAtManagementGroupOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getAtManagementGroupSend( + context, + managementGroupName, + policyDefinitionName, + policyDefinitionVersion, + options, + ); + return _getAtManagementGroupDeserialize(result); +} + +export function _listBuiltInSend( + context: Client, + policyDefinitionName: string, + options: PolicyDefinitionVersionsListBuiltInOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions{?api%2Dversion,%24top}", + { + policyDefinitionName: policyDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24top": options?.top, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listBuiltInDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicyDefinitionVersionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policyDefinitionVersionListResultDeserializer(result.body); +} + +/** This operation retrieves a list of all the built-in policy definition versions for the given policy definition. */ +export function listBuiltIn( + context: Client, + policyDefinitionName: string, + options: PolicyDefinitionVersionsListBuiltInOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listBuiltInSend(context, policyDefinitionName, options), + _listBuiltInDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2025-03-01" }, + ); +} + +export function _getBuiltInSend( + context: Client, + policyDefinitionName: string, + policyDefinitionVersion: string, + options: PolicyDefinitionVersionsGetBuiltInOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}{?api%2Dversion}", + { + policyDefinitionName: policyDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getBuiltInDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policyDefinitionVersionDeserializer(result.body); +} + +/** This operation retrieves the built-in policy definition version with the given name. */ +export async function getBuiltIn( + context: Client, + policyDefinitionName: string, + policyDefinitionVersion: string, + options: PolicyDefinitionVersionsGetBuiltInOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getBuiltInSend( + context, + policyDefinitionName, + policyDefinitionVersion, + options, + ); + return _getBuiltInDeserialize(result); +} + +export function _listSend( + context: Client, + policyDefinitionName: string, + options: PolicyDefinitionVersionsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions{?api%2Dversion,%24top}", + { + subscriptionId: context.subscriptionId, + policyDefinitionName: policyDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24top": options?.top, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicyDefinitionVersionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policyDefinitionVersionListResultDeserializer(result.body); +} + +/** This operation retrieves a list of all the policy definition versions for the given policy definition. */ +export function list( + context: Client, + policyDefinitionName: string, + options: PolicyDefinitionVersionsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listSend(context, policyDefinitionName, options), + _listDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2025-03-01" }, + ); +} + +export function _$deleteSend( + context: Client, + policyDefinitionName: string, + policyDefinitionVersion: string, + options: PolicyDefinitionVersionsDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + policyDefinitionName: policyDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).delete({ ...operationOptionsToRequestParameters(options) }); +} + +export async function _$deleteDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200", "204"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** This operation deletes the policy definition version in the given subscription with the given name. */ +/** + * @fixme delete is a reserved word that cannot be used as an operation name. + * Please add @clientName("clientName") or @clientName("", "javascript") + * to the operation to override the generated name. + */ +export async function $delete( + context: Client, + policyDefinitionName: string, + policyDefinitionVersion: string, + options: PolicyDefinitionVersionsDeleteOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _$deleteSend( + context, + policyDefinitionName, + policyDefinitionVersion, + options, + ); + return _$deleteDeserialize(result); +} + +export function _createOrUpdateSend( + context: Client, + policyDefinitionName: string, + policyDefinitionVersion: string, + parameters: PolicyDefinitionVersion, + options: PolicyDefinitionVersionsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + policyDefinitionName: policyDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: policyDefinitionVersionSerializer(parameters), + }); +} + +export async function _createOrUpdateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policyDefinitionVersionDeserializer(result.body); +} + +/** This operation creates or updates a policy definition in the given subscription with the given name. */ +export async function createOrUpdate( + context: Client, + policyDefinitionName: string, + policyDefinitionVersion: string, + parameters: PolicyDefinitionVersion, + options: PolicyDefinitionVersionsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _createOrUpdateSend( + context, + policyDefinitionName, + policyDefinitionVersion, + parameters, + options, + ); + return _createOrUpdateDeserialize(result); +} + +export function _getSend( + context: Client, + policyDefinitionName: string, + policyDefinitionVersion: string, + options: PolicyDefinitionVersionsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + policyDefinitionName: policyDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policyDefinitionVersionDeserializer(result.body); +} + +/** This operation retrieves the policy definition version in the given subscription with the given name. */ +export async function get( + context: Client, + policyDefinitionName: string, + policyDefinitionVersion: string, + options: PolicyDefinitionVersionsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getSend(context, policyDefinitionName, policyDefinitionVersion, options); + return _getDeserialize(result); +} diff --git a/sdk/policy/arm-policy/src/api/policyDefinitionVersions/options.ts b/sdk/policy/arm-policy/src/api/policyDefinitionVersions/options.ts new file mode 100644 index 000000000000..c5bd861d5f5c --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policyDefinitionVersions/options.ts @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface PolicyDefinitionVersionsListAllOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyDefinitionVersionsListAllBuiltinsOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyDefinitionVersionsListByManagementGroupOptionalParams extends OperationOptions { + /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ + top?: number; +} + +/** Optional parameters. */ +export interface PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyDefinitionVersionsGetAtManagementGroupOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyDefinitionVersionsListBuiltInOptionalParams extends OperationOptions { + /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ + top?: number; +} + +/** Optional parameters. */ +export interface PolicyDefinitionVersionsGetBuiltInOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyDefinitionVersionsListOptionalParams extends OperationOptions { + /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ + top?: number; +} + +/** Optional parameters. */ +export interface PolicyDefinitionVersionsDeleteOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyDefinitionVersionsCreateOrUpdateOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyDefinitionVersionsGetOptionalParams extends OperationOptions {} diff --git a/sdk/policy/arm-policy/src/api/policyDefinitions/index.ts b/sdk/policy/arm-policy/src/api/policyDefinitions/index.ts new file mode 100644 index 000000000000..da72286e8d99 --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policyDefinitions/index.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + listByManagementGroup, + deleteAtManagementGroup, + createOrUpdateAtManagementGroup, + getAtManagementGroup, + listBuiltIn, + getBuiltIn, + list, + $delete, + createOrUpdate, + get, +} from "./operations.js"; +export { + PolicyDefinitionsListByManagementGroupOptionalParams, + PolicyDefinitionsDeleteAtManagementGroupOptionalParams, + PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, + PolicyDefinitionsGetAtManagementGroupOptionalParams, + PolicyDefinitionsListBuiltInOptionalParams, + PolicyDefinitionsGetBuiltInOptionalParams, + PolicyDefinitionsListOptionalParams, + PolicyDefinitionsDeleteOptionalParams, + PolicyDefinitionsCreateOrUpdateOptionalParams, + PolicyDefinitionsGetOptionalParams, +} from "./options.js"; diff --git a/sdk/policy/arm-policy/src/api/policyDefinitions/operations.ts b/sdk/policy/arm-policy/src/api/policyDefinitions/operations.ts new file mode 100644 index 000000000000..6beee8b0c1e9 --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policyDefinitions/operations.ts @@ -0,0 +1,515 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { PolicyContext as Client } from "../index.js"; +import type { PolicyDefinition, _PolicyDefinitionListResult } from "../../models/models.js"; +import { + errorResponseDeserializer, + policyDefinitionSerializer, + policyDefinitionDeserializer, + _policyDefinitionListResultDeserializer, +} from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { buildPagedAsyncIterator } from "../../static-helpers/pagingHelpers.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import type { + PolicyDefinitionsListByManagementGroupOptionalParams, + PolicyDefinitionsDeleteAtManagementGroupOptionalParams, + PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, + PolicyDefinitionsGetAtManagementGroupOptionalParams, + PolicyDefinitionsListBuiltInOptionalParams, + PolicyDefinitionsGetBuiltInOptionalParams, + PolicyDefinitionsListOptionalParams, + PolicyDefinitionsDeleteOptionalParams, + PolicyDefinitionsCreateOrUpdateOptionalParams, + PolicyDefinitionsGetOptionalParams, +} from "./options.js"; +import type { StreamableMethod, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError, operationOptionsToRequestParameters } from "@azure-rest/core-client"; + +export function _listByManagementGroupSend( + context: Client, + managementGroupId: string, + options: PolicyDefinitionsListByManagementGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions{?api%2Dversion,%24filter,%24top}", + { + managementGroupId: managementGroupId, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24filter": options?.filter, + "%24top": options?.top, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listByManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicyDefinitionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policyDefinitionListResultDeserializer(result.body); +} + +/** This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. */ +export function listByManagementGroup( + context: Client, + managementGroupId: string, + options: PolicyDefinitionsListByManagementGroupOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listByManagementGroupSend(context, managementGroupId, options), + _listByManagementGroupDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2025-03-01" }, + ); +} + +export function _deleteAtManagementGroupSend( + context: Client, + managementGroupId: string, + policyDefinitionName: string, + options: PolicyDefinitionsDeleteAtManagementGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}{?api%2Dversion}", + { + managementGroupId: managementGroupId, + policyDefinitionName: policyDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).delete({ ...operationOptionsToRequestParameters(options) }); +} + +export async function _deleteAtManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "204"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** This operation deletes the policy definition in the given management group with the given name. */ +export async function deleteAtManagementGroup( + context: Client, + managementGroupId: string, + policyDefinitionName: string, + options: PolicyDefinitionsDeleteAtManagementGroupOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _deleteAtManagementGroupSend( + context, + managementGroupId, + policyDefinitionName, + options, + ); + return _deleteAtManagementGroupDeserialize(result); +} + +export function _createOrUpdateAtManagementGroupSend( + context: Client, + managementGroupId: string, + policyDefinitionName: string, + parameters: PolicyDefinition, + options: PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}{?api%2Dversion}", + { + managementGroupId: managementGroupId, + policyDefinitionName: policyDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: policyDefinitionSerializer(parameters), + }); +} + +export async function _createOrUpdateAtManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policyDefinitionDeserializer(result.body); +} + +/** This operation creates or updates a policy definition in the given management group with the given name. */ +export async function createOrUpdateAtManagementGroup( + context: Client, + managementGroupId: string, + policyDefinitionName: string, + parameters: PolicyDefinition, + options: PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _createOrUpdateAtManagementGroupSend( + context, + managementGroupId, + policyDefinitionName, + parameters, + options, + ); + return _createOrUpdateAtManagementGroupDeserialize(result); +} + +export function _getAtManagementGroupSend( + context: Client, + managementGroupId: string, + policyDefinitionName: string, + options: PolicyDefinitionsGetAtManagementGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}{?api%2Dversion}", + { + managementGroupId: managementGroupId, + policyDefinitionName: policyDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getAtManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policyDefinitionDeserializer(result.body); +} + +/** This operation retrieves the policy definition in the given management group with the given name. */ +export async function getAtManagementGroup( + context: Client, + managementGroupId: string, + policyDefinitionName: string, + options: PolicyDefinitionsGetAtManagementGroupOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getAtManagementGroupSend( + context, + managementGroupId, + policyDefinitionName, + options, + ); + return _getAtManagementGroupDeserialize(result); +} + +export function _listBuiltInSend( + context: Client, + options: PolicyDefinitionsListBuiltInOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Authorization/policyDefinitions{?api%2Dversion,%24filter,%24top}", + { + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24filter": options?.filter, + "%24top": options?.top, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listBuiltInDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicyDefinitionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policyDefinitionListResultDeserializer(result.body); +} + +/** This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. */ +export function listBuiltIn( + context: Client, + options: PolicyDefinitionsListBuiltInOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listBuiltInSend(context, options), + _listBuiltInDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2025-03-01" }, + ); +} + +export function _getBuiltInSend( + context: Client, + policyDefinitionName: string, + options: PolicyDefinitionsGetBuiltInOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}{?api%2Dversion}", + { + policyDefinitionName: policyDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getBuiltInDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policyDefinitionDeserializer(result.body); +} + +/** This operation retrieves the built-in policy definition with the given name. */ +export async function getBuiltIn( + context: Client, + policyDefinitionName: string, + options: PolicyDefinitionsGetBuiltInOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getBuiltInSend(context, policyDefinitionName, options); + return _getBuiltInDeserialize(result); +} + +export function _listSend( + context: Client, + options: PolicyDefinitionsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions{?api%2Dversion,%24filter,%24top}", + { + subscriptionId: context.subscriptionId, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24filter": options?.filter, + "%24top": options?.top, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicyDefinitionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policyDefinitionListResultDeserializer(result.body); +} + +/** This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. */ +export function list( + context: Client, + options: PolicyDefinitionsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listSend(context, options), + _listDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2025-03-01" }, + ); +} + +export function _$deleteSend( + context: Client, + policyDefinitionName: string, + options: PolicyDefinitionsDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + policyDefinitionName: policyDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).delete({ ...operationOptionsToRequestParameters(options) }); +} + +export async function _$deleteDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200", "204"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** This operation deletes the policy definition in the given subscription with the given name. */ +/** + * @fixme delete is a reserved word that cannot be used as an operation name. + * Please add @clientName("clientName") or @clientName("", "javascript") + * to the operation to override the generated name. + */ +export async function $delete( + context: Client, + policyDefinitionName: string, + options: PolicyDefinitionsDeleteOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _$deleteSend(context, policyDefinitionName, options); + return _$deleteDeserialize(result); +} + +export function _createOrUpdateSend( + context: Client, + policyDefinitionName: string, + parameters: PolicyDefinition, + options: PolicyDefinitionsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + policyDefinitionName: policyDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: policyDefinitionSerializer(parameters), + }); +} + +export async function _createOrUpdateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policyDefinitionDeserializer(result.body); +} + +/** This operation creates or updates a policy definition in the given subscription with the given name. */ +export async function createOrUpdate( + context: Client, + policyDefinitionName: string, + parameters: PolicyDefinition, + options: PolicyDefinitionsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _createOrUpdateSend(context, policyDefinitionName, parameters, options); + return _createOrUpdateDeserialize(result); +} + +export function _getSend( + context: Client, + policyDefinitionName: string, + options: PolicyDefinitionsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + policyDefinitionName: policyDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policyDefinitionDeserializer(result.body); +} + +/** This operation retrieves the policy definition in the given subscription with the given name. */ +export async function get( + context: Client, + policyDefinitionName: string, + options: PolicyDefinitionsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getSend(context, policyDefinitionName, options); + return _getDeserialize(result); +} diff --git a/sdk/policy/arm-policy/src/api/policyDefinitions/options.ts b/sdk/policy/arm-policy/src/api/policyDefinitions/options.ts new file mode 100644 index 000000000000..204187462de4 --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policyDefinitions/options.ts @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface PolicyDefinitionsListByManagementGroupOptionalParams extends OperationOptions { + /** The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given scope. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. */ + filter?: string; + /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ + top?: number; +} + +/** Optional parameters. */ +export interface PolicyDefinitionsDeleteAtManagementGroupOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyDefinitionsGetAtManagementGroupOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyDefinitionsListBuiltInOptionalParams extends OperationOptions { + /** The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given scope. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. */ + filter?: string; + /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ + top?: number; +} + +/** Optional parameters. */ +export interface PolicyDefinitionsGetBuiltInOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyDefinitionsListOptionalParams extends OperationOptions { + /** The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given scope. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. */ + filter?: string; + /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ + top?: number; +} + +/** Optional parameters. */ +export interface PolicyDefinitionsDeleteOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyDefinitionsCreateOrUpdateOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyDefinitionsGetOptionalParams extends OperationOptions {} diff --git a/sdk/policy/arm-policy/src/api/policySetDefinitionVersions/index.ts b/sdk/policy/arm-policy/src/api/policySetDefinitionVersions/index.ts new file mode 100644 index 000000000000..44fa372f4f78 --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policySetDefinitionVersions/index.ts @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + listAll, + listAllAtManagementGroup, + listAllBuiltins, + listByManagementGroup, + deleteAtManagementGroup, + createOrUpdateAtManagementGroup, + getAtManagementGroup, + listBuiltIn, + getBuiltIn, + list, + $delete, + createOrUpdate, + get, +} from "./operations.js"; +export { + PolicySetDefinitionVersionsListAllOptionalParams, + PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams, + PolicySetDefinitionVersionsListAllBuiltinsOptionalParams, + PolicySetDefinitionVersionsListByManagementGroupOptionalParams, + PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams, + PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, + PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams, + PolicySetDefinitionVersionsListBuiltInOptionalParams, + PolicySetDefinitionVersionsGetBuiltInOptionalParams, + PolicySetDefinitionVersionsListOptionalParams, + PolicySetDefinitionVersionsDeleteOptionalParams, + PolicySetDefinitionVersionsCreateOrUpdateOptionalParams, + PolicySetDefinitionVersionsGetOptionalParams, +} from "./options.js"; diff --git a/sdk/policy/arm-policy/src/api/policySetDefinitionVersions/operations.ts b/sdk/policy/arm-policy/src/api/policySetDefinitionVersions/operations.ts new file mode 100644 index 000000000000..ce3a075e42e6 --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policySetDefinitionVersions/operations.ts @@ -0,0 +1,715 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { PolicyContext as Client } from "../index.js"; +import type { + PolicySetDefinitionVersion, + _PolicySetDefinitionVersionListResult, +} from "../../models/models.js"; +import { + errorResponseDeserializer, + policySetDefinitionVersionSerializer, + policySetDefinitionVersionDeserializer, + _policySetDefinitionVersionListResultDeserializer, +} from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { buildPagedAsyncIterator } from "../../static-helpers/pagingHelpers.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import type { + PolicySetDefinitionVersionsListAllOptionalParams, + PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams, + PolicySetDefinitionVersionsListAllBuiltinsOptionalParams, + PolicySetDefinitionVersionsListByManagementGroupOptionalParams, + PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams, + PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, + PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams, + PolicySetDefinitionVersionsListBuiltInOptionalParams, + PolicySetDefinitionVersionsGetBuiltInOptionalParams, + PolicySetDefinitionVersionsListOptionalParams, + PolicySetDefinitionVersionsDeleteOptionalParams, + PolicySetDefinitionVersionsCreateOrUpdateOptionalParams, + PolicySetDefinitionVersionsGetOptionalParams, +} from "./options.js"; +import type { StreamableMethod, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError, operationOptionsToRequestParameters } from "@azure-rest/core-client"; + +export function _listAllSend( + context: Client, + options: PolicySetDefinitionVersionsListAllOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listAllDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicySetDefinitionVersionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policySetDefinitionVersionListResultDeserializer(result.body); +} + +/** This operation lists all the policy set definition versions for all policy set definitions within a subscription. */ +export async function listAll( + context: Client, + options: PolicySetDefinitionVersionsListAllOptionalParams = { requestOptions: {} }, +): Promise<_PolicySetDefinitionVersionListResult> { + const result = await _listAllSend(context, options); + return _listAllDeserialize(result); +} + +export function _listAllAtManagementGroupSend( + context: Client, + managementGroupName: string, + options: PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions{?api%2Dversion}", + { + managementGroupName: managementGroupName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listAllAtManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicySetDefinitionVersionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policySetDefinitionVersionListResultDeserializer(result.body); +} + +/** This operation lists all the policy set definition versions for all policy set definitions at the management group scope. */ +export async function listAllAtManagementGroup( + context: Client, + managementGroupName: string, + options: PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams = { + requestOptions: {}, + }, +): Promise<_PolicySetDefinitionVersionListResult> { + const result = await _listAllAtManagementGroupSend(context, managementGroupName, options); + return _listAllAtManagementGroupDeserialize(result); +} + +export function _listAllBuiltinsSend( + context: Client, + options: PolicySetDefinitionVersionsListAllBuiltinsOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Authorization/listPolicySetDefinitionVersions{?api%2Dversion}", + { + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listAllBuiltinsDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicySetDefinitionVersionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policySetDefinitionVersionListResultDeserializer(result.body); +} + +/** This operation lists all the built-in policy set definition versions for all built-in policy set definitions. */ +export async function listAllBuiltins( + context: Client, + options: PolicySetDefinitionVersionsListAllBuiltinsOptionalParams = { requestOptions: {} }, +): Promise<_PolicySetDefinitionVersionListResult> { + const result = await _listAllBuiltinsSend(context, options); + return _listAllBuiltinsDeserialize(result); +} + +export function _listByManagementGroupSend( + context: Client, + managementGroupName: string, + policySetDefinitionName: string, + options: PolicySetDefinitionVersionsListByManagementGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions{?api%2Dversion,%24expand,%24top}", + { + managementGroupName: managementGroupName, + policySetDefinitionName: policySetDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24expand": options?.expand, + "%24top": options?.top, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listByManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicySetDefinitionVersionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policySetDefinitionVersionListResultDeserializer(result.body); +} + +/** This operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. */ +export function listByManagementGroup( + context: Client, + managementGroupName: string, + policySetDefinitionName: string, + options: PolicySetDefinitionVersionsListByManagementGroupOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => + _listByManagementGroupSend(context, managementGroupName, policySetDefinitionName, options), + _listByManagementGroupDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2025-03-01" }, + ); +} + +export function _deleteAtManagementGroupSend( + context: Client, + managementGroupName: string, + policySetDefinitionName: string, + policyDefinitionVersion: string, + options: PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}{?api%2Dversion}", + { + managementGroupName: managementGroupName, + policySetDefinitionName: policySetDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).delete({ ...operationOptionsToRequestParameters(options) }); +} + +export async function _deleteAtManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "204"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** This operation deletes the policy set definition version in the given management group with the given name and version. */ +export async function deleteAtManagementGroup( + context: Client, + managementGroupName: string, + policySetDefinitionName: string, + policyDefinitionVersion: string, + options: PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams = { + requestOptions: {}, + }, +): Promise { + const result = await _deleteAtManagementGroupSend( + context, + managementGroupName, + policySetDefinitionName, + policyDefinitionVersion, + options, + ); + return _deleteAtManagementGroupDeserialize(result); +} + +export function _createOrUpdateAtManagementGroupSend( + context: Client, + managementGroupName: string, + policySetDefinitionName: string, + policyDefinitionVersion: string, + parameters: PolicySetDefinitionVersion, + options: PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}{?api%2Dversion}", + { + managementGroupName: managementGroupName, + policySetDefinitionName: policySetDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: policySetDefinitionVersionSerializer(parameters), + }); +} + +export async function _createOrUpdateAtManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policySetDefinitionVersionDeserializer(result.body); +} + +/** This operation creates or updates a policy set definition version in the given management group with the given name and version. */ +export async function createOrUpdateAtManagementGroup( + context: Client, + managementGroupName: string, + policySetDefinitionName: string, + policyDefinitionVersion: string, + parameters: PolicySetDefinitionVersion, + options: PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams = { + requestOptions: {}, + }, +): Promise { + const result = await _createOrUpdateAtManagementGroupSend( + context, + managementGroupName, + policySetDefinitionName, + policyDefinitionVersion, + parameters, + options, + ); + return _createOrUpdateAtManagementGroupDeserialize(result); +} + +export function _getAtManagementGroupSend( + context: Client, + managementGroupName: string, + policySetDefinitionName: string, + policyDefinitionVersion: string, + options: PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}{?api%2Dversion,%24expand}", + { + managementGroupName: managementGroupName, + policySetDefinitionName: policySetDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24expand": options?.expand, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getAtManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policySetDefinitionVersionDeserializer(result.body); +} + +/** This operation retrieves the policy set definition version in the given management group with the given name and version. */ +export async function getAtManagementGroup( + context: Client, + managementGroupName: string, + policySetDefinitionName: string, + policyDefinitionVersion: string, + options: PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getAtManagementGroupSend( + context, + managementGroupName, + policySetDefinitionName, + policyDefinitionVersion, + options, + ); + return _getAtManagementGroupDeserialize(result); +} + +export function _listBuiltInSend( + context: Client, + policySetDefinitionName: string, + options: PolicySetDefinitionVersionsListBuiltInOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions{?api%2Dversion,%24expand,%24top}", + { + policySetDefinitionName: policySetDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24expand": options?.expand, + "%24top": options?.top, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listBuiltInDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicySetDefinitionVersionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policySetDefinitionVersionListResultDeserializer(result.body); +} + +/** This operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. */ +export function listBuiltIn( + context: Client, + policySetDefinitionName: string, + options: PolicySetDefinitionVersionsListBuiltInOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listBuiltInSend(context, policySetDefinitionName, options), + _listBuiltInDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2025-03-01" }, + ); +} + +export function _getBuiltInSend( + context: Client, + policySetDefinitionName: string, + policyDefinitionVersion: string, + options: PolicySetDefinitionVersionsGetBuiltInOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}{?api%2Dversion,%24expand}", + { + policySetDefinitionName: policySetDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24expand": options?.expand, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getBuiltInDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policySetDefinitionVersionDeserializer(result.body); +} + +/** This operation retrieves the built-in policy set definition version with the given name and version. */ +export async function getBuiltIn( + context: Client, + policySetDefinitionName: string, + policyDefinitionVersion: string, + options: PolicySetDefinitionVersionsGetBuiltInOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getBuiltInSend( + context, + policySetDefinitionName, + policyDefinitionVersion, + options, + ); + return _getBuiltInDeserialize(result); +} + +export function _listSend( + context: Client, + policySetDefinitionName: string, + options: PolicySetDefinitionVersionsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions{?api%2Dversion,%24expand,%24top}", + { + subscriptionId: context.subscriptionId, + policySetDefinitionName: policySetDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24expand": options?.expand, + "%24top": options?.top, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicySetDefinitionVersionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policySetDefinitionVersionListResultDeserializer(result.body); +} + +/** This operation retrieves a list of all the policy set definition versions for the given policy set definition. */ +export function list( + context: Client, + policySetDefinitionName: string, + options: PolicySetDefinitionVersionsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listSend(context, policySetDefinitionName, options), + _listDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2025-03-01" }, + ); +} + +export function _$deleteSend( + context: Client, + policySetDefinitionName: string, + policyDefinitionVersion: string, + options: PolicySetDefinitionVersionsDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + policySetDefinitionName: policySetDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).delete({ ...operationOptionsToRequestParameters(options) }); +} + +export async function _$deleteDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200", "204"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** This operation deletes the policy set definition version in the given subscription with the given name and version. */ +/** + * @fixme delete is a reserved word that cannot be used as an operation name. + * Please add @clientName("clientName") or @clientName("", "javascript") + * to the operation to override the generated name. + */ +export async function $delete( + context: Client, + policySetDefinitionName: string, + policyDefinitionVersion: string, + options: PolicySetDefinitionVersionsDeleteOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _$deleteSend( + context, + policySetDefinitionName, + policyDefinitionVersion, + options, + ); + return _$deleteDeserialize(result); +} + +export function _createOrUpdateSend( + context: Client, + policySetDefinitionName: string, + policyDefinitionVersion: string, + parameters: PolicySetDefinitionVersion, + options: PolicySetDefinitionVersionsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + policySetDefinitionName: policySetDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: policySetDefinitionVersionSerializer(parameters), + }); +} + +export async function _createOrUpdateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policySetDefinitionVersionDeserializer(result.body); +} + +/** This operation creates or updates a policy set definition version in the given subscription with the given name and version. */ +export async function createOrUpdate( + context: Client, + policySetDefinitionName: string, + policyDefinitionVersion: string, + parameters: PolicySetDefinitionVersion, + options: PolicySetDefinitionVersionsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _createOrUpdateSend( + context, + policySetDefinitionName, + policyDefinitionVersion, + parameters, + options, + ); + return _createOrUpdateDeserialize(result); +} + +export function _getSend( + context: Client, + policySetDefinitionName: string, + policyDefinitionVersion: string, + options: PolicySetDefinitionVersionsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}{?api%2Dversion,%24expand}", + { + subscriptionId: context.subscriptionId, + policySetDefinitionName: policySetDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24expand": options?.expand, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policySetDefinitionVersionDeserializer(result.body); +} + +/** This operation retrieves the policy set definition version in the given subscription with the given name and version. */ +export async function get( + context: Client, + policySetDefinitionName: string, + policyDefinitionVersion: string, + options: PolicySetDefinitionVersionsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getSend(context, policySetDefinitionName, policyDefinitionVersion, options); + return _getDeserialize(result); +} diff --git a/sdk/policy/arm-policy/src/api/policySetDefinitionVersions/options.ts b/sdk/policy/arm-policy/src/api/policySetDefinitionVersions/options.ts new file mode 100644 index 000000000000..db260a2d0c84 --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policySetDefinitionVersions/options.ts @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface PolicySetDefinitionVersionsListAllOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicySetDefinitionVersionsListAllBuiltinsOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicySetDefinitionVersionsListByManagementGroupOptionalParams extends OperationOptions { + /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ + expand?: string; + /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ + top?: number; +} + +/** Optional parameters. */ +export interface PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams extends OperationOptions { + /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ + expand?: string; +} + +/** Optional parameters. */ +export interface PolicySetDefinitionVersionsListBuiltInOptionalParams extends OperationOptions { + /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ + expand?: string; + /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ + top?: number; +} + +/** Optional parameters. */ +export interface PolicySetDefinitionVersionsGetBuiltInOptionalParams extends OperationOptions { + /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ + expand?: string; +} + +/** Optional parameters. */ +export interface PolicySetDefinitionVersionsListOptionalParams extends OperationOptions { + /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ + expand?: string; + /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ + top?: number; +} + +/** Optional parameters. */ +export interface PolicySetDefinitionVersionsDeleteOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicySetDefinitionVersionsCreateOrUpdateOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicySetDefinitionVersionsGetOptionalParams extends OperationOptions { + /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ + expand?: string; +} diff --git a/sdk/policy/arm-policy/src/api/policySetDefinitions/index.ts b/sdk/policy/arm-policy/src/api/policySetDefinitions/index.ts new file mode 100644 index 000000000000..344d4bb14d4a --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policySetDefinitions/index.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + listByManagementGroup, + deleteAtManagementGroup, + createOrUpdateAtManagementGroup, + getAtManagementGroup, + listBuiltIn, + getBuiltIn, + list, + $delete, + createOrUpdate, + get, +} from "./operations.js"; +export { + PolicySetDefinitionsListByManagementGroupOptionalParams, + PolicySetDefinitionsDeleteAtManagementGroupOptionalParams, + PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, + PolicySetDefinitionsGetAtManagementGroupOptionalParams, + PolicySetDefinitionsListBuiltInOptionalParams, + PolicySetDefinitionsGetBuiltInOptionalParams, + PolicySetDefinitionsListOptionalParams, + PolicySetDefinitionsDeleteOptionalParams, + PolicySetDefinitionsCreateOrUpdateOptionalParams, + PolicySetDefinitionsGetOptionalParams, +} from "./options.js"; diff --git a/sdk/policy/arm-policy/src/api/policySetDefinitions/operations.ts b/sdk/policy/arm-policy/src/api/policySetDefinitions/operations.ts new file mode 100644 index 000000000000..e272bbe8f0bb --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policySetDefinitions/operations.ts @@ -0,0 +1,525 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { PolicyContext as Client } from "../index.js"; +import type { PolicySetDefinition, _PolicySetDefinitionListResult } from "../../models/models.js"; +import { + errorResponseDeserializer, + policySetDefinitionSerializer, + policySetDefinitionDeserializer, + _policySetDefinitionListResultDeserializer, +} from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { buildPagedAsyncIterator } from "../../static-helpers/pagingHelpers.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import type { + PolicySetDefinitionsListByManagementGroupOptionalParams, + PolicySetDefinitionsDeleteAtManagementGroupOptionalParams, + PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, + PolicySetDefinitionsGetAtManagementGroupOptionalParams, + PolicySetDefinitionsListBuiltInOptionalParams, + PolicySetDefinitionsGetBuiltInOptionalParams, + PolicySetDefinitionsListOptionalParams, + PolicySetDefinitionsDeleteOptionalParams, + PolicySetDefinitionsCreateOrUpdateOptionalParams, + PolicySetDefinitionsGetOptionalParams, +} from "./options.js"; +import type { StreamableMethod, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError, operationOptionsToRequestParameters } from "@azure-rest/core-client"; + +export function _listByManagementGroupSend( + context: Client, + managementGroupId: string, + options: PolicySetDefinitionsListByManagementGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions{?api%2Dversion,%24filter,%24expand,%24top}", + { + managementGroupId: managementGroupId, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24filter": options?.filter, + "%24expand": options?.expand, + "%24top": options?.top, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listByManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicySetDefinitionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policySetDefinitionListResultDeserializer(result.body); +} + +/** This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. */ +export function listByManagementGroup( + context: Client, + managementGroupId: string, + options: PolicySetDefinitionsListByManagementGroupOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listByManagementGroupSend(context, managementGroupId, options), + _listByManagementGroupDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2025-03-01" }, + ); +} + +export function _deleteAtManagementGroupSend( + context: Client, + managementGroupId: string, + policySetDefinitionName: string, + options: PolicySetDefinitionsDeleteAtManagementGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}{?api%2Dversion}", + { + managementGroupId: managementGroupId, + policySetDefinitionName: policySetDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).delete({ ...operationOptionsToRequestParameters(options) }); +} + +export async function _deleteAtManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "204"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** This operation deletes the policy set definition in the given management group with the given name. */ +export async function deleteAtManagementGroup( + context: Client, + managementGroupId: string, + policySetDefinitionName: string, + options: PolicySetDefinitionsDeleteAtManagementGroupOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _deleteAtManagementGroupSend( + context, + managementGroupId, + policySetDefinitionName, + options, + ); + return _deleteAtManagementGroupDeserialize(result); +} + +export function _createOrUpdateAtManagementGroupSend( + context: Client, + managementGroupId: string, + policySetDefinitionName: string, + parameters: PolicySetDefinition, + options: PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}{?api%2Dversion}", + { + managementGroupId: managementGroupId, + policySetDefinitionName: policySetDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: policySetDefinitionSerializer(parameters), + }); +} + +export async function _createOrUpdateAtManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policySetDefinitionDeserializer(result.body); +} + +/** This operation creates or updates a policy set definition in the given management group with the given name. */ +export async function createOrUpdateAtManagementGroup( + context: Client, + managementGroupId: string, + policySetDefinitionName: string, + parameters: PolicySetDefinition, + options: PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams = { + requestOptions: {}, + }, +): Promise { + const result = await _createOrUpdateAtManagementGroupSend( + context, + managementGroupId, + policySetDefinitionName, + parameters, + options, + ); + return _createOrUpdateAtManagementGroupDeserialize(result); +} + +export function _getAtManagementGroupSend( + context: Client, + managementGroupId: string, + policySetDefinitionName: string, + options: PolicySetDefinitionsGetAtManagementGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}{?api%2Dversion,%24expand}", + { + managementGroupId: managementGroupId, + policySetDefinitionName: policySetDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24expand": options?.expand, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getAtManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policySetDefinitionDeserializer(result.body); +} + +/** This operation retrieves the policy set definition in the given management group with the given name. */ +export async function getAtManagementGroup( + context: Client, + managementGroupId: string, + policySetDefinitionName: string, + options: PolicySetDefinitionsGetAtManagementGroupOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getAtManagementGroupSend( + context, + managementGroupId, + policySetDefinitionName, + options, + ); + return _getAtManagementGroupDeserialize(result); +} + +export function _listBuiltInSend( + context: Client, + options: PolicySetDefinitionsListBuiltInOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Authorization/policySetDefinitions{?api%2Dversion,%24filter,%24expand,%24top}", + { + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24filter": options?.filter, + "%24expand": options?.expand, + "%24top": options?.top, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listBuiltInDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicySetDefinitionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policySetDefinitionListResultDeserializer(result.body); +} + +/** This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. */ +export function listBuiltIn( + context: Client, + options: PolicySetDefinitionsListBuiltInOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listBuiltInSend(context, options), + _listBuiltInDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2025-03-01" }, + ); +} + +export function _getBuiltInSend( + context: Client, + policySetDefinitionName: string, + options: PolicySetDefinitionsGetBuiltInOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}{?api%2Dversion,%24expand}", + { + policySetDefinitionName: policySetDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24expand": options?.expand, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getBuiltInDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policySetDefinitionDeserializer(result.body); +} + +/** This operation retrieves the built-in policy set definition with the given name. */ +export async function getBuiltIn( + context: Client, + policySetDefinitionName: string, + options: PolicySetDefinitionsGetBuiltInOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getBuiltInSend(context, policySetDefinitionName, options); + return _getBuiltInDeserialize(result); +} + +export function _listSend( + context: Client, + options: PolicySetDefinitionsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions{?api%2Dversion,%24filter,%24expand,%24top}", + { + subscriptionId: context.subscriptionId, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24filter": options?.filter, + "%24expand": options?.expand, + "%24top": options?.top, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listDeserialize( + result: PathUncheckedResponse, +): Promise<_PolicySetDefinitionListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _policySetDefinitionListResultDeserializer(result.body); +} + +/** This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. */ +export function list( + context: Client, + options: PolicySetDefinitionsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listSend(context, options), + _listDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2025-03-01" }, + ); +} + +export function _$deleteSend( + context: Client, + policySetDefinitionName: string, + options: PolicySetDefinitionsDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + policySetDefinitionName: policySetDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).delete({ ...operationOptionsToRequestParameters(options) }); +} + +export async function _$deleteDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200", "204"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** This operation deletes the policy set definition in the given subscription with the given name. */ +/** + * @fixme delete is a reserved word that cannot be used as an operation name. + * Please add @clientName("clientName") or @clientName("", "javascript") + * to the operation to override the generated name. + */ +export async function $delete( + context: Client, + policySetDefinitionName: string, + options: PolicySetDefinitionsDeleteOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _$deleteSend(context, policySetDefinitionName, options); + return _$deleteDeserialize(result); +} + +export function _createOrUpdateSend( + context: Client, + policySetDefinitionName: string, + parameters: PolicySetDefinition, + options: PolicySetDefinitionsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + policySetDefinitionName: policySetDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: policySetDefinitionSerializer(parameters), + }); +} + +export async function _createOrUpdateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policySetDefinitionDeserializer(result.body); +} + +/** This operation creates or updates a policy set definition in the given subscription with the given name. */ +export async function createOrUpdate( + context: Client, + policySetDefinitionName: string, + parameters: PolicySetDefinition, + options: PolicySetDefinitionsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _createOrUpdateSend(context, policySetDefinitionName, parameters, options); + return _createOrUpdateDeserialize(result); +} + +export function _getSend( + context: Client, + policySetDefinitionName: string, + options: PolicySetDefinitionsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}{?api%2Dversion,%24expand}", + { + subscriptionId: context.subscriptionId, + policySetDefinitionName: policySetDefinitionName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + "%24expand": options?.expand, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policySetDefinitionDeserializer(result.body); +} + +/** This operation retrieves the policy set definition in the given subscription with the given name. */ +export async function get( + context: Client, + policySetDefinitionName: string, + options: PolicySetDefinitionsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getSend(context, policySetDefinitionName, options); + return _getDeserialize(result); +} diff --git a/sdk/policy/arm-policy/src/api/policySetDefinitions/options.ts b/sdk/policy/arm-policy/src/api/policySetDefinitions/options.ts new file mode 100644 index 000000000000..211c953cc85c --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policySetDefinitions/options.ts @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface PolicySetDefinitionsListByManagementGroupOptionalParams extends OperationOptions { + /** The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given scope. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. */ + filter?: string; + /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ + expand?: string; + /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ + top?: number; +} + +/** Optional parameters. */ +export interface PolicySetDefinitionsDeleteAtManagementGroupOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicySetDefinitionsGetAtManagementGroupOptionalParams extends OperationOptions { + /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ + expand?: string; +} + +/** Optional parameters. */ +export interface PolicySetDefinitionsListBuiltInOptionalParams extends OperationOptions { + /** The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given scope. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. */ + filter?: string; + /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ + expand?: string; + /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ + top?: number; +} + +/** Optional parameters. */ +export interface PolicySetDefinitionsGetBuiltInOptionalParams extends OperationOptions { + /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ + expand?: string; +} + +/** Optional parameters. */ +export interface PolicySetDefinitionsListOptionalParams extends OperationOptions { + /** The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given scope. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. */ + filter?: string; + /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ + expand?: string; + /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ + top?: number; +} + +/** Optional parameters. */ +export interface PolicySetDefinitionsDeleteOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicySetDefinitionsCreateOrUpdateOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicySetDefinitionsGetOptionalParams extends OperationOptions { + /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ + expand?: string; +} diff --git a/sdk/policy/arm-policy/src/api/policyTokens/index.ts b/sdk/policy/arm-policy/src/api/policyTokens/index.ts new file mode 100644 index 000000000000..4150a27470fa --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policyTokens/index.ts @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { acquireAtManagementGroup, acquire } from "./operations.js"; +export { + PolicyTokensAcquireAtManagementGroupOptionalParams, + PolicyTokensAcquireOptionalParams, +} from "./options.js"; diff --git a/sdk/policy/arm-policy/src/api/policyTokens/operations.ts b/sdk/policy/arm-policy/src/api/policyTokens/operations.ts new file mode 100644 index 000000000000..06862efa0dad --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policyTokens/operations.ts @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { PolicyContext as Client } from "../index.js"; +import type { PolicyTokenRequest, PolicyTokenResponse } from "../../models/models.js"; +import { + errorResponseDeserializer, + policyTokenRequestSerializer, + policyTokenResponseDeserializer, +} from "../../models/models.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import type { + PolicyTokensAcquireAtManagementGroupOptionalParams, + PolicyTokensAcquireOptionalParams, +} from "./options.js"; +import type { StreamableMethod, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError, operationOptionsToRequestParameters } from "@azure-rest/core-client"; + +export function _acquireAtManagementGroupSend( + context: Client, + managementGroupName: string, + parameters: PolicyTokenRequest, + options: PolicyTokensAcquireAtManagementGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/acquirePolicyToken{?api%2Dversion}", + { + managementGroupName: managementGroupName, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: policyTokenRequestSerializer(parameters), + }); +} + +export async function _acquireAtManagementGroupDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policyTokenResponseDeserializer(result.body); +} + +/** This operation acquires a policy token in the given management group for the given request body. */ +export async function acquireAtManagementGroup( + context: Client, + managementGroupName: string, + parameters: PolicyTokenRequest, + options: PolicyTokensAcquireAtManagementGroupOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _acquireAtManagementGroupSend( + context, + managementGroupName, + parameters, + options, + ); + return _acquireAtManagementGroupDeserialize(result); +} + +export function _acquireSend( + context: Client, + parameters: PolicyTokenRequest, + options: PolicyTokensAcquireOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/acquirePolicyToken{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + "api%2Dversion": context.apiVersion ?? "2025-03-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: policyTokenRequestSerializer(parameters), + }); +} + +export async function _acquireDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return policyTokenResponseDeserializer(result.body); +} + +/** This operation acquires a policy token in the given subscription for the given request body. */ +export async function acquire( + context: Client, + parameters: PolicyTokenRequest, + options: PolicyTokensAcquireOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _acquireSend(context, parameters, options); + return _acquireDeserialize(result); +} diff --git a/sdk/policy/arm-policy/src/api/policyTokens/options.ts b/sdk/policy/arm-policy/src/api/policyTokens/options.ts new file mode 100644 index 000000000000..00b5d550d90b --- /dev/null +++ b/sdk/policy/arm-policy/src/api/policyTokens/options.ts @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface PolicyTokensAcquireAtManagementGroupOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface PolicyTokensAcquireOptionalParams extends OperationOptions {} diff --git a/sdk/policy/arm-policy/src/classic/index.ts b/sdk/policy/arm-policy/src/classic/index.ts new file mode 100644 index 000000000000..4974d70202fb --- /dev/null +++ b/sdk/policy/arm-policy/src/classic/index.ts @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { PolicyAssignmentsOperations } from "./policyAssignments/index.js"; +export { PolicyDefinitionsOperations } from "./policyDefinitions/index.js"; +export { PolicyDefinitionVersionsOperations } from "./policyDefinitionVersions/index.js"; +export { PolicySetDefinitionsOperations } from "./policySetDefinitions/index.js"; +export { PolicySetDefinitionVersionsOperations } from "./policySetDefinitionVersions/index.js"; +export { PolicyTokensOperations } from "./policyTokens/index.js"; diff --git a/sdk/policy/arm-policy/src/classic/policyAssignments/index.ts b/sdk/policy/arm-policy/src/classic/policyAssignments/index.ts new file mode 100644 index 000000000000..c32908c72102 --- /dev/null +++ b/sdk/policy/arm-policy/src/classic/policyAssignments/index.ts @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { PolicyContext } from "../../api/policyContext.js"; +import { + listForResource, + list, + listForManagementGroup, + listForResourceGroup, + $delete, + update, + create, + get, +} from "../../api/policyAssignments/operations.js"; +import type { + PolicyAssignmentsListForResourceOptionalParams, + PolicyAssignmentsListOptionalParams, + PolicyAssignmentsListForManagementGroupOptionalParams, + PolicyAssignmentsListForResourceGroupOptionalParams, + PolicyAssignmentsDeleteOptionalParams, + PolicyAssignmentsUpdateOptionalParams, + PolicyAssignmentsCreateOptionalParams, + PolicyAssignmentsGetOptionalParams, +} from "../../api/policyAssignments/options.js"; +import type { PolicyAssignment, PolicyAssignmentUpdate } from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a PolicyAssignments operations. */ +export interface PolicyAssignmentsOperations { + /** This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). */ + listForResource: ( + resourceGroupName: string, + resourceProviderNamespace: string, + parentResourcePath: string, + resourceType: string, + resourceName: string, + options?: PolicyAssignmentsListForResourceOptionalParams, + ) => PagedAsyncIterableIterator; + /** This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. */ + list: ( + options?: PolicyAssignmentsListOptionalParams, + ) => PagedAsyncIterableIterator; + /** This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. */ + listForManagementGroup: ( + managementGroupId: string, + options?: PolicyAssignmentsListForManagementGroupOptionalParams, + ) => PagedAsyncIterableIterator; + /** This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. */ + listForResourceGroup: ( + resourceGroupName: string, + options?: PolicyAssignmentsListForResourceGroupOptionalParams, + ) => PagedAsyncIterableIterator; + /** This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. */ + /** + * @fixme delete is a reserved word that cannot be used as an operation name. + * Please add @clientName("clientName") or @clientName("", "javascript") + * to the operation to override the generated name. + */ + delete: ( + scope: string, + policyAssignmentName: string, + options?: PolicyAssignmentsDeleteOptionalParams, + ) => Promise; + /** This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. */ + update: ( + scope: string, + policyAssignmentName: string, + parameters: PolicyAssignmentUpdate, + options?: PolicyAssignmentsUpdateOptionalParams, + ) => Promise; + /** This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. */ + create: ( + scope: string, + policyAssignmentName: string, + parameters: PolicyAssignment, + options?: PolicyAssignmentsCreateOptionalParams, + ) => Promise; + /** This operation retrieves a single policy assignment, given its name and the scope it was created at. */ + get: ( + scope: string, + policyAssignmentName: string, + options?: PolicyAssignmentsGetOptionalParams, + ) => Promise; +} + +function _getPolicyAssignments(context: PolicyContext) { + return { + listForResource: ( + resourceGroupName: string, + resourceProviderNamespace: string, + parentResourcePath: string, + resourceType: string, + resourceName: string, + options?: PolicyAssignmentsListForResourceOptionalParams, + ) => + listForResource( + context, + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName, + options, + ), + list: (options?: PolicyAssignmentsListOptionalParams) => list(context, options), + listForManagementGroup: ( + managementGroupId: string, + options?: PolicyAssignmentsListForManagementGroupOptionalParams, + ) => listForManagementGroup(context, managementGroupId, options), + listForResourceGroup: ( + resourceGroupName: string, + options?: PolicyAssignmentsListForResourceGroupOptionalParams, + ) => listForResourceGroup(context, resourceGroupName, options), + delete: ( + scope: string, + policyAssignmentName: string, + options?: PolicyAssignmentsDeleteOptionalParams, + ) => $delete(context, scope, policyAssignmentName, options), + update: ( + scope: string, + policyAssignmentName: string, + parameters: PolicyAssignmentUpdate, + options?: PolicyAssignmentsUpdateOptionalParams, + ) => update(context, scope, policyAssignmentName, parameters, options), + create: ( + scope: string, + policyAssignmentName: string, + parameters: PolicyAssignment, + options?: PolicyAssignmentsCreateOptionalParams, + ) => create(context, scope, policyAssignmentName, parameters, options), + get: ( + scope: string, + policyAssignmentName: string, + options?: PolicyAssignmentsGetOptionalParams, + ) => get(context, scope, policyAssignmentName, options), + }; +} + +export function _getPolicyAssignmentsOperations( + context: PolicyContext, +): PolicyAssignmentsOperations { + return { + ..._getPolicyAssignments(context), + }; +} diff --git a/sdk/policy/arm-policy/src/classic/policyDefinitionVersions/index.ts b/sdk/policy/arm-policy/src/classic/policyDefinitionVersions/index.ts new file mode 100644 index 000000000000..a988f336f017 --- /dev/null +++ b/sdk/policy/arm-policy/src/classic/policyDefinitionVersions/index.ts @@ -0,0 +1,218 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { PolicyContext } from "../../api/policyContext.js"; +import { + listAll, + listAllAtManagementGroup, + listAllBuiltins, + listByManagementGroup, + deleteAtManagementGroup, + createOrUpdateAtManagementGroup, + getAtManagementGroup, + listBuiltIn, + getBuiltIn, + list, + $delete, + createOrUpdate, + get, +} from "../../api/policyDefinitionVersions/operations.js"; +import type { + PolicyDefinitionVersionsListAllOptionalParams, + PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams, + PolicyDefinitionVersionsListAllBuiltinsOptionalParams, + PolicyDefinitionVersionsListByManagementGroupOptionalParams, + PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams, + PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, + PolicyDefinitionVersionsGetAtManagementGroupOptionalParams, + PolicyDefinitionVersionsListBuiltInOptionalParams, + PolicyDefinitionVersionsGetBuiltInOptionalParams, + PolicyDefinitionVersionsListOptionalParams, + PolicyDefinitionVersionsDeleteOptionalParams, + PolicyDefinitionVersionsCreateOrUpdateOptionalParams, + PolicyDefinitionVersionsGetOptionalParams, +} from "../../api/policyDefinitionVersions/options.js"; +import type { + PolicyDefinitionVersion, + _PolicyDefinitionVersionListResult, +} from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a PolicyDefinitionVersions operations. */ +export interface PolicyDefinitionVersionsOperations { + /** This operation lists all the policy definition versions for all policy definitions within a subscription. */ + listAll: ( + options?: PolicyDefinitionVersionsListAllOptionalParams, + ) => Promise<_PolicyDefinitionVersionListResult>; + /** This operation lists all the policy definition versions for all policy definitions at the management group scope. */ + listAllAtManagementGroup: ( + managementGroupName: string, + options?: PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams, + ) => Promise<_PolicyDefinitionVersionListResult>; + /** This operation lists all the built-in policy definition versions for all built-in policy definitions. */ + listAllBuiltins: ( + options?: PolicyDefinitionVersionsListAllBuiltinsOptionalParams, + ) => Promise<_PolicyDefinitionVersionListResult>; + /** This operation retrieves a list of all the policy definition versions for the given policy definition in the given management group. */ + listByManagementGroup: ( + managementGroupName: string, + policyDefinitionName: string, + options?: PolicyDefinitionVersionsListByManagementGroupOptionalParams, + ) => PagedAsyncIterableIterator; + /** This operation deletes the policy definition in the given management group with the given name. */ + deleteAtManagementGroup: ( + managementGroupName: string, + policyDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams, + ) => Promise; + /** This operation creates or updates a policy definition version in the given management group with the given name. */ + createOrUpdateAtManagementGroup: ( + managementGroupName: string, + policyDefinitionName: string, + policyDefinitionVersion: string, + parameters: PolicyDefinitionVersion, + options?: PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, + ) => Promise; + /** This operation retrieves the policy definition version in the given management group with the given name. */ + getAtManagementGroup: ( + managementGroupName: string, + policyDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicyDefinitionVersionsGetAtManagementGroupOptionalParams, + ) => Promise; + /** This operation retrieves a list of all the built-in policy definition versions for the given policy definition. */ + listBuiltIn: ( + policyDefinitionName: string, + options?: PolicyDefinitionVersionsListBuiltInOptionalParams, + ) => PagedAsyncIterableIterator; + /** This operation retrieves the built-in policy definition version with the given name. */ + getBuiltIn: ( + policyDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicyDefinitionVersionsGetBuiltInOptionalParams, + ) => Promise; + /** This operation retrieves a list of all the policy definition versions for the given policy definition. */ + list: ( + policyDefinitionName: string, + options?: PolicyDefinitionVersionsListOptionalParams, + ) => PagedAsyncIterableIterator; + /** This operation deletes the policy definition version in the given subscription with the given name. */ + /** + * @fixme delete is a reserved word that cannot be used as an operation name. + * Please add @clientName("clientName") or @clientName("", "javascript") + * to the operation to override the generated name. + */ + delete: ( + policyDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicyDefinitionVersionsDeleteOptionalParams, + ) => Promise; + /** This operation creates or updates a policy definition in the given subscription with the given name. */ + createOrUpdate: ( + policyDefinitionName: string, + policyDefinitionVersion: string, + parameters: PolicyDefinitionVersion, + options?: PolicyDefinitionVersionsCreateOrUpdateOptionalParams, + ) => Promise; + /** This operation retrieves the policy definition version in the given subscription with the given name. */ + get: ( + policyDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicyDefinitionVersionsGetOptionalParams, + ) => Promise; +} + +function _getPolicyDefinitionVersions(context: PolicyContext) { + return { + listAll: (options?: PolicyDefinitionVersionsListAllOptionalParams) => listAll(context, options), + listAllAtManagementGroup: ( + managementGroupName: string, + options?: PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams, + ) => listAllAtManagementGroup(context, managementGroupName, options), + listAllBuiltins: (options?: PolicyDefinitionVersionsListAllBuiltinsOptionalParams) => + listAllBuiltins(context, options), + listByManagementGroup: ( + managementGroupName: string, + policyDefinitionName: string, + options?: PolicyDefinitionVersionsListByManagementGroupOptionalParams, + ) => listByManagementGroup(context, managementGroupName, policyDefinitionName, options), + deleteAtManagementGroup: ( + managementGroupName: string, + policyDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams, + ) => + deleteAtManagementGroup( + context, + managementGroupName, + policyDefinitionName, + policyDefinitionVersion, + options, + ), + createOrUpdateAtManagementGroup: ( + managementGroupName: string, + policyDefinitionName: string, + policyDefinitionVersion: string, + parameters: PolicyDefinitionVersion, + options?: PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, + ) => + createOrUpdateAtManagementGroup( + context, + managementGroupName, + policyDefinitionName, + policyDefinitionVersion, + parameters, + options, + ), + getAtManagementGroup: ( + managementGroupName: string, + policyDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicyDefinitionVersionsGetAtManagementGroupOptionalParams, + ) => + getAtManagementGroup( + context, + managementGroupName, + policyDefinitionName, + policyDefinitionVersion, + options, + ), + listBuiltIn: ( + policyDefinitionName: string, + options?: PolicyDefinitionVersionsListBuiltInOptionalParams, + ) => listBuiltIn(context, policyDefinitionName, options), + getBuiltIn: ( + policyDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicyDefinitionVersionsGetBuiltInOptionalParams, + ) => getBuiltIn(context, policyDefinitionName, policyDefinitionVersion, options), + list: (policyDefinitionName: string, options?: PolicyDefinitionVersionsListOptionalParams) => + list(context, policyDefinitionName, options), + delete: ( + policyDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicyDefinitionVersionsDeleteOptionalParams, + ) => $delete(context, policyDefinitionName, policyDefinitionVersion, options), + createOrUpdate: ( + policyDefinitionName: string, + policyDefinitionVersion: string, + parameters: PolicyDefinitionVersion, + options?: PolicyDefinitionVersionsCreateOrUpdateOptionalParams, + ) => + createOrUpdate(context, policyDefinitionName, policyDefinitionVersion, parameters, options), + get: ( + policyDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicyDefinitionVersionsGetOptionalParams, + ) => get(context, policyDefinitionName, policyDefinitionVersion, options), + }; +} + +export function _getPolicyDefinitionVersionsOperations( + context: PolicyContext, +): PolicyDefinitionVersionsOperations { + return { + ..._getPolicyDefinitionVersions(context), + }; +} diff --git a/sdk/policy/arm-policy/src/classic/policyDefinitions/index.ts b/sdk/policy/arm-policy/src/classic/policyDefinitions/index.ts new file mode 100644 index 000000000000..43f1dad43e8f --- /dev/null +++ b/sdk/policy/arm-policy/src/classic/policyDefinitions/index.ts @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { PolicyContext } from "../../api/policyContext.js"; +import { + listByManagementGroup, + deleteAtManagementGroup, + createOrUpdateAtManagementGroup, + getAtManagementGroup, + listBuiltIn, + getBuiltIn, + list, + $delete, + createOrUpdate, + get, +} from "../../api/policyDefinitions/operations.js"; +import type { + PolicyDefinitionsListByManagementGroupOptionalParams, + PolicyDefinitionsDeleteAtManagementGroupOptionalParams, + PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, + PolicyDefinitionsGetAtManagementGroupOptionalParams, + PolicyDefinitionsListBuiltInOptionalParams, + PolicyDefinitionsGetBuiltInOptionalParams, + PolicyDefinitionsListOptionalParams, + PolicyDefinitionsDeleteOptionalParams, + PolicyDefinitionsCreateOrUpdateOptionalParams, + PolicyDefinitionsGetOptionalParams, +} from "../../api/policyDefinitions/options.js"; +import type { PolicyDefinition } from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a PolicyDefinitions operations. */ +export interface PolicyDefinitionsOperations { + /** This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. */ + listByManagementGroup: ( + managementGroupId: string, + options?: PolicyDefinitionsListByManagementGroupOptionalParams, + ) => PagedAsyncIterableIterator; + /** This operation deletes the policy definition in the given management group with the given name. */ + deleteAtManagementGroup: ( + managementGroupId: string, + policyDefinitionName: string, + options?: PolicyDefinitionsDeleteAtManagementGroupOptionalParams, + ) => Promise; + /** This operation creates or updates a policy definition in the given management group with the given name. */ + createOrUpdateAtManagementGroup: ( + managementGroupId: string, + policyDefinitionName: string, + parameters: PolicyDefinition, + options?: PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, + ) => Promise; + /** This operation retrieves the policy definition in the given management group with the given name. */ + getAtManagementGroup: ( + managementGroupId: string, + policyDefinitionName: string, + options?: PolicyDefinitionsGetAtManagementGroupOptionalParams, + ) => Promise; + /** This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. */ + listBuiltIn: ( + options?: PolicyDefinitionsListBuiltInOptionalParams, + ) => PagedAsyncIterableIterator; + /** This operation retrieves the built-in policy definition with the given name. */ + getBuiltIn: ( + policyDefinitionName: string, + options?: PolicyDefinitionsGetBuiltInOptionalParams, + ) => Promise; + /** This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. */ + list: ( + options?: PolicyDefinitionsListOptionalParams, + ) => PagedAsyncIterableIterator; + /** This operation deletes the policy definition in the given subscription with the given name. */ + /** + * @fixme delete is a reserved word that cannot be used as an operation name. + * Please add @clientName("clientName") or @clientName("", "javascript") + * to the operation to override the generated name. + */ + delete: ( + policyDefinitionName: string, + options?: PolicyDefinitionsDeleteOptionalParams, + ) => Promise; + /** This operation creates or updates a policy definition in the given subscription with the given name. */ + createOrUpdate: ( + policyDefinitionName: string, + parameters: PolicyDefinition, + options?: PolicyDefinitionsCreateOrUpdateOptionalParams, + ) => Promise; + /** This operation retrieves the policy definition in the given subscription with the given name. */ + get: ( + policyDefinitionName: string, + options?: PolicyDefinitionsGetOptionalParams, + ) => Promise; +} + +function _getPolicyDefinitions(context: PolicyContext) { + return { + listByManagementGroup: ( + managementGroupId: string, + options?: PolicyDefinitionsListByManagementGroupOptionalParams, + ) => listByManagementGroup(context, managementGroupId, options), + deleteAtManagementGroup: ( + managementGroupId: string, + policyDefinitionName: string, + options?: PolicyDefinitionsDeleteAtManagementGroupOptionalParams, + ) => deleteAtManagementGroup(context, managementGroupId, policyDefinitionName, options), + createOrUpdateAtManagementGroup: ( + managementGroupId: string, + policyDefinitionName: string, + parameters: PolicyDefinition, + options?: PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, + ) => + createOrUpdateAtManagementGroup( + context, + managementGroupId, + policyDefinitionName, + parameters, + options, + ), + getAtManagementGroup: ( + managementGroupId: string, + policyDefinitionName: string, + options?: PolicyDefinitionsGetAtManagementGroupOptionalParams, + ) => getAtManagementGroup(context, managementGroupId, policyDefinitionName, options), + listBuiltIn: (options?: PolicyDefinitionsListBuiltInOptionalParams) => + listBuiltIn(context, options), + getBuiltIn: ( + policyDefinitionName: string, + options?: PolicyDefinitionsGetBuiltInOptionalParams, + ) => getBuiltIn(context, policyDefinitionName, options), + list: (options?: PolicyDefinitionsListOptionalParams) => list(context, options), + delete: (policyDefinitionName: string, options?: PolicyDefinitionsDeleteOptionalParams) => + $delete(context, policyDefinitionName, options), + createOrUpdate: ( + policyDefinitionName: string, + parameters: PolicyDefinition, + options?: PolicyDefinitionsCreateOrUpdateOptionalParams, + ) => createOrUpdate(context, policyDefinitionName, parameters, options), + get: (policyDefinitionName: string, options?: PolicyDefinitionsGetOptionalParams) => + get(context, policyDefinitionName, options), + }; +} + +export function _getPolicyDefinitionsOperations( + context: PolicyContext, +): PolicyDefinitionsOperations { + return { + ..._getPolicyDefinitions(context), + }; +} diff --git a/sdk/policy/arm-policy/src/classic/policySetDefinitionVersions/index.ts b/sdk/policy/arm-policy/src/classic/policySetDefinitionVersions/index.ts new file mode 100644 index 000000000000..d8ab7736c989 --- /dev/null +++ b/sdk/policy/arm-policy/src/classic/policySetDefinitionVersions/index.ts @@ -0,0 +1,227 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { PolicyContext } from "../../api/policyContext.js"; +import { + listAll, + listAllAtManagementGroup, + listAllBuiltins, + listByManagementGroup, + deleteAtManagementGroup, + createOrUpdateAtManagementGroup, + getAtManagementGroup, + listBuiltIn, + getBuiltIn, + list, + $delete, + createOrUpdate, + get, +} from "../../api/policySetDefinitionVersions/operations.js"; +import type { + PolicySetDefinitionVersionsListAllOptionalParams, + PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams, + PolicySetDefinitionVersionsListAllBuiltinsOptionalParams, + PolicySetDefinitionVersionsListByManagementGroupOptionalParams, + PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams, + PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, + PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams, + PolicySetDefinitionVersionsListBuiltInOptionalParams, + PolicySetDefinitionVersionsGetBuiltInOptionalParams, + PolicySetDefinitionVersionsListOptionalParams, + PolicySetDefinitionVersionsDeleteOptionalParams, + PolicySetDefinitionVersionsCreateOrUpdateOptionalParams, + PolicySetDefinitionVersionsGetOptionalParams, +} from "../../api/policySetDefinitionVersions/options.js"; +import type { + PolicySetDefinitionVersion, + _PolicySetDefinitionVersionListResult, +} from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a PolicySetDefinitionVersions operations. */ +export interface PolicySetDefinitionVersionsOperations { + /** This operation lists all the policy set definition versions for all policy set definitions within a subscription. */ + listAll: ( + options?: PolicySetDefinitionVersionsListAllOptionalParams, + ) => Promise<_PolicySetDefinitionVersionListResult>; + /** This operation lists all the policy set definition versions for all policy set definitions at the management group scope. */ + listAllAtManagementGroup: ( + managementGroupName: string, + options?: PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams, + ) => Promise<_PolicySetDefinitionVersionListResult>; + /** This operation lists all the built-in policy set definition versions for all built-in policy set definitions. */ + listAllBuiltins: ( + options?: PolicySetDefinitionVersionsListAllBuiltinsOptionalParams, + ) => Promise<_PolicySetDefinitionVersionListResult>; + /** This operation retrieves a list of all the policy set definition versions for the given policy set definition in a given management group. */ + listByManagementGroup: ( + managementGroupName: string, + policySetDefinitionName: string, + options?: PolicySetDefinitionVersionsListByManagementGroupOptionalParams, + ) => PagedAsyncIterableIterator; + /** This operation deletes the policy set definition version in the given management group with the given name and version. */ + deleteAtManagementGroup: ( + managementGroupName: string, + policySetDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams, + ) => Promise; + /** This operation creates or updates a policy set definition version in the given management group with the given name and version. */ + createOrUpdateAtManagementGroup: ( + managementGroupName: string, + policySetDefinitionName: string, + policyDefinitionVersion: string, + parameters: PolicySetDefinitionVersion, + options?: PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, + ) => Promise; + /** This operation retrieves the policy set definition version in the given management group with the given name and version. */ + getAtManagementGroup: ( + managementGroupName: string, + policySetDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams, + ) => Promise; + /** This operation retrieves a list of all the built-in policy set definition versions for the given built-in policy set definition. */ + listBuiltIn: ( + policySetDefinitionName: string, + options?: PolicySetDefinitionVersionsListBuiltInOptionalParams, + ) => PagedAsyncIterableIterator; + /** This operation retrieves the built-in policy set definition version with the given name and version. */ + getBuiltIn: ( + policySetDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicySetDefinitionVersionsGetBuiltInOptionalParams, + ) => Promise; + /** This operation retrieves a list of all the policy set definition versions for the given policy set definition. */ + list: ( + policySetDefinitionName: string, + options?: PolicySetDefinitionVersionsListOptionalParams, + ) => PagedAsyncIterableIterator; + /** This operation deletes the policy set definition version in the given subscription with the given name and version. */ + /** + * @fixme delete is a reserved word that cannot be used as an operation name. + * Please add @clientName("clientName") or @clientName("", "javascript") + * to the operation to override the generated name. + */ + delete: ( + policySetDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicySetDefinitionVersionsDeleteOptionalParams, + ) => Promise; + /** This operation creates or updates a policy set definition version in the given subscription with the given name and version. */ + createOrUpdate: ( + policySetDefinitionName: string, + policyDefinitionVersion: string, + parameters: PolicySetDefinitionVersion, + options?: PolicySetDefinitionVersionsCreateOrUpdateOptionalParams, + ) => Promise; + /** This operation retrieves the policy set definition version in the given subscription with the given name and version. */ + get: ( + policySetDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicySetDefinitionVersionsGetOptionalParams, + ) => Promise; +} + +function _getPolicySetDefinitionVersions(context: PolicyContext) { + return { + listAll: (options?: PolicySetDefinitionVersionsListAllOptionalParams) => + listAll(context, options), + listAllAtManagementGroup: ( + managementGroupName: string, + options?: PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams, + ) => listAllAtManagementGroup(context, managementGroupName, options), + listAllBuiltins: (options?: PolicySetDefinitionVersionsListAllBuiltinsOptionalParams) => + listAllBuiltins(context, options), + listByManagementGroup: ( + managementGroupName: string, + policySetDefinitionName: string, + options?: PolicySetDefinitionVersionsListByManagementGroupOptionalParams, + ) => listByManagementGroup(context, managementGroupName, policySetDefinitionName, options), + deleteAtManagementGroup: ( + managementGroupName: string, + policySetDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams, + ) => + deleteAtManagementGroup( + context, + managementGroupName, + policySetDefinitionName, + policyDefinitionVersion, + options, + ), + createOrUpdateAtManagementGroup: ( + managementGroupName: string, + policySetDefinitionName: string, + policyDefinitionVersion: string, + parameters: PolicySetDefinitionVersion, + options?: PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, + ) => + createOrUpdateAtManagementGroup( + context, + managementGroupName, + policySetDefinitionName, + policyDefinitionVersion, + parameters, + options, + ), + getAtManagementGroup: ( + managementGroupName: string, + policySetDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams, + ) => + getAtManagementGroup( + context, + managementGroupName, + policySetDefinitionName, + policyDefinitionVersion, + options, + ), + listBuiltIn: ( + policySetDefinitionName: string, + options?: PolicySetDefinitionVersionsListBuiltInOptionalParams, + ) => listBuiltIn(context, policySetDefinitionName, options), + getBuiltIn: ( + policySetDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicySetDefinitionVersionsGetBuiltInOptionalParams, + ) => getBuiltIn(context, policySetDefinitionName, policyDefinitionVersion, options), + list: ( + policySetDefinitionName: string, + options?: PolicySetDefinitionVersionsListOptionalParams, + ) => list(context, policySetDefinitionName, options), + delete: ( + policySetDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicySetDefinitionVersionsDeleteOptionalParams, + ) => $delete(context, policySetDefinitionName, policyDefinitionVersion, options), + createOrUpdate: ( + policySetDefinitionName: string, + policyDefinitionVersion: string, + parameters: PolicySetDefinitionVersion, + options?: PolicySetDefinitionVersionsCreateOrUpdateOptionalParams, + ) => + createOrUpdate( + context, + policySetDefinitionName, + policyDefinitionVersion, + parameters, + options, + ), + get: ( + policySetDefinitionName: string, + policyDefinitionVersion: string, + options?: PolicySetDefinitionVersionsGetOptionalParams, + ) => get(context, policySetDefinitionName, policyDefinitionVersion, options), + }; +} + +export function _getPolicySetDefinitionVersionsOperations( + context: PolicyContext, +): PolicySetDefinitionVersionsOperations { + return { + ..._getPolicySetDefinitionVersions(context), + }; +} diff --git a/sdk/policy/arm-policy/src/classic/policySetDefinitions/index.ts b/sdk/policy/arm-policy/src/classic/policySetDefinitions/index.ts new file mode 100644 index 000000000000..5932a34799cb --- /dev/null +++ b/sdk/policy/arm-policy/src/classic/policySetDefinitions/index.ts @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { PolicyContext } from "../../api/policyContext.js"; +import { + listByManagementGroup, + deleteAtManagementGroup, + createOrUpdateAtManagementGroup, + getAtManagementGroup, + listBuiltIn, + getBuiltIn, + list, + $delete, + createOrUpdate, + get, +} from "../../api/policySetDefinitions/operations.js"; +import type { + PolicySetDefinitionsListByManagementGroupOptionalParams, + PolicySetDefinitionsDeleteAtManagementGroupOptionalParams, + PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, + PolicySetDefinitionsGetAtManagementGroupOptionalParams, + PolicySetDefinitionsListBuiltInOptionalParams, + PolicySetDefinitionsGetBuiltInOptionalParams, + PolicySetDefinitionsListOptionalParams, + PolicySetDefinitionsDeleteOptionalParams, + PolicySetDefinitionsCreateOrUpdateOptionalParams, + PolicySetDefinitionsGetOptionalParams, +} from "../../api/policySetDefinitions/options.js"; +import type { PolicySetDefinition } from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a PolicySetDefinitions operations. */ +export interface PolicySetDefinitionsOperations { + /** This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. */ + listByManagementGroup: ( + managementGroupId: string, + options?: PolicySetDefinitionsListByManagementGroupOptionalParams, + ) => PagedAsyncIterableIterator; + /** This operation deletes the policy set definition in the given management group with the given name. */ + deleteAtManagementGroup: ( + managementGroupId: string, + policySetDefinitionName: string, + options?: PolicySetDefinitionsDeleteAtManagementGroupOptionalParams, + ) => Promise; + /** This operation creates or updates a policy set definition in the given management group with the given name. */ + createOrUpdateAtManagementGroup: ( + managementGroupId: string, + policySetDefinitionName: string, + parameters: PolicySetDefinition, + options?: PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, + ) => Promise; + /** This operation retrieves the policy set definition in the given management group with the given name. */ + getAtManagementGroup: ( + managementGroupId: string, + policySetDefinitionName: string, + options?: PolicySetDefinitionsGetAtManagementGroupOptionalParams, + ) => Promise; + /** This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. */ + listBuiltIn: ( + options?: PolicySetDefinitionsListBuiltInOptionalParams, + ) => PagedAsyncIterableIterator; + /** This operation retrieves the built-in policy set definition with the given name. */ + getBuiltIn: ( + policySetDefinitionName: string, + options?: PolicySetDefinitionsGetBuiltInOptionalParams, + ) => Promise; + /** This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. */ + list: ( + options?: PolicySetDefinitionsListOptionalParams, + ) => PagedAsyncIterableIterator; + /** This operation deletes the policy set definition in the given subscription with the given name. */ + /** + * @fixme delete is a reserved word that cannot be used as an operation name. + * Please add @clientName("clientName") or @clientName("", "javascript") + * to the operation to override the generated name. + */ + delete: ( + policySetDefinitionName: string, + options?: PolicySetDefinitionsDeleteOptionalParams, + ) => Promise; + /** This operation creates or updates a policy set definition in the given subscription with the given name. */ + createOrUpdate: ( + policySetDefinitionName: string, + parameters: PolicySetDefinition, + options?: PolicySetDefinitionsCreateOrUpdateOptionalParams, + ) => Promise; + /** This operation retrieves the policy set definition in the given subscription with the given name. */ + get: ( + policySetDefinitionName: string, + options?: PolicySetDefinitionsGetOptionalParams, + ) => Promise; +} + +function _getPolicySetDefinitions(context: PolicyContext) { + return { + listByManagementGroup: ( + managementGroupId: string, + options?: PolicySetDefinitionsListByManagementGroupOptionalParams, + ) => listByManagementGroup(context, managementGroupId, options), + deleteAtManagementGroup: ( + managementGroupId: string, + policySetDefinitionName: string, + options?: PolicySetDefinitionsDeleteAtManagementGroupOptionalParams, + ) => deleteAtManagementGroup(context, managementGroupId, policySetDefinitionName, options), + createOrUpdateAtManagementGroup: ( + managementGroupId: string, + policySetDefinitionName: string, + parameters: PolicySetDefinition, + options?: PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, + ) => + createOrUpdateAtManagementGroup( + context, + managementGroupId, + policySetDefinitionName, + parameters, + options, + ), + getAtManagementGroup: ( + managementGroupId: string, + policySetDefinitionName: string, + options?: PolicySetDefinitionsGetAtManagementGroupOptionalParams, + ) => getAtManagementGroup(context, managementGroupId, policySetDefinitionName, options), + listBuiltIn: (options?: PolicySetDefinitionsListBuiltInOptionalParams) => + listBuiltIn(context, options), + getBuiltIn: ( + policySetDefinitionName: string, + options?: PolicySetDefinitionsGetBuiltInOptionalParams, + ) => getBuiltIn(context, policySetDefinitionName, options), + list: (options?: PolicySetDefinitionsListOptionalParams) => list(context, options), + delete: (policySetDefinitionName: string, options?: PolicySetDefinitionsDeleteOptionalParams) => + $delete(context, policySetDefinitionName, options), + createOrUpdate: ( + policySetDefinitionName: string, + parameters: PolicySetDefinition, + options?: PolicySetDefinitionsCreateOrUpdateOptionalParams, + ) => createOrUpdate(context, policySetDefinitionName, parameters, options), + get: (policySetDefinitionName: string, options?: PolicySetDefinitionsGetOptionalParams) => + get(context, policySetDefinitionName, options), + }; +} + +export function _getPolicySetDefinitionsOperations( + context: PolicyContext, +): PolicySetDefinitionsOperations { + return { + ..._getPolicySetDefinitions(context), + }; +} diff --git a/sdk/policy/arm-policy/src/classic/policyTokens/index.ts b/sdk/policy/arm-policy/src/classic/policyTokens/index.ts new file mode 100644 index 000000000000..f9dc255ac172 --- /dev/null +++ b/sdk/policy/arm-policy/src/classic/policyTokens/index.ts @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { PolicyContext } from "../../api/policyContext.js"; +import { acquireAtManagementGroup, acquire } from "../../api/policyTokens/operations.js"; +import type { + PolicyTokensAcquireAtManagementGroupOptionalParams, + PolicyTokensAcquireOptionalParams, +} from "../../api/policyTokens/options.js"; +import type { PolicyTokenRequest, PolicyTokenResponse } from "../../models/models.js"; + +/** Interface representing a PolicyTokens operations. */ +export interface PolicyTokensOperations { + /** This operation acquires a policy token in the given management group for the given request body. */ + acquireAtManagementGroup: ( + managementGroupName: string, + parameters: PolicyTokenRequest, + options?: PolicyTokensAcquireAtManagementGroupOptionalParams, + ) => Promise; + /** This operation acquires a policy token in the given subscription for the given request body. */ + acquire: ( + parameters: PolicyTokenRequest, + options?: PolicyTokensAcquireOptionalParams, + ) => Promise; +} + +function _getPolicyTokens(context: PolicyContext) { + return { + acquireAtManagementGroup: ( + managementGroupName: string, + parameters: PolicyTokenRequest, + options?: PolicyTokensAcquireAtManagementGroupOptionalParams, + ) => acquireAtManagementGroup(context, managementGroupName, parameters, options), + acquire: (parameters: PolicyTokenRequest, options?: PolicyTokensAcquireOptionalParams) => + acquire(context, parameters, options), + }; +} + +export function _getPolicyTokensOperations(context: PolicyContext): PolicyTokensOperations { + return { + ..._getPolicyTokens(context), + }; +} diff --git a/sdk/policy/arm-policy/src/index.ts b/sdk/policy/arm-policy/src/index.ts index 3f936f83fead..6e548e934146 100644 --- a/sdk/policy/arm-policy/src/index.ts +++ b/sdk/policy/arm-policy/src/index.ts @@ -1,13 +1,149 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { AzureClouds, AzureSupportedClouds } from "./static-helpers/cloudSettingHelpers.js"; +import { + PageSettings, + ContinuablePage, + PagedAsyncIterableIterator, +} from "./static-helpers/pagingHelpers.js"; -/// -export { getContinuationToken } from "./pagingHelper.js"; -export * from "./models/index.js"; export { PolicyClient } from "./policyClient.js"; -export * from "./operationsInterfaces/index.js"; +export { + PolicyAssignment, + PolicyAssignmentProperties, + ParameterValuesValue, + KnownEnforcementMode, + EnforcementMode, + NonComplianceMessage, + ResourceSelector, + Selector, + KnownSelectorKind, + SelectorKind, + Override, + KnownOverrideKind, + OverrideKind, + KnownAssignmentType, + AssignmentType, + Identity, + ResourceIdentityType, + UserAssignedIdentitiesValue, + ExtensionResource, + Resource, + SystemData, + KnownCreatedByType, + CreatedByType, + ErrorResponse, + ErrorDetail, + ErrorAdditionalInfo, + PolicyAssignmentUpdate, + PolicyAssignmentUpdateProperties, + PolicyDefinition, + PolicyDefinitionProperties, + KnownPolicyType, + PolicyType, + ParameterDefinitionsValue, + KnownParameterType, + ParameterType, + ParameterDefinitionsValueMetadata, + ExternalEvaluationEnforcementSettings, + ExternalEvaluationEndpointSettings, + ProxyResource, + PolicyDefinitionVersion, + PolicyDefinitionVersionProperties, + PolicySetDefinition, + PolicySetDefinitionProperties, + PolicyDefinitionReference, + PolicyDefinitionGroup, + PolicySetDefinitionVersion, + PolicySetDefinitionVersionProperties, + PolicyTokenRequest, + PolicyTokenOperation, + PolicyTokenResponse, + KnownPolicyTokenResult, + PolicyTokenResult, + ExternalEvaluationEndpointInvocationResult, + PolicyLogInfo, + KnownExternalEndpointResult, + ExternalEndpointResult, + KnownVersions, +} from "./models/index.js"; +export { PolicyClientOptionalParams } from "./api/index.js"; +export { + PolicyAssignmentsListForResourceOptionalParams, + PolicyAssignmentsListOptionalParams, + PolicyAssignmentsListForManagementGroupOptionalParams, + PolicyAssignmentsListForResourceGroupOptionalParams, + PolicyAssignmentsDeleteOptionalParams, + PolicyAssignmentsUpdateOptionalParams, + PolicyAssignmentsCreateOptionalParams, + PolicyAssignmentsGetOptionalParams, +} from "./api/policyAssignments/index.js"; +export { + PolicyDefinitionsListByManagementGroupOptionalParams, + PolicyDefinitionsDeleteAtManagementGroupOptionalParams, + PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, + PolicyDefinitionsGetAtManagementGroupOptionalParams, + PolicyDefinitionsListBuiltInOptionalParams, + PolicyDefinitionsGetBuiltInOptionalParams, + PolicyDefinitionsListOptionalParams, + PolicyDefinitionsDeleteOptionalParams, + PolicyDefinitionsCreateOrUpdateOptionalParams, + PolicyDefinitionsGetOptionalParams, +} from "./api/policyDefinitions/index.js"; +export { + PolicyDefinitionVersionsListAllOptionalParams, + PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams, + PolicyDefinitionVersionsListAllBuiltinsOptionalParams, + PolicyDefinitionVersionsListByManagementGroupOptionalParams, + PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams, + PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, + PolicyDefinitionVersionsGetAtManagementGroupOptionalParams, + PolicyDefinitionVersionsListBuiltInOptionalParams, + PolicyDefinitionVersionsGetBuiltInOptionalParams, + PolicyDefinitionVersionsListOptionalParams, + PolicyDefinitionVersionsDeleteOptionalParams, + PolicyDefinitionVersionsCreateOrUpdateOptionalParams, + PolicyDefinitionVersionsGetOptionalParams, +} from "./api/policyDefinitionVersions/index.js"; +export { + PolicySetDefinitionsListByManagementGroupOptionalParams, + PolicySetDefinitionsDeleteAtManagementGroupOptionalParams, + PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, + PolicySetDefinitionsGetAtManagementGroupOptionalParams, + PolicySetDefinitionsListBuiltInOptionalParams, + PolicySetDefinitionsGetBuiltInOptionalParams, + PolicySetDefinitionsListOptionalParams, + PolicySetDefinitionsDeleteOptionalParams, + PolicySetDefinitionsCreateOrUpdateOptionalParams, + PolicySetDefinitionsGetOptionalParams, +} from "./api/policySetDefinitions/index.js"; +export { + PolicySetDefinitionVersionsListAllOptionalParams, + PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams, + PolicySetDefinitionVersionsListAllBuiltinsOptionalParams, + PolicySetDefinitionVersionsListByManagementGroupOptionalParams, + PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams, + PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, + PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams, + PolicySetDefinitionVersionsListBuiltInOptionalParams, + PolicySetDefinitionVersionsGetBuiltInOptionalParams, + PolicySetDefinitionVersionsListOptionalParams, + PolicySetDefinitionVersionsDeleteOptionalParams, + PolicySetDefinitionVersionsCreateOrUpdateOptionalParams, + PolicySetDefinitionVersionsGetOptionalParams, +} from "./api/policySetDefinitionVersions/index.js"; +export { + PolicyTokensAcquireAtManagementGroupOptionalParams, + PolicyTokensAcquireOptionalParams, +} from "./api/policyTokens/index.js"; +export { + PolicyAssignmentsOperations, + PolicyDefinitionsOperations, + PolicyDefinitionVersionsOperations, + PolicySetDefinitionsOperations, + PolicySetDefinitionVersionsOperations, + PolicyTokensOperations, +} from "./classic/index.js"; +export { PageSettings, ContinuablePage, PagedAsyncIterableIterator }; +export { AzureClouds, AzureSupportedClouds }; diff --git a/sdk/policy/arm-policy/src/logger.ts b/sdk/policy/arm-policy/src/logger.ts new file mode 100644 index 000000000000..286b91ee1c2e --- /dev/null +++ b/sdk/policy/arm-policy/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-policy"); diff --git a/sdk/policy/arm-policy/src/models/index.ts b/sdk/policy/arm-policy/src/models/index.ts index 7c4e42df2a4e..037230881fbe 100644 --- a/sdk/policy/arm-policy/src/models/index.ts +++ b/sdk/policy/arm-policy/src/models/index.ts @@ -1,1264 +1,62 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type * as coreClient from "@azure/core-client"; - -/** The policy definition. */ -export interface PolicyDefinition { - /** - * The ID of the policy definition. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly id?: string; - /** - * The name of the policy definition. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly name?: string; - /** - * The type of the resource (Microsoft.Authorization/policyDefinitions). - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly type?: string; - /** - * The system metadata relating to this resource. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly systemData?: SystemData; - /** The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. */ - policyType?: PolicyType; - /** The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. */ - mode?: string; - /** The display name of the policy definition. */ - displayName?: string; - /** The policy definition description. */ - description?: string; - /** The policy rule. */ - policyRule?: any; - /** The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. */ - metadata?: any; - /** The parameter definitions for parameters used in the policy rule. The keys are the parameter names. */ - parameters?: { [propertyName: string]: ParameterDefinitionsValue }; - /** The policy definition version in #.#.# format. */ - version?: string; - /** A list of available versions for this policy definition. */ - versions?: string[]; -} - -/** The definition of a parameter that can be provided to the policy. */ -export interface ParameterDefinitionsValue { - /** The data type of the parameter. */ - type?: ParameterType; - /** The allowed values for the parameter. */ - allowedValues?: any[]; - /** The default value for the parameter if no value is provided. */ - defaultValue?: any; - /** Provides validation of parameter inputs during assignment using a self-defined JSON schema. This property is only supported for object-type parameters and follows the Json.NET Schema 2019-09 implementation. You can learn more about using schemas at https://json-schema.org/ and test draft schemas at https://www.jsonschemavalidator.net/. */ - schema?: any; - /** General metadata for the parameter. */ - metadata?: ParameterDefinitionsValueMetadata; -} - -/** General metadata for the parameter. */ -export interface ParameterDefinitionsValueMetadata { - /** Describes unknown properties. The value of an unknown property can be of "any" type. */ - [property: string]: any; - /** The display name for the parameter. */ - displayName?: string; - /** The description of the parameter. */ - description?: string; - /** Used when assigning the policy definition through the portal. Provides a context aware list of values for the user to choose from. */ - strongType?: string; - /** Set to true to have Azure portal create role assignments on the resource ID or resource scope value of this parameter during policy assignment. This property is useful in case you wish to assign permissions outside the assignment scope. */ - assignPermissions?: boolean; -} - -/** 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; -} - -/** An error response from a policy operation. */ -export interface CloudError { - /** Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.) */ - error?: ErrorResponse; -} - -/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.) */ -export interface ErrorResponse { - /** - * The error code. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly code?: string; - /** - * The error message. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly message?: string; - /** - * The error target. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly target?: string; - /** - * The error details. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly details?: ErrorResponse[]; - /** - * The error additional info. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly additionalInfo?: ErrorAdditionalInfo[]; -} - -/** The resource management error additional info. */ -export interface ErrorAdditionalInfo { - /** - * The additional info type. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly type?: string; - /** - * The additional info. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly info?: any; -} - -/** List of policy definitions. */ -export interface PolicyDefinitionListResult { - /** An array of policy definitions. */ - value?: PolicyDefinition[]; - /** The URL to use for getting the next set of results. */ - nextLink?: string; -} - -/** List of policy definition versions. */ -export interface PolicyDefinitionVersionListResult { - /** An array of policy definitions versions. */ - value?: PolicyDefinitionVersion[]; - /** The URL to use for getting the next set of results. */ - nextLink?: string; -} - -/** The ID of the policy definition version. */ -export interface PolicyDefinitionVersion { - /** - * The ID of the policy definition version. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly id?: string; - /** - * The name of the policy definition version. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly name?: string; - /** - * The type of the resource (Microsoft.Authorization/policyDefinitions/versions). - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly type?: string; - /** - * The system metadata relating to this resource. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly systemData?: SystemData; - /** The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. */ - policyType?: PolicyType; - /** The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. */ - mode?: string; - /** The display name of the policy definition. */ - displayName?: string; - /** The policy definition description. */ - description?: string; - /** The policy rule. */ - policyRule?: any; - /** The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. */ - metadata?: any; - /** The parameter definitions for parameters used in the policy rule. The keys are the parameter names. */ - parameters?: { [propertyName: string]: ParameterDefinitionsValue }; - /** The policy definition version in #.#.# format. */ - version?: string; -} - -/** The policy set definition. */ -export interface PolicySetDefinition { - /** - * The ID of the policy set definition. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly id?: string; - /** - * The name of the policy set definition. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly name?: string; - /** - * The type of the resource (Microsoft.Authorization/policySetDefinitions). - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly type?: string; - /** - * The system metadata relating to this resource. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly systemData?: SystemData; - /** The type of policy set definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. */ - policyType?: PolicyType; - /** The display name of the policy set definition. */ - displayName?: string; - /** The policy set definition description. */ - description?: string; - /** The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. */ - metadata?: any; - /** The policy set definition parameters that can be used in policy definition references. */ - parameters?: { [propertyName: string]: ParameterDefinitionsValue }; - /** An array of policy definition references. */ - policyDefinitions?: PolicyDefinitionReference[]; - /** The metadata describing groups of policy definition references within the policy set definition. */ - policyDefinitionGroups?: PolicyDefinitionGroup[]; - /** The policy set definition version in #.#.# format. */ - version?: string; - /** A list of available versions for this policy set definition. */ - versions?: string[]; -} - -/** The policy definition reference. */ -export interface PolicyDefinitionReference { - /** The ID of the policy definition or policy set definition. */ - policyDefinitionId: string; - /** The version of the policy definition to use. */ - definitionVersion?: string; - /** - * The latest version of the policy definition available. This is only present if requested via the $expand query parameter. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly latestDefinitionVersion?: string; - /** - * The effective version of the policy definition in use. This is only present if requested via the $expand query parameter. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly effectiveDefinitionVersion?: string; - /** The parameter values for the referenced policy rule. The keys are the parameter names. */ - parameters?: { [propertyName: string]: ParameterValuesValue }; - /** A unique id (within the policy set definition) for this policy definition reference. */ - policyDefinitionReferenceId?: string; - /** The name of the groups that this policy definition reference belongs to. */ - groupNames?: string[]; -} - -/** The value of a parameter. */ -export interface ParameterValuesValue { - /** The value of the parameter. */ - value?: any; -} - -/** The policy definition group. */ -export interface PolicyDefinitionGroup { - /** The name of the group. */ - name: string; - /** The group's display name. */ - displayName?: string; - /** The group's category. */ - category?: string; - /** The group's description. */ - description?: string; - /** A resource ID of a resource that contains additional metadata about the group. */ - additionalMetadataId?: string; -} - -/** List of policy set definitions. */ -export interface PolicySetDefinitionListResult { - /** An array of policy set definitions. */ - value?: PolicySetDefinition[]; - /** The URL to use for getting the next set of results. */ - nextLink?: string; -} - -/** List of policy set definition versions. */ -export interface PolicySetDefinitionVersionListResult { - /** An array of policy set definition versions. */ - value?: PolicySetDefinitionVersion[]; - /** The URL to use for getting the next set of results. */ - nextLink?: string; -} - -/** The policy set definition version. */ -export interface PolicySetDefinitionVersion { - /** - * The ID of the policy set definition version. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly id?: string; - /** - * The name of the policy set definition version. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly name?: string; - /** - * The type of the resource (Microsoft.Authorization/policySetDefinitions/versions). - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly type?: string; - /** - * The system metadata relating to this resource. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly systemData?: SystemData; - /** The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. */ - policyType?: PolicyType; - /** The display name of the policy set definition. */ - displayName?: string; - /** The policy set definition description. */ - description?: string; - /** The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. */ - metadata?: any; - /** The policy set definition parameters that can be used in policy definition references. */ - parameters?: { [propertyName: string]: ParameterDefinitionsValue }; - /** An array of policy definition references. */ - policyDefinitions?: PolicyDefinitionReference[]; - /** The metadata describing groups of policy definition references within the policy set definition. */ - policyDefinitionGroups?: PolicyDefinitionGroup[]; - /** The policy set definition version in #.#.# format. */ - version?: string; -} - -/** The policy assignment. */ -export interface PolicyAssignment { - /** - * The ID of the policy assignment. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly id?: string; - /** - * The type of the policy assignment. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly type?: string; - /** - * The name of the policy assignment. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly name?: string; - /** The location of the policy assignment. Only required when utilizing managed identity. */ - location?: string; - /** The managed identity associated with the policy assignment. */ - identity?: Identity; - /** - * The system metadata relating to this resource. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly systemData?: SystemData; - /** The display name of the policy assignment. */ - displayName?: string; - /** The ID of the policy definition or policy set definition being assigned. */ - policyDefinitionId?: string; - /** The version of the policy definition to use. */ - definitionVersion?: string; - /** - * The latest version of the policy definition available. This is only present if requested via the $expand query parameter. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly latestDefinitionVersion?: string; - /** - * The effective version of the policy definition in use. This is only present if requested via the $expand query parameter. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly effectiveDefinitionVersion?: string; - /** - * The scope for the policy assignment. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly scope?: string; - /** The policy's excluded scopes. */ - notScopes?: string[]; - /** The parameter values for the assigned policy rule. The keys are the parameter names. */ - parameters?: { [propertyName: string]: ParameterValuesValue }; - /** This message will be part of response in case of policy violation. */ - description?: string; - /** The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. */ - metadata?: any; - /** The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. */ - enforcementMode?: EnforcementMode; - /** The messages that describe why a resource is non-compliant with the policy. */ - nonComplianceMessages?: NonComplianceMessage[]; - /** The resource selector list to filter policies by resource properties. */ - resourceSelectors?: ResourceSelector[]; - /** The policy property value override. */ - overrides?: Override[]; - /** The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable. */ - assignmentType?: AssignmentType; -} - -/** A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results. */ -export interface NonComplianceMessage { - /** A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results. */ - message: string; - /** The policy definition reference ID within a policy set definition the message is intended for. This is only applicable if the policy assignment assigns a policy set definition. If this is not provided the message applies to all policies assigned by this policy assignment. */ - policyDefinitionReferenceId?: string; -} - -/** The resource selector to filter policies by resource properties. */ -export interface ResourceSelector { - /** The name of the resource selector. */ - name?: string; - /** The list of the selector expressions. */ - selectors?: Selector[]; -} - -/** The selector expression. */ -export interface Selector { - /** The selector kind. */ - kind?: SelectorKind; - /** The list of values to filter in. */ - in?: string[]; - /** The list of values to filter out. */ - notIn?: string[]; -} - -/** The policy property value override. */ -export interface Override { - /** The override kind. */ - kind?: OverrideKind; - /** The value to override the policy property. */ - value?: string; - /** The list of the selector expressions. */ - selectors?: Selector[]; -} - -/** Identity for the resource. Policy assignments support a maximum of one identity. That is either a system assigned identity or a single user assigned identity. */ -export interface Identity { - /** - * The principal ID of the resource identity. This property will only be provided for a system assigned identity - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly principalId?: string; - /** - * The tenant ID of the resource identity. This property will only be provided for a system assigned identity - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly tenantId?: string; - /** The identity type. This is the only required field when adding a system or user assigned identity to a resource. */ - type?: ResourceIdentityType; - /** The user identity associated with the policy. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. */ - userAssignedIdentities?: { - [propertyName: string]: UserAssignedIdentitiesValue; - }; -} - -export interface UserAssignedIdentitiesValue { - /** - * The principal id of user assigned identity. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly principalId?: string; - /** - * The client id of user assigned identity. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly clientId?: string; -} - -/** The policy assignment for Patch request. */ -export interface PolicyAssignmentUpdate { - /** The location of the policy assignment. Only required when utilizing managed identity. */ - location?: string; - /** The managed identity associated with the policy assignment. */ - identity?: Identity; - /** The resource selector list to filter policies by resource properties. */ - resourceSelectors?: ResourceSelector[]; - /** The policy property value override. */ - overrides?: Override[]; -} - -/** List of policy assignments. */ -export interface PolicyAssignmentListResult { - /** An array of policy assignments. */ - value?: PolicyAssignment[]; - /** The URL to use for getting the next set of results. */ - nextLink?: string; -} - -/** Known values of {@link PolicyType} that the service accepts. */ -export enum KnownPolicyType { - /** NotSpecified */ - NotSpecified = "NotSpecified", - /** BuiltIn */ - BuiltIn = "BuiltIn", - /** Custom */ - Custom = "Custom", - /** Static */ - Static = "Static", -} - -/** - * Defines values for PolicyType. \ - * {@link KnownPolicyType} can be used interchangeably with PolicyType, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **NotSpecified** \ - * **BuiltIn** \ - * **Custom** \ - * **Static** - */ -export type PolicyType = string; - -/** Known values of {@link ParameterType} that the service accepts. */ -export enum KnownParameterType { - /** String */ - String = "String", - /** Array */ - Array = "Array", - /** Object */ - Object = "Object", - /** Boolean */ - Boolean = "Boolean", - /** Integer */ - Integer = "Integer", - /** Float */ - Float = "Float", - /** DateTime */ - DateTime = "DateTime", -} - -/** - * Defines values for ParameterType. \ - * {@link KnownParameterType} can be used interchangeably with ParameterType, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **String** \ - * **Array** \ - * **Object** \ - * **Boolean** \ - * **Integer** \ - * **Float** \ - * **DateTime** - */ -export type ParameterType = string; - -/** Known values of {@link CreatedByType} that the service accepts. */ -export enum KnownCreatedByType { - /** User */ - User = "User", - /** Application */ - Application = "Application", - /** ManagedIdentity */ - ManagedIdentity = "ManagedIdentity", - /** Key */ - Key = "Key", -} - -/** - * Defines values for CreatedByType. \ - * {@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** \ - * **Application** \ - * **ManagedIdentity** \ - * **Key** - */ -export type CreatedByType = string; - -/** Known values of {@link EnforcementMode} that the service accepts. */ -export enum KnownEnforcementMode { - /** The policy effect is enforced during resource creation or update. */ - Default = "Default", - /** The policy effect is not enforced during resource creation or update. */ - DoNotEnforce = "DoNotEnforce", -} - -/** - * Defines values for EnforcementMode. \ - * {@link KnownEnforcementMode} can be used interchangeably with EnforcementMode, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **Default**: The policy effect is enforced during resource creation or update. \ - * **DoNotEnforce**: The policy effect is not enforced during resource creation or update. - */ -export type EnforcementMode = string; - -/** Known values of {@link SelectorKind} that the service accepts. */ -export enum KnownSelectorKind { - /** The selector kind to filter policies by the resource location. */ - ResourceLocation = "resourceLocation", - /** The selector kind to filter policies by the resource type. */ - ResourceType = "resourceType", - /** The selector kind to filter policies by the resource without location. */ - ResourceWithoutLocation = "resourceWithoutLocation", - /** The selector kind to filter policies by the policy definition reference ID. */ - PolicyDefinitionReferenceId = "policyDefinitionReferenceId", -} - -/** - * Defines values for SelectorKind. \ - * {@link KnownSelectorKind} can be used interchangeably with SelectorKind, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **resourceLocation**: The selector kind to filter policies by the resource location. \ - * **resourceType**: The selector kind to filter policies by the resource type. \ - * **resourceWithoutLocation**: The selector kind to filter policies by the resource without location. \ - * **policyDefinitionReferenceId**: The selector kind to filter policies by the policy definition reference ID. - */ -export type SelectorKind = string; - -/** Known values of {@link OverrideKind} that the service accepts. */ -export enum KnownOverrideKind { - /** It will override the policy effect type. */ - PolicyEffect = "policyEffect", - /** It will override the definition version property value of the policy assignment. */ - DefinitionVersion = "definitionVersion", -} - -/** - * Defines values for OverrideKind. \ - * {@link KnownOverrideKind} can be used interchangeably with OverrideKind, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **policyEffect**: It will override the policy effect type. \ - * **definitionVersion**: It will override the definition version property value of the policy assignment. - */ -export type OverrideKind = string; - -/** Known values of {@link AssignmentType} that the service accepts. */ -export enum KnownAssignmentType { - /** NotSpecified */ - NotSpecified = "NotSpecified", - /** System */ - System = "System", - /** SystemHidden */ - SystemHidden = "SystemHidden", - /** Custom */ - Custom = "Custom", -} - -/** - * Defines values for AssignmentType. \ - * {@link KnownAssignmentType} can be used interchangeably with AssignmentType, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **NotSpecified** \ - * **System** \ - * **SystemHidden** \ - * **Custom** - */ -export type AssignmentType = string; -/** Defines values for ResourceIdentityType. */ -export type ResourceIdentityType = "SystemAssigned" | "UserAssigned" | "None"; - -/** Optional parameters. */ -export interface PolicyDefinitionsCreateOrUpdateOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the createOrUpdate operation. */ -export type PolicyDefinitionsCreateOrUpdateResponse = PolicyDefinition; - -/** Optional parameters. */ -export interface PolicyDefinitionsDeleteOptionalParams extends coreClient.OperationOptions {} - -/** Optional parameters. */ -export interface PolicyDefinitionsGetOptionalParams extends coreClient.OperationOptions {} - -/** Contains response data for the get operation. */ -export type PolicyDefinitionsGetResponse = PolicyDefinition; - -/** Optional parameters. */ -export interface PolicyDefinitionsGetBuiltInOptionalParams extends coreClient.OperationOptions {} - -/** Contains response data for the getBuiltIn operation. */ -export type PolicyDefinitionsGetBuiltInResponse = PolicyDefinition; - -/** Optional parameters. */ -export interface PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the createOrUpdateAtManagementGroup operation. */ -export type PolicyDefinitionsCreateOrUpdateAtManagementGroupResponse = PolicyDefinition; - -/** Optional parameters. */ -export interface PolicyDefinitionsDeleteAtManagementGroupOptionalParams - extends coreClient.OperationOptions {} - -/** Optional parameters. */ -export interface PolicyDefinitionsGetAtManagementGroupOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the getAtManagementGroup operation. */ -export type PolicyDefinitionsGetAtManagementGroupResponse = PolicyDefinition; - -/** Optional parameters. */ -export interface PolicyDefinitionsListOptionalParams extends coreClient.OperationOptions { - /** The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given scope. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. */ - filter?: string; - /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ - top?: number; -} - -/** Contains response data for the list operation. */ -export type PolicyDefinitionsListResponse = PolicyDefinitionListResult; - -/** Optional parameters. */ -export interface PolicyDefinitionsListBuiltInOptionalParams extends coreClient.OperationOptions { - /** The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given scope. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. */ - filter?: string; - /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ - top?: number; -} - -/** Contains response data for the listBuiltIn operation. */ -export type PolicyDefinitionsListBuiltInResponse = PolicyDefinitionListResult; - -/** Optional parameters. */ -export interface PolicyDefinitionsListByManagementGroupOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given scope. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. */ - filter?: string; - /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ - top?: number; -} - -/** Contains response data for the listByManagementGroup operation. */ -export type PolicyDefinitionsListByManagementGroupResponse = PolicyDefinitionListResult; - -/** Optional parameters. */ -export interface PolicyDefinitionsListNextOptionalParams extends coreClient.OperationOptions {} - -/** Contains response data for the listNext operation. */ -export type PolicyDefinitionsListNextResponse = PolicyDefinitionListResult; - -/** Optional parameters. */ -export interface PolicyDefinitionsListBuiltInNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listBuiltInNext operation. */ -export type PolicyDefinitionsListBuiltInNextResponse = PolicyDefinitionListResult; - -/** Optional parameters. */ -export interface PolicyDefinitionsListByManagementGroupNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listByManagementGroupNext operation. */ -export type PolicyDefinitionsListByManagementGroupNextResponse = PolicyDefinitionListResult; - -/** Optional parameters. */ -export interface PolicyDefinitionVersionsListAllBuiltinsOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listAllBuiltins operation. */ -export type PolicyDefinitionVersionsListAllBuiltinsResponse = PolicyDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listAllAtManagementGroup operation. */ -export type PolicyDefinitionVersionsListAllAtManagementGroupResponse = - PolicyDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicyDefinitionVersionsListAllOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listAll operation. */ -export type PolicyDefinitionVersionsListAllResponse = PolicyDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicyDefinitionVersionsCreateOrUpdateOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the createOrUpdate operation. */ -export type PolicyDefinitionVersionsCreateOrUpdateResponse = PolicyDefinitionVersion; - -/** Optional parameters. */ -export interface PolicyDefinitionVersionsDeleteOptionalParams extends coreClient.OperationOptions {} - -/** Optional parameters. */ -export interface PolicyDefinitionVersionsGetOptionalParams extends coreClient.OperationOptions {} - -/** Contains response data for the get operation. */ -export type PolicyDefinitionVersionsGetResponse = PolicyDefinitionVersion; - -/** Optional parameters. */ -export interface PolicyDefinitionVersionsGetBuiltInOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the getBuiltIn operation. */ -export type PolicyDefinitionVersionsGetBuiltInResponse = PolicyDefinitionVersion; - -/** Optional parameters. */ -export interface PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the createOrUpdateAtManagementGroup operation. */ -export type PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupResponse = - PolicyDefinitionVersion; - -/** Optional parameters. */ -export interface PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams - extends coreClient.OperationOptions {} - -/** Optional parameters. */ -export interface PolicyDefinitionVersionsGetAtManagementGroupOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the getAtManagementGroup operation. */ -export type PolicyDefinitionVersionsGetAtManagementGroupResponse = PolicyDefinitionVersion; - -/** Optional parameters. */ -export interface PolicyDefinitionVersionsListOptionalParams extends coreClient.OperationOptions { - /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ - top?: number; -} - -/** Contains response data for the list operation. */ -export type PolicyDefinitionVersionsListResponse = PolicyDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicyDefinitionVersionsListBuiltInOptionalParams - extends coreClient.OperationOptions { - /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ - top?: number; -} - -/** Contains response data for the listBuiltIn operation. */ -export type PolicyDefinitionVersionsListBuiltInResponse = PolicyDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicyDefinitionVersionsListByManagementGroupOptionalParams - extends coreClient.OperationOptions { - /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ - top?: number; -} - -/** Contains response data for the listByManagementGroup operation. */ -export type PolicyDefinitionVersionsListByManagementGroupResponse = - PolicyDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicyDefinitionVersionsListNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listNext operation. */ -export type PolicyDefinitionVersionsListNextResponse = PolicyDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicyDefinitionVersionsListBuiltInNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listBuiltInNext operation. */ -export type PolicyDefinitionVersionsListBuiltInNextResponse = PolicyDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicyDefinitionVersionsListByManagementGroupNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listByManagementGroupNext operation. */ -export type PolicyDefinitionVersionsListByManagementGroupNextResponse = - PolicyDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicySetDefinitionsCreateOrUpdateOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the createOrUpdate operation. */ -export type PolicySetDefinitionsCreateOrUpdateResponse = PolicySetDefinition; - -/** Optional parameters. */ -export interface PolicySetDefinitionsDeleteOptionalParams extends coreClient.OperationOptions {} - -/** Optional parameters. */ -export interface PolicySetDefinitionsGetOptionalParams extends coreClient.OperationOptions { - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the get operation. */ -export type PolicySetDefinitionsGetResponse = PolicySetDefinition; - -/** Optional parameters. */ -export interface PolicySetDefinitionsGetBuiltInOptionalParams extends coreClient.OperationOptions { - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the getBuiltIn operation. */ -export type PolicySetDefinitionsGetBuiltInResponse = PolicySetDefinition; - -/** Optional parameters. */ -export interface PolicySetDefinitionsListOptionalParams extends coreClient.OperationOptions { - /** The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given scope. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. */ - filter?: string; - /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ - top?: number; - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the list operation. */ -export type PolicySetDefinitionsListResponse = PolicySetDefinitionListResult; - -/** Optional parameters. */ -export interface PolicySetDefinitionsListBuiltInOptionalParams extends coreClient.OperationOptions { - /** The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given scope. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. */ - filter?: string; - /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ - top?: number; - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the listBuiltIn operation. */ -export type PolicySetDefinitionsListBuiltInResponse = PolicySetDefinitionListResult; - -/** Optional parameters. */ -export interface PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the createOrUpdateAtManagementGroup operation. */ -export type PolicySetDefinitionsCreateOrUpdateAtManagementGroupResponse = PolicySetDefinition; - -/** Optional parameters. */ -export interface PolicySetDefinitionsDeleteAtManagementGroupOptionalParams - extends coreClient.OperationOptions {} - -/** Optional parameters. */ -export interface PolicySetDefinitionsGetAtManagementGroupOptionalParams - extends coreClient.OperationOptions { - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the getAtManagementGroup operation. */ -export type PolicySetDefinitionsGetAtManagementGroupResponse = PolicySetDefinition; - -/** Optional parameters. */ -export interface PolicySetDefinitionsListByManagementGroupOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given scope. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. */ - filter?: string; - /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ - top?: number; - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the listByManagementGroup operation. */ -export type PolicySetDefinitionsListByManagementGroupResponse = PolicySetDefinitionListResult; - -/** Optional parameters. */ -export interface PolicySetDefinitionsListNextOptionalParams extends coreClient.OperationOptions {} - -/** Contains response data for the listNext operation. */ -export type PolicySetDefinitionsListNextResponse = PolicySetDefinitionListResult; - -/** Optional parameters. */ -export interface PolicySetDefinitionsListBuiltInNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listBuiltInNext operation. */ -export type PolicySetDefinitionsListBuiltInNextResponse = PolicySetDefinitionListResult; - -/** Optional parameters. */ -export interface PolicySetDefinitionsListByManagementGroupNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listByManagementGroupNext operation. */ -export type PolicySetDefinitionsListByManagementGroupNextResponse = PolicySetDefinitionListResult; - -/** Optional parameters. */ -export interface PolicySetDefinitionVersionsListAllBuiltinsOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listAllBuiltins operation. */ -export type PolicySetDefinitionVersionsListAllBuiltinsResponse = - PolicySetDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listAllAtManagementGroup operation. */ -export type PolicySetDefinitionVersionsListAllAtManagementGroupResponse = - PolicySetDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicySetDefinitionVersionsListAllOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listAll operation. */ -export type PolicySetDefinitionVersionsListAllResponse = PolicySetDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicySetDefinitionVersionsCreateOrUpdateOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the createOrUpdate operation. */ -export type PolicySetDefinitionVersionsCreateOrUpdateResponse = PolicySetDefinitionVersion; - -/** Optional parameters. */ -export interface PolicySetDefinitionVersionsDeleteOptionalParams - extends coreClient.OperationOptions {} - -/** Optional parameters. */ -export interface PolicySetDefinitionVersionsGetOptionalParams extends coreClient.OperationOptions { - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the get operation. */ -export type PolicySetDefinitionVersionsGetResponse = PolicySetDefinitionVersion; - -/** Optional parameters. */ -export interface PolicySetDefinitionVersionsGetBuiltInOptionalParams - extends coreClient.OperationOptions { - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the getBuiltIn operation. */ -export type PolicySetDefinitionVersionsGetBuiltInResponse = PolicySetDefinitionVersion; - -/** Optional parameters. */ -export interface PolicySetDefinitionVersionsListOptionalParams extends coreClient.OperationOptions { - /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ - top?: number; - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the list operation. */ -export type PolicySetDefinitionVersionsListResponse = PolicySetDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicySetDefinitionVersionsListBuiltInOptionalParams - extends coreClient.OperationOptions { - /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ - top?: number; - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the listBuiltIn operation. */ -export type PolicySetDefinitionVersionsListBuiltInResponse = PolicySetDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the createOrUpdateAtManagementGroup operation. */ -export type PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupResponse = - PolicySetDefinitionVersion; - -/** Optional parameters. */ -export interface PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams - extends coreClient.OperationOptions {} - -/** Optional parameters. */ -export interface PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams - extends coreClient.OperationOptions { - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the getAtManagementGroup operation. */ -export type PolicySetDefinitionVersionsGetAtManagementGroupResponse = PolicySetDefinitionVersion; - -/** Optional parameters. */ -export interface PolicySetDefinitionVersionsListByManagementGroupOptionalParams - extends coreClient.OperationOptions { - /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ - top?: number; - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the listByManagementGroup operation. */ -export type PolicySetDefinitionVersionsListByManagementGroupResponse = - PolicySetDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicySetDefinitionVersionsListNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listNext operation. */ -export type PolicySetDefinitionVersionsListNextResponse = PolicySetDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicySetDefinitionVersionsListBuiltInNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listBuiltInNext operation. */ -export type PolicySetDefinitionVersionsListBuiltInNextResponse = - PolicySetDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicySetDefinitionVersionsListByManagementGroupNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listByManagementGroupNext operation. */ -export type PolicySetDefinitionVersionsListByManagementGroupNextResponse = - PolicySetDefinitionVersionListResult; - -/** Optional parameters. */ -export interface PolicyAssignmentsDeleteOptionalParams extends coreClient.OperationOptions {} - -/** Contains response data for the delete operation. */ -export type PolicyAssignmentsDeleteResponse = PolicyAssignment; - -/** Optional parameters. */ -export interface PolicyAssignmentsCreateOptionalParams extends coreClient.OperationOptions {} - -/** Contains response data for the create operation. */ -export type PolicyAssignmentsCreateResponse = PolicyAssignment; - -/** Optional parameters. */ -export interface PolicyAssignmentsGetOptionalParams extends coreClient.OperationOptions { - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the get operation. */ -export type PolicyAssignmentsGetResponse = PolicyAssignment; - -/** Optional parameters. */ -export interface PolicyAssignmentsUpdateOptionalParams extends coreClient.OperationOptions {} - -/** Contains response data for the update operation. */ -export type PolicyAssignmentsUpdateResponse = PolicyAssignment; - -/** Optional parameters. */ -export interface PolicyAssignmentsListForResourceGroupOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is everything in the unfiltered list except those applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. */ - filter?: string; - /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ - top?: number; - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the listForResourceGroup operation. */ -export type PolicyAssignmentsListForResourceGroupResponse = PolicyAssignmentListResult; - -/** Optional parameters. */ -export interface PolicyAssignmentsListForResourceOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is everything in the unfiltered list except those applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. */ - filter?: string; - /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ - top?: number; - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the listForResource operation. */ -export type PolicyAssignmentsListForResourceResponse = PolicyAssignmentListResult; - -/** Optional parameters. */ -export interface PolicyAssignmentsListForManagementGroupOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is everything in the unfiltered list except those applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. */ - filter?: string; - /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ - top?: number; - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the listForManagementGroup operation. */ -export type PolicyAssignmentsListForManagementGroupResponse = PolicyAssignmentListResult; - -/** Optional parameters. */ -export interface PolicyAssignmentsListOptionalParams extends coreClient.OperationOptions { - /** The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is everything in the unfiltered list except those applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. */ - filter?: string; - /** Maximum number of records to return. When the $top filter is not provided, it will return 500 records. */ - top?: number; - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the list operation. */ -export type PolicyAssignmentsListResponse = PolicyAssignmentListResult; - -/** Optional parameters. */ -export interface PolicyAssignmentsDeleteByIdOptionalParams extends coreClient.OperationOptions {} - -/** Contains response data for the deleteById operation. */ -export type PolicyAssignmentsDeleteByIdResponse = PolicyAssignment; - -/** Optional parameters. */ -export interface PolicyAssignmentsCreateByIdOptionalParams extends coreClient.OperationOptions {} - -/** Contains response data for the createById operation. */ -export type PolicyAssignmentsCreateByIdResponse = PolicyAssignment; - -/** Optional parameters. */ -export interface PolicyAssignmentsGetByIdOptionalParams extends coreClient.OperationOptions { - /** Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. */ - expand?: string; -} - -/** Contains response data for the getById operation. */ -export type PolicyAssignmentsGetByIdResponse = PolicyAssignment; - -/** Optional parameters. */ -export interface PolicyAssignmentsUpdateByIdOptionalParams extends coreClient.OperationOptions {} - -/** Contains response data for the updateById operation. */ -export type PolicyAssignmentsUpdateByIdResponse = PolicyAssignment; - -/** Optional parameters. */ -export interface PolicyAssignmentsListForResourceGroupNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listForResourceGroupNext operation. */ -export type PolicyAssignmentsListForResourceGroupNextResponse = PolicyAssignmentListResult; - -/** Optional parameters. */ -export interface PolicyAssignmentsListForResourceNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listForResourceNext operation. */ -export type PolicyAssignmentsListForResourceNextResponse = PolicyAssignmentListResult; - -/** Optional parameters. */ -export interface PolicyAssignmentsListForManagementGroupNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listForManagementGroupNext operation. */ -export type PolicyAssignmentsListForManagementGroupNextResponse = PolicyAssignmentListResult; - -/** Optional parameters. */ -export interface PolicyAssignmentsListNextOptionalParams extends coreClient.OperationOptions {} - -/** Contains response data for the listNext operation. */ -export type PolicyAssignmentsListNextResponse = PolicyAssignmentListResult; - -/** Optional parameters. */ -export interface PolicyClientOptionalParams extends coreClient.ServiceClientOptions { - /** server parameter */ - $host?: string; - /** Api Version */ - apiVersion?: string; - /** Overrides client endpoint. */ - endpoint?: string; -} +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + PolicyAssignment, + PolicyAssignmentProperties, + ParameterValuesValue, + KnownEnforcementMode, + EnforcementMode, + NonComplianceMessage, + ResourceSelector, + Selector, + KnownSelectorKind, + SelectorKind, + Override, + KnownOverrideKind, + OverrideKind, + KnownAssignmentType, + AssignmentType, + Identity, + ResourceIdentityType, + UserAssignedIdentitiesValue, + ExtensionResource, + Resource, + SystemData, + KnownCreatedByType, + CreatedByType, + ErrorResponse, + ErrorDetail, + ErrorAdditionalInfo, + PolicyAssignmentUpdate, + PolicyAssignmentUpdateProperties, + PolicyDefinition, + PolicyDefinitionProperties, + KnownPolicyType, + PolicyType, + ParameterDefinitionsValue, + KnownParameterType, + ParameterType, + ParameterDefinitionsValueMetadata, + ExternalEvaluationEnforcementSettings, + ExternalEvaluationEndpointSettings, + ProxyResource, + PolicyDefinitionVersion, + PolicyDefinitionVersionProperties, + PolicySetDefinition, + PolicySetDefinitionProperties, + PolicyDefinitionReference, + PolicyDefinitionGroup, + PolicySetDefinitionVersion, + PolicySetDefinitionVersionProperties, + PolicyTokenRequest, + PolicyTokenOperation, + PolicyTokenResponse, + KnownPolicyTokenResult, + PolicyTokenResult, + ExternalEvaluationEndpointInvocationResult, + PolicyLogInfo, + KnownExternalEndpointResult, + ExternalEndpointResult, + KnownVersions, +} from "./models.js"; diff --git a/sdk/policy/arm-policy/src/models/mappers.ts b/sdk/policy/arm-policy/src/models/mappers.ts deleted file mode 100644 index 53248dd6981d..000000000000 --- a/sdk/policy/arm-policy/src/models/mappers.ts +++ /dev/null @@ -1,1280 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type * as coreClient from "@azure/core-client"; - -export const PolicyDefinition: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "PolicyDefinition", - modelProperties: { - id: { - serializedName: "id", - readOnly: true, - type: { - name: "String", - }, - }, - name: { - serializedName: "name", - readOnly: true, - type: { - name: "String", - }, - }, - type: { - serializedName: "type", - readOnly: true, - type: { - name: "String", - }, - }, - systemData: { - serializedName: "systemData", - type: { - name: "Composite", - className: "SystemData", - }, - }, - policyType: { - serializedName: "properties.policyType", - type: { - name: "String", - }, - }, - mode: { - defaultValue: "Indexed", - serializedName: "properties.mode", - type: { - name: "String", - }, - }, - displayName: { - serializedName: "properties.displayName", - type: { - name: "String", - }, - }, - description: { - serializedName: "properties.description", - type: { - name: "String", - }, - }, - policyRule: { - serializedName: "properties.policyRule", - type: { - name: "any", - }, - }, - metadata: { - serializedName: "properties.metadata", - type: { - name: "any", - }, - }, - parameters: { - serializedName: "properties.parameters", - type: { - name: "Dictionary", - value: { - type: { name: "Composite", className: "ParameterDefinitionsValue" }, - }, - }, - }, - version: { - serializedName: "properties.version", - type: { - name: "String", - }, - }, - versions: { - serializedName: "properties.versions", - type: { - name: "Sequence", - element: { - type: { - name: "String", - }, - }, - }, - }, - }, - }, -}; - -export const ParameterDefinitionsValue: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ParameterDefinitionsValue", - modelProperties: { - type: { - serializedName: "type", - type: { - name: "String", - }, - }, - allowedValues: { - serializedName: "allowedValues", - type: { - name: "Sequence", - element: { - type: { - name: "any", - }, - }, - }, - }, - defaultValue: { - serializedName: "defaultValue", - type: { - name: "any", - }, - }, - schema: { - serializedName: "schema", - type: { - name: "any", - }, - }, - metadata: { - serializedName: "metadata", - type: { - name: "Composite", - className: "ParameterDefinitionsValueMetadata", - }, - }, - }, - }, -}; - -export const ParameterDefinitionsValueMetadata: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ParameterDefinitionsValueMetadata", - additionalProperties: { type: { name: "Object" } }, - modelProperties: { - displayName: { - serializedName: "displayName", - type: { - name: "String", - }, - }, - description: { - serializedName: "description", - type: { - name: "String", - }, - }, - strongType: { - serializedName: "strongType", - type: { - name: "String", - }, - }, - assignPermissions: { - serializedName: "assignPermissions", - type: { - name: "Boolean", - }, - }, - }, - }, -}; - -export const SystemData: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "SystemData", - modelProperties: { - createdBy: { - serializedName: "createdBy", - type: { - name: "String", - }, - }, - createdByType: { - serializedName: "createdByType", - type: { - name: "String", - }, - }, - createdAt: { - serializedName: "createdAt", - type: { - name: "DateTime", - }, - }, - lastModifiedBy: { - serializedName: "lastModifiedBy", - type: { - name: "String", - }, - }, - lastModifiedByType: { - serializedName: "lastModifiedByType", - type: { - name: "String", - }, - }, - lastModifiedAt: { - serializedName: "lastModifiedAt", - type: { - name: "DateTime", - }, - }, - }, - }, -}; - -export const CloudError: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "CloudError", - modelProperties: { - error: { - serializedName: "error", - type: { - name: "Composite", - className: "ErrorResponse", - }, - }, - }, - }, -}; - -export const ErrorResponse: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ErrorResponse", - modelProperties: { - code: { - serializedName: "code", - readOnly: true, - type: { - name: "String", - }, - }, - message: { - serializedName: "message", - readOnly: true, - type: { - name: "String", - }, - }, - target: { - serializedName: "target", - readOnly: true, - type: { - name: "String", - }, - }, - details: { - serializedName: "details", - readOnly: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "ErrorResponse", - }, - }, - }, - }, - additionalInfo: { - serializedName: "additionalInfo", - readOnly: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "ErrorAdditionalInfo", - }, - }, - }, - }, - }, - }, -}; - -export const ErrorAdditionalInfo: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ErrorAdditionalInfo", - modelProperties: { - type: { - serializedName: "type", - readOnly: true, - type: { - name: "String", - }, - }, - info: { - serializedName: "info", - readOnly: true, - type: { - name: "any", - }, - }, - }, - }, -}; - -export const PolicyDefinitionListResult: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "PolicyDefinitionListResult", - modelProperties: { - value: { - serializedName: "value", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "PolicyDefinition", - }, - }, - }, - }, - nextLink: { - serializedName: "nextLink", - type: { - name: "String", - }, - }, - }, - }, -}; - -export const PolicyDefinitionVersionListResult: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "PolicyDefinitionVersionListResult", - modelProperties: { - value: { - serializedName: "value", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "PolicyDefinitionVersion", - }, - }, - }, - }, - nextLink: { - serializedName: "nextLink", - type: { - name: "String", - }, - }, - }, - }, -}; - -export const PolicyDefinitionVersion: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "PolicyDefinitionVersion", - modelProperties: { - id: { - serializedName: "id", - readOnly: true, - type: { - name: "String", - }, - }, - name: { - serializedName: "name", - readOnly: true, - type: { - name: "String", - }, - }, - type: { - serializedName: "type", - readOnly: true, - type: { - name: "String", - }, - }, - systemData: { - serializedName: "systemData", - type: { - name: "Composite", - className: "SystemData", - }, - }, - policyType: { - serializedName: "properties.policyType", - type: { - name: "String", - }, - }, - mode: { - defaultValue: "Indexed", - serializedName: "properties.mode", - type: { - name: "String", - }, - }, - displayName: { - serializedName: "properties.displayName", - type: { - name: "String", - }, - }, - description: { - serializedName: "properties.description", - type: { - name: "String", - }, - }, - policyRule: { - serializedName: "properties.policyRule", - type: { - name: "any", - }, - }, - metadata: { - serializedName: "properties.metadata", - type: { - name: "any", - }, - }, - parameters: { - serializedName: "properties.parameters", - type: { - name: "Dictionary", - value: { - type: { name: "Composite", className: "ParameterDefinitionsValue" }, - }, - }, - }, - version: { - serializedName: "properties.version", - type: { - name: "String", - }, - }, - }, - }, -}; - -export const PolicySetDefinition: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "PolicySetDefinition", - modelProperties: { - id: { - serializedName: "id", - readOnly: true, - type: { - name: "String", - }, - }, - name: { - serializedName: "name", - readOnly: true, - type: { - name: "String", - }, - }, - type: { - serializedName: "type", - readOnly: true, - type: { - name: "String", - }, - }, - systemData: { - serializedName: "systemData", - type: { - name: "Composite", - className: "SystemData", - }, - }, - policyType: { - serializedName: "properties.policyType", - type: { - name: "String", - }, - }, - displayName: { - serializedName: "properties.displayName", - type: { - name: "String", - }, - }, - description: { - serializedName: "properties.description", - type: { - name: "String", - }, - }, - metadata: { - serializedName: "properties.metadata", - type: { - name: "any", - }, - }, - parameters: { - serializedName: "properties.parameters", - type: { - name: "Dictionary", - value: { - type: { name: "Composite", className: "ParameterDefinitionsValue" }, - }, - }, - }, - policyDefinitions: { - serializedName: "properties.policyDefinitions", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "PolicyDefinitionReference", - }, - }, - }, - }, - policyDefinitionGroups: { - serializedName: "properties.policyDefinitionGroups", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "PolicyDefinitionGroup", - }, - }, - }, - }, - version: { - serializedName: "properties.version", - type: { - name: "String", - }, - }, - versions: { - serializedName: "properties.versions", - type: { - name: "Sequence", - element: { - type: { - name: "String", - }, - }, - }, - }, - }, - }, -}; - -export const PolicyDefinitionReference: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "PolicyDefinitionReference", - modelProperties: { - policyDefinitionId: { - serializedName: "policyDefinitionId", - required: true, - type: { - name: "String", - }, - }, - definitionVersion: { - serializedName: "definitionVersion", - type: { - name: "String", - }, - }, - latestDefinitionVersion: { - serializedName: "latestDefinitionVersion", - readOnly: true, - type: { - name: "String", - }, - }, - effectiveDefinitionVersion: { - serializedName: "effectiveDefinitionVersion", - readOnly: true, - type: { - name: "String", - }, - }, - parameters: { - serializedName: "parameters", - type: { - name: "Dictionary", - value: { - type: { name: "Composite", className: "ParameterValuesValue" }, - }, - }, - }, - policyDefinitionReferenceId: { - serializedName: "policyDefinitionReferenceId", - type: { - name: "String", - }, - }, - groupNames: { - serializedName: "groupNames", - type: { - name: "Sequence", - element: { - type: { - name: "String", - }, - }, - }, - }, - }, - }, -}; - -export const ParameterValuesValue: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ParameterValuesValue", - modelProperties: { - value: { - serializedName: "value", - type: { - name: "any", - }, - }, - }, - }, -}; - -export const PolicyDefinitionGroup: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "PolicyDefinitionGroup", - modelProperties: { - name: { - serializedName: "name", - required: true, - type: { - name: "String", - }, - }, - displayName: { - serializedName: "displayName", - type: { - name: "String", - }, - }, - category: { - serializedName: "category", - type: { - name: "String", - }, - }, - description: { - serializedName: "description", - type: { - name: "String", - }, - }, - additionalMetadataId: { - serializedName: "additionalMetadataId", - type: { - name: "String", - }, - }, - }, - }, -}; - -export const PolicySetDefinitionListResult: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "PolicySetDefinitionListResult", - modelProperties: { - value: { - serializedName: "value", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "PolicySetDefinition", - }, - }, - }, - }, - nextLink: { - serializedName: "nextLink", - type: { - name: "String", - }, - }, - }, - }, -}; - -export const PolicySetDefinitionVersionListResult: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "PolicySetDefinitionVersionListResult", - modelProperties: { - value: { - serializedName: "value", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "PolicySetDefinitionVersion", - }, - }, - }, - }, - nextLink: { - serializedName: "nextLink", - type: { - name: "String", - }, - }, - }, - }, -}; - -export const PolicySetDefinitionVersion: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "PolicySetDefinitionVersion", - modelProperties: { - id: { - serializedName: "id", - readOnly: true, - type: { - name: "String", - }, - }, - name: { - serializedName: "name", - readOnly: true, - type: { - name: "String", - }, - }, - type: { - serializedName: "type", - readOnly: true, - type: { - name: "String", - }, - }, - systemData: { - serializedName: "systemData", - type: { - name: "Composite", - className: "SystemData", - }, - }, - policyType: { - serializedName: "properties.policyType", - type: { - name: "String", - }, - }, - displayName: { - serializedName: "properties.displayName", - type: { - name: "String", - }, - }, - description: { - serializedName: "properties.description", - type: { - name: "String", - }, - }, - metadata: { - serializedName: "properties.metadata", - type: { - name: "any", - }, - }, - parameters: { - serializedName: "properties.parameters", - type: { - name: "Dictionary", - value: { - type: { name: "Composite", className: "ParameterDefinitionsValue" }, - }, - }, - }, - policyDefinitions: { - serializedName: "properties.policyDefinitions", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "PolicyDefinitionReference", - }, - }, - }, - }, - policyDefinitionGroups: { - serializedName: "properties.policyDefinitionGroups", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "PolicyDefinitionGroup", - }, - }, - }, - }, - version: { - serializedName: "properties.version", - type: { - name: "String", - }, - }, - }, - }, -}; - -export const PolicyAssignment: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "PolicyAssignment", - modelProperties: { - id: { - serializedName: "id", - readOnly: true, - type: { - name: "String", - }, - }, - type: { - serializedName: "type", - readOnly: true, - type: { - name: "String", - }, - }, - name: { - serializedName: "name", - readOnly: true, - type: { - name: "String", - }, - }, - location: { - serializedName: "location", - type: { - name: "String", - }, - }, - identity: { - serializedName: "identity", - type: { - name: "Composite", - className: "Identity", - }, - }, - systemData: { - serializedName: "systemData", - type: { - name: "Composite", - className: "SystemData", - }, - }, - displayName: { - serializedName: "properties.displayName", - type: { - name: "String", - }, - }, - policyDefinitionId: { - serializedName: "properties.policyDefinitionId", - type: { - name: "String", - }, - }, - definitionVersion: { - serializedName: "properties.definitionVersion", - type: { - name: "String", - }, - }, - latestDefinitionVersion: { - serializedName: "properties.latestDefinitionVersion", - readOnly: true, - type: { - name: "String", - }, - }, - effectiveDefinitionVersion: { - serializedName: "properties.effectiveDefinitionVersion", - readOnly: true, - type: { - name: "String", - }, - }, - scope: { - serializedName: "properties.scope", - readOnly: true, - type: { - name: "String", - }, - }, - notScopes: { - serializedName: "properties.notScopes", - type: { - name: "Sequence", - element: { - type: { - name: "String", - }, - }, - }, - }, - parameters: { - serializedName: "properties.parameters", - type: { - name: "Dictionary", - value: { - type: { name: "Composite", className: "ParameterValuesValue" }, - }, - }, - }, - description: { - serializedName: "properties.description", - type: { - name: "String", - }, - }, - metadata: { - serializedName: "properties.metadata", - type: { - name: "any", - }, - }, - enforcementMode: { - defaultValue: "Default", - serializedName: "properties.enforcementMode", - type: { - name: "String", - }, - }, - nonComplianceMessages: { - serializedName: "properties.nonComplianceMessages", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "NonComplianceMessage", - }, - }, - }, - }, - resourceSelectors: { - serializedName: "properties.resourceSelectors", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "ResourceSelector", - }, - }, - }, - }, - overrides: { - serializedName: "properties.overrides", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "Override", - }, - }, - }, - }, - assignmentType: { - serializedName: "properties.assignmentType", - type: { - name: "String", - }, - }, - }, - }, -}; - -export const NonComplianceMessage: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "NonComplianceMessage", - modelProperties: { - message: { - serializedName: "message", - required: true, - type: { - name: "String", - }, - }, - policyDefinitionReferenceId: { - serializedName: "policyDefinitionReferenceId", - type: { - name: "String", - }, - }, - }, - }, -}; - -export const ResourceSelector: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ResourceSelector", - modelProperties: { - name: { - serializedName: "name", - type: { - name: "String", - }, - }, - selectors: { - serializedName: "selectors", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "Selector", - }, - }, - }, - }, - }, - }, -}; - -export const Selector: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "Selector", - modelProperties: { - kind: { - serializedName: "kind", - type: { - name: "String", - }, - }, - in: { - serializedName: "in", - type: { - name: "Sequence", - element: { - type: { - name: "String", - }, - }, - }, - }, - notIn: { - serializedName: "notIn", - type: { - name: "Sequence", - element: { - type: { - name: "String", - }, - }, - }, - }, - }, - }, -}; - -export const Override: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "Override", - modelProperties: { - kind: { - serializedName: "kind", - type: { - name: "String", - }, - }, - value: { - serializedName: "value", - type: { - name: "String", - }, - }, - selectors: { - serializedName: "selectors", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "Selector", - }, - }, - }, - }, - }, - }, -}; - -export const Identity: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "Identity", - modelProperties: { - principalId: { - serializedName: "principalId", - readOnly: true, - type: { - name: "String", - }, - }, - tenantId: { - serializedName: "tenantId", - readOnly: true, - type: { - name: "String", - }, - }, - type: { - serializedName: "type", - type: { - name: "Enum", - allowedValues: ["SystemAssigned", "UserAssigned", "None"], - }, - }, - userAssignedIdentities: { - serializedName: "userAssignedIdentities", - type: { - name: "Dictionary", - value: { - type: { - name: "Composite", - className: "UserAssignedIdentitiesValue", - }, - }, - }, - }, - }, - }, -}; - -export const UserAssignedIdentitiesValue: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "UserAssignedIdentitiesValue", - modelProperties: { - principalId: { - serializedName: "principalId", - readOnly: true, - type: { - name: "String", - }, - }, - clientId: { - serializedName: "clientId", - readOnly: true, - type: { - name: "String", - }, - }, - }, - }, -}; - -export const PolicyAssignmentUpdate: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "PolicyAssignmentUpdate", - modelProperties: { - location: { - serializedName: "location", - type: { - name: "String", - }, - }, - identity: { - serializedName: "identity", - type: { - name: "Composite", - className: "Identity", - }, - }, - resourceSelectors: { - serializedName: "properties.resourceSelectors", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "ResourceSelector", - }, - }, - }, - }, - overrides: { - serializedName: "properties.overrides", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "Override", - }, - }, - }, - }, - }, - }, -}; - -export const PolicyAssignmentListResult: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "PolicyAssignmentListResult", - modelProperties: { - value: { - serializedName: "value", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "PolicyAssignment", - }, - }, - }, - }, - nextLink: { - serializedName: "nextLink", - type: { - name: "String", - }, - }, - }, - }, -}; diff --git a/sdk/policy/arm-policy/src/models/models.ts b/sdk/policy/arm-policy/src/models/models.ts new file mode 100644 index 000000000000..74a339667015 --- /dev/null +++ b/sdk/policy/arm-policy/src/models/models.ts @@ -0,0 +1,2223 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { areAllPropsUndefined } from "../static-helpers/serialization/check-prop-undefined.js"; +import { serializeRecord } from "../static-helpers/serialization/serialize-record.js"; + +/** + * This file contains only generated model types and their (de)serializers. + * Disable the following rules for internal models with '_' prefix and deserializers which require 'any' for raw JSON input. + */ +/* eslint-disable @typescript-eslint/naming-convention */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/** The policy assignment. */ +export interface PolicyAssignment extends ExtensionResource { + /** The location of the policy assignment. Only required when utilizing managed identity. */ + location?: string; + /** The managed identity associated with the policy assignment. */ + identity?: Identity; + /** The display name of the policy assignment. */ + displayName?: string; + /** The ID of the policy definition or policy set definition being assigned. */ + policyDefinitionId?: string; + /** The version of the policy definition to use. */ + definitionVersion?: string; + /** The latest version of the policy definition available. This is only present if requested via the $expand query parameter. */ + readonly latestDefinitionVersion?: string; + /** The effective version of the policy definition in use. This is only present if requested via the $expand query parameter. */ + readonly effectiveDefinitionVersion?: string; + /** The scope for the policy assignment. */ + readonly scope?: string; + /** The policy's excluded scopes. */ + notScopes?: string[]; + /** The parameter values for the assigned policy rule. The keys are the parameter names. */ + parameters?: Record; + /** This message will be part of response in case of policy violation. */ + description?: string; + /** The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. */ + metadata?: any; + /** The policy assignment enforcement mode. Possible values are Default, DoNotEnforce, and Enroll */ + enforcementMode?: EnforcementMode; + /** The messages that describe why a resource is non-compliant with the policy. */ + nonComplianceMessages?: NonComplianceMessage[]; + /** The resource selector list to filter policies by resource properties. */ + resourceSelectors?: ResourceSelector[]; + /** The policy property value override. */ + overrides?: Override[]; + /** The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable. */ + assignmentType?: AssignmentType; + /** The instance ID of the policy assignment. This ID only and always changes when the assignment is deleted and recreated. */ + readonly instanceId?: string; +} + +export function policyAssignmentSerializer(item: PolicyAssignment): any { + return { + properties: areAllPropsUndefined(item, [ + "displayName", + "policyDefinitionId", + "definitionVersion", + "notScopes", + "parameters", + "description", + "metadata", + "enforcementMode", + "nonComplianceMessages", + "resourceSelectors", + "overrides", + "assignmentType", + ]) + ? undefined + : _policyAssignmentPropertiesSerializer(item), + location: item["location"], + identity: !item["identity"] ? item["identity"] : identitySerializer(item["identity"]), + }; +} + +export function policyAssignmentDeserializer(item: any): PolicyAssignment { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + ...(!item["properties"] + ? item["properties"] + : _policyAssignmentPropertiesDeserializer(item["properties"])), + location: item["location"], + identity: !item["identity"] ? item["identity"] : identityDeserializer(item["identity"]), + }; +} + +/** The policy assignment properties. */ +export interface PolicyAssignmentProperties { + /** The display name of the policy assignment. */ + displayName?: string; + /** The ID of the policy definition or policy set definition being assigned. */ + policyDefinitionId?: string; + /** The version of the policy definition to use. */ + definitionVersion?: string; + /** The latest version of the policy definition available. This is only present if requested via the $expand query parameter. */ + readonly latestDefinitionVersion?: string; + /** The effective version of the policy definition in use. This is only present if requested via the $expand query parameter. */ + readonly effectiveDefinitionVersion?: string; + /** The scope for the policy assignment. */ + readonly scope?: string; + /** The policy's excluded scopes. */ + notScopes?: string[]; + /** The parameter values for the assigned policy rule. The keys are the parameter names. */ + parameters?: Record; + /** This message will be part of response in case of policy violation. */ + description?: string; + /** The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. */ + metadata?: any; + /** The policy assignment enforcement mode. Possible values are Default, DoNotEnforce, and Enroll */ + enforcementMode?: EnforcementMode; + /** The messages that describe why a resource is non-compliant with the policy. */ + nonComplianceMessages?: NonComplianceMessage[]; + /** The resource selector list to filter policies by resource properties. */ + resourceSelectors?: ResourceSelector[]; + /** The policy property value override. */ + overrides?: Override[]; + /** The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable. */ + assignmentType?: AssignmentType; + /** The instance ID of the policy assignment. This ID only and always changes when the assignment is deleted and recreated. */ + readonly instanceId?: string; +} + +export function policyAssignmentPropertiesSerializer(item: PolicyAssignmentProperties): any { + return { + displayName: item["displayName"], + policyDefinitionId: item["policyDefinitionId"], + definitionVersion: item["definitionVersion"], + notScopes: !item["notScopes"] + ? item["notScopes"] + : item["notScopes"].map((p: any) => { + return p; + }), + parameters: !item["parameters"] + ? item["parameters"] + : parameterValuesValueRecordSerializer(item["parameters"]), + description: item["description"], + metadata: item["metadata"], + enforcementMode: item["enforcementMode"], + nonComplianceMessages: !item["nonComplianceMessages"] + ? item["nonComplianceMessages"] + : nonComplianceMessageArraySerializer(item["nonComplianceMessages"]), + resourceSelectors: !item["resourceSelectors"] + ? item["resourceSelectors"] + : resourceSelectorArraySerializer(item["resourceSelectors"]), + overrides: !item["overrides"] ? item["overrides"] : overrideArraySerializer(item["overrides"]), + assignmentType: item["assignmentType"], + }; +} + +export function policyAssignmentPropertiesDeserializer(item: any): PolicyAssignmentProperties { + return { + displayName: item["displayName"], + policyDefinitionId: item["policyDefinitionId"], + definitionVersion: item["definitionVersion"], + latestDefinitionVersion: item["latestDefinitionVersion"], + effectiveDefinitionVersion: item["effectiveDefinitionVersion"], + scope: item["scope"], + notScopes: !item["notScopes"] + ? item["notScopes"] + : item["notScopes"].map((p: any) => { + return p; + }), + parameters: !item["parameters"] + ? item["parameters"] + : parameterValuesValueRecordDeserializer(item["parameters"]), + description: item["description"], + metadata: item["metadata"], + enforcementMode: item["enforcementMode"], + nonComplianceMessages: !item["nonComplianceMessages"] + ? item["nonComplianceMessages"] + : nonComplianceMessageArrayDeserializer(item["nonComplianceMessages"]), + resourceSelectors: !item["resourceSelectors"] + ? item["resourceSelectors"] + : resourceSelectorArrayDeserializer(item["resourceSelectors"]), + overrides: !item["overrides"] + ? item["overrides"] + : overrideArrayDeserializer(item["overrides"]), + assignmentType: item["assignmentType"], + instanceId: item["instanceId"], + }; +} + +export function parameterValuesValueRecordSerializer( + item: Record, +): Record { + const result: Record = {}; + Object.keys(item).map((key) => { + result[key] = !item[key] ? item[key] : parameterValuesValueSerializer(item[key]); + }); + return result; +} + +export function parameterValuesValueRecordDeserializer( + item: Record, +): Record { + const result: Record = {}; + Object.keys(item).map((key) => { + result[key] = !item[key] ? item[key] : parameterValuesValueDeserializer(item[key]); + }); + return result; +} + +/** The value of a parameter. */ +export interface ParameterValuesValue { + /** The value of the parameter. */ + value?: any; +} + +export function parameterValuesValueSerializer(item: ParameterValuesValue): any { + return { value: item["value"] }; +} + +export function parameterValuesValueDeserializer(item: any): ParameterValuesValue { + return { + value: item["value"], + }; +} + +/** The policy assignment enforcement mode. Possible values are Default, DoNotEnforce, and Enroll */ +export enum KnownEnforcementMode { + /** The policy effect is enforced during resource creation or update. */ + Default = "Default", + /** The policy effect is not enforced during resource creation or update. */ + DoNotEnforce = "DoNotEnforce", + /** The policy effect is not enforced during resource creation or update until the resource or scope of the resource is enrolled to the assignment instance. Enrollment occurs upon deployment of the policy enrollment resource. */ + Enroll = "Enroll", +} + +/** + * The policy assignment enforcement mode. Possible values are Default, DoNotEnforce, and Enroll \ + * {@link KnownEnforcementMode} can be used interchangeably with EnforcementMode, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Default**: The policy effect is enforced during resource creation or update. \ + * **DoNotEnforce**: The policy effect is not enforced during resource creation or update. \ + * **Enroll**: The policy effect is not enforced during resource creation or update until the resource or scope of the resource is enrolled to the assignment instance. Enrollment occurs upon deployment of the policy enrollment resource. + */ +export type EnforcementMode = string; + +export function nonComplianceMessageArraySerializer(result: Array): any[] { + return result.map((item) => { + return nonComplianceMessageSerializer(item); + }); +} + +export function nonComplianceMessageArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return nonComplianceMessageDeserializer(item); + }); +} + +/** A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results. */ +export interface NonComplianceMessage { + /** A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results. */ + message: string; + /** The policy definition reference ID within a policy set definition the message is intended for. This is only applicable if the policy assignment assigns a policy set definition. If this is not provided the message applies to all policies assigned by this policy assignment. */ + policyDefinitionReferenceId?: string; +} + +export function nonComplianceMessageSerializer(item: NonComplianceMessage): any { + return { + message: item["message"], + policyDefinitionReferenceId: item["policyDefinitionReferenceId"], + }; +} + +export function nonComplianceMessageDeserializer(item: any): NonComplianceMessage { + return { + message: item["message"], + policyDefinitionReferenceId: item["policyDefinitionReferenceId"], + }; +} + +export function resourceSelectorArraySerializer(result: Array): any[] { + return result.map((item) => { + return resourceSelectorSerializer(item); + }); +} + +export function resourceSelectorArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return resourceSelectorDeserializer(item); + }); +} + +/** The resource selector to filter policies by resource properties. */ +export interface ResourceSelector { + /** The name of the resource selector. */ + name?: string; + /** The list of the selector expressions. */ + selectors?: Selector[]; +} + +export function resourceSelectorSerializer(item: ResourceSelector): any { + return { + name: item["name"], + selectors: !item["selectors"] ? item["selectors"] : selectorArraySerializer(item["selectors"]), + }; +} + +export function resourceSelectorDeserializer(item: any): ResourceSelector { + return { + name: item["name"], + selectors: !item["selectors"] + ? item["selectors"] + : selectorArrayDeserializer(item["selectors"]), + }; +} + +export function selectorArraySerializer(result: Array): any[] { + return result.map((item) => { + return selectorSerializer(item); + }); +} + +export function selectorArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return selectorDeserializer(item); + }); +} + +/** The selector expression. */ +export interface Selector { + /** The selector kind. */ + kind?: SelectorKind; + /** The list of values to filter in. */ + in?: string[]; + /** The list of values to filter out. */ + notIn?: string[]; +} + +export function selectorSerializer(item: Selector): any { + return { + kind: item["kind"], + in: !item["in"] + ? item["in"] + : item["in"].map((p: any) => { + return p; + }), + notIn: !item["notIn"] + ? item["notIn"] + : item["notIn"].map((p: any) => { + return p; + }), + }; +} + +export function selectorDeserializer(item: any): Selector { + return { + kind: item["kind"], + in: !item["in"] + ? item["in"] + : item["in"].map((p: any) => { + return p; + }), + notIn: !item["notIn"] + ? item["notIn"] + : item["notIn"].map((p: any) => { + return p; + }), + }; +} + +/** The selector kind. */ +export enum KnownSelectorKind { + /** The selector kind to filter policies by the resource location. */ + ResourceLocation = "resourceLocation", + /** The selector kind to filter policies by the resource type. */ + ResourceType = "resourceType", + /** The selector kind to filter policies by the resource without location. */ + ResourceWithoutLocation = "resourceWithoutLocation", + /** The selector kind to filter policies by the policy definition reference ID. */ + PolicyDefinitionReferenceId = "policyDefinitionReferenceId", +} + +/** + * The selector kind. \ + * {@link KnownSelectorKind} can be used interchangeably with SelectorKind, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **resourceLocation**: The selector kind to filter policies by the resource location. \ + * **resourceType**: The selector kind to filter policies by the resource type. \ + * **resourceWithoutLocation**: The selector kind to filter policies by the resource without location. \ + * **policyDefinitionReferenceId**: The selector kind to filter policies by the policy definition reference ID. + */ +export type SelectorKind = string; + +export function overrideArraySerializer(result: Array): any[] { + return result.map((item) => { + return overrideSerializer(item); + }); +} + +export function overrideArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return overrideDeserializer(item); + }); +} + +/** The policy property value override. */ +export interface Override { + /** The override kind. */ + kind?: OverrideKind; + /** The value to override the policy property. */ + value?: string; + /** The list of the selector expressions. */ + selectors?: Selector[]; +} + +export function overrideSerializer(item: Override): any { + return { + kind: item["kind"], + value: item["value"], + selectors: !item["selectors"] ? item["selectors"] : selectorArraySerializer(item["selectors"]), + }; +} + +export function overrideDeserializer(item: any): Override { + return { + kind: item["kind"], + value: item["value"], + selectors: !item["selectors"] + ? item["selectors"] + : selectorArrayDeserializer(item["selectors"]), + }; +} + +/** The override kind. */ +export enum KnownOverrideKind { + /** It will override the policy effect type. */ + PolicyEffect = "policyEffect", + /** It will override the definition version property value of the policy assignment. */ + DefinitionVersion = "definitionVersion", +} + +/** + * The override kind. \ + * {@link KnownOverrideKind} can be used interchangeably with OverrideKind, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **policyEffect**: It will override the policy effect type. \ + * **definitionVersion**: It will override the definition version property value of the policy assignment. + */ +export type OverrideKind = string; + +/** The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable. */ +export enum KnownAssignmentType { + /** The not specified assignment type. */ + NotSpecified = "NotSpecified", + /** The system assignment type. */ + System = "System", + /** The system hidden assignment type. */ + SystemHidden = "SystemHidden", + /** The custom assignment type. */ + Custom = "Custom", +} + +/** + * The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable. \ + * {@link KnownAssignmentType} can be used interchangeably with AssignmentType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **NotSpecified**: The not specified assignment type. \ + * **System**: The system assignment type. \ + * **SystemHidden**: The system hidden assignment type. \ + * **Custom**: The custom assignment type. + */ +export type AssignmentType = string; + +/** Identity for the resource. Policy assignments support a maximum of one identity. That is either a system assigned identity or a single user assigned identity. */ +export interface Identity { + /** The principal ID of the resource identity. This property will only be provided for a system assigned identity */ + readonly principalId?: string; + /** The tenant ID of the resource identity. This property will only be provided for a system assigned identity */ + readonly tenantId?: string; + /** The identity type. This is the only required field when adding a system or user assigned identity to a resource. */ + type?: ResourceIdentityType; + /** The user identity associated with the policy. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. */ + userAssignedIdentities?: Record; +} + +export function identitySerializer(item: Identity): any { + return { + type: item["type"], + userAssignedIdentities: !item["userAssignedIdentities"] + ? item["userAssignedIdentities"] + : userAssignedIdentitiesValueRecordSerializer(item["userAssignedIdentities"]), + }; +} + +export function identityDeserializer(item: any): Identity { + return { + principalId: item["principalId"], + tenantId: item["tenantId"], + type: item["type"], + userAssignedIdentities: !item["userAssignedIdentities"] + ? item["userAssignedIdentities"] + : userAssignedIdentitiesValueRecordDeserializer(item["userAssignedIdentities"]), + }; +} + +/** The identity type. This is the only required field when adding a system or user assigned identity to a resource. */ +export type ResourceIdentityType = "SystemAssigned" | "UserAssigned" | "None"; + +export function userAssignedIdentitiesValueRecordSerializer( + item: Record, +): Record { + const result: Record = {}; + Object.keys(item).map((key) => { + result[key] = !item[key] ? item[key] : userAssignedIdentitiesValueSerializer(item[key]); + }); + return result; +} + +export function userAssignedIdentitiesValueRecordDeserializer( + item: Record, +): Record { + const result: Record = {}; + Object.keys(item).map((key) => { + result[key] = !item[key] ? item[key] : userAssignedIdentitiesValueDeserializer(item[key]); + }); + return result; +} + +/** model interface UserAssignedIdentitiesValue */ +export interface UserAssignedIdentitiesValue { + /** The principal id of user assigned identity. */ + readonly principalId?: string; + /** The client id of user assigned identity. */ + readonly clientId?: string; +} + +export function userAssignedIdentitiesValueSerializer(item: UserAssignedIdentitiesValue): any { + return item; +} + +export function userAssignedIdentitiesValueDeserializer(item: any): UserAssignedIdentitiesValue { + return { + principalId: item["principalId"], + clientId: item["clientId"], + }; +} + +/** The base extension resource. */ +export interface ExtensionResource extends Resource {} + +export function extensionResourceSerializer(item: ExtensionResource): any { + return item; +} + +export function extensionResourceDeserializer(item: any): ExtensionResource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + }; +} + +/** Common fields that are returned in the response for all Azure Resource Manager resources */ +export interface Resource { + /** Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} */ + readonly id?: string; + /** The name of the resource */ + readonly name?: string; + /** The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" */ + readonly type?: string; + /** Azure Resource Manager metadata containing createdBy and modifiedBy information. */ + readonly systemData?: SystemData; +} + +export function 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; + +/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. */ +export interface ErrorResponse { + /** The error object. */ + error?: ErrorDetail; +} + +export function errorResponseDeserializer(item: any): ErrorResponse { + return { + error: !item["error"] ? item["error"] : errorDetailDeserializer(item["error"]), + }; +} + +/** The error detail. */ +export interface ErrorDetail { + /** The error code. */ + readonly code?: string; + /** The error message. */ + readonly message?: string; + /** The error target. */ + readonly target?: string; + /** The error details. */ + readonly details?: ErrorDetail[]; + /** The error additional info. */ + readonly additionalInfo?: ErrorAdditionalInfo[]; +} + +export function errorDetailDeserializer(item: any): ErrorDetail { + return { + code: item["code"], + message: item["message"], + target: item["target"], + details: !item["details"] ? item["details"] : errorDetailArrayDeserializer(item["details"]), + additionalInfo: !item["additionalInfo"] + ? item["additionalInfo"] + : errorAdditionalInfoArrayDeserializer(item["additionalInfo"]), + }; +} + +export function errorDetailArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return errorDetailDeserializer(item); + }); +} + +export function errorAdditionalInfoArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return errorAdditionalInfoDeserializer(item); + }); +} + +/** The resource management error additional info. */ +export interface ErrorAdditionalInfo { + /** The additional info type. */ + readonly type?: string; + /** The additional info. */ + readonly info?: any; +} + +export function errorAdditionalInfoDeserializer(item: any): ErrorAdditionalInfo { + return { + type: item["type"], + info: item["info"], + }; +} + +/** The policy assignment for Patch request. */ +export interface PolicyAssignmentUpdate { + /** The location of the policy assignment. Only required when utilizing managed identity. */ + location?: string; + /** The managed identity associated with the policy assignment. */ + identity?: Identity; + /** The resource selector list to filter policies by resource properties. */ + resourceSelectors?: ResourceSelector[]; + /** The policy property value override. */ + overrides?: Override[]; +} + +export function policyAssignmentUpdateSerializer(item: PolicyAssignmentUpdate): any { + return { + properties: areAllPropsUndefined(item, ["resourceSelectors", "overrides"]) + ? undefined + : _policyAssignmentUpdatePropertiesSerializer(item), + location: item["location"], + identity: !item["identity"] ? item["identity"] : identitySerializer(item["identity"]), + }; +} + +/** The policy assignment properties for Patch request. */ +export interface PolicyAssignmentUpdateProperties { + /** The resource selector list to filter policies by resource properties. */ + resourceSelectors?: ResourceSelector[]; + /** The policy property value override. */ + overrides?: Override[]; +} + +export function policyAssignmentUpdatePropertiesSerializer( + item: PolicyAssignmentUpdateProperties, +): any { + return { + resourceSelectors: !item["resourceSelectors"] + ? item["resourceSelectors"] + : resourceSelectorArraySerializer(item["resourceSelectors"]), + overrides: !item["overrides"] ? item["overrides"] : overrideArraySerializer(item["overrides"]), + }; +} + +/** The response of a PolicyAssignment list operation. */ +export interface _PolicyAssignmentListResult { + /** The PolicyAssignment items on this page */ + value: PolicyAssignment[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _policyAssignmentListResultDeserializer(item: any): _PolicyAssignmentListResult { + return { + value: policyAssignmentArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function policyAssignmentArraySerializer(result: Array): any[] { + return result.map((item) => { + return policyAssignmentSerializer(item); + }); +} + +export function policyAssignmentArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return policyAssignmentDeserializer(item); + }); +} + +/** The policy definition. */ +export interface PolicyDefinition extends ProxyResource { + /** The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. */ + policyType?: PolicyType; + /** The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. */ + mode?: string; + /** The display name of the policy definition. */ + displayName?: string; + /** The policy definition description. */ + description?: string; + /** The policy rule. */ + policyRule?: any; + /** The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. */ + metadata?: any; + /** The parameter definitions for parameters used in the policy rule. The keys are the parameter names. */ + parameters?: Record; + /** The policy definition version in #.#.# format. */ + version?: string; + /** A list of available versions for this policy definition. */ + versions?: string[]; + /** The details of the source of external evaluation results required by the policy during enforcement evaluation. */ + externalEvaluationEnforcementSettings?: ExternalEvaluationEnforcementSettings; +} + +export function policyDefinitionSerializer(item: PolicyDefinition): any { + return { + properties: areAllPropsUndefined(item, [ + "policyType", + "mode", + "displayName", + "description", + "policyRule", + "metadata", + "parameters", + "version", + "versions", + "externalEvaluationEnforcementSettings", + ]) + ? undefined + : _policyDefinitionPropertiesSerializer(item), + }; +} + +export function policyDefinitionDeserializer(item: any): PolicyDefinition { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + ...(!item["properties"] + ? item["properties"] + : _policyDefinitionPropertiesDeserializer(item["properties"])), + }; +} + +/** The policy definition properties. */ +export interface PolicyDefinitionProperties { + /** The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. */ + policyType?: PolicyType; + /** The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. */ + mode?: string; + /** The display name of the policy definition. */ + displayName?: string; + /** The policy definition description. */ + description?: string; + /** The policy rule. */ + policyRule?: any; + /** The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. */ + metadata?: any; + /** The parameter definitions for parameters used in the policy rule. The keys are the parameter names. */ + parameters?: Record; + /** The policy definition version in #.#.# format. */ + version?: string; + /** A list of available versions for this policy definition. */ + versions?: string[]; + /** The details of the source of external evaluation results required by the policy during enforcement evaluation. */ + externalEvaluationEnforcementSettings?: ExternalEvaluationEnforcementSettings; +} + +export function policyDefinitionPropertiesSerializer(item: PolicyDefinitionProperties): any { + return { + policyType: item["policyType"], + mode: item["mode"], + displayName: item["displayName"], + description: item["description"], + policyRule: item["policyRule"], + metadata: item["metadata"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterDefinitionsValueRecordSerializer(item["parameters"]), + version: item["version"], + versions: !item["versions"] + ? item["versions"] + : item["versions"].map((p: any) => { + return p; + }), + externalEvaluationEnforcementSettings: !item["externalEvaluationEnforcementSettings"] + ? item["externalEvaluationEnforcementSettings"] + : externalEvaluationEnforcementSettingsSerializer( + item["externalEvaluationEnforcementSettings"], + ), + }; +} + +export function policyDefinitionPropertiesDeserializer(item: any): PolicyDefinitionProperties { + return { + policyType: item["policyType"], + mode: item["mode"], + displayName: item["displayName"], + description: item["description"], + policyRule: item["policyRule"], + metadata: item["metadata"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterDefinitionsValueRecordDeserializer(item["parameters"]), + version: item["version"], + versions: !item["versions"] + ? item["versions"] + : item["versions"].map((p: any) => { + return p; + }), + externalEvaluationEnforcementSettings: !item["externalEvaluationEnforcementSettings"] + ? item["externalEvaluationEnforcementSettings"] + : externalEvaluationEnforcementSettingsDeserializer( + item["externalEvaluationEnforcementSettings"], + ), + }; +} + +/** The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. */ +export enum KnownPolicyType { + /** The not specified policy definition type. */ + NotSpecified = "NotSpecified", + /** The built in policy definition type. */ + BuiltIn = "BuiltIn", + /** The custom policy definition type. */ + Custom = "Custom", + /** The static policy definition type. */ + Static = "Static", +} + +/** + * The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. \ + * {@link KnownPolicyType} can be used interchangeably with PolicyType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **NotSpecified**: The not specified policy definition type. \ + * **BuiltIn**: The built in policy definition type. \ + * **Custom**: The custom policy definition type. \ + * **Static**: The static policy definition type. + */ +export type PolicyType = string; + +export function parameterDefinitionsValueRecordSerializer( + item: Record, +): Record { + const result: Record = {}; + Object.keys(item).map((key) => { + result[key] = !item[key] ? item[key] : parameterDefinitionsValueSerializer(item[key]); + }); + return result; +} + +export function parameterDefinitionsValueRecordDeserializer( + item: Record, +): Record { + const result: Record = {}; + Object.keys(item).map((key) => { + result[key] = !item[key] ? item[key] : parameterDefinitionsValueDeserializer(item[key]); + }); + return result; +} + +/** The definition of a parameter that can be provided to the policy. */ +export interface ParameterDefinitionsValue { + /** The data type of the parameter. */ + type?: ParameterType; + /** The allowed values for the parameter. */ + allowedValues?: any[]; + /** The default value for the parameter if no value is provided. */ + defaultValue?: any; + /** Provides validation of parameter inputs during assignment using a self-defined JSON schema. This property is only supported for object-type parameters and follows the Json.NET Schema 2019-09 implementation. You can learn more about using schemas at https://json-schema.org/ and test draft schemas at https://www.jsonschemavalidator.net/. */ + schema?: any; + /** General metadata for the parameter. */ + metadata?: ParameterDefinitionsValueMetadata; +} + +export function parameterDefinitionsValueSerializer(item: ParameterDefinitionsValue): any { + return { + type: item["type"], + allowedValues: !item["allowedValues"] + ? item["allowedValues"] + : item["allowedValues"].map((p: any) => { + return p; + }), + defaultValue: item["defaultValue"], + schema: item["schema"], + metadata: !item["metadata"] + ? item["metadata"] + : parameterDefinitionsValueMetadataSerializer(item["metadata"]), + }; +} + +export function parameterDefinitionsValueDeserializer(item: any): ParameterDefinitionsValue { + return { + type: item["type"], + allowedValues: !item["allowedValues"] + ? item["allowedValues"] + : item["allowedValues"].map((p: any) => { + return p; + }), + defaultValue: item["defaultValue"], + schema: item["schema"], + metadata: !item["metadata"] + ? item["metadata"] + : parameterDefinitionsValueMetadataDeserializer(item["metadata"]), + }; +} + +/** The data type of the parameter. */ +export enum KnownParameterType { + /** The string parameter type. */ + String = "String", + /** The array parameter type. */ + Array = "Array", + /** The object parameter type. */ + Object = "Object", + /** The boolean parameter type. */ + Boolean = "Boolean", + /** The integer parameter type. */ + Integer = "Integer", + /** The float parameter type. */ + Float = "Float", + /** The date-time parameter type. */ + DateTime = "DateTime", +} + +/** + * The data type of the parameter. \ + * {@link KnownParameterType} can be used interchangeably with ParameterType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **String**: The string parameter type. \ + * **Array**: The array parameter type. \ + * **Object**: The object parameter type. \ + * **Boolean**: The boolean parameter type. \ + * **Integer**: The integer parameter type. \ + * **Float**: The float parameter type. \ + * **DateTime**: The date-time parameter type. + */ +export type ParameterType = string; + +/** General metadata for the parameter. */ +export interface ParameterDefinitionsValueMetadata { + /** The display name for the parameter. */ + displayName?: string; + /** The description of the parameter. */ + description?: string; + /** Used when assigning the policy definition through the portal. Provides a context aware list of values for the user to choose from. */ + strongType?: string; + /** Set to true to have Azure portal create role assignments on the resource ID or resource scope value of this parameter during policy assignment. This property is useful in case you wish to assign permissions outside the assignment scope. */ + assignPermissions?: boolean; + /** Additional properties */ + additionalProperties?: Record; +} + +export function parameterDefinitionsValueMetadataSerializer( + item: ParameterDefinitionsValueMetadata, +): any { + return { + ...serializeRecord(item.additionalProperties ?? {}), + displayName: item["displayName"], + description: item["description"], + strongType: item["strongType"], + assignPermissions: item["assignPermissions"], + }; +} + +export function parameterDefinitionsValueMetadataDeserializer( + item: any, +): ParameterDefinitionsValueMetadata { + return { + additionalProperties: serializeRecord(item, [ + "displayName", + "description", + "strongType", + "assignPermissions", + ]), + displayName: item["displayName"], + description: item["description"], + strongType: item["strongType"], + assignPermissions: item["assignPermissions"], + }; +} + +/** The details of the source of external evaluation results required by the policy during enforcement evaluation. */ +export interface ExternalEvaluationEnforcementSettings { + /** What to do when evaluating an enforcement policy that requires an external evaluation and the token is missing. Possible values are Audit and Deny and language expressions are supported. */ + missingTokenAction?: string; + /** The lifespan of the endpoint invocation result after which it's no longer valid. Value is expected to follow the ISO 8601 duration format and language expressions are supported. */ + resultLifespan?: string; + /** The settings of an external endpoint providing evaluation results. */ + endpointSettings?: ExternalEvaluationEndpointSettings; + /** An array of the role definition Ids the assignment's MSI will need in order to invoke the endpoint. */ + roleDefinitionIds?: string[]; +} + +export function externalEvaluationEnforcementSettingsSerializer( + item: ExternalEvaluationEnforcementSettings, +): any { + return { + missingTokenAction: item["missingTokenAction"], + resultLifespan: item["resultLifespan"], + endpointSettings: !item["endpointSettings"] + ? item["endpointSettings"] + : externalEvaluationEndpointSettingsSerializer(item["endpointSettings"]), + roleDefinitionIds: !item["roleDefinitionIds"] + ? item["roleDefinitionIds"] + : item["roleDefinitionIds"].map((p: any) => { + return p; + }), + }; +} + +export function externalEvaluationEnforcementSettingsDeserializer( + item: any, +): ExternalEvaluationEnforcementSettings { + return { + missingTokenAction: item["missingTokenAction"], + resultLifespan: item["resultLifespan"], + endpointSettings: !item["endpointSettings"] + ? item["endpointSettings"] + : externalEvaluationEndpointSettingsDeserializer(item["endpointSettings"]), + roleDefinitionIds: !item["roleDefinitionIds"] + ? item["roleDefinitionIds"] + : item["roleDefinitionIds"].map((p: any) => { + return p; + }), + }; +} + +/** The settings of an external endpoint providing evaluation results. */ +export interface ExternalEvaluationEndpointSettings { + /** The kind of the endpoint. */ + kind?: string; + /** The details of the endpoint. */ + details?: any; +} + +export function externalEvaluationEndpointSettingsSerializer( + item: ExternalEvaluationEndpointSettings, +): any { + return { kind: item["kind"], details: item["details"] }; +} + +export function externalEvaluationEndpointSettingsDeserializer( + item: any, +): ExternalEvaluationEndpointSettings { + return { + kind: item["kind"], + details: item["details"], + }; +} + +/** 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"]), + }; +} + +/** The response of a PolicyDefinition list operation. */ +export interface _PolicyDefinitionListResult { + /** The PolicyDefinition items on this page */ + value: PolicyDefinition[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _policyDefinitionListResultDeserializer(item: any): _PolicyDefinitionListResult { + return { + value: policyDefinitionArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function policyDefinitionArraySerializer(result: Array): any[] { + return result.map((item) => { + return policyDefinitionSerializer(item); + }); +} + +export function policyDefinitionArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return policyDefinitionDeserializer(item); + }); +} + +/** The ID of the policy definition version. */ +export interface PolicyDefinitionVersion extends ProxyResource { + /** The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. */ + policyType?: PolicyType; + /** The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. */ + mode?: string; + /** The display name of the policy definition. */ + displayName?: string; + /** The policy definition description. */ + description?: string; + /** The policy rule. */ + policyRule?: any; + /** The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. */ + metadata?: any; + /** The parameter definitions for parameters used in the policy rule. The keys are the parameter names. */ + parameters?: Record; + /** The policy definition version in #.#.# format. */ + version?: string; + /** The details of the source of external evaluation results required by the policy during enforcement evaluation. */ + externalEvaluationEnforcementSettings?: ExternalEvaluationEnforcementSettings; +} + +export function policyDefinitionVersionSerializer(item: PolicyDefinitionVersion): any { + return { + properties: areAllPropsUndefined(item, [ + "policyType", + "mode", + "displayName", + "description", + "policyRule", + "metadata", + "parameters", + "version", + "externalEvaluationEnforcementSettings", + ]) + ? undefined + : _policyDefinitionVersionPropertiesSerializer(item), + }; +} + +export function policyDefinitionVersionDeserializer(item: any): PolicyDefinitionVersion { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + ...(!item["properties"] + ? item["properties"] + : _policyDefinitionVersionPropertiesDeserializer(item["properties"])), + }; +} + +/** The policy definition properties. */ +export interface PolicyDefinitionVersionProperties { + /** The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. */ + policyType?: PolicyType; + /** The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. */ + mode?: string; + /** The display name of the policy definition. */ + displayName?: string; + /** The policy definition description. */ + description?: string; + /** The policy rule. */ + policyRule?: any; + /** The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. */ + metadata?: any; + /** The parameter definitions for parameters used in the policy rule. The keys are the parameter names. */ + parameters?: Record; + /** The policy definition version in #.#.# format. */ + version?: string; + /** The details of the source of external evaluation results required by the policy during enforcement evaluation. */ + externalEvaluationEnforcementSettings?: ExternalEvaluationEnforcementSettings; +} + +export function policyDefinitionVersionPropertiesSerializer( + item: PolicyDefinitionVersionProperties, +): any { + return { + policyType: item["policyType"], + mode: item["mode"], + displayName: item["displayName"], + description: item["description"], + policyRule: item["policyRule"], + metadata: item["metadata"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterDefinitionsValueRecordSerializer(item["parameters"]), + version: item["version"], + externalEvaluationEnforcementSettings: !item["externalEvaluationEnforcementSettings"] + ? item["externalEvaluationEnforcementSettings"] + : externalEvaluationEnforcementSettingsSerializer( + item["externalEvaluationEnforcementSettings"], + ), + }; +} + +export function policyDefinitionVersionPropertiesDeserializer( + item: any, +): PolicyDefinitionVersionProperties { + return { + policyType: item["policyType"], + mode: item["mode"], + displayName: item["displayName"], + description: item["description"], + policyRule: item["policyRule"], + metadata: item["metadata"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterDefinitionsValueRecordDeserializer(item["parameters"]), + version: item["version"], + externalEvaluationEnforcementSettings: !item["externalEvaluationEnforcementSettings"] + ? item["externalEvaluationEnforcementSettings"] + : externalEvaluationEnforcementSettingsDeserializer( + item["externalEvaluationEnforcementSettings"], + ), + }; +} + +/** The response of a PolicyDefinitionVersion list operation. */ +export interface _PolicyDefinitionVersionListResult { + /** The PolicyDefinitionVersion items on this page */ + value: PolicyDefinitionVersion[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _policyDefinitionVersionListResultDeserializer( + item: any, +): _PolicyDefinitionVersionListResult { + return { + value: policyDefinitionVersionArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function policyDefinitionVersionArraySerializer( + result: Array, +): any[] { + return result.map((item) => { + return policyDefinitionVersionSerializer(item); + }); +} + +export function policyDefinitionVersionArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return policyDefinitionVersionDeserializer(item); + }); +} + +/** The policy set definition. */ +export interface PolicySetDefinition extends ProxyResource { + /** The type of policy set definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. */ + policyType?: PolicyType; + /** The display name of the policy set definition. */ + displayName?: string; + /** The policy set definition description. */ + description?: string; + /** The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. */ + metadata?: any; + /** The policy set definition parameters that can be used in policy definition references. */ + parameters?: Record; + /** An array of policy definition references. */ + policyDefinitions?: PolicyDefinitionReference[]; + /** The metadata describing groups of policy definition references within the policy set definition. */ + policyDefinitionGroups?: PolicyDefinitionGroup[]; + /** The policy set definition version in #.#.# format. */ + version?: string; + /** A list of available versions for this policy set definition. */ + versions?: string[]; +} + +export function policySetDefinitionSerializer(item: PolicySetDefinition): any { + return { + properties: areAllPropsUndefined(item, [ + "policyType", + "displayName", + "description", + "metadata", + "parameters", + "policyDefinitions", + "policyDefinitionGroups", + "version", + "versions", + ]) + ? undefined + : _policySetDefinitionPropertiesSerializer(item), + }; +} + +export function policySetDefinitionDeserializer(item: any): PolicySetDefinition { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + ...(!item["properties"] + ? item["properties"] + : _policySetDefinitionPropertiesDeserializer(item["properties"])), + }; +} + +/** The policy set definition properties. */ +export interface PolicySetDefinitionProperties { + /** The type of policy set definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. */ + policyType?: PolicyType; + /** The display name of the policy set definition. */ + displayName?: string; + /** The policy set definition description. */ + description?: string; + /** The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. */ + metadata?: any; + /** The policy set definition parameters that can be used in policy definition references. */ + parameters?: Record; + /** An array of policy definition references. */ + policyDefinitions: PolicyDefinitionReference[]; + /** The metadata describing groups of policy definition references within the policy set definition. */ + policyDefinitionGroups?: PolicyDefinitionGroup[]; + /** The policy set definition version in #.#.# format. */ + version?: string; + /** A list of available versions for this policy set definition. */ + versions?: string[]; +} + +export function policySetDefinitionPropertiesSerializer(item: PolicySetDefinitionProperties): any { + return { + policyType: item["policyType"], + displayName: item["displayName"], + description: item["description"], + metadata: item["metadata"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterDefinitionsValueRecordSerializer(item["parameters"]), + policyDefinitions: policyDefinitionReferenceArraySerializer(item["policyDefinitions"]), + policyDefinitionGroups: !item["policyDefinitionGroups"] + ? item["policyDefinitionGroups"] + : policyDefinitionGroupArraySerializer(item["policyDefinitionGroups"]), + version: item["version"], + versions: !item["versions"] + ? item["versions"] + : item["versions"].map((p: any) => { + return p; + }), + }; +} + +export function policySetDefinitionPropertiesDeserializer( + item: any, +): PolicySetDefinitionProperties { + return { + policyType: item["policyType"], + displayName: item["displayName"], + description: item["description"], + metadata: item["metadata"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterDefinitionsValueRecordDeserializer(item["parameters"]), + policyDefinitions: policyDefinitionReferenceArrayDeserializer(item["policyDefinitions"]), + policyDefinitionGroups: !item["policyDefinitionGroups"] + ? item["policyDefinitionGroups"] + : policyDefinitionGroupArrayDeserializer(item["policyDefinitionGroups"]), + version: item["version"], + versions: !item["versions"] + ? item["versions"] + : item["versions"].map((p: any) => { + return p; + }), + }; +} + +export function policyDefinitionReferenceArraySerializer( + result: Array, +): any[] { + return result.map((item) => { + return policyDefinitionReferenceSerializer(item); + }); +} + +export function policyDefinitionReferenceArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return policyDefinitionReferenceDeserializer(item); + }); +} + +/** The policy definition reference. */ +export interface PolicyDefinitionReference { + /** The ID of the policy definition or policy set definition. */ + policyDefinitionId: string; + /** The version of the policy definition to use. */ + definitionVersion?: string; + /** The latest version of the policy definition available. This is only present if requested via the $expand query parameter. */ + readonly latestDefinitionVersion?: string; + /** The effective version of the policy definition in use. This is only present if requested via the $expand query parameter. */ + readonly effectiveDefinitionVersion?: string; + /** The parameter values for the referenced policy rule. The keys are the parameter names. */ + parameters?: Record; + /** A unique id (within the policy set definition) for this policy definition reference. */ + policyDefinitionReferenceId?: string; + /** The name of the groups that this policy definition reference belongs to. */ + groupNames?: string[]; +} + +export function policyDefinitionReferenceSerializer(item: PolicyDefinitionReference): any { + return { + policyDefinitionId: item["policyDefinitionId"], + definitionVersion: item["definitionVersion"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterValuesValueRecordSerializer(item["parameters"]), + policyDefinitionReferenceId: item["policyDefinitionReferenceId"], + groupNames: !item["groupNames"] + ? item["groupNames"] + : item["groupNames"].map((p: any) => { + return p; + }), + }; +} + +export function policyDefinitionReferenceDeserializer(item: any): PolicyDefinitionReference { + return { + policyDefinitionId: item["policyDefinitionId"], + definitionVersion: item["definitionVersion"], + latestDefinitionVersion: item["latestDefinitionVersion"], + effectiveDefinitionVersion: item["effectiveDefinitionVersion"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterValuesValueRecordDeserializer(item["parameters"]), + policyDefinitionReferenceId: item["policyDefinitionReferenceId"], + groupNames: !item["groupNames"] + ? item["groupNames"] + : item["groupNames"].map((p: any) => { + return p; + }), + }; +} + +export function policyDefinitionGroupArraySerializer(result: Array): any[] { + return result.map((item) => { + return policyDefinitionGroupSerializer(item); + }); +} + +export function policyDefinitionGroupArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return policyDefinitionGroupDeserializer(item); + }); +} + +/** The policy definition group. */ +export interface PolicyDefinitionGroup { + /** The name of the group. */ + name: string; + /** The group's display name. */ + displayName?: string; + /** The group's category. */ + category?: string; + /** The group's description. */ + description?: string; + /** A resource ID of a resource that contains additional metadata about the group. */ + additionalMetadataId?: string; +} + +export function policyDefinitionGroupSerializer(item: PolicyDefinitionGroup): any { + return { + name: item["name"], + displayName: item["displayName"], + category: item["category"], + description: item["description"], + additionalMetadataId: item["additionalMetadataId"], + }; +} + +export function policyDefinitionGroupDeserializer(item: any): PolicyDefinitionGroup { + return { + name: item["name"], + displayName: item["displayName"], + category: item["category"], + description: item["description"], + additionalMetadataId: item["additionalMetadataId"], + }; +} + +/** The response of a PolicySetDefinition list operation. */ +export interface _PolicySetDefinitionListResult { + /** The PolicySetDefinition items on this page */ + value: PolicySetDefinition[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _policySetDefinitionListResultDeserializer( + item: any, +): _PolicySetDefinitionListResult { + return { + value: policySetDefinitionArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function policySetDefinitionArraySerializer(result: Array): any[] { + return result.map((item) => { + return policySetDefinitionSerializer(item); + }); +} + +export function policySetDefinitionArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return policySetDefinitionDeserializer(item); + }); +} + +/** The policy set definition version. */ +export interface PolicySetDefinitionVersion extends ProxyResource { + /** The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. */ + policyType?: PolicyType; + /** The display name of the policy set definition. */ + displayName?: string; + /** The policy set definition description. */ + description?: string; + /** The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. */ + metadata?: any; + /** The policy set definition parameters that can be used in policy definition references. */ + parameters?: Record; + /** An array of policy definition references. */ + policyDefinitions?: PolicyDefinitionReference[]; + /** The metadata describing groups of policy definition references within the policy set definition. */ + policyDefinitionGroups?: PolicyDefinitionGroup[]; + /** The policy set definition version in #.#.# format. */ + version?: string; +} + +export function policySetDefinitionVersionSerializer(item: PolicySetDefinitionVersion): any { + return { + properties: areAllPropsUndefined(item, [ + "policyType", + "displayName", + "description", + "metadata", + "parameters", + "policyDefinitions", + "policyDefinitionGroups", + "version", + ]) + ? undefined + : _policySetDefinitionVersionPropertiesSerializer(item), + }; +} + +export function policySetDefinitionVersionDeserializer(item: any): PolicySetDefinitionVersion { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + ...(!item["properties"] + ? item["properties"] + : _policySetDefinitionVersionPropertiesDeserializer(item["properties"])), + }; +} + +/** The policy set definition properties. */ +export interface PolicySetDefinitionVersionProperties { + /** The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. */ + policyType?: PolicyType; + /** The display name of the policy set definition. */ + displayName?: string; + /** The policy set definition description. */ + description?: string; + /** The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. */ + metadata?: any; + /** The policy set definition parameters that can be used in policy definition references. */ + parameters?: Record; + /** An array of policy definition references. */ + policyDefinitions: PolicyDefinitionReference[]; + /** The metadata describing groups of policy definition references within the policy set definition. */ + policyDefinitionGroups?: PolicyDefinitionGroup[]; + /** The policy set definition version in #.#.# format. */ + version?: string; +} + +export function policySetDefinitionVersionPropertiesSerializer( + item: PolicySetDefinitionVersionProperties, +): any { + return { + policyType: item["policyType"], + displayName: item["displayName"], + description: item["description"], + metadata: item["metadata"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterDefinitionsValueRecordSerializer(item["parameters"]), + policyDefinitions: policyDefinitionReferenceArraySerializer(item["policyDefinitions"]), + policyDefinitionGroups: !item["policyDefinitionGroups"] + ? item["policyDefinitionGroups"] + : policyDefinitionGroupArraySerializer(item["policyDefinitionGroups"]), + version: item["version"], + }; +} + +export function policySetDefinitionVersionPropertiesDeserializer( + item: any, +): PolicySetDefinitionVersionProperties { + return { + policyType: item["policyType"], + displayName: item["displayName"], + description: item["description"], + metadata: item["metadata"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterDefinitionsValueRecordDeserializer(item["parameters"]), + policyDefinitions: policyDefinitionReferenceArrayDeserializer(item["policyDefinitions"]), + policyDefinitionGroups: !item["policyDefinitionGroups"] + ? item["policyDefinitionGroups"] + : policyDefinitionGroupArrayDeserializer(item["policyDefinitionGroups"]), + version: item["version"], + }; +} + +/** The response of a PolicySetDefinitionVersion list operation. */ +export interface _PolicySetDefinitionVersionListResult { + /** The PolicySetDefinitionVersion items on this page */ + value: PolicySetDefinitionVersion[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _policySetDefinitionVersionListResultDeserializer( + item: any, +): _PolicySetDefinitionVersionListResult { + return { + value: policySetDefinitionVersionArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function policySetDefinitionVersionArraySerializer( + result: Array, +): any[] { + return result.map((item) => { + return policySetDefinitionVersionSerializer(item); + }); +} + +export function policySetDefinitionVersionArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return policySetDefinitionVersionDeserializer(item); + }); +} + +/** The policy token request properties. */ +export interface PolicyTokenRequest { + /** The resource operation to acquire a token for. */ + operation: PolicyTokenOperation; + /** The change reference. */ + changeReference?: string; +} + +export function policyTokenRequestSerializer(item: PolicyTokenRequest): any { + return { + operation: policyTokenOperationSerializer(item["operation"]), + changeReference: item["changeReference"], + }; +} + +/** The resource operation to acquire a token for. */ +export interface PolicyTokenOperation { + /** The request URI of the resource operation. */ + uri: string; + /** The http method of the resource operation. */ + httpMethod: string; + /** The payload of the resource operation. */ + content?: any; +} + +export function policyTokenOperationSerializer(item: PolicyTokenOperation): any { + return { uri: item["uri"], httpMethod: item["httpMethod"], content: item["content"] }; +} + +/** The policy token response properties. */ +export interface PolicyTokenResponse { + /** The result of the completed token acquisition operation. Possible values are Succeeded and Failed. */ + result?: PolicyTokenResult; + /** Status message with additional details about the token acquisition operation result. */ + message?: string; + /** The date and time after which the client can try to acquire a token again in the case of retry-able failures. */ + retryAfter?: Date; + /** An array of external evaluation endpoint invocation results. */ + results?: ExternalEvaluationEndpointInvocationResult[]; + /** The change reference associated with the operation for which the token is acquired. */ + changeReference?: string; + /** The issued policy token. */ + token?: string; + /** The unique Id assigned to the policy token. */ + tokenId?: string; + /** The expiration of the policy token. */ + expiration?: Date; +} + +export function policyTokenResponseDeserializer(item: any): PolicyTokenResponse { + return { + result: item["result"], + message: item["message"], + retryAfter: !item["retryAfter"] ? item["retryAfter"] : new Date(item["retryAfter"]), + results: !item["results"] + ? item["results"] + : externalEvaluationEndpointInvocationResultArrayDeserializer(item["results"]), + changeReference: item["changeReference"], + token: item["token"], + tokenId: item["tokenId"], + expiration: !item["expiration"] ? item["expiration"] : new Date(item["expiration"]), + }; +} + +/** The result of the completed token acquisition operation. Possible values are Succeeded and Failed. */ +export enum KnownPolicyTokenResult { + /** The token acquisition succeeded. */ + Succeeded = "Succeeded", + /** The token acquisition failed. */ + Failed = "Failed", +} + +/** + * The result of the completed token acquisition operation. Possible values are Succeeded and Failed. \ + * {@link KnownPolicyTokenResult} can be used interchangeably with PolicyTokenResult, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Succeeded**: The token acquisition succeeded. \ + * **Failed**: The token acquisition failed. + */ +export type PolicyTokenResult = string; + +export function externalEvaluationEndpointInvocationResultArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return externalEvaluationEndpointInvocationResultDeserializer(item); + }); +} + +/** The external evaluation endpoint invocation results. */ +export interface ExternalEvaluationEndpointInvocationResult { + /** The details of the policy requiring the external endpoint invocation. */ + policyInfo?: PolicyLogInfo; + /** The result of the external endpoint. Possible values are Succeeded and Failed. */ + result?: ExternalEndpointResult; + /** The status message with additional details about the invocation result. */ + message?: string; + /** The date and time after which a failed endpoint invocation can be retried. */ + retryAfter?: Date; + /** The set of claims that will be attached to the policy token as an attestation for the result of the endpoint invocation. */ + claims?: any; + /** The expiration of the results. */ + expiration?: Date; +} + +export function externalEvaluationEndpointInvocationResultDeserializer( + item: any, +): ExternalEvaluationEndpointInvocationResult { + return { + policyInfo: !item["policyInfo"] + ? item["policyInfo"] + : policyLogInfoDeserializer(item["policyInfo"]), + result: item["result"], + message: item["message"], + retryAfter: !item["retryAfter"] ? item["retryAfter"] : new Date(item["retryAfter"]), + claims: item["claims"], + expiration: !item["expiration"] ? item["expiration"] : new Date(item["expiration"]), + }; +} + +/** The policy log info. */ +export interface PolicyLogInfo { + /** The policy definition Id. */ + policyDefinitionId?: string; + /** The policy set definition Id. */ + policySetDefinitionId?: string; + /** The policy definition instance Id inside a policy set. */ + policyDefinitionReferenceId?: string; + /** The policy set definition name. */ + policySetDefinitionName?: string; + /** The policy set definition display name. */ + policySetDefinitionDisplayName?: string; + /** The policy set definition version. */ + policySetDefinitionVersion?: string; + /** The policy set definition category. */ + policySetDefinitionCategory?: string; + /** The policy definition name. */ + policyDefinitionName?: string; + /** The policy definition display name. */ + policyDefinitionDisplayName?: string; + /** The policy definition version. */ + policyDefinitionVersion?: string; + /** The policy definition action. */ + policyDefinitionEffect?: string; + /** An array of policy definition group names. */ + policyDefinitionGroupNames?: string[]; + /** The policy assignment Id. */ + policyAssignmentId?: string; + /** The policy assignment name. */ + policyAssignmentName?: string; + /** The policy assignment display name. */ + policyAssignmentDisplayName?: string; + /** The policy assignment version. */ + policyAssignmentVersion?: string; + /** The policy assignment scope. */ + policyAssignmentScope?: string; + /** The resource location. */ + resourceLocation?: string; + /** The management group ancestors. */ + ancestors?: string; + /** The policy compliance reason code. */ + complianceReasonCode?: string; + /** An array of policy exemption Ids. */ + policyExemptionIds?: string[]; +} + +export function policyLogInfoDeserializer(item: any): PolicyLogInfo { + return { + policyDefinitionId: item["policyDefinitionId"], + policySetDefinitionId: item["policySetDefinitionId"], + policyDefinitionReferenceId: item["policyDefinitionReferenceId"], + policySetDefinitionName: item["policySetDefinitionName"], + policySetDefinitionDisplayName: item["policySetDefinitionDisplayName"], + policySetDefinitionVersion: item["policySetDefinitionVersion"], + policySetDefinitionCategory: item["policySetDefinitionCategory"], + policyDefinitionName: item["policyDefinitionName"], + policyDefinitionDisplayName: item["policyDefinitionDisplayName"], + policyDefinitionVersion: item["policyDefinitionVersion"], + policyDefinitionEffect: item["policyDefinitionEffect"], + policyDefinitionGroupNames: !item["policyDefinitionGroupNames"] + ? item["policyDefinitionGroupNames"] + : item["policyDefinitionGroupNames"].map((p: any) => { + return p; + }), + policyAssignmentId: item["policyAssignmentId"], + policyAssignmentName: item["policyAssignmentName"], + policyAssignmentDisplayName: item["policyAssignmentDisplayName"], + policyAssignmentVersion: item["policyAssignmentVersion"], + policyAssignmentScope: item["policyAssignmentScope"], + resourceLocation: item["resourceLocation"], + ancestors: item["ancestors"], + complianceReasonCode: item["complianceReasonCode"], + policyExemptionIds: !item["policyExemptionIds"] + ? item["policyExemptionIds"] + : item["policyExemptionIds"].map((p: any) => { + return p; + }), + }; +} + +/** The result of the external endpoint. Possible values are Succeeded and Failed. */ +export enum KnownExternalEndpointResult { + /** The external endpoint succeeded. */ + Succeeded = "Succeeded", + /** The external endpoint failed. */ + Failed = "Failed", +} + +/** + * The result of the external endpoint. Possible values are Succeeded and Failed. \ + * {@link KnownExternalEndpointResult} can be used interchangeably with ExternalEndpointResult, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Succeeded**: The external endpoint succeeded. \ + * **Failed**: The external endpoint failed. + */ +export type ExternalEndpointResult = string; + +/** The available API versions. */ +export enum KnownVersions { + /** The 2025-03-01 API version. */ + V20250301 = "2025-03-01", +} + +export function _policyAssignmentPropertiesSerializer(item: PolicyAssignment): any { + return { + displayName: item["displayName"], + policyDefinitionId: item["policyDefinitionId"], + definitionVersion: item["definitionVersion"], + notScopes: !item["notScopes"] + ? item["notScopes"] + : item["notScopes"].map((p: any) => { + return p; + }), + parameters: !item["parameters"] + ? item["parameters"] + : parameterValuesValueRecordSerializer(item["parameters"]), + description: item["description"], + metadata: item["metadata"], + enforcementMode: item["enforcementMode"], + nonComplianceMessages: !item["nonComplianceMessages"] + ? item["nonComplianceMessages"] + : nonComplianceMessageArraySerializer(item["nonComplianceMessages"]), + resourceSelectors: !item["resourceSelectors"] + ? item["resourceSelectors"] + : resourceSelectorArraySerializer(item["resourceSelectors"]), + overrides: !item["overrides"] ? item["overrides"] : overrideArraySerializer(item["overrides"]), + assignmentType: item["assignmentType"], + }; +} + +export function _policyAssignmentPropertiesDeserializer(item: any) { + return { + displayName: item["displayName"], + policyDefinitionId: item["policyDefinitionId"], + definitionVersion: item["definitionVersion"], + latestDefinitionVersion: item["latestDefinitionVersion"], + effectiveDefinitionVersion: item["effectiveDefinitionVersion"], + scope: item["scope"], + notScopes: !item["notScopes"] + ? item["notScopes"] + : item["notScopes"].map((p: any) => { + return p; + }), + parameters: !item["parameters"] + ? item["parameters"] + : parameterValuesValueRecordDeserializer(item["parameters"]), + description: item["description"], + metadata: item["metadata"], + enforcementMode: item["enforcementMode"], + nonComplianceMessages: !item["nonComplianceMessages"] + ? item["nonComplianceMessages"] + : nonComplianceMessageArrayDeserializer(item["nonComplianceMessages"]), + resourceSelectors: !item["resourceSelectors"] + ? item["resourceSelectors"] + : resourceSelectorArrayDeserializer(item["resourceSelectors"]), + overrides: !item["overrides"] + ? item["overrides"] + : overrideArrayDeserializer(item["overrides"]), + assignmentType: item["assignmentType"], + instanceId: item["instanceId"], + }; +} + +export function _policyAssignmentUpdatePropertiesSerializer(item: PolicyAssignmentUpdate): any { + return { + resourceSelectors: !item["resourceSelectors"] + ? item["resourceSelectors"] + : resourceSelectorArraySerializer(item["resourceSelectors"]), + overrides: !item["overrides"] ? item["overrides"] : overrideArraySerializer(item["overrides"]), + }; +} + +export function _policyDefinitionPropertiesSerializer(item: PolicyDefinition): any { + return { + policyType: item["policyType"], + mode: item["mode"], + displayName: item["displayName"], + description: item["description"], + policyRule: item["policyRule"], + metadata: item["metadata"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterDefinitionsValueRecordSerializer(item["parameters"]), + version: item["version"], + versions: !item["versions"] + ? item["versions"] + : item["versions"].map((p: any) => { + return p; + }), + externalEvaluationEnforcementSettings: !item["externalEvaluationEnforcementSettings"] + ? item["externalEvaluationEnforcementSettings"] + : externalEvaluationEnforcementSettingsSerializer( + item["externalEvaluationEnforcementSettings"], + ), + }; +} + +export function _policyDefinitionPropertiesDeserializer(item: any) { + return { + policyType: item["policyType"], + mode: item["mode"], + displayName: item["displayName"], + description: item["description"], + policyRule: item["policyRule"], + metadata: item["metadata"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterDefinitionsValueRecordDeserializer(item["parameters"]), + version: item["version"], + versions: !item["versions"] + ? item["versions"] + : item["versions"].map((p: any) => { + return p; + }), + externalEvaluationEnforcementSettings: !item["externalEvaluationEnforcementSettings"] + ? item["externalEvaluationEnforcementSettings"] + : externalEvaluationEnforcementSettingsDeserializer( + item["externalEvaluationEnforcementSettings"], + ), + }; +} + +export function _policyDefinitionVersionPropertiesSerializer(item: PolicyDefinitionVersion): any { + return { + policyType: item["policyType"], + mode: item["mode"], + displayName: item["displayName"], + description: item["description"], + policyRule: item["policyRule"], + metadata: item["metadata"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterDefinitionsValueRecordSerializer(item["parameters"]), + version: item["version"], + externalEvaluationEnforcementSettings: !item["externalEvaluationEnforcementSettings"] + ? item["externalEvaluationEnforcementSettings"] + : externalEvaluationEnforcementSettingsSerializer( + item["externalEvaluationEnforcementSettings"], + ), + }; +} + +export function _policyDefinitionVersionPropertiesDeserializer(item: any) { + return { + policyType: item["policyType"], + mode: item["mode"], + displayName: item["displayName"], + description: item["description"], + policyRule: item["policyRule"], + metadata: item["metadata"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterDefinitionsValueRecordDeserializer(item["parameters"]), + version: item["version"], + externalEvaluationEnforcementSettings: !item["externalEvaluationEnforcementSettings"] + ? item["externalEvaluationEnforcementSettings"] + : externalEvaluationEnforcementSettingsDeserializer( + item["externalEvaluationEnforcementSettings"], + ), + }; +} + +export function _policySetDefinitionPropertiesSerializer(item: PolicySetDefinition): any { + return { + policyType: item["policyType"], + displayName: item["displayName"], + description: item["description"], + metadata: item["metadata"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterDefinitionsValueRecordSerializer(item["parameters"]), + policyDefinitions: !item["policyDefinitions"] + ? item["policyDefinitions"] + : policyDefinitionReferenceArraySerializer(item["policyDefinitions"]), + policyDefinitionGroups: !item["policyDefinitionGroups"] + ? item["policyDefinitionGroups"] + : policyDefinitionGroupArraySerializer(item["policyDefinitionGroups"]), + version: item["version"], + versions: !item["versions"] + ? item["versions"] + : item["versions"].map((p: any) => { + return p; + }), + }; +} + +export function _policySetDefinitionPropertiesDeserializer(item: any) { + return { + policyType: item["policyType"], + displayName: item["displayName"], + description: item["description"], + metadata: item["metadata"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterDefinitionsValueRecordDeserializer(item["parameters"]), + policyDefinitions: !item["policyDefinitions"] + ? item["policyDefinitions"] + : policyDefinitionReferenceArrayDeserializer(item["policyDefinitions"]), + policyDefinitionGroups: !item["policyDefinitionGroups"] + ? item["policyDefinitionGroups"] + : policyDefinitionGroupArrayDeserializer(item["policyDefinitionGroups"]), + version: item["version"], + versions: !item["versions"] + ? item["versions"] + : item["versions"].map((p: any) => { + return p; + }), + }; +} + +export function _policySetDefinitionVersionPropertiesSerializer( + item: PolicySetDefinitionVersion, +): any { + return { + policyType: item["policyType"], + displayName: item["displayName"], + description: item["description"], + metadata: item["metadata"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterDefinitionsValueRecordSerializer(item["parameters"]), + policyDefinitions: !item["policyDefinitions"] + ? item["policyDefinitions"] + : policyDefinitionReferenceArraySerializer(item["policyDefinitions"]), + policyDefinitionGroups: !item["policyDefinitionGroups"] + ? item["policyDefinitionGroups"] + : policyDefinitionGroupArraySerializer(item["policyDefinitionGroups"]), + version: item["version"], + }; +} + +export function _policySetDefinitionVersionPropertiesDeserializer(item: any) { + return { + policyType: item["policyType"], + displayName: item["displayName"], + description: item["description"], + metadata: item["metadata"], + parameters: !item["parameters"] + ? item["parameters"] + : parameterDefinitionsValueRecordDeserializer(item["parameters"]), + policyDefinitions: !item["policyDefinitions"] + ? item["policyDefinitions"] + : policyDefinitionReferenceArrayDeserializer(item["policyDefinitions"]), + policyDefinitionGroups: !item["policyDefinitionGroups"] + ? item["policyDefinitionGroups"] + : policyDefinitionGroupArrayDeserializer(item["policyDefinitionGroups"]), + version: item["version"], + }; +} diff --git a/sdk/policy/arm-policy/src/models/parameters.ts b/sdk/policy/arm-policy/src/models/parameters.ts deleted file mode 100644 index b952660472ca..000000000000 --- a/sdk/policy/arm-policy/src/models/parameters.ts +++ /dev/null @@ -1,328 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { - OperationParameter, - OperationURLParameter, - OperationQueryParameter, -} from "@azure/core-client"; -import { - PolicyDefinition as PolicyDefinitionMapper, - PolicyDefinitionVersion as PolicyDefinitionVersionMapper, - PolicySetDefinition as PolicySetDefinitionMapper, - PolicySetDefinitionVersion as PolicySetDefinitionVersionMapper, - PolicyAssignment as PolicyAssignmentMapper, - PolicyAssignmentUpdate as PolicyAssignmentUpdateMapper, -} from "../models/mappers.js"; - -export const contentType: OperationParameter = { - parameterPath: ["options", "contentType"], - mapper: { - defaultValue: "application/json", - isConstant: true, - serializedName: "Content-Type", - type: { - name: "String", - }, - }, -}; - -export const parameters: OperationParameter = { - parameterPath: "parameters", - mapper: PolicyDefinitionMapper, -}; - -export const accept: OperationParameter = { - parameterPath: "accept", - mapper: { - defaultValue: "application/json", - isConstant: true, - serializedName: "Accept", - type: { - name: "String", - }, - }, -}; - -export const $host: OperationURLParameter = { - parameterPath: "$host", - mapper: { - serializedName: "$host", - required: true, - type: { - name: "String", - }, - }, - skipEncoding: true, -}; - -export const subscriptionId: OperationURLParameter = { - parameterPath: "subscriptionId", - mapper: { - serializedName: "subscriptionId", - required: true, - type: { - name: "Uuid", - }, - }, -}; - -export const policyDefinitionName: OperationURLParameter = { - parameterPath: "policyDefinitionName", - mapper: { - constraints: { - Pattern: new RegExp("^[^<>*%&:\\?.+/]*[^<>*%&:\\?.+/ ]+$"), - }, - serializedName: "policyDefinitionName", - required: true, - type: { - name: "String", - }, - }, -}; - -export const apiVersion: OperationQueryParameter = { - parameterPath: "apiVersion", - mapper: { - defaultValue: "2024-05-01", - isConstant: true, - serializedName: "api-version", - type: { - name: "String", - }, - }, -}; - -export const managementGroupId: OperationURLParameter = { - parameterPath: "managementGroupId", - mapper: { - serializedName: "managementGroupId", - required: true, - type: { - name: "String", - }, - }, -}; - -export const filter: OperationQueryParameter = { - parameterPath: ["options", "filter"], - mapper: { - serializedName: "$filter", - type: { - name: "String", - }, - }, - skipEncoding: true, -}; - -export const top: OperationQueryParameter = { - parameterPath: ["options", "top"], - mapper: { - constraints: { - InclusiveMaximum: 1000, - InclusiveMinimum: 1, - }, - serializedName: "$top", - type: { - name: "Number", - }, - }, -}; - -export const nextLink: OperationURLParameter = { - parameterPath: "nextLink", - mapper: { - serializedName: "nextLink", - required: true, - type: { - name: "String", - }, - }, - skipEncoding: true, -}; - -export const managementGroupName: OperationURLParameter = { - parameterPath: "managementGroupName", - mapper: { - constraints: { - MaxLength: 90, - MinLength: 1, - }, - serializedName: "managementGroupName", - required: true, - type: { - name: "String", - }, - }, -}; - -export const parameters1: OperationParameter = { - parameterPath: "parameters", - mapper: PolicyDefinitionVersionMapper, -}; - -export const policyDefinitionVersion: OperationURLParameter = { - parameterPath: "policyDefinitionVersion", - mapper: { - constraints: { - Pattern: new RegExp("^\\d+\\.\\d+\\.\\d+$"), - }, - serializedName: "policyDefinitionVersion", - required: true, - type: { - name: "String", - }, - }, -}; - -export const parameters2: OperationParameter = { - parameterPath: "parameters", - mapper: PolicySetDefinitionMapper, -}; - -export const policySetDefinitionName: OperationURLParameter = { - parameterPath: "policySetDefinitionName", - mapper: { - constraints: { - Pattern: new RegExp("^[^<>*%&:\\?.+/]*[^<>*%&:\\?.+/ ]+$"), - }, - serializedName: "policySetDefinitionName", - required: true, - type: { - name: "String", - }, - }, -}; - -export const expand: OperationQueryParameter = { - parameterPath: ["options", "expand"], - mapper: { - serializedName: "$expand", - type: { - name: "String", - }, - }, -}; - -export const parameters3: OperationParameter = { - parameterPath: "parameters", - mapper: PolicySetDefinitionVersionMapper, -}; - -export const scope: OperationURLParameter = { - parameterPath: "scope", - mapper: { - serializedName: "scope", - required: true, - type: { - name: "String", - }, - }, - skipEncoding: true, -}; - -export const policyAssignmentName: OperationURLParameter = { - parameterPath: "policyAssignmentName", - mapper: { - constraints: { - Pattern: new RegExp("^[^<>*%&:\\?.+/]*[^<>*%&:\\?.+/ ]+$"), - }, - serializedName: "policyAssignmentName", - required: true, - type: { - name: "String", - }, - }, -}; - -export const parameters4: OperationParameter = { - parameterPath: "parameters", - mapper: PolicyAssignmentMapper, -}; - -export const parameters5: OperationParameter = { - parameterPath: "parameters", - mapper: PolicyAssignmentUpdateMapper, -}; - -export const resourceGroupName: OperationURLParameter = { - parameterPath: "resourceGroupName", - mapper: { - constraints: { - Pattern: new RegExp("^[-\\w\\._\\(\\)]+$"), - MaxLength: 90, - MinLength: 1, - }, - serializedName: "resourceGroupName", - required: true, - type: { - name: "String", - }, - }, -}; - -export const resourceProviderNamespace: OperationURLParameter = { - parameterPath: "resourceProviderNamespace", - mapper: { - serializedName: "resourceProviderNamespace", - required: true, - type: { - name: "String", - }, - }, -}; - -export const parentResourcePath: OperationURLParameter = { - parameterPath: "parentResourcePath", - mapper: { - serializedName: "parentResourcePath", - required: true, - type: { - name: "String", - }, - }, - skipEncoding: true, -}; - -export const resourceType: OperationURLParameter = { - parameterPath: "resourceType", - mapper: { - serializedName: "resourceType", - required: true, - type: { - name: "String", - }, - }, - skipEncoding: true, -}; - -export const resourceName: OperationURLParameter = { - parameterPath: "resourceName", - mapper: { - constraints: { - Pattern: new RegExp("^.+$"), - }, - serializedName: "resourceName", - required: true, - type: { - name: "String", - }, - }, -}; - -export const policyAssignmentId: OperationURLParameter = { - parameterPath: "policyAssignmentId", - mapper: { - serializedName: "policyAssignmentId", - required: true, - type: { - name: "String", - }, - }, - skipEncoding: true, -}; diff --git a/sdk/policy/arm-policy/src/operations/index.ts b/sdk/policy/arm-policy/src/operations/index.ts deleted file mode 100644 index c79764594dfa..000000000000 --- a/sdk/policy/arm-policy/src/operations/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export * from "./policyDefinitions.js"; -export * from "./policyDefinitionVersions.js"; -export * from "./policySetDefinitions.js"; -export * from "./policySetDefinitionVersions.js"; -export * from "./policyAssignments.js"; diff --git a/sdk/policy/arm-policy/src/operations/policyAssignments.ts b/sdk/policy/arm-policy/src/operations/policyAssignments.ts deleted file mode 100644 index ed4ffda3a577..000000000000 --- a/sdk/policy/arm-policy/src/operations/policyAssignments.ts +++ /dev/null @@ -1,1075 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; -import { setContinuationToken } from "../pagingHelper.js"; -import type { PolicyAssignments } from "../operationsInterfaces/index.js"; -import * as coreClient from "@azure/core-client"; -import * as Mappers from "../models/mappers.js"; -import * as Parameters from "../models/parameters.js"; -import type { PolicyClient } from "../policyClient.js"; -import type { - PolicyAssignment, - PolicyAssignmentsListForResourceGroupNextOptionalParams, - PolicyAssignmentsListForResourceGroupOptionalParams, - PolicyAssignmentsListForResourceGroupResponse, - PolicyAssignmentsListForResourceNextOptionalParams, - PolicyAssignmentsListForResourceOptionalParams, - PolicyAssignmentsListForResourceResponse, - PolicyAssignmentsListForManagementGroupNextOptionalParams, - PolicyAssignmentsListForManagementGroupOptionalParams, - PolicyAssignmentsListForManagementGroupResponse, - PolicyAssignmentsListNextOptionalParams, - PolicyAssignmentsListOptionalParams, - PolicyAssignmentsListResponse, - PolicyAssignmentsDeleteOptionalParams, - PolicyAssignmentsDeleteResponse, - PolicyAssignmentsCreateOptionalParams, - PolicyAssignmentsCreateResponse, - PolicyAssignmentsGetOptionalParams, - PolicyAssignmentsGetResponse, - PolicyAssignmentUpdate, - PolicyAssignmentsUpdateOptionalParams, - PolicyAssignmentsUpdateResponse, - PolicyAssignmentsDeleteByIdOptionalParams, - PolicyAssignmentsDeleteByIdResponse, - PolicyAssignmentsCreateByIdOptionalParams, - PolicyAssignmentsCreateByIdResponse, - PolicyAssignmentsGetByIdOptionalParams, - PolicyAssignmentsGetByIdResponse, - PolicyAssignmentsUpdateByIdOptionalParams, - PolicyAssignmentsUpdateByIdResponse, - PolicyAssignmentsListForResourceGroupNextResponse, - PolicyAssignmentsListForResourceNextResponse, - PolicyAssignmentsListForManagementGroupNextResponse, - PolicyAssignmentsListNextResponse, -} from "../models/index.js"; - -/// -/** Class containing PolicyAssignments operations. */ -export class PolicyAssignmentsImpl implements PolicyAssignments { - private readonly client: PolicyClient; - - /** - * Initialize a new instance of the class PolicyAssignments class. - * @param client Reference to the service client - */ - constructor(client: PolicyClient) { - this.client = client; - } - - /** - * This operation retrieves the list of all policy assignments associated with the given resource group - * in the given subscription that match the optional given $filter. Valid values for $filter are: - * 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the - * unfiltered list includes all policy assignments associated with the resource group, including those - * that apply directly or apply from containing scopes, as well as any applied to resources contained - * within the resource group. If $filter=atScope() is provided, the returned list includes all policy - * assignments that apply to the resource group, which is everything in the unfiltered list except - * those applied to resources contained within the resource group. If $filter=atExactScope() is - * provided, the returned list only includes all policy assignments that at the resource group. If - * $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy - * assignments of the policy definition whose id is {value} that apply to the resource group. - * @param resourceGroupName The name of the resource group that contains policy assignments. - * @param options The options parameters. - */ - public listForResourceGroup( - resourceGroupName: string, - options?: PolicyAssignmentsListForResourceGroupOptionalParams, - ): PagedAsyncIterableIterator { - const iter = this.listForResourceGroupPagingAll(resourceGroupName, options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listForResourceGroupPagingPage(resourceGroupName, options, settings); - }, - }; - } - - private async *listForResourceGroupPagingPage( - resourceGroupName: string, - options?: PolicyAssignmentsListForResourceGroupOptionalParams, - settings?: PageSettings, - ): AsyncIterableIterator { - let result: PolicyAssignmentsListForResourceGroupResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._listForResourceGroup(resourceGroupName, options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listForResourceGroupNext(resourceGroupName, continuationToken, options); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listForResourceGroupPagingAll( - resourceGroupName: string, - options?: PolicyAssignmentsListForResourceGroupOptionalParams, - ): AsyncIterableIterator { - for await (const page of this.listForResourceGroupPagingPage(resourceGroupName, options)) { - yield* page; - } - } - - /** - * This operation retrieves the list of all policy assignments associated with the specified resource - * in the given resource group and subscription that match the optional given $filter. Valid values for - * $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not - * provided, the unfiltered list includes all policy assignments associated with the resource, - * including those that apply directly or from all containing scopes, as well as any applied to - * resources contained within the resource. If $filter=atScope() is provided, the returned list - * includes all policy assignments that apply to the resource, which is everything in the unfiltered - * list except those applied to resources contained within the resource. If $filter=atExactScope() is - * provided, the returned list only includes all policy assignments that at the resource level. If - * $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy - * assignments of the policy definition whose id is {value} that apply to the resource. Three - * parameters plus the resource name are used to identify a specific resource. If the resource is not - * part of a parent resource (the more common case), the parent resource path should not be provided - * (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == - * 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == - * 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. - * For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == - * 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == - * 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the - * namespace and type name separately is to provide both in the {resourceType} parameter, format: - * ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == - * 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - * @param resourceGroupName The name of the resource group containing the resource. - * @param resourceProviderNamespace The namespace of the resource provider. For example, the namespace - * of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) - * @param parentResourcePath The parent resource path. Use empty string if there is none. - * @param resourceType The resource type name. For example the type name of a web app is 'sites' (from - * Microsoft.Web/sites). - * @param resourceName The name of the resource. - * @param options The options parameters. - */ - public listForResource( - resourceGroupName: string, - resourceProviderNamespace: string, - parentResourcePath: string, - resourceType: string, - resourceName: string, - options?: PolicyAssignmentsListForResourceOptionalParams, - ): PagedAsyncIterableIterator { - const iter = this.listForResourcePagingAll( - resourceGroupName, - resourceProviderNamespace, - parentResourcePath, - resourceType, - resourceName, - options, - ); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listForResourcePagingPage( - resourceGroupName, - resourceProviderNamespace, - parentResourcePath, - resourceType, - resourceName, - options, - settings, - ); - }, - }; - } - - private async *listForResourcePagingPage( - resourceGroupName: string, - resourceProviderNamespace: string, - parentResourcePath: string, - resourceType: string, - resourceName: string, - options?: PolicyAssignmentsListForResourceOptionalParams, - settings?: PageSettings, - ): AsyncIterableIterator { - let result: PolicyAssignmentsListForResourceResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._listForResource( - resourceGroupName, - resourceProviderNamespace, - parentResourcePath, - resourceType, - resourceName, - options, - ); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listForResourceNext( - resourceGroupName, - resourceProviderNamespace, - parentResourcePath, - resourceType, - resourceName, - continuationToken, - options, - ); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listForResourcePagingAll( - resourceGroupName: string, - resourceProviderNamespace: string, - parentResourcePath: string, - resourceType: string, - resourceName: string, - options?: PolicyAssignmentsListForResourceOptionalParams, - ): AsyncIterableIterator { - for await (const page of this.listForResourcePagingPage( - resourceGroupName, - resourceProviderNamespace, - parentResourcePath, - resourceType, - resourceName, - options, - )) { - yield* page; - } - } - - /** - * This operation retrieves the list of all policy assignments applicable to the management group that - * match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or - * 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all - * policy assignments that are assigned to the management group or the management group's ancestors. If - * $filter=atExactScope() is provided, the returned list only includes all policy assignments that at - * the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list - * includes all policy assignments of the policy definition whose id is {value} that apply to the - * management group. - * @param managementGroupId The ID of the management group. - * @param options The options parameters. - */ - public listForManagementGroup( - managementGroupId: string, - options?: PolicyAssignmentsListForManagementGroupOptionalParams, - ): PagedAsyncIterableIterator { - const iter = this.listForManagementGroupPagingAll(managementGroupId, options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listForManagementGroupPagingPage(managementGroupId, options, settings); - }, - }; - } - - private async *listForManagementGroupPagingPage( - managementGroupId: string, - options?: PolicyAssignmentsListForManagementGroupOptionalParams, - settings?: PageSettings, - ): AsyncIterableIterator { - let result: PolicyAssignmentsListForManagementGroupResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._listForManagementGroup(managementGroupId, options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listForManagementGroupNext( - managementGroupId, - continuationToken, - options, - ); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listForManagementGroupPagingAll( - managementGroupId: string, - options?: PolicyAssignmentsListForManagementGroupOptionalParams, - ): AsyncIterableIterator { - for await (const page of this.listForManagementGroupPagingPage(managementGroupId, options)) { - yield* page; - } - } - - /** - * This operation retrieves the list of all policy assignments associated with the given subscription - * that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' - * or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all - * policy assignments associated with the subscription, including those that apply directly or from - * management groups that contain the given subscription, as well as any applied to objects contained - * within the subscription. If $filter=atScope() is provided, the returned list includes all policy - * assignments that apply to the subscription, which is everything in the unfiltered list except those - * applied to objects contained within the subscription. If $filter=atExactScope() is provided, the - * returned list only includes all policy assignments that at the subscription. If - * $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy - * assignments of the policy definition whose id is {value}. - * @param options The options parameters. - */ - public list( - options?: PolicyAssignmentsListOptionalParams, - ): PagedAsyncIterableIterator { - const iter = this.listPagingAll(options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listPagingPage(options, settings); - }, - }; - } - - private async *listPagingPage( - options?: PolicyAssignmentsListOptionalParams, - settings?: PageSettings, - ): AsyncIterableIterator { - let result: PolicyAssignmentsListResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._list(options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listNext(continuationToken, options); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listPagingAll( - options?: PolicyAssignmentsListOptionalParams, - ): AsyncIterableIterator { - for await (const page of this.listPagingPage(options)) { - yield* page; - } - } - - /** - * This operation deletes a policy assignment, given its name and the scope it was created in. The - * scope of a policy assignment is the part of its ID preceding - * '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - * @param scope The scope of the policy assignment. Valid scopes are: management group (format: - * '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - * '/subscriptions/{subscriptionId}'), resource group (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' - * @param policyAssignmentName The name of the policy assignment to delete. - * @param options The options parameters. - */ - delete( - scope: string, - policyAssignmentName: string, - options?: PolicyAssignmentsDeleteOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { scope, policyAssignmentName, options }, - deleteOperationSpec, - ); - } - - /** - * This operation creates or updates a policy assignment with the given scope and name. Policy - * assignments apply to all resources contained within their scope. For example, when you assign a - * policy at resource group scope, that policy applies to all resources in the group. - * @param scope The scope of the policy assignment. Valid scopes are: management group (format: - * '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - * '/subscriptions/{subscriptionId}'), resource group (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' - * @param policyAssignmentName The name of the policy assignment. - * @param parameters Parameters for the policy assignment. - * @param options The options parameters. - */ - create( - scope: string, - policyAssignmentName: string, - parameters: PolicyAssignment, - options?: PolicyAssignmentsCreateOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { scope, policyAssignmentName, parameters, options }, - createOperationSpec, - ); - } - - /** - * This operation retrieves a single policy assignment, given its name and the scope it was created at. - * @param scope The scope of the policy assignment. Valid scopes are: management group (format: - * '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - * '/subscriptions/{subscriptionId}'), resource group (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' - * @param policyAssignmentName The name of the policy assignment to get. - * @param options The options parameters. - */ - get( - scope: string, - policyAssignmentName: string, - options?: PolicyAssignmentsGetOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { scope, policyAssignmentName, options }, - getOperationSpec, - ); - } - - /** - * This operation updates a policy assignment with the given scope and name. Policy assignments apply - * to all resources contained within their scope. For example, when you assign a policy at resource - * group scope, that policy applies to all resources in the group. - * @param scope The scope of the policy assignment. Valid scopes are: management group (format: - * '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - * '/subscriptions/{subscriptionId}'), resource group (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' - * @param policyAssignmentName The name of the policy assignment. - * @param parameters Parameters for policy assignment patch request. - * @param options The options parameters. - */ - update( - scope: string, - policyAssignmentName: string, - parameters: PolicyAssignmentUpdate, - options?: PolicyAssignmentsUpdateOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { scope, policyAssignmentName, parameters, options }, - updateOperationSpec, - ); - } - - /** - * This operation retrieves the list of all policy assignments associated with the given resource group - * in the given subscription that match the optional given $filter. Valid values for $filter are: - * 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the - * unfiltered list includes all policy assignments associated with the resource group, including those - * that apply directly or apply from containing scopes, as well as any applied to resources contained - * within the resource group. If $filter=atScope() is provided, the returned list includes all policy - * assignments that apply to the resource group, which is everything in the unfiltered list except - * those applied to resources contained within the resource group. If $filter=atExactScope() is - * provided, the returned list only includes all policy assignments that at the resource group. If - * $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy - * assignments of the policy definition whose id is {value} that apply to the resource group. - * @param resourceGroupName The name of the resource group that contains policy assignments. - * @param options The options parameters. - */ - private _listForResourceGroup( - resourceGroupName: string, - options?: PolicyAssignmentsListForResourceGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { resourceGroupName, options }, - listForResourceGroupOperationSpec, - ); - } - - /** - * This operation retrieves the list of all policy assignments associated with the specified resource - * in the given resource group and subscription that match the optional given $filter. Valid values for - * $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not - * provided, the unfiltered list includes all policy assignments associated with the resource, - * including those that apply directly or from all containing scopes, as well as any applied to - * resources contained within the resource. If $filter=atScope() is provided, the returned list - * includes all policy assignments that apply to the resource, which is everything in the unfiltered - * list except those applied to resources contained within the resource. If $filter=atExactScope() is - * provided, the returned list only includes all policy assignments that at the resource level. If - * $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy - * assignments of the policy definition whose id is {value} that apply to the resource. Three - * parameters plus the resource name are used to identify a specific resource. If the resource is not - * part of a parent resource (the more common case), the parent resource path should not be provided - * (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == - * 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == - * 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. - * For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == - * 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == - * 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the - * namespace and type name separately is to provide both in the {resourceType} parameter, format: - * ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == - * 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - * @param resourceGroupName The name of the resource group containing the resource. - * @param resourceProviderNamespace The namespace of the resource provider. For example, the namespace - * of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) - * @param parentResourcePath The parent resource path. Use empty string if there is none. - * @param resourceType The resource type name. For example the type name of a web app is 'sites' (from - * Microsoft.Web/sites). - * @param resourceName The name of the resource. - * @param options The options parameters. - */ - private _listForResource( - resourceGroupName: string, - resourceProviderNamespace: string, - parentResourcePath: string, - resourceType: string, - resourceName: string, - options?: PolicyAssignmentsListForResourceOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { - resourceGroupName, - resourceProviderNamespace, - parentResourcePath, - resourceType, - resourceName, - options, - }, - listForResourceOperationSpec, - ); - } - - /** - * This operation retrieves the list of all policy assignments applicable to the management group that - * match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or - * 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all - * policy assignments that are assigned to the management group or the management group's ancestors. If - * $filter=atExactScope() is provided, the returned list only includes all policy assignments that at - * the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list - * includes all policy assignments of the policy definition whose id is {value} that apply to the - * management group. - * @param managementGroupId The ID of the management group. - * @param options The options parameters. - */ - private _listForManagementGroup( - managementGroupId: string, - options?: PolicyAssignmentsListForManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupId, options }, - listForManagementGroupOperationSpec, - ); - } - - /** - * This operation retrieves the list of all policy assignments associated with the given subscription - * that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' - * or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all - * policy assignments associated with the subscription, including those that apply directly or from - * management groups that contain the given subscription, as well as any applied to objects contained - * within the subscription. If $filter=atScope() is provided, the returned list includes all policy - * assignments that apply to the subscription, which is everything in the unfiltered list except those - * applied to objects contained within the subscription. If $filter=atExactScope() is provided, the - * returned list only includes all policy assignments that at the subscription. If - * $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy - * assignments of the policy definition whose id is {value}. - * @param options The options parameters. - */ - private _list( - options?: PolicyAssignmentsListOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ options }, listOperationSpec); - } - - /** - * This operation deletes the policy with the given ID. Policy assignment IDs have this format: - * '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats - * for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management - * group), '/subscriptions/{subscriptionId}' (subscription), - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' - * (resource). - * @param policyAssignmentId The ID of the policy assignment to delete. Use the format - * '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - * @param options The options parameters. - */ - deleteById( - policyAssignmentId: string, - options?: PolicyAssignmentsDeleteByIdOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policyAssignmentId, options }, - deleteByIdOperationSpec, - ); - } - - /** - * This operation creates or updates the policy assignment with the given ID. Policy assignments made - * on a scope apply to all resources contained in that scope. For example, when you assign a policy to - * a resource group that policy applies to all resources in the group. Policy assignment IDs have this - * format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid - * scopes are: management group (format: - * '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - * '/subscriptions/{subscriptionId}'), resource group (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * @param policyAssignmentId The ID of the policy assignment to create. Use the format - * '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - * @param parameters Parameters for policy assignment. - * @param options The options parameters. - */ - createById( - policyAssignmentId: string, - parameters: PolicyAssignment, - options?: PolicyAssignmentsCreateByIdOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policyAssignmentId, parameters, options }, - createByIdOperationSpec, - ); - } - - /** - * The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this - * format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid - * scopes are: management group (format: - * '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - * '/subscriptions/{subscriptionId}'), resource group (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * @param policyAssignmentId The ID of the policy assignment to get. Use the format - * '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - * @param options The options parameters. - */ - getById( - policyAssignmentId: string, - options?: PolicyAssignmentsGetByIdOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ policyAssignmentId, options }, getByIdOperationSpec); - } - - /** - * This operation updates the policy assignment with the given ID. Policy assignments made on a scope - * apply to all resources contained in that scope. For example, when you assign a policy to a resource - * group that policy applies to all resources in the group. Policy assignment IDs have this format: - * '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes - * are: management group (format: - * '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - * '/subscriptions/{subscriptionId}'), resource group (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * @param policyAssignmentId The ID of the policy assignment to update. Use the format - * '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - * @param parameters Parameters for policy assignment patch request. - * @param options The options parameters. - */ - updateById( - policyAssignmentId: string, - parameters: PolicyAssignmentUpdate, - options?: PolicyAssignmentsUpdateByIdOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policyAssignmentId, parameters, options }, - updateByIdOperationSpec, - ); - } - - /** - * ListForResourceGroupNext - * @param resourceGroupName The name of the resource group that contains policy assignments. - * @param nextLink The nextLink from the previous successful call to the ListForResourceGroup method. - * @param options The options parameters. - */ - private _listForResourceGroupNext( - resourceGroupName: string, - nextLink: string, - options?: PolicyAssignmentsListForResourceGroupNextOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { resourceGroupName, nextLink, options }, - listForResourceGroupNextOperationSpec, - ); - } - - /** - * ListForResourceNext - * @param resourceGroupName The name of the resource group containing the resource. - * @param resourceProviderNamespace The namespace of the resource provider. For example, the namespace - * of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) - * @param parentResourcePath The parent resource path. Use empty string if there is none. - * @param resourceType The resource type name. For example the type name of a web app is 'sites' (from - * Microsoft.Web/sites). - * @param resourceName The name of the resource. - * @param nextLink The nextLink from the previous successful call to the ListForResource method. - * @param options The options parameters. - */ - private _listForResourceNext( - resourceGroupName: string, - resourceProviderNamespace: string, - parentResourcePath: string, - resourceType: string, - resourceName: string, - nextLink: string, - options?: PolicyAssignmentsListForResourceNextOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { - resourceGroupName, - resourceProviderNamespace, - parentResourcePath, - resourceType, - resourceName, - nextLink, - options, - }, - listForResourceNextOperationSpec, - ); - } - - /** - * ListForManagementGroupNext - * @param managementGroupId The ID of the management group. - * @param nextLink The nextLink from the previous successful call to the ListForManagementGroup method. - * @param options The options parameters. - */ - private _listForManagementGroupNext( - managementGroupId: string, - nextLink: string, - options?: PolicyAssignmentsListForManagementGroupNextOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupId, nextLink, options }, - listForManagementGroupNextOperationSpec, - ); - } - - /** - * ListNext - * @param nextLink The nextLink from the previous successful call to the List method. - * @param options The options parameters. - */ - private _listNext( - nextLink: string, - options?: PolicyAssignmentsListNextOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ nextLink, options }, listNextOperationSpec); - } -} -// Operation Specifications -const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); - -const deleteOperationSpec: coreClient.OperationSpec = { - path: "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}", - httpMethod: "DELETE", - responses: { - 200: { - bodyMapper: Mappers.PolicyAssignment, - }, - 204: {}, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.scope, Parameters.policyAssignmentName], - headerParameters: [Parameters.accept], - serializer, -}; -const createOperationSpec: coreClient.OperationSpec = { - path: "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}", - httpMethod: "PUT", - responses: { - 201: { - bodyMapper: Mappers.PolicyAssignment, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - requestBody: Parameters.parameters4, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.scope, Parameters.policyAssignmentName], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer, -}; -const getOperationSpec: coreClient.OperationSpec = { - path: "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyAssignment, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.expand], - urlParameters: [Parameters.$host, Parameters.scope, Parameters.policyAssignmentName], - headerParameters: [Parameters.accept], - serializer, -}; -const updateOperationSpec: coreClient.OperationSpec = { - path: "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}", - httpMethod: "PATCH", - responses: { - 200: { - bodyMapper: Mappers.PolicyAssignment, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - requestBody: Parameters.parameters5, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.scope, Parameters.policyAssignmentName], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer, -}; -const listForResourceGroupOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyAssignmentListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.filter, Parameters.top, Parameters.expand], - urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName], - headerParameters: [Parameters.accept], - serializer, -}; -const listForResourceOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyAssignmentListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.filter, Parameters.top, Parameters.expand], - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.resourceGroupName, - Parameters.resourceProviderNamespace, - Parameters.parentResourcePath, - Parameters.resourceType, - Parameters.resourceName, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const listForManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyAssignmentListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.filter, Parameters.top, Parameters.expand], - urlParameters: [Parameters.$host, Parameters.managementGroupId], - headerParameters: [Parameters.accept], - serializer, -}; -const listOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyAssignmentListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.filter, Parameters.top, Parameters.expand], - urlParameters: [Parameters.$host, Parameters.subscriptionId], - headerParameters: [Parameters.accept], - serializer, -}; -const deleteByIdOperationSpec: coreClient.OperationSpec = { - path: "/{policyAssignmentId}", - httpMethod: "DELETE", - responses: { - 200: { - bodyMapper: Mappers.PolicyAssignment, - }, - 204: {}, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.policyAssignmentId], - headerParameters: [Parameters.accept], - serializer, -}; -const createByIdOperationSpec: coreClient.OperationSpec = { - path: "/{policyAssignmentId}", - httpMethod: "PUT", - responses: { - 201: { - bodyMapper: Mappers.PolicyAssignment, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - requestBody: Parameters.parameters4, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.policyAssignmentId], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer, -}; -const getByIdOperationSpec: coreClient.OperationSpec = { - path: "/{policyAssignmentId}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyAssignment, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.expand], - urlParameters: [Parameters.$host, Parameters.policyAssignmentId], - headerParameters: [Parameters.accept], - serializer, -}; -const updateByIdOperationSpec: coreClient.OperationSpec = { - path: "/{policyAssignmentId}", - httpMethod: "PATCH", - responses: { - 200: { - bodyMapper: Mappers.PolicyAssignment, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - requestBody: Parameters.parameters5, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.policyAssignmentId], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer, -}; -const listForResourceGroupNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyAssignmentListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.nextLink, - Parameters.resourceGroupName, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const listForResourceNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyAssignmentListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.nextLink, - Parameters.resourceGroupName, - Parameters.resourceProviderNamespace, - Parameters.parentResourcePath, - Parameters.resourceType, - Parameters.resourceName, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const listForManagementGroupNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyAssignmentListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - urlParameters: [Parameters.$host, Parameters.managementGroupId, Parameters.nextLink], - headerParameters: [Parameters.accept], - serializer, -}; -const listNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyAssignmentListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.nextLink], - headerParameters: [Parameters.accept], - serializer, -}; diff --git a/sdk/policy/arm-policy/src/operations/policyDefinitionVersions.ts b/sdk/policy/arm-policy/src/operations/policyDefinitionVersions.ts deleted file mode 100644 index 10a05fa65a79..000000000000 --- a/sdk/policy/arm-policy/src/operations/policyDefinitionVersions.ts +++ /dev/null @@ -1,870 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; -import { setContinuationToken } from "../pagingHelper.js"; -import type { PolicyDefinitionVersions } from "../operationsInterfaces/index.js"; -import * as coreClient from "@azure/core-client"; -import * as Mappers from "../models/mappers.js"; -import * as Parameters from "../models/parameters.js"; -import type { PolicyClient } from "../policyClient.js"; -import type { - PolicyDefinitionVersion, - PolicyDefinitionVersionsListNextOptionalParams, - PolicyDefinitionVersionsListOptionalParams, - PolicyDefinitionVersionsListResponse, - PolicyDefinitionVersionsListBuiltInNextOptionalParams, - PolicyDefinitionVersionsListBuiltInOptionalParams, - PolicyDefinitionVersionsListBuiltInResponse, - PolicyDefinitionVersionsListByManagementGroupNextOptionalParams, - PolicyDefinitionVersionsListByManagementGroupOptionalParams, - PolicyDefinitionVersionsListByManagementGroupResponse, - PolicyDefinitionVersionsListAllBuiltinsOptionalParams, - PolicyDefinitionVersionsListAllBuiltinsResponse, - PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams, - PolicyDefinitionVersionsListAllAtManagementGroupResponse, - PolicyDefinitionVersionsListAllOptionalParams, - PolicyDefinitionVersionsListAllResponse, - PolicyDefinitionVersionsCreateOrUpdateOptionalParams, - PolicyDefinitionVersionsCreateOrUpdateResponse, - PolicyDefinitionVersionsDeleteOptionalParams, - PolicyDefinitionVersionsGetOptionalParams, - PolicyDefinitionVersionsGetResponse, - PolicyDefinitionVersionsGetBuiltInOptionalParams, - PolicyDefinitionVersionsGetBuiltInResponse, - PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, - PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupResponse, - PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams, - PolicyDefinitionVersionsGetAtManagementGroupOptionalParams, - PolicyDefinitionVersionsGetAtManagementGroupResponse, - PolicyDefinitionVersionsListNextResponse, - PolicyDefinitionVersionsListBuiltInNextResponse, - PolicyDefinitionVersionsListByManagementGroupNextResponse, -} from "../models/index.js"; - -/// -/** Class containing PolicyDefinitionVersions operations. */ -export class PolicyDefinitionVersionsImpl implements PolicyDefinitionVersions { - private readonly client: PolicyClient; - - /** - * Initialize a new instance of the class PolicyDefinitionVersions class. - * @param client Reference to the service client - */ - constructor(client: PolicyClient) { - this.client = client; - } - - /** - * This operation retrieves a list of all the policy definition versions for the given policy - * definition. - * @param policyDefinitionName The name of the policy definition. - * @param options The options parameters. - */ - public list( - policyDefinitionName: string, - options?: PolicyDefinitionVersionsListOptionalParams, - ): PagedAsyncIterableIterator { - const iter = this.listPagingAll(policyDefinitionName, options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listPagingPage(policyDefinitionName, options, settings); - }, - }; - } - - private async *listPagingPage( - policyDefinitionName: string, - options?: PolicyDefinitionVersionsListOptionalParams, - settings?: PageSettings, - ): AsyncIterableIterator { - let result: PolicyDefinitionVersionsListResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._list(policyDefinitionName, options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listNext(policyDefinitionName, continuationToken, options); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listPagingAll( - policyDefinitionName: string, - options?: PolicyDefinitionVersionsListOptionalParams, - ): AsyncIterableIterator { - for await (const page of this.listPagingPage(policyDefinitionName, options)) { - yield* page; - } - } - - /** - * This operation retrieves a list of all the built-in policy definition versions for the given policy - * definition. - * @param policyDefinitionName The name of the policy definition. - * @param options The options parameters. - */ - public listBuiltIn( - policyDefinitionName: string, - options?: PolicyDefinitionVersionsListBuiltInOptionalParams, - ): PagedAsyncIterableIterator { - const iter = this.listBuiltInPagingAll(policyDefinitionName, options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listBuiltInPagingPage(policyDefinitionName, options, settings); - }, - }; - } - - private async *listBuiltInPagingPage( - policyDefinitionName: string, - options?: PolicyDefinitionVersionsListBuiltInOptionalParams, - settings?: PageSettings, - ): AsyncIterableIterator { - let result: PolicyDefinitionVersionsListBuiltInResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._listBuiltIn(policyDefinitionName, options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listBuiltInNext(policyDefinitionName, continuationToken, options); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listBuiltInPagingAll( - policyDefinitionName: string, - options?: PolicyDefinitionVersionsListBuiltInOptionalParams, - ): AsyncIterableIterator { - for await (const page of this.listBuiltInPagingPage(policyDefinitionName, options)) { - yield* page; - } - } - - /** - * This operation retrieves a list of all the policy definition versions for the given policy - * definition in the given management group. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policyDefinitionName The name of the policy definition. - * @param options The options parameters. - */ - public listByManagementGroup( - managementGroupName: string, - policyDefinitionName: string, - options?: PolicyDefinitionVersionsListByManagementGroupOptionalParams, - ): PagedAsyncIterableIterator { - const iter = this.listByManagementGroupPagingAll( - managementGroupName, - policyDefinitionName, - options, - ); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listByManagementGroupPagingPage( - managementGroupName, - policyDefinitionName, - options, - settings, - ); - }, - }; - } - - private async *listByManagementGroupPagingPage( - managementGroupName: string, - policyDefinitionName: string, - options?: PolicyDefinitionVersionsListByManagementGroupOptionalParams, - settings?: PageSettings, - ): AsyncIterableIterator { - let result: PolicyDefinitionVersionsListByManagementGroupResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._listByManagementGroup( - managementGroupName, - policyDefinitionName, - options, - ); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listByManagementGroupNext( - managementGroupName, - policyDefinitionName, - continuationToken, - options, - ); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listByManagementGroupPagingAll( - managementGroupName: string, - policyDefinitionName: string, - options?: PolicyDefinitionVersionsListByManagementGroupOptionalParams, - ): AsyncIterableIterator { - for await (const page of this.listByManagementGroupPagingPage( - managementGroupName, - policyDefinitionName, - options, - )) { - yield* page; - } - } - - /** - * This operation lists all the built-in policy definition versions for all built-in policy - * definitions. - * @param options The options parameters. - */ - listAllBuiltins( - options?: PolicyDefinitionVersionsListAllBuiltinsOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ options }, listAllBuiltinsOperationSpec); - } - - /** - * This operation lists all the policy definition versions for all policy definitions at the management - * group scope. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param options The options parameters. - */ - listAllAtManagementGroup( - managementGroupName: string, - options?: PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupName, options }, - listAllAtManagementGroupOperationSpec, - ); - } - - /** - * This operation lists all the policy definition versions for all policy definitions within a - * subscription. - * @param options The options parameters. - */ - listAll( - options?: PolicyDefinitionVersionsListAllOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ options }, listAllOperationSpec); - } - - /** - * This operation creates or updates a policy definition in the given subscription with the given name. - * @param policyDefinitionName The name of the policy definition. - * @param policyDefinitionVersion The policy definition version. The format is x.y.z where x is the - * major version number, y is the minor version number, and z is the patch number - * @param parameters The policy definition properties. - * @param options The options parameters. - */ - createOrUpdate( - policyDefinitionName: string, - policyDefinitionVersion: string, - parameters: PolicyDefinitionVersion, - options?: PolicyDefinitionVersionsCreateOrUpdateOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policyDefinitionName, policyDefinitionVersion, parameters, options }, - createOrUpdateOperationSpec, - ); - } - - /** - * This operation deletes the policy definition version in the given subscription with the given name. - * @param policyDefinitionName The name of the policy definition. - * @param policyDefinitionVersion The policy definition version. The format is x.y.z where x is the - * major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - delete( - policyDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicyDefinitionVersionsDeleteOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policyDefinitionName, policyDefinitionVersion, options }, - deleteOperationSpec, - ); - } - - /** - * This operation retrieves the policy definition version in the given subscription with the given - * name. - * @param policyDefinitionName The name of the policy definition. - * @param policyDefinitionVersion The policy definition version. The format is x.y.z where x is the - * major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - get( - policyDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicyDefinitionVersionsGetOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policyDefinitionName, policyDefinitionVersion, options }, - getOperationSpec, - ); - } - - /** - * This operation retrieves the built-in policy definition version with the given name. - * @param policyDefinitionName The name of the policy definition. - * @param policyDefinitionVersion The policy definition version. The format is x.y.z where x is the - * major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - getBuiltIn( - policyDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicyDefinitionVersionsGetBuiltInOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policyDefinitionName, policyDefinitionVersion, options }, - getBuiltInOperationSpec, - ); - } - - /** - * This operation creates or updates a policy definition version in the given management group with the - * given name. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policyDefinitionName The name of the policy definition. - * @param policyDefinitionVersion The policy definition version. The format is x.y.z where x is the - * major version number, y is the minor version number, and z is the patch number - * @param parameters The policy definition properties. - * @param options The options parameters. - */ - createOrUpdateAtManagementGroup( - managementGroupName: string, - policyDefinitionName: string, - policyDefinitionVersion: string, - parameters: PolicyDefinitionVersion, - options?: PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { - managementGroupName, - policyDefinitionName, - policyDefinitionVersion, - parameters, - options, - }, - createOrUpdateAtManagementGroupOperationSpec, - ); - } - - /** - * This operation deletes the policy definition in the given management group with the given name. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policyDefinitionName The name of the policy definition. - * @param policyDefinitionVersion The policy definition version. The format is x.y.z where x is the - * major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - deleteAtManagementGroup( - managementGroupName: string, - policyDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { - managementGroupName, - policyDefinitionName, - policyDefinitionVersion, - options, - }, - deleteAtManagementGroupOperationSpec, - ); - } - - /** - * This operation retrieves the policy definition version in the given management group with the given - * name. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policyDefinitionName The name of the policy definition. - * @param policyDefinitionVersion The policy definition version. The format is x.y.z where x is the - * major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - getAtManagementGroup( - managementGroupName: string, - policyDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicyDefinitionVersionsGetAtManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { - managementGroupName, - policyDefinitionName, - policyDefinitionVersion, - options, - }, - getAtManagementGroupOperationSpec, - ); - } - - /** - * This operation retrieves a list of all the policy definition versions for the given policy - * definition. - * @param policyDefinitionName The name of the policy definition. - * @param options The options parameters. - */ - private _list( - policyDefinitionName: string, - options?: PolicyDefinitionVersionsListOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ policyDefinitionName, options }, listOperationSpec); - } - - /** - * This operation retrieves a list of all the built-in policy definition versions for the given policy - * definition. - * @param policyDefinitionName The name of the policy definition. - * @param options The options parameters. - */ - private _listBuiltIn( - policyDefinitionName: string, - options?: PolicyDefinitionVersionsListBuiltInOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policyDefinitionName, options }, - listBuiltInOperationSpec, - ); - } - - /** - * This operation retrieves a list of all the policy definition versions for the given policy - * definition in the given management group. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policyDefinitionName The name of the policy definition. - * @param options The options parameters. - */ - private _listByManagementGroup( - managementGroupName: string, - policyDefinitionName: string, - options?: PolicyDefinitionVersionsListByManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupName, policyDefinitionName, options }, - listByManagementGroupOperationSpec, - ); - } - - /** - * ListNext - * @param policyDefinitionName The name of the policy definition. - * @param nextLink The nextLink from the previous successful call to the List method. - * @param options The options parameters. - */ - private _listNext( - policyDefinitionName: string, - nextLink: string, - options?: PolicyDefinitionVersionsListNextOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policyDefinitionName, nextLink, options }, - listNextOperationSpec, - ); - } - - /** - * ListBuiltInNext - * @param policyDefinitionName The name of the policy definition. - * @param nextLink The nextLink from the previous successful call to the ListBuiltIn method. - * @param options The options parameters. - */ - private _listBuiltInNext( - policyDefinitionName: string, - nextLink: string, - options?: PolicyDefinitionVersionsListBuiltInNextOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policyDefinitionName, nextLink, options }, - listBuiltInNextOperationSpec, - ); - } - - /** - * ListByManagementGroupNext - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policyDefinitionName The name of the policy definition. - * @param nextLink The nextLink from the previous successful call to the ListByManagementGroup method. - * @param options The options parameters. - */ - private _listByManagementGroupNext( - managementGroupName: string, - policyDefinitionName: string, - nextLink: string, - options?: PolicyDefinitionVersionsListByManagementGroupNextOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupName, policyDefinitionName, nextLink, options }, - listByManagementGroupNextOperationSpec, - ); - } -} -// Operation Specifications -const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); - -const listAllBuiltinsOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Authorization/listPolicyDefinitionVersions", - httpMethod: "POST", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host], - headerParameters: [Parameters.accept], - serializer, -}; -const listAllAtManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/listPolicyDefinitionVersions", - httpMethod: "POST", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.managementGroupName], - headerParameters: [Parameters.accept], - serializer, -}; -const listAllOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/listPolicyDefinitionVersions", - httpMethod: "POST", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.subscriptionId], - headerParameters: [Parameters.accept], - serializer, -}; -const createOrUpdateOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}", - httpMethod: "PUT", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionVersion, - }, - 201: { - bodyMapper: Mappers.PolicyDefinitionVersion, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - requestBody: Parameters.parameters1, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.policyDefinitionName, - Parameters.policyDefinitionVersion, - ], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer, -}; -const deleteOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}", - httpMethod: "DELETE", - responses: { - 200: {}, - 204: {}, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.policyDefinitionName, - Parameters.policyDefinitionVersion, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const getOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionVersion, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.policyDefinitionName, - Parameters.policyDefinitionVersion, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const getBuiltInOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionVersion, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.policyDefinitionName, - Parameters.policyDefinitionVersion, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const createOrUpdateAtManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}", - httpMethod: "PUT", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionVersion, - }, - 201: { - bodyMapper: Mappers.PolicyDefinitionVersion, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - requestBody: Parameters.parameters1, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.policyDefinitionName, - Parameters.managementGroupName, - Parameters.policyDefinitionVersion, - ], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer, -}; -const deleteAtManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}", - httpMethod: "DELETE", - responses: { - 200: {}, - 204: {}, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.policyDefinitionName, - Parameters.managementGroupName, - Parameters.policyDefinitionVersion, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const getAtManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionVersion, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.policyDefinitionName, - Parameters.managementGroupName, - Parameters.policyDefinitionVersion, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const listOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.top], - urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.policyDefinitionName], - headerParameters: [Parameters.accept], - serializer, -}; -const listBuiltInOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.top], - urlParameters: [Parameters.$host, Parameters.policyDefinitionName], - headerParameters: [Parameters.accept], - serializer, -}; -const listByManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.top], - urlParameters: [ - Parameters.$host, - Parameters.policyDefinitionName, - Parameters.managementGroupName, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const listNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.policyDefinitionName, - Parameters.nextLink, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const listBuiltInNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - urlParameters: [Parameters.$host, Parameters.policyDefinitionName, Parameters.nextLink], - headerParameters: [Parameters.accept], - serializer, -}; -const listByManagementGroupNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - urlParameters: [ - Parameters.$host, - Parameters.policyDefinitionName, - Parameters.nextLink, - Parameters.managementGroupName, - ], - headerParameters: [Parameters.accept], - serializer, -}; diff --git a/sdk/policy/arm-policy/src/operations/policyDefinitions.ts b/sdk/policy/arm-policy/src/operations/policyDefinitions.ts deleted file mode 100644 index 9403dc058982..000000000000 --- a/sdk/policy/arm-policy/src/operations/policyDefinitions.ts +++ /dev/null @@ -1,662 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; -import { setContinuationToken } from "../pagingHelper.js"; -import type { PolicyDefinitions } from "../operationsInterfaces/index.js"; -import * as coreClient from "@azure/core-client"; -import * as Mappers from "../models/mappers.js"; -import * as Parameters from "../models/parameters.js"; -import type { PolicyClient } from "../policyClient.js"; -import type { - PolicyDefinition, - PolicyDefinitionsListNextOptionalParams, - PolicyDefinitionsListOptionalParams, - PolicyDefinitionsListResponse, - PolicyDefinitionsListBuiltInNextOptionalParams, - PolicyDefinitionsListBuiltInOptionalParams, - PolicyDefinitionsListBuiltInResponse, - PolicyDefinitionsListByManagementGroupNextOptionalParams, - PolicyDefinitionsListByManagementGroupOptionalParams, - PolicyDefinitionsListByManagementGroupResponse, - PolicyDefinitionsCreateOrUpdateOptionalParams, - PolicyDefinitionsCreateOrUpdateResponse, - PolicyDefinitionsDeleteOptionalParams, - PolicyDefinitionsGetOptionalParams, - PolicyDefinitionsGetResponse, - PolicyDefinitionsGetBuiltInOptionalParams, - PolicyDefinitionsGetBuiltInResponse, - PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, - PolicyDefinitionsCreateOrUpdateAtManagementGroupResponse, - PolicyDefinitionsDeleteAtManagementGroupOptionalParams, - PolicyDefinitionsGetAtManagementGroupOptionalParams, - PolicyDefinitionsGetAtManagementGroupResponse, - PolicyDefinitionsListNextResponse, - PolicyDefinitionsListBuiltInNextResponse, - PolicyDefinitionsListByManagementGroupNextResponse, -} from "../models/index.js"; - -/// -/** Class containing PolicyDefinitions operations. */ -export class PolicyDefinitionsImpl implements PolicyDefinitions { - private readonly client: PolicyClient; - - /** - * Initialize a new instance of the class PolicyDefinitions class. - * @param client Reference to the service client - */ - constructor(client: PolicyClient) { - this.client = client; - } - - /** - * This operation retrieves a list of all the policy definitions in a given subscription that match the - * optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or - * 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy - * definitions associated with the subscription, including those that apply directly or from management - * groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list - * only includes all policy definitions that at the given subscription. If $filter='policyType -eq - * {value}' is provided, the returned list only includes all policy definitions whose type match the - * {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If - * $filter='category -eq {value}' is provided, the returned list only includes all policy definitions - * whose category match the {value}. - * @param options The options parameters. - */ - public list( - options?: PolicyDefinitionsListOptionalParams, - ): PagedAsyncIterableIterator { - const iter = this.listPagingAll(options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listPagingPage(options, settings); - }, - }; - } - - private async *listPagingPage( - options?: PolicyDefinitionsListOptionalParams, - settings?: PageSettings, - ): AsyncIterableIterator { - let result: PolicyDefinitionsListResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._list(options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listNext(continuationToken, options); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listPagingAll( - options?: PolicyDefinitionsListOptionalParams, - ): AsyncIterableIterator { - for await (const page of this.listPagingPage(options)) { - yield* page; - } - } - - /** - * This operation retrieves a list of all the built-in policy definitions that match the optional given - * $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all - * built-in policy definitions whose type match the {value}. Possible policyType values are - * NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the - * returned list only includes all built-in policy definitions whose category match the {value}. - * @param options The options parameters. - */ - public listBuiltIn( - options?: PolicyDefinitionsListBuiltInOptionalParams, - ): PagedAsyncIterableIterator { - const iter = this.listBuiltInPagingAll(options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listBuiltInPagingPage(options, settings); - }, - }; - } - - private async *listBuiltInPagingPage( - options?: PolicyDefinitionsListBuiltInOptionalParams, - settings?: PageSettings, - ): AsyncIterableIterator { - let result: PolicyDefinitionsListBuiltInResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._listBuiltIn(options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listBuiltInNext(continuationToken, options); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listBuiltInPagingAll( - options?: PolicyDefinitionsListBuiltInOptionalParams, - ): AsyncIterableIterator { - for await (const page of this.listBuiltInPagingPage(options)) { - yield* page; - } - } - - /** - * This operation retrieves a list of all the policy definitions in a given management group that match - * the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' - * or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy - * definitions associated with the management group, including those that apply directly or from - * management groups that contain the given management group. If $filter=atExactScope() is provided, - * the returned list only includes all policy definitions that at the given management group. If - * $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions - * whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and - * Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy - * definitions whose category match the {value}. - * @param managementGroupId The ID of the management group. - * @param options The options parameters. - */ - public listByManagementGroup( - managementGroupId: string, - options?: PolicyDefinitionsListByManagementGroupOptionalParams, - ): PagedAsyncIterableIterator { - const iter = this.listByManagementGroupPagingAll(managementGroupId, options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listByManagementGroupPagingPage(managementGroupId, options, settings); - }, - }; - } - - private async *listByManagementGroupPagingPage( - managementGroupId: string, - options?: PolicyDefinitionsListByManagementGroupOptionalParams, - settings?: PageSettings, - ): AsyncIterableIterator { - let result: PolicyDefinitionsListByManagementGroupResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._listByManagementGroup(managementGroupId, options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listByManagementGroupNext(managementGroupId, continuationToken, options); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listByManagementGroupPagingAll( - managementGroupId: string, - options?: PolicyDefinitionsListByManagementGroupOptionalParams, - ): AsyncIterableIterator { - for await (const page of this.listByManagementGroupPagingPage(managementGroupId, options)) { - yield* page; - } - } - - /** - * This operation creates or updates a policy definition in the given subscription with the given name. - * @param policyDefinitionName The name of the policy definition to create. - * @param parameters The policy definition properties. - * @param options The options parameters. - */ - createOrUpdate( - policyDefinitionName: string, - parameters: PolicyDefinition, - options?: PolicyDefinitionsCreateOrUpdateOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policyDefinitionName, parameters, options }, - createOrUpdateOperationSpec, - ); - } - - /** - * This operation deletes the policy definition in the given subscription with the given name. - * @param policyDefinitionName The name of the policy definition to delete. - * @param options The options parameters. - */ - delete( - policyDefinitionName: string, - options?: PolicyDefinitionsDeleteOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ policyDefinitionName, options }, deleteOperationSpec); - } - - /** - * This operation retrieves the policy definition in the given subscription with the given name. - * @param policyDefinitionName The name of the policy definition to get. - * @param options The options parameters. - */ - get( - policyDefinitionName: string, - options?: PolicyDefinitionsGetOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ policyDefinitionName, options }, getOperationSpec); - } - - /** - * This operation retrieves the built-in policy definition with the given name. - * @param policyDefinitionName The name of the built-in policy definition to get. - * @param options The options parameters. - */ - getBuiltIn( - policyDefinitionName: string, - options?: PolicyDefinitionsGetBuiltInOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policyDefinitionName, options }, - getBuiltInOperationSpec, - ); - } - - /** - * This operation creates or updates a policy definition in the given management group with the given - * name. - * @param managementGroupId The ID of the management group. - * @param policyDefinitionName The name of the policy definition to create. - * @param parameters The policy definition properties. - * @param options The options parameters. - */ - createOrUpdateAtManagementGroup( - managementGroupId: string, - policyDefinitionName: string, - parameters: PolicyDefinition, - options?: PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupId, policyDefinitionName, parameters, options }, - createOrUpdateAtManagementGroupOperationSpec, - ); - } - - /** - * This operation deletes the policy definition in the given management group with the given name. - * @param managementGroupId The ID of the management group. - * @param policyDefinitionName The name of the policy definition to delete. - * @param options The options parameters. - */ - deleteAtManagementGroup( - managementGroupId: string, - policyDefinitionName: string, - options?: PolicyDefinitionsDeleteAtManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupId, policyDefinitionName, options }, - deleteAtManagementGroupOperationSpec, - ); - } - - /** - * This operation retrieves the policy definition in the given management group with the given name. - * @param managementGroupId The ID of the management group. - * @param policyDefinitionName The name of the policy definition to get. - * @param options The options parameters. - */ - getAtManagementGroup( - managementGroupId: string, - policyDefinitionName: string, - options?: PolicyDefinitionsGetAtManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupId, policyDefinitionName, options }, - getAtManagementGroupOperationSpec, - ); - } - - /** - * This operation retrieves a list of all the policy definitions in a given subscription that match the - * optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or - * 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy - * definitions associated with the subscription, including those that apply directly or from management - * groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list - * only includes all policy definitions that at the given subscription. If $filter='policyType -eq - * {value}' is provided, the returned list only includes all policy definitions whose type match the - * {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If - * $filter='category -eq {value}' is provided, the returned list only includes all policy definitions - * whose category match the {value}. - * @param options The options parameters. - */ - private _list( - options?: PolicyDefinitionsListOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ options }, listOperationSpec); - } - - /** - * This operation retrieves a list of all the built-in policy definitions that match the optional given - * $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all - * built-in policy definitions whose type match the {value}. Possible policyType values are - * NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the - * returned list only includes all built-in policy definitions whose category match the {value}. - * @param options The options parameters. - */ - private _listBuiltIn( - options?: PolicyDefinitionsListBuiltInOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ options }, listBuiltInOperationSpec); - } - - /** - * This operation retrieves a list of all the policy definitions in a given management group that match - * the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' - * or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy - * definitions associated with the management group, including those that apply directly or from - * management groups that contain the given management group. If $filter=atExactScope() is provided, - * the returned list only includes all policy definitions that at the given management group. If - * $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions - * whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and - * Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy - * definitions whose category match the {value}. - * @param managementGroupId The ID of the management group. - * @param options The options parameters. - */ - private _listByManagementGroup( - managementGroupId: string, - options?: PolicyDefinitionsListByManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupId, options }, - listByManagementGroupOperationSpec, - ); - } - - /** - * ListNext - * @param nextLink The nextLink from the previous successful call to the List method. - * @param options The options parameters. - */ - private _listNext( - nextLink: string, - options?: PolicyDefinitionsListNextOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ nextLink, options }, listNextOperationSpec); - } - - /** - * ListBuiltInNext - * @param nextLink The nextLink from the previous successful call to the ListBuiltIn method. - * @param options The options parameters. - */ - private _listBuiltInNext( - nextLink: string, - options?: PolicyDefinitionsListBuiltInNextOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ nextLink, options }, listBuiltInNextOperationSpec); - } - - /** - * ListByManagementGroupNext - * @param managementGroupId The ID of the management group. - * @param nextLink The nextLink from the previous successful call to the ListByManagementGroup method. - * @param options The options parameters. - */ - private _listByManagementGroupNext( - managementGroupId: string, - nextLink: string, - options?: PolicyDefinitionsListByManagementGroupNextOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupId, nextLink, options }, - listByManagementGroupNextOperationSpec, - ); - } -} -// Operation Specifications -const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); - -const createOrUpdateOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", - httpMethod: "PUT", - responses: { - 201: { - bodyMapper: Mappers.PolicyDefinition, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - requestBody: Parameters.parameters, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.policyDefinitionName], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer, -}; -const deleteOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", - httpMethod: "DELETE", - responses: { - 200: {}, - 204: {}, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.policyDefinitionName], - headerParameters: [Parameters.accept], - serializer, -}; -const getOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinition, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.policyDefinitionName], - headerParameters: [Parameters.accept], - serializer, -}; -const getBuiltInOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinition, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.policyDefinitionName], - headerParameters: [Parameters.accept], - serializer, -}; -const createOrUpdateAtManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", - httpMethod: "PUT", - responses: { - 201: { - bodyMapper: Mappers.PolicyDefinition, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - requestBody: Parameters.parameters, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.policyDefinitionName, Parameters.managementGroupId], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer, -}; -const deleteAtManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", - httpMethod: "DELETE", - responses: { - 200: {}, - 204: {}, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.policyDefinitionName, Parameters.managementGroupId], - headerParameters: [Parameters.accept], - serializer, -}; -const getAtManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinition, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.policyDefinitionName, Parameters.managementGroupId], - headerParameters: [Parameters.accept], - serializer, -}; -const listOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.filter, Parameters.top], - urlParameters: [Parameters.$host, Parameters.subscriptionId], - headerParameters: [Parameters.accept], - serializer, -}; -const listBuiltInOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Authorization/policyDefinitions", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.filter, Parameters.top], - urlParameters: [Parameters.$host], - headerParameters: [Parameters.accept], - serializer, -}; -const listByManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.filter, Parameters.top], - urlParameters: [Parameters.$host, Parameters.managementGroupId], - headerParameters: [Parameters.accept], - serializer, -}; -const listNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.nextLink], - headerParameters: [Parameters.accept], - serializer, -}; -const listBuiltInNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - urlParameters: [Parameters.$host, Parameters.nextLink], - headerParameters: [Parameters.accept], - serializer, -}; -const listByManagementGroupNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicyDefinitionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - urlParameters: [Parameters.$host, Parameters.managementGroupId, Parameters.nextLink], - headerParameters: [Parameters.accept], - serializer, -}; diff --git a/sdk/policy/arm-policy/src/operations/policySetDefinitionVersions.ts b/sdk/policy/arm-policy/src/operations/policySetDefinitionVersions.ts deleted file mode 100644 index 4367dd3ff95b..000000000000 --- a/sdk/policy/arm-policy/src/operations/policySetDefinitionVersions.ts +++ /dev/null @@ -1,876 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; -import { setContinuationToken } from "../pagingHelper.js"; -import type { PolicySetDefinitionVersions } from "../operationsInterfaces/index.js"; -import * as coreClient from "@azure/core-client"; -import * as Mappers from "../models/mappers.js"; -import * as Parameters from "../models/parameters.js"; -import type { PolicyClient } from "../policyClient.js"; -import type { - PolicySetDefinitionVersion, - PolicySetDefinitionVersionsListNextOptionalParams, - PolicySetDefinitionVersionsListOptionalParams, - PolicySetDefinitionVersionsListResponse, - PolicySetDefinitionVersionsListBuiltInNextOptionalParams, - PolicySetDefinitionVersionsListBuiltInOptionalParams, - PolicySetDefinitionVersionsListBuiltInResponse, - PolicySetDefinitionVersionsListByManagementGroupNextOptionalParams, - PolicySetDefinitionVersionsListByManagementGroupOptionalParams, - PolicySetDefinitionVersionsListByManagementGroupResponse, - PolicySetDefinitionVersionsListAllBuiltinsOptionalParams, - PolicySetDefinitionVersionsListAllBuiltinsResponse, - PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams, - PolicySetDefinitionVersionsListAllAtManagementGroupResponse, - PolicySetDefinitionVersionsListAllOptionalParams, - PolicySetDefinitionVersionsListAllResponse, - PolicySetDefinitionVersionsCreateOrUpdateOptionalParams, - PolicySetDefinitionVersionsCreateOrUpdateResponse, - PolicySetDefinitionVersionsDeleteOptionalParams, - PolicySetDefinitionVersionsGetOptionalParams, - PolicySetDefinitionVersionsGetResponse, - PolicySetDefinitionVersionsGetBuiltInOptionalParams, - PolicySetDefinitionVersionsGetBuiltInResponse, - PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, - PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupResponse, - PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams, - PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams, - PolicySetDefinitionVersionsGetAtManagementGroupResponse, - PolicySetDefinitionVersionsListNextResponse, - PolicySetDefinitionVersionsListBuiltInNextResponse, - PolicySetDefinitionVersionsListByManagementGroupNextResponse, -} from "../models/index.js"; - -/// -/** Class containing PolicySetDefinitionVersions operations. */ -export class PolicySetDefinitionVersionsImpl implements PolicySetDefinitionVersions { - private readonly client: PolicyClient; - - /** - * Initialize a new instance of the class PolicySetDefinitionVersions class. - * @param client Reference to the service client - */ - constructor(client: PolicyClient) { - this.client = client; - } - - /** - * This operation retrieves a list of all the policy set definition versions for the given policy set - * definition. - * @param policySetDefinitionName The name of the policy set definition. - * @param options The options parameters. - */ - public list( - policySetDefinitionName: string, - options?: PolicySetDefinitionVersionsListOptionalParams, - ): PagedAsyncIterableIterator { - const iter = this.listPagingAll(policySetDefinitionName, options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listPagingPage(policySetDefinitionName, options, settings); - }, - }; - } - - private async *listPagingPage( - policySetDefinitionName: string, - options?: PolicySetDefinitionVersionsListOptionalParams, - settings?: PageSettings, - ): AsyncIterableIterator { - let result: PolicySetDefinitionVersionsListResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._list(policySetDefinitionName, options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listNext(policySetDefinitionName, continuationToken, options); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listPagingAll( - policySetDefinitionName: string, - options?: PolicySetDefinitionVersionsListOptionalParams, - ): AsyncIterableIterator { - for await (const page of this.listPagingPage(policySetDefinitionName, options)) { - yield* page; - } - } - - /** - * This operation retrieves a list of all the built-in policy set definition versions for the given - * built-in policy set definition. - * @param policySetDefinitionName The name of the policy set definition. - * @param options The options parameters. - */ - public listBuiltIn( - policySetDefinitionName: string, - options?: PolicySetDefinitionVersionsListBuiltInOptionalParams, - ): PagedAsyncIterableIterator { - const iter = this.listBuiltInPagingAll(policySetDefinitionName, options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listBuiltInPagingPage(policySetDefinitionName, options, settings); - }, - }; - } - - private async *listBuiltInPagingPage( - policySetDefinitionName: string, - options?: PolicySetDefinitionVersionsListBuiltInOptionalParams, - settings?: PageSettings, - ): AsyncIterableIterator { - let result: PolicySetDefinitionVersionsListBuiltInResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._listBuiltIn(policySetDefinitionName, options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listBuiltInNext(policySetDefinitionName, continuationToken, options); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listBuiltInPagingAll( - policySetDefinitionName: string, - options?: PolicySetDefinitionVersionsListBuiltInOptionalParams, - ): AsyncIterableIterator { - for await (const page of this.listBuiltInPagingPage(policySetDefinitionName, options)) { - yield* page; - } - } - - /** - * This operation retrieves a list of all the policy set definition versions for the given policy set - * definition in a given management group. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policySetDefinitionName The name of the policy set definition. - * @param options The options parameters. - */ - public listByManagementGroup( - managementGroupName: string, - policySetDefinitionName: string, - options?: PolicySetDefinitionVersionsListByManagementGroupOptionalParams, - ): PagedAsyncIterableIterator { - const iter = this.listByManagementGroupPagingAll( - managementGroupName, - policySetDefinitionName, - options, - ); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listByManagementGroupPagingPage( - managementGroupName, - policySetDefinitionName, - options, - settings, - ); - }, - }; - } - - private async *listByManagementGroupPagingPage( - managementGroupName: string, - policySetDefinitionName: string, - options?: PolicySetDefinitionVersionsListByManagementGroupOptionalParams, - settings?: PageSettings, - ): AsyncIterableIterator { - let result: PolicySetDefinitionVersionsListByManagementGroupResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._listByManagementGroup( - managementGroupName, - policySetDefinitionName, - options, - ); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listByManagementGroupNext( - managementGroupName, - policySetDefinitionName, - continuationToken, - options, - ); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listByManagementGroupPagingAll( - managementGroupName: string, - policySetDefinitionName: string, - options?: PolicySetDefinitionVersionsListByManagementGroupOptionalParams, - ): AsyncIterableIterator { - for await (const page of this.listByManagementGroupPagingPage( - managementGroupName, - policySetDefinitionName, - options, - )) { - yield* page; - } - } - - /** - * This operation lists all the built-in policy set definition versions for all built-in policy set - * definitions. - * @param options The options parameters. - */ - listAllBuiltins( - options?: PolicySetDefinitionVersionsListAllBuiltinsOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ options }, listAllBuiltinsOperationSpec); - } - - /** - * This operation lists all the policy set definition versions for all policy set definitions at the - * management group scope. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param options The options parameters. - */ - listAllAtManagementGroup( - managementGroupName: string, - options?: PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupName, options }, - listAllAtManagementGroupOperationSpec, - ); - } - - /** - * This operation lists all the policy set definition versions for all policy set definitions within a - * subscription. - * @param options The options parameters. - */ - listAll( - options?: PolicySetDefinitionVersionsListAllOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ options }, listAllOperationSpec); - } - - /** - * This operation creates or updates a policy set definition version in the given subscription with the - * given name and version. - * @param policySetDefinitionName The name of the policy set definition. - * @param policyDefinitionVersion The policy set definition version. The format is x.y.z where x is - * the major version number, y is the minor version number, and z is the patch number - * @param parameters The policy set definition properties. - * @param options The options parameters. - */ - createOrUpdate( - policySetDefinitionName: string, - policyDefinitionVersion: string, - parameters: PolicySetDefinitionVersion, - options?: PolicySetDefinitionVersionsCreateOrUpdateOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policySetDefinitionName, policyDefinitionVersion, parameters, options }, - createOrUpdateOperationSpec, - ); - } - - /** - * This operation deletes the policy set definition version in the given subscription with the given - * name and version. - * @param policySetDefinitionName The name of the policy set definition. - * @param policyDefinitionVersion The policy set definition version. The format is x.y.z where x is - * the major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - delete( - policySetDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicySetDefinitionVersionsDeleteOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policySetDefinitionName, policyDefinitionVersion, options }, - deleteOperationSpec, - ); - } - - /** - * This operation retrieves the policy set definition version in the given subscription with the given - * name and version. - * @param policySetDefinitionName The name of the policy set definition. - * @param policyDefinitionVersion The policy set definition version. The format is x.y.z where x is - * the major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - get( - policySetDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicySetDefinitionVersionsGetOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policySetDefinitionName, policyDefinitionVersion, options }, - getOperationSpec, - ); - } - - /** - * This operation retrieves the built-in policy set definition version with the given name and version. - * @param policySetDefinitionName The name of the policy set definition. - * @param policyDefinitionVersion The policy set definition version. The format is x.y.z where x is - * the major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - getBuiltIn( - policySetDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicySetDefinitionVersionsGetBuiltInOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policySetDefinitionName, policyDefinitionVersion, options }, - getBuiltInOperationSpec, - ); - } - - /** - * This operation retrieves a list of all the policy set definition versions for the given policy set - * definition. - * @param policySetDefinitionName The name of the policy set definition. - * @param options The options parameters. - */ - private _list( - policySetDefinitionName: string, - options?: PolicySetDefinitionVersionsListOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policySetDefinitionName, options }, - listOperationSpec, - ); - } - - /** - * This operation retrieves a list of all the built-in policy set definition versions for the given - * built-in policy set definition. - * @param policySetDefinitionName The name of the policy set definition. - * @param options The options parameters. - */ - private _listBuiltIn( - policySetDefinitionName: string, - options?: PolicySetDefinitionVersionsListBuiltInOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policySetDefinitionName, options }, - listBuiltInOperationSpec, - ); - } - - /** - * This operation creates or updates a policy set definition version in the given management group with - * the given name and version. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policySetDefinitionName The name of the policy set definition. - * @param policyDefinitionVersion The policy set definition version. The format is x.y.z where x is - * the major version number, y is the minor version number, and z is the patch number - * @param parameters The policy set definition version properties. - * @param options The options parameters. - */ - createOrUpdateAtManagementGroup( - managementGroupName: string, - policySetDefinitionName: string, - policyDefinitionVersion: string, - parameters: PolicySetDefinitionVersion, - options?: PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { - managementGroupName, - policySetDefinitionName, - policyDefinitionVersion, - parameters, - options, - }, - createOrUpdateAtManagementGroupOperationSpec, - ); - } - - /** - * This operation deletes the policy set definition version in the given management group with the - * given name and version. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policySetDefinitionName The name of the policy set definition. - * @param policyDefinitionVersion The policy set definition version. The format is x.y.z where x is - * the major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - deleteAtManagementGroup( - managementGroupName: string, - policySetDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { - managementGroupName, - policySetDefinitionName, - policyDefinitionVersion, - options, - }, - deleteAtManagementGroupOperationSpec, - ); - } - - /** - * This operation retrieves the policy set definition version in the given management group with the - * given name and version. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policySetDefinitionName The name of the policy set definition. - * @param policyDefinitionVersion The policy set definition version. The format is x.y.z where x is - * the major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - getAtManagementGroup( - managementGroupName: string, - policySetDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { - managementGroupName, - policySetDefinitionName, - policyDefinitionVersion, - options, - }, - getAtManagementGroupOperationSpec, - ); - } - - /** - * This operation retrieves a list of all the policy set definition versions for the given policy set - * definition in a given management group. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policySetDefinitionName The name of the policy set definition. - * @param options The options parameters. - */ - private _listByManagementGroup( - managementGroupName: string, - policySetDefinitionName: string, - options?: PolicySetDefinitionVersionsListByManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupName, policySetDefinitionName, options }, - listByManagementGroupOperationSpec, - ); - } - - /** - * ListNext - * @param policySetDefinitionName The name of the policy set definition. - * @param nextLink The nextLink from the previous successful call to the List method. - * @param options The options parameters. - */ - private _listNext( - policySetDefinitionName: string, - nextLink: string, - options?: PolicySetDefinitionVersionsListNextOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policySetDefinitionName, nextLink, options }, - listNextOperationSpec, - ); - } - - /** - * ListBuiltInNext - * @param policySetDefinitionName The name of the policy set definition. - * @param nextLink The nextLink from the previous successful call to the ListBuiltIn method. - * @param options The options parameters. - */ - private _listBuiltInNext( - policySetDefinitionName: string, - nextLink: string, - options?: PolicySetDefinitionVersionsListBuiltInNextOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policySetDefinitionName, nextLink, options }, - listBuiltInNextOperationSpec, - ); - } - - /** - * ListByManagementGroupNext - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policySetDefinitionName The name of the policy set definition. - * @param nextLink The nextLink from the previous successful call to the ListByManagementGroup method. - * @param options The options parameters. - */ - private _listByManagementGroupNext( - managementGroupName: string, - policySetDefinitionName: string, - nextLink: string, - options?: PolicySetDefinitionVersionsListByManagementGroupNextOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupName, policySetDefinitionName, nextLink, options }, - listByManagementGroupNextOperationSpec, - ); - } -} -// Operation Specifications -const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); - -const listAllBuiltinsOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Authorization/listPolicySetDefinitionVersions", - httpMethod: "POST", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host], - headerParameters: [Parameters.accept], - serializer, -}; -const listAllAtManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions", - httpMethod: "POST", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.managementGroupName], - headerParameters: [Parameters.accept], - serializer, -}; -const listAllOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions", - httpMethod: "POST", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.subscriptionId], - headerParameters: [Parameters.accept], - serializer, -}; -const createOrUpdateOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}", - httpMethod: "PUT", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionVersion, - }, - 201: { - bodyMapper: Mappers.PolicySetDefinitionVersion, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - requestBody: Parameters.parameters3, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.policyDefinitionVersion, - Parameters.policySetDefinitionName, - ], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer, -}; -const deleteOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}", - httpMethod: "DELETE", - responses: { - 200: {}, - 204: {}, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.policyDefinitionVersion, - Parameters.policySetDefinitionName, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const getOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionVersion, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.expand], - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.policyDefinitionVersion, - Parameters.policySetDefinitionName, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const getBuiltInOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionVersion, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.expand], - urlParameters: [ - Parameters.$host, - Parameters.policyDefinitionVersion, - Parameters.policySetDefinitionName, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const listOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.top, Parameters.expand], - urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.policySetDefinitionName], - headerParameters: [Parameters.accept], - serializer, -}; -const listBuiltInOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.top, Parameters.expand], - urlParameters: [Parameters.$host, Parameters.policySetDefinitionName], - headerParameters: [Parameters.accept], - serializer, -}; -const createOrUpdateAtManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}", - httpMethod: "PUT", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionVersion, - }, - 201: { - bodyMapper: Mappers.PolicySetDefinitionVersion, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - requestBody: Parameters.parameters3, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.managementGroupName, - Parameters.policyDefinitionVersion, - Parameters.policySetDefinitionName, - ], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer, -}; -const deleteAtManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}", - httpMethod: "DELETE", - responses: { - 200: {}, - 204: {}, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.managementGroupName, - Parameters.policyDefinitionVersion, - Parameters.policySetDefinitionName, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const getAtManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionVersion, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.expand], - urlParameters: [ - Parameters.$host, - Parameters.managementGroupName, - Parameters.policyDefinitionVersion, - Parameters.policySetDefinitionName, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const listByManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.top, Parameters.expand], - urlParameters: [ - Parameters.$host, - Parameters.managementGroupName, - Parameters.policySetDefinitionName, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const listNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.nextLink, - Parameters.policySetDefinitionName, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const listBuiltInNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - urlParameters: [Parameters.$host, Parameters.nextLink, Parameters.policySetDefinitionName], - headerParameters: [Parameters.accept], - serializer, -}; -const listByManagementGroupNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionVersionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - urlParameters: [ - Parameters.$host, - Parameters.nextLink, - Parameters.managementGroupName, - Parameters.policySetDefinitionName, - ], - headerParameters: [Parameters.accept], - serializer, -}; diff --git a/sdk/policy/arm-policy/src/operations/policySetDefinitions.ts b/sdk/policy/arm-policy/src/operations/policySetDefinitions.ts deleted file mode 100644 index 8fcc4484c0b7..000000000000 --- a/sdk/policy/arm-policy/src/operations/policySetDefinitions.ts +++ /dev/null @@ -1,681 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; -import { setContinuationToken } from "../pagingHelper.js"; -import type { PolicySetDefinitions } from "../operationsInterfaces/index.js"; -import * as coreClient from "@azure/core-client"; -import * as Mappers from "../models/mappers.js"; -import * as Parameters from "../models/parameters.js"; -import type { PolicyClient } from "../policyClient.js"; -import type { - PolicySetDefinition, - PolicySetDefinitionsListNextOptionalParams, - PolicySetDefinitionsListOptionalParams, - PolicySetDefinitionsListResponse, - PolicySetDefinitionsListBuiltInNextOptionalParams, - PolicySetDefinitionsListBuiltInOptionalParams, - PolicySetDefinitionsListBuiltInResponse, - PolicySetDefinitionsListByManagementGroupNextOptionalParams, - PolicySetDefinitionsListByManagementGroupOptionalParams, - PolicySetDefinitionsListByManagementGroupResponse, - PolicySetDefinitionsCreateOrUpdateOptionalParams, - PolicySetDefinitionsCreateOrUpdateResponse, - PolicySetDefinitionsDeleteOptionalParams, - PolicySetDefinitionsGetOptionalParams, - PolicySetDefinitionsGetResponse, - PolicySetDefinitionsGetBuiltInOptionalParams, - PolicySetDefinitionsGetBuiltInResponse, - PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, - PolicySetDefinitionsCreateOrUpdateAtManagementGroupResponse, - PolicySetDefinitionsDeleteAtManagementGroupOptionalParams, - PolicySetDefinitionsGetAtManagementGroupOptionalParams, - PolicySetDefinitionsGetAtManagementGroupResponse, - PolicySetDefinitionsListNextResponse, - PolicySetDefinitionsListBuiltInNextResponse, - PolicySetDefinitionsListByManagementGroupNextResponse, -} from "../models/index.js"; - -/// -/** Class containing PolicySetDefinitions operations. */ -export class PolicySetDefinitionsImpl implements PolicySetDefinitions { - private readonly client: PolicyClient; - - /** - * Initialize a new instance of the class PolicySetDefinitions class. - * @param client Reference to the service client - */ - constructor(client: PolicyClient) { - this.client = client; - } - - /** - * This operation retrieves a list of all the policy set definitions in a given subscription that match - * the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' - * or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set - * definitions associated with the subscription, including those that apply directly or from management - * groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list - * only includes all policy set definitions that at the given subscription. If $filter='policyType -eq - * {value}' is provided, the returned list only includes all policy set definitions whose type match - * the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category - * -eq {value}' is provided, the returned list only includes all policy set definitions whose category - * match the {value}. - * @param options The options parameters. - */ - public list( - options?: PolicySetDefinitionsListOptionalParams, - ): PagedAsyncIterableIterator { - const iter = this.listPagingAll(options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listPagingPage(options, settings); - }, - }; - } - - private async *listPagingPage( - options?: PolicySetDefinitionsListOptionalParams, - settings?: PageSettings, - ): AsyncIterableIterator { - let result: PolicySetDefinitionsListResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._list(options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listNext(continuationToken, options); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listPagingAll( - options?: PolicySetDefinitionsListOptionalParams, - ): AsyncIterableIterator { - for await (const page of this.listPagingPage(options)) { - yield* page; - } - } - - /** - * This operation retrieves a list of all the built-in policy set definitions that match the optional - * given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all - * built-in policy set definitions whose category match the {value}. - * @param options The options parameters. - */ - public listBuiltIn( - options?: PolicySetDefinitionsListBuiltInOptionalParams, - ): PagedAsyncIterableIterator { - const iter = this.listBuiltInPagingAll(options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listBuiltInPagingPage(options, settings); - }, - }; - } - - private async *listBuiltInPagingPage( - options?: PolicySetDefinitionsListBuiltInOptionalParams, - settings?: PageSettings, - ): AsyncIterableIterator { - let result: PolicySetDefinitionsListBuiltInResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._listBuiltIn(options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listBuiltInNext(continuationToken, options); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listBuiltInPagingAll( - options?: PolicySetDefinitionsListBuiltInOptionalParams, - ): AsyncIterableIterator { - for await (const page of this.listBuiltInPagingPage(options)) { - yield* page; - } - } - - /** - * This operation retrieves a list of all the policy set definitions in a given management group that - * match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq - * {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all - * policy set definitions associated with the management group, including those that apply directly or - * from management groups that contain the given management group. If $filter=atExactScope() is - * provided, the returned list only includes all policy set definitions that at the given management - * group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy - * set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn - * and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all - * policy set definitions whose category match the {value}. - * @param managementGroupId The ID of the management group. - * @param options The options parameters. - */ - public listByManagementGroup( - managementGroupId: string, - options?: PolicySetDefinitionsListByManagementGroupOptionalParams, - ): PagedAsyncIterableIterator { - const iter = this.listByManagementGroupPagingAll(managementGroupId, options); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: (settings?: PageSettings) => { - if (settings?.maxPageSize) { - throw new Error("maxPageSize is not supported by this operation."); - } - return this.listByManagementGroupPagingPage(managementGroupId, options, settings); - }, - }; - } - - private async *listByManagementGroupPagingPage( - managementGroupId: string, - options?: PolicySetDefinitionsListByManagementGroupOptionalParams, - settings?: PageSettings, - ): AsyncIterableIterator { - let result: PolicySetDefinitionsListByManagementGroupResponse; - let continuationToken = settings?.continuationToken; - if (!continuationToken) { - result = await this._listByManagementGroup(managementGroupId, options); - let page = result.value || []; - continuationToken = result.nextLink; - setContinuationToken(page, continuationToken); - yield page; - } - while (continuationToken) { - result = await this._listByManagementGroupNext(managementGroupId, continuationToken, options); - continuationToken = result.nextLink; - let page = result.value || []; - setContinuationToken(page, continuationToken); - yield page; - } - } - - private async *listByManagementGroupPagingAll( - managementGroupId: string, - options?: PolicySetDefinitionsListByManagementGroupOptionalParams, - ): AsyncIterableIterator { - for await (const page of this.listByManagementGroupPagingPage(managementGroupId, options)) { - yield* page; - } - } - - /** - * This operation creates or updates a policy set definition in the given subscription with the given - * name. - * @param policySetDefinitionName The name of the policy set definition to create. - * @param parameters The policy set definition properties. - * @param options The options parameters. - */ - createOrUpdate( - policySetDefinitionName: string, - parameters: PolicySetDefinition, - options?: PolicySetDefinitionsCreateOrUpdateOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policySetDefinitionName, parameters, options }, - createOrUpdateOperationSpec, - ); - } - - /** - * This operation deletes the policy set definition in the given subscription with the given name. - * @param policySetDefinitionName The name of the policy set definition to delete. - * @param options The options parameters. - */ - delete( - policySetDefinitionName: string, - options?: PolicySetDefinitionsDeleteOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policySetDefinitionName, options }, - deleteOperationSpec, - ); - } - - /** - * This operation retrieves the policy set definition in the given subscription with the given name. - * @param policySetDefinitionName The name of the policy set definition to get. - * @param options The options parameters. - */ - get( - policySetDefinitionName: string, - options?: PolicySetDefinitionsGetOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ policySetDefinitionName, options }, getOperationSpec); - } - - /** - * This operation retrieves the built-in policy set definition with the given name. - * @param policySetDefinitionName The name of the policy set definition to get. - * @param options The options parameters. - */ - getBuiltIn( - policySetDefinitionName: string, - options?: PolicySetDefinitionsGetBuiltInOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { policySetDefinitionName, options }, - getBuiltInOperationSpec, - ); - } - - /** - * This operation retrieves a list of all the policy set definitions in a given subscription that match - * the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' - * or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set - * definitions associated with the subscription, including those that apply directly or from management - * groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list - * only includes all policy set definitions that at the given subscription. If $filter='policyType -eq - * {value}' is provided, the returned list only includes all policy set definitions whose type match - * the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category - * -eq {value}' is provided, the returned list only includes all policy set definitions whose category - * match the {value}. - * @param options The options parameters. - */ - private _list( - options?: PolicySetDefinitionsListOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ options }, listOperationSpec); - } - - /** - * This operation retrieves a list of all the built-in policy set definitions that match the optional - * given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all - * built-in policy set definitions whose category match the {value}. - * @param options The options parameters. - */ - private _listBuiltIn( - options?: PolicySetDefinitionsListBuiltInOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ options }, listBuiltInOperationSpec); - } - - /** - * This operation creates or updates a policy set definition in the given management group with the - * given name. - * @param managementGroupId The ID of the management group. - * @param policySetDefinitionName The name of the policy set definition to create. - * @param parameters The policy set definition properties. - * @param options The options parameters. - */ - createOrUpdateAtManagementGroup( - managementGroupId: string, - policySetDefinitionName: string, - parameters: PolicySetDefinition, - options?: PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupId, policySetDefinitionName, parameters, options }, - createOrUpdateAtManagementGroupOperationSpec, - ); - } - - /** - * This operation deletes the policy set definition in the given management group with the given name. - * @param managementGroupId The ID of the management group. - * @param policySetDefinitionName The name of the policy set definition to delete. - * @param options The options parameters. - */ - deleteAtManagementGroup( - managementGroupId: string, - policySetDefinitionName: string, - options?: PolicySetDefinitionsDeleteAtManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupId, policySetDefinitionName, options }, - deleteAtManagementGroupOperationSpec, - ); - } - - /** - * This operation retrieves the policy set definition in the given management group with the given - * name. - * @param managementGroupId The ID of the management group. - * @param policySetDefinitionName The name of the policy set definition to get. - * @param options The options parameters. - */ - getAtManagementGroup( - managementGroupId: string, - policySetDefinitionName: string, - options?: PolicySetDefinitionsGetAtManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupId, policySetDefinitionName, options }, - getAtManagementGroupOperationSpec, - ); - } - - /** - * This operation retrieves a list of all the policy set definitions in a given management group that - * match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq - * {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all - * policy set definitions associated with the management group, including those that apply directly or - * from management groups that contain the given management group. If $filter=atExactScope() is - * provided, the returned list only includes all policy set definitions that at the given management - * group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy - * set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn - * and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all - * policy set definitions whose category match the {value}. - * @param managementGroupId The ID of the management group. - * @param options The options parameters. - */ - private _listByManagementGroup( - managementGroupId: string, - options?: PolicySetDefinitionsListByManagementGroupOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupId, options }, - listByManagementGroupOperationSpec, - ); - } - - /** - * ListNext - * @param nextLink The nextLink from the previous successful call to the List method. - * @param options The options parameters. - */ - private _listNext( - nextLink: string, - options?: PolicySetDefinitionsListNextOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ nextLink, options }, listNextOperationSpec); - } - - /** - * ListBuiltInNext - * @param nextLink The nextLink from the previous successful call to the ListBuiltIn method. - * @param options The options parameters. - */ - private _listBuiltInNext( - nextLink: string, - options?: PolicySetDefinitionsListBuiltInNextOptionalParams, - ): Promise { - return this.client.sendOperationRequest({ nextLink, options }, listBuiltInNextOperationSpec); - } - - /** - * ListByManagementGroupNext - * @param managementGroupId The ID of the management group. - * @param nextLink The nextLink from the previous successful call to the ListByManagementGroup method. - * @param options The options parameters. - */ - private _listByManagementGroupNext( - managementGroupId: string, - nextLink: string, - options?: PolicySetDefinitionsListByManagementGroupNextOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { managementGroupId, nextLink, options }, - listByManagementGroupNextOperationSpec, - ); - } -} -// Operation Specifications -const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); - -const createOrUpdateOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", - httpMethod: "PUT", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinition, - }, - 201: { - bodyMapper: Mappers.PolicySetDefinition, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - requestBody: Parameters.parameters2, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.policySetDefinitionName], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer, -}; -const deleteOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", - httpMethod: "DELETE", - responses: { - 200: {}, - 204: {}, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.policySetDefinitionName], - headerParameters: [Parameters.accept], - serializer, -}; -const getOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinition, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.expand], - urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.policySetDefinitionName], - headerParameters: [Parameters.accept], - serializer, -}; -const getBuiltInOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinition, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.expand], - urlParameters: [Parameters.$host, Parameters.policySetDefinitionName], - headerParameters: [Parameters.accept], - serializer, -}; -const listOperationSpec: coreClient.OperationSpec = { - path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.filter, Parameters.top, Parameters.expand], - urlParameters: [Parameters.$host, Parameters.subscriptionId], - headerParameters: [Parameters.accept], - serializer, -}; -const listBuiltInOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Authorization/policySetDefinitions", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.filter, Parameters.top, Parameters.expand], - urlParameters: [Parameters.$host], - headerParameters: [Parameters.accept], - serializer, -}; -const createOrUpdateAtManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", - httpMethod: "PUT", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinition, - }, - 201: { - bodyMapper: Mappers.PolicySetDefinition, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - requestBody: Parameters.parameters2, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.managementGroupId, - Parameters.policySetDefinitionName, - ], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer, -}; -const deleteAtManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", - httpMethod: "DELETE", - responses: { - 200: {}, - 204: {}, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.managementGroupId, - Parameters.policySetDefinitionName, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const getAtManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinition, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.expand], - urlParameters: [ - Parameters.$host, - Parameters.managementGroupId, - Parameters.policySetDefinitionName, - ], - headerParameters: [Parameters.accept], - serializer, -}; -const listByManagementGroupOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - queryParameters: [Parameters.apiVersion, Parameters.filter, Parameters.top, Parameters.expand], - urlParameters: [Parameters.$host, Parameters.managementGroupId], - headerParameters: [Parameters.accept], - serializer, -}; -const listNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.nextLink], - headerParameters: [Parameters.accept], - serializer, -}; -const listBuiltInNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - urlParameters: [Parameters.$host, Parameters.nextLink], - headerParameters: [Parameters.accept], - serializer, -}; -const listByManagementGroupNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.PolicySetDefinitionListResult, - }, - default: { - bodyMapper: Mappers.CloudError, - }, - }, - urlParameters: [Parameters.$host, Parameters.managementGroupId, Parameters.nextLink], - headerParameters: [Parameters.accept], - serializer, -}; diff --git a/sdk/policy/arm-policy/src/operationsInterfaces/index.ts b/sdk/policy/arm-policy/src/operationsInterfaces/index.ts deleted file mode 100644 index c79764594dfa..000000000000 --- a/sdk/policy/arm-policy/src/operationsInterfaces/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export * from "./policyDefinitions.js"; -export * from "./policyDefinitionVersions.js"; -export * from "./policySetDefinitions.js"; -export * from "./policySetDefinitionVersions.js"; -export * from "./policyAssignments.js"; diff --git a/sdk/policy/arm-policy/src/operationsInterfaces/policyAssignments.ts b/sdk/policy/arm-policy/src/operationsInterfaces/policyAssignments.ts deleted file mode 100644 index ffd0633fdcc0..000000000000 --- a/sdk/policy/arm-policy/src/operationsInterfaces/policyAssignments.ts +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PagedAsyncIterableIterator } from "@azure/core-paging"; -import type { - PolicyAssignment, - PolicyAssignmentsListForResourceGroupOptionalParams, - PolicyAssignmentsListForResourceOptionalParams, - PolicyAssignmentsListForManagementGroupOptionalParams, - PolicyAssignmentsListOptionalParams, - PolicyAssignmentsDeleteOptionalParams, - PolicyAssignmentsDeleteResponse, - PolicyAssignmentsCreateOptionalParams, - PolicyAssignmentsCreateResponse, - PolicyAssignmentsGetOptionalParams, - PolicyAssignmentsGetResponse, - PolicyAssignmentUpdate, - PolicyAssignmentsUpdateOptionalParams, - PolicyAssignmentsUpdateResponse, - PolicyAssignmentsDeleteByIdOptionalParams, - PolicyAssignmentsDeleteByIdResponse, - PolicyAssignmentsCreateByIdOptionalParams, - PolicyAssignmentsCreateByIdResponse, - PolicyAssignmentsGetByIdOptionalParams, - PolicyAssignmentsGetByIdResponse, - PolicyAssignmentsUpdateByIdOptionalParams, - PolicyAssignmentsUpdateByIdResponse, -} from "../models/index.js"; - -/// -/** Interface representing a PolicyAssignments. */ -export interface PolicyAssignments { - /** - * This operation retrieves the list of all policy assignments associated with the given resource group - * in the given subscription that match the optional given $filter. Valid values for $filter are: - * 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the - * unfiltered list includes all policy assignments associated with the resource group, including those - * that apply directly or apply from containing scopes, as well as any applied to resources contained - * within the resource group. If $filter=atScope() is provided, the returned list includes all policy - * assignments that apply to the resource group, which is everything in the unfiltered list except - * those applied to resources contained within the resource group. If $filter=atExactScope() is - * provided, the returned list only includes all policy assignments that at the resource group. If - * $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy - * assignments of the policy definition whose id is {value} that apply to the resource group. - * @param resourceGroupName The name of the resource group that contains policy assignments. - * @param options The options parameters. - */ - listForResourceGroup( - resourceGroupName: string, - options?: PolicyAssignmentsListForResourceGroupOptionalParams, - ): PagedAsyncIterableIterator; - /** - * This operation retrieves the list of all policy assignments associated with the specified resource - * in the given resource group and subscription that match the optional given $filter. Valid values for - * $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not - * provided, the unfiltered list includes all policy assignments associated with the resource, - * including those that apply directly or from all containing scopes, as well as any applied to - * resources contained within the resource. If $filter=atScope() is provided, the returned list - * includes all policy assignments that apply to the resource, which is everything in the unfiltered - * list except those applied to resources contained within the resource. If $filter=atExactScope() is - * provided, the returned list only includes all policy assignments that at the resource level. If - * $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy - * assignments of the policy definition whose id is {value} that apply to the resource. Three - * parameters plus the resource name are used to identify a specific resource. If the resource is not - * part of a parent resource (the more common case), the parent resource path should not be provided - * (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == - * 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == - * 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. - * For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == - * 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == - * 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the - * namespace and type name separately is to provide both in the {resourceType} parameter, format: - * ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == - * 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - * @param resourceGroupName The name of the resource group containing the resource. - * @param resourceProviderNamespace The namespace of the resource provider. For example, the namespace - * of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) - * @param parentResourcePath The parent resource path. Use empty string if there is none. - * @param resourceType The resource type name. For example the type name of a web app is 'sites' (from - * Microsoft.Web/sites). - * @param resourceName The name of the resource. - * @param options The options parameters. - */ - listForResource( - resourceGroupName: string, - resourceProviderNamespace: string, - parentResourcePath: string, - resourceType: string, - resourceName: string, - options?: PolicyAssignmentsListForResourceOptionalParams, - ): PagedAsyncIterableIterator; - /** - * This operation retrieves the list of all policy assignments applicable to the management group that - * match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or - * 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all - * policy assignments that are assigned to the management group or the management group's ancestors. If - * $filter=atExactScope() is provided, the returned list only includes all policy assignments that at - * the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list - * includes all policy assignments of the policy definition whose id is {value} that apply to the - * management group. - * @param managementGroupId The ID of the management group. - * @param options The options parameters. - */ - listForManagementGroup( - managementGroupId: string, - options?: PolicyAssignmentsListForManagementGroupOptionalParams, - ): PagedAsyncIterableIterator; - /** - * This operation retrieves the list of all policy assignments associated with the given subscription - * that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' - * or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all - * policy assignments associated with the subscription, including those that apply directly or from - * management groups that contain the given subscription, as well as any applied to objects contained - * within the subscription. If $filter=atScope() is provided, the returned list includes all policy - * assignments that apply to the subscription, which is everything in the unfiltered list except those - * applied to objects contained within the subscription. If $filter=atExactScope() is provided, the - * returned list only includes all policy assignments that at the subscription. If - * $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy - * assignments of the policy definition whose id is {value}. - * @param options The options parameters. - */ - list(options?: PolicyAssignmentsListOptionalParams): PagedAsyncIterableIterator; - /** - * This operation deletes a policy assignment, given its name and the scope it was created in. The - * scope of a policy assignment is the part of its ID preceding - * '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - * @param scope The scope of the policy assignment. Valid scopes are: management group (format: - * '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - * '/subscriptions/{subscriptionId}'), resource group (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' - * @param policyAssignmentName The name of the policy assignment to delete. - * @param options The options parameters. - */ - delete( - scope: string, - policyAssignmentName: string, - options?: PolicyAssignmentsDeleteOptionalParams, - ): Promise; - /** - * This operation creates or updates a policy assignment with the given scope and name. Policy - * assignments apply to all resources contained within their scope. For example, when you assign a - * policy at resource group scope, that policy applies to all resources in the group. - * @param scope The scope of the policy assignment. Valid scopes are: management group (format: - * '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - * '/subscriptions/{subscriptionId}'), resource group (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' - * @param policyAssignmentName The name of the policy assignment. - * @param parameters Parameters for the policy assignment. - * @param options The options parameters. - */ - create( - scope: string, - policyAssignmentName: string, - parameters: PolicyAssignment, - options?: PolicyAssignmentsCreateOptionalParams, - ): Promise; - /** - * This operation retrieves a single policy assignment, given its name and the scope it was created at. - * @param scope The scope of the policy assignment. Valid scopes are: management group (format: - * '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - * '/subscriptions/{subscriptionId}'), resource group (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' - * @param policyAssignmentName The name of the policy assignment to get. - * @param options The options parameters. - */ - get( - scope: string, - policyAssignmentName: string, - options?: PolicyAssignmentsGetOptionalParams, - ): Promise; - /** - * This operation updates a policy assignment with the given scope and name. Policy assignments apply - * to all resources contained within their scope. For example, when you assign a policy at resource - * group scope, that policy applies to all resources in the group. - * @param scope The scope of the policy assignment. Valid scopes are: management group (format: - * '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - * '/subscriptions/{subscriptionId}'), resource group (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' - * @param policyAssignmentName The name of the policy assignment. - * @param parameters Parameters for policy assignment patch request. - * @param options The options parameters. - */ - update( - scope: string, - policyAssignmentName: string, - parameters: PolicyAssignmentUpdate, - options?: PolicyAssignmentsUpdateOptionalParams, - ): Promise; - /** - * This operation deletes the policy with the given ID. Policy assignment IDs have this format: - * '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats - * for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management - * group), '/subscriptions/{subscriptionId}' (subscription), - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' - * (resource). - * @param policyAssignmentId The ID of the policy assignment to delete. Use the format - * '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - * @param options The options parameters. - */ - deleteById( - policyAssignmentId: string, - options?: PolicyAssignmentsDeleteByIdOptionalParams, - ): Promise; - /** - * This operation creates or updates the policy assignment with the given ID. Policy assignments made - * on a scope apply to all resources contained in that scope. For example, when you assign a policy to - * a resource group that policy applies to all resources in the group. Policy assignment IDs have this - * format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid - * scopes are: management group (format: - * '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - * '/subscriptions/{subscriptionId}'), resource group (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * @param policyAssignmentId The ID of the policy assignment to create. Use the format - * '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - * @param parameters Parameters for policy assignment. - * @param options The options parameters. - */ - createById( - policyAssignmentId: string, - parameters: PolicyAssignment, - options?: PolicyAssignmentsCreateByIdOptionalParams, - ): Promise; - /** - * The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this - * format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid - * scopes are: management group (format: - * '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - * '/subscriptions/{subscriptionId}'), resource group (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * @param policyAssignmentId The ID of the policy assignment to get. Use the format - * '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - * @param options The options parameters. - */ - getById( - policyAssignmentId: string, - options?: PolicyAssignmentsGetByIdOptionalParams, - ): Promise; - /** - * This operation updates the policy assignment with the given ID. Policy assignments made on a scope - * apply to all resources contained in that scope. For example, when you assign a policy to a resource - * group that policy applies to all resources in the group. Policy assignment IDs have this format: - * '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes - * are: management group (format: - * '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - * '/subscriptions/{subscriptionId}'), resource group (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - * @param policyAssignmentId The ID of the policy assignment to update. Use the format - * '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - * @param parameters Parameters for policy assignment patch request. - * @param options The options parameters. - */ - updateById( - policyAssignmentId: string, - parameters: PolicyAssignmentUpdate, - options?: PolicyAssignmentsUpdateByIdOptionalParams, - ): Promise; -} diff --git a/sdk/policy/arm-policy/src/operationsInterfaces/policyDefinitionVersions.ts b/sdk/policy/arm-policy/src/operationsInterfaces/policyDefinitionVersions.ts deleted file mode 100644 index 6770b03ecca2..000000000000 --- a/sdk/policy/arm-policy/src/operationsInterfaces/policyDefinitionVersions.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PagedAsyncIterableIterator } from "@azure/core-paging"; -import type { - PolicyDefinitionVersion, - PolicyDefinitionVersionsListOptionalParams, - PolicyDefinitionVersionsListBuiltInOptionalParams, - PolicyDefinitionVersionsListByManagementGroupOptionalParams, - PolicyDefinitionVersionsListAllBuiltinsOptionalParams, - PolicyDefinitionVersionsListAllBuiltinsResponse, - PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams, - PolicyDefinitionVersionsListAllAtManagementGroupResponse, - PolicyDefinitionVersionsListAllOptionalParams, - PolicyDefinitionVersionsListAllResponse, - PolicyDefinitionVersionsCreateOrUpdateOptionalParams, - PolicyDefinitionVersionsCreateOrUpdateResponse, - PolicyDefinitionVersionsDeleteOptionalParams, - PolicyDefinitionVersionsGetOptionalParams, - PolicyDefinitionVersionsGetResponse, - PolicyDefinitionVersionsGetBuiltInOptionalParams, - PolicyDefinitionVersionsGetBuiltInResponse, - PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, - PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupResponse, - PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams, - PolicyDefinitionVersionsGetAtManagementGroupOptionalParams, - PolicyDefinitionVersionsGetAtManagementGroupResponse, -} from "../models/index.js"; - -/// -/** Interface representing a PolicyDefinitionVersions. */ -export interface PolicyDefinitionVersions { - /** - * This operation retrieves a list of all the policy definition versions for the given policy - * definition. - * @param policyDefinitionName The name of the policy definition. - * @param options The options parameters. - */ - list( - policyDefinitionName: string, - options?: PolicyDefinitionVersionsListOptionalParams, - ): PagedAsyncIterableIterator; - /** - * This operation retrieves a list of all the built-in policy definition versions for the given policy - * definition. - * @param policyDefinitionName The name of the policy definition. - * @param options The options parameters. - */ - listBuiltIn( - policyDefinitionName: string, - options?: PolicyDefinitionVersionsListBuiltInOptionalParams, - ): PagedAsyncIterableIterator; - /** - * This operation retrieves a list of all the policy definition versions for the given policy - * definition in the given management group. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policyDefinitionName The name of the policy definition. - * @param options The options parameters. - */ - listByManagementGroup( - managementGroupName: string, - policyDefinitionName: string, - options?: PolicyDefinitionVersionsListByManagementGroupOptionalParams, - ): PagedAsyncIterableIterator; - /** - * This operation lists all the built-in policy definition versions for all built-in policy - * definitions. - * @param options The options parameters. - */ - listAllBuiltins( - options?: PolicyDefinitionVersionsListAllBuiltinsOptionalParams, - ): Promise; - /** - * This operation lists all the policy definition versions for all policy definitions at the management - * group scope. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param options The options parameters. - */ - listAllAtManagementGroup( - managementGroupName: string, - options?: PolicyDefinitionVersionsListAllAtManagementGroupOptionalParams, - ): Promise; - /** - * This operation lists all the policy definition versions for all policy definitions within a - * subscription. - * @param options The options parameters. - */ - listAll( - options?: PolicyDefinitionVersionsListAllOptionalParams, - ): Promise; - /** - * This operation creates or updates a policy definition in the given subscription with the given name. - * @param policyDefinitionName The name of the policy definition. - * @param policyDefinitionVersion The policy definition version. The format is x.y.z where x is the - * major version number, y is the minor version number, and z is the patch number - * @param parameters The policy definition properties. - * @param options The options parameters. - */ - createOrUpdate( - policyDefinitionName: string, - policyDefinitionVersion: string, - parameters: PolicyDefinitionVersion, - options?: PolicyDefinitionVersionsCreateOrUpdateOptionalParams, - ): Promise; - /** - * This operation deletes the policy definition version in the given subscription with the given name. - * @param policyDefinitionName The name of the policy definition. - * @param policyDefinitionVersion The policy definition version. The format is x.y.z where x is the - * major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - delete( - policyDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicyDefinitionVersionsDeleteOptionalParams, - ): Promise; - /** - * This operation retrieves the policy definition version in the given subscription with the given - * name. - * @param policyDefinitionName The name of the policy definition. - * @param policyDefinitionVersion The policy definition version. The format is x.y.z where x is the - * major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - get( - policyDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicyDefinitionVersionsGetOptionalParams, - ): Promise; - /** - * This operation retrieves the built-in policy definition version with the given name. - * @param policyDefinitionName The name of the policy definition. - * @param policyDefinitionVersion The policy definition version. The format is x.y.z where x is the - * major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - getBuiltIn( - policyDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicyDefinitionVersionsGetBuiltInOptionalParams, - ): Promise; - /** - * This operation creates or updates a policy definition version in the given management group with the - * given name. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policyDefinitionName The name of the policy definition. - * @param policyDefinitionVersion The policy definition version. The format is x.y.z where x is the - * major version number, y is the minor version number, and z is the patch number - * @param parameters The policy definition properties. - * @param options The options parameters. - */ - createOrUpdateAtManagementGroup( - managementGroupName: string, - policyDefinitionName: string, - policyDefinitionVersion: string, - parameters: PolicyDefinitionVersion, - options?: PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, - ): Promise; - /** - * This operation deletes the policy definition in the given management group with the given name. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policyDefinitionName The name of the policy definition. - * @param policyDefinitionVersion The policy definition version. The format is x.y.z where x is the - * major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - deleteAtManagementGroup( - managementGroupName: string, - policyDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicyDefinitionVersionsDeleteAtManagementGroupOptionalParams, - ): Promise; - /** - * This operation retrieves the policy definition version in the given management group with the given - * name. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policyDefinitionName The name of the policy definition. - * @param policyDefinitionVersion The policy definition version. The format is x.y.z where x is the - * major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - getAtManagementGroup( - managementGroupName: string, - policyDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicyDefinitionVersionsGetAtManagementGroupOptionalParams, - ): Promise; -} diff --git a/sdk/policy/arm-policy/src/operationsInterfaces/policyDefinitions.ts b/sdk/policy/arm-policy/src/operationsInterfaces/policyDefinitions.ts deleted file mode 100644 index 10ff89f75714..000000000000 --- a/sdk/policy/arm-policy/src/operationsInterfaces/policyDefinitions.ts +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PagedAsyncIterableIterator } from "@azure/core-paging"; -import type { - PolicyDefinition, - PolicyDefinitionsListOptionalParams, - PolicyDefinitionsListBuiltInOptionalParams, - PolicyDefinitionsListByManagementGroupOptionalParams, - PolicyDefinitionsCreateOrUpdateOptionalParams, - PolicyDefinitionsCreateOrUpdateResponse, - PolicyDefinitionsDeleteOptionalParams, - PolicyDefinitionsGetOptionalParams, - PolicyDefinitionsGetResponse, - PolicyDefinitionsGetBuiltInOptionalParams, - PolicyDefinitionsGetBuiltInResponse, - PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, - PolicyDefinitionsCreateOrUpdateAtManagementGroupResponse, - PolicyDefinitionsDeleteAtManagementGroupOptionalParams, - PolicyDefinitionsGetAtManagementGroupOptionalParams, - PolicyDefinitionsGetAtManagementGroupResponse, -} from "../models/index.js"; - -/// -/** Interface representing a PolicyDefinitions. */ -export interface PolicyDefinitions { - /** - * This operation retrieves a list of all the policy definitions in a given subscription that match the - * optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or - * 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy - * definitions associated with the subscription, including those that apply directly or from management - * groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list - * only includes all policy definitions that at the given subscription. If $filter='policyType -eq - * {value}' is provided, the returned list only includes all policy definitions whose type match the - * {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If - * $filter='category -eq {value}' is provided, the returned list only includes all policy definitions - * whose category match the {value}. - * @param options The options parameters. - */ - list(options?: PolicyDefinitionsListOptionalParams): PagedAsyncIterableIterator; - /** - * This operation retrieves a list of all the built-in policy definitions that match the optional given - * $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all - * built-in policy definitions whose type match the {value}. Possible policyType values are - * NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the - * returned list only includes all built-in policy definitions whose category match the {value}. - * @param options The options parameters. - */ - listBuiltIn( - options?: PolicyDefinitionsListBuiltInOptionalParams, - ): PagedAsyncIterableIterator; - /** - * This operation retrieves a list of all the policy definitions in a given management group that match - * the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' - * or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy - * definitions associated with the management group, including those that apply directly or from - * management groups that contain the given management group. If $filter=atExactScope() is provided, - * the returned list only includes all policy definitions that at the given management group. If - * $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions - * whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and - * Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy - * definitions whose category match the {value}. - * @param managementGroupId The ID of the management group. - * @param options The options parameters. - */ - listByManagementGroup( - managementGroupId: string, - options?: PolicyDefinitionsListByManagementGroupOptionalParams, - ): PagedAsyncIterableIterator; - /** - * This operation creates or updates a policy definition in the given subscription with the given name. - * @param policyDefinitionName The name of the policy definition to create. - * @param parameters The policy definition properties. - * @param options The options parameters. - */ - createOrUpdate( - policyDefinitionName: string, - parameters: PolicyDefinition, - options?: PolicyDefinitionsCreateOrUpdateOptionalParams, - ): Promise; - /** - * This operation deletes the policy definition in the given subscription with the given name. - * @param policyDefinitionName The name of the policy definition to delete. - * @param options The options parameters. - */ - delete( - policyDefinitionName: string, - options?: PolicyDefinitionsDeleteOptionalParams, - ): Promise; - /** - * This operation retrieves the policy definition in the given subscription with the given name. - * @param policyDefinitionName The name of the policy definition to get. - * @param options The options parameters. - */ - get( - policyDefinitionName: string, - options?: PolicyDefinitionsGetOptionalParams, - ): Promise; - /** - * This operation retrieves the built-in policy definition with the given name. - * @param policyDefinitionName The name of the built-in policy definition to get. - * @param options The options parameters. - */ - getBuiltIn( - policyDefinitionName: string, - options?: PolicyDefinitionsGetBuiltInOptionalParams, - ): Promise; - /** - * This operation creates or updates a policy definition in the given management group with the given - * name. - * @param managementGroupId The ID of the management group. - * @param policyDefinitionName The name of the policy definition to create. - * @param parameters The policy definition properties. - * @param options The options parameters. - */ - createOrUpdateAtManagementGroup( - managementGroupId: string, - policyDefinitionName: string, - parameters: PolicyDefinition, - options?: PolicyDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, - ): Promise; - /** - * This operation deletes the policy definition in the given management group with the given name. - * @param managementGroupId The ID of the management group. - * @param policyDefinitionName The name of the policy definition to delete. - * @param options The options parameters. - */ - deleteAtManagementGroup( - managementGroupId: string, - policyDefinitionName: string, - options?: PolicyDefinitionsDeleteAtManagementGroupOptionalParams, - ): Promise; - /** - * This operation retrieves the policy definition in the given management group with the given name. - * @param managementGroupId The ID of the management group. - * @param policyDefinitionName The name of the policy definition to get. - * @param options The options parameters. - */ - getAtManagementGroup( - managementGroupId: string, - policyDefinitionName: string, - options?: PolicyDefinitionsGetAtManagementGroupOptionalParams, - ): Promise; -} diff --git a/sdk/policy/arm-policy/src/operationsInterfaces/policySetDefinitionVersions.ts b/sdk/policy/arm-policy/src/operationsInterfaces/policySetDefinitionVersions.ts deleted file mode 100644 index 2edd06e19857..000000000000 --- a/sdk/policy/arm-policy/src/operationsInterfaces/policySetDefinitionVersions.ts +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PagedAsyncIterableIterator } from "@azure/core-paging"; -import type { - PolicySetDefinitionVersion, - PolicySetDefinitionVersionsListOptionalParams, - PolicySetDefinitionVersionsListBuiltInOptionalParams, - PolicySetDefinitionVersionsListByManagementGroupOptionalParams, - PolicySetDefinitionVersionsListAllBuiltinsOptionalParams, - PolicySetDefinitionVersionsListAllBuiltinsResponse, - PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams, - PolicySetDefinitionVersionsListAllAtManagementGroupResponse, - PolicySetDefinitionVersionsListAllOptionalParams, - PolicySetDefinitionVersionsListAllResponse, - PolicySetDefinitionVersionsCreateOrUpdateOptionalParams, - PolicySetDefinitionVersionsCreateOrUpdateResponse, - PolicySetDefinitionVersionsDeleteOptionalParams, - PolicySetDefinitionVersionsGetOptionalParams, - PolicySetDefinitionVersionsGetResponse, - PolicySetDefinitionVersionsGetBuiltInOptionalParams, - PolicySetDefinitionVersionsGetBuiltInResponse, - PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, - PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupResponse, - PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams, - PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams, - PolicySetDefinitionVersionsGetAtManagementGroupResponse, -} from "../models/index.js"; - -/// -/** Interface representing a PolicySetDefinitionVersions. */ -export interface PolicySetDefinitionVersions { - /** - * This operation retrieves a list of all the policy set definition versions for the given policy set - * definition. - * @param policySetDefinitionName The name of the policy set definition. - * @param options The options parameters. - */ - list( - policySetDefinitionName: string, - options?: PolicySetDefinitionVersionsListOptionalParams, - ): PagedAsyncIterableIterator; - /** - * This operation retrieves a list of all the built-in policy set definition versions for the given - * built-in policy set definition. - * @param policySetDefinitionName The name of the policy set definition. - * @param options The options parameters. - */ - listBuiltIn( - policySetDefinitionName: string, - options?: PolicySetDefinitionVersionsListBuiltInOptionalParams, - ): PagedAsyncIterableIterator; - /** - * This operation retrieves a list of all the policy set definition versions for the given policy set - * definition in a given management group. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policySetDefinitionName The name of the policy set definition. - * @param options The options parameters. - */ - listByManagementGroup( - managementGroupName: string, - policySetDefinitionName: string, - options?: PolicySetDefinitionVersionsListByManagementGroupOptionalParams, - ): PagedAsyncIterableIterator; - /** - * This operation lists all the built-in policy set definition versions for all built-in policy set - * definitions. - * @param options The options parameters. - */ - listAllBuiltins( - options?: PolicySetDefinitionVersionsListAllBuiltinsOptionalParams, - ): Promise; - /** - * This operation lists all the policy set definition versions for all policy set definitions at the - * management group scope. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param options The options parameters. - */ - listAllAtManagementGroup( - managementGroupName: string, - options?: PolicySetDefinitionVersionsListAllAtManagementGroupOptionalParams, - ): Promise; - /** - * This operation lists all the policy set definition versions for all policy set definitions within a - * subscription. - * @param options The options parameters. - */ - listAll( - options?: PolicySetDefinitionVersionsListAllOptionalParams, - ): Promise; - /** - * This operation creates or updates a policy set definition version in the given subscription with the - * given name and version. - * @param policySetDefinitionName The name of the policy set definition. - * @param policyDefinitionVersion The policy set definition version. The format is x.y.z where x is - * the major version number, y is the minor version number, and z is the patch number - * @param parameters The policy set definition properties. - * @param options The options parameters. - */ - createOrUpdate( - policySetDefinitionName: string, - policyDefinitionVersion: string, - parameters: PolicySetDefinitionVersion, - options?: PolicySetDefinitionVersionsCreateOrUpdateOptionalParams, - ): Promise; - /** - * This operation deletes the policy set definition version in the given subscription with the given - * name and version. - * @param policySetDefinitionName The name of the policy set definition. - * @param policyDefinitionVersion The policy set definition version. The format is x.y.z where x is - * the major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - delete( - policySetDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicySetDefinitionVersionsDeleteOptionalParams, - ): Promise; - /** - * This operation retrieves the policy set definition version in the given subscription with the given - * name and version. - * @param policySetDefinitionName The name of the policy set definition. - * @param policyDefinitionVersion The policy set definition version. The format is x.y.z where x is - * the major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - get( - policySetDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicySetDefinitionVersionsGetOptionalParams, - ): Promise; - /** - * This operation retrieves the built-in policy set definition version with the given name and version. - * @param policySetDefinitionName The name of the policy set definition. - * @param policyDefinitionVersion The policy set definition version. The format is x.y.z where x is - * the major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - getBuiltIn( - policySetDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicySetDefinitionVersionsGetBuiltInOptionalParams, - ): Promise; - /** - * This operation creates or updates a policy set definition version in the given management group with - * the given name and version. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policySetDefinitionName The name of the policy set definition. - * @param policyDefinitionVersion The policy set definition version. The format is x.y.z where x is - * the major version number, y is the minor version number, and z is the patch number - * @param parameters The policy set definition version properties. - * @param options The options parameters. - */ - createOrUpdateAtManagementGroup( - managementGroupName: string, - policySetDefinitionName: string, - policyDefinitionVersion: string, - parameters: PolicySetDefinitionVersion, - options?: PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupOptionalParams, - ): Promise; - /** - * This operation deletes the policy set definition version in the given management group with the - * given name and version. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policySetDefinitionName The name of the policy set definition. - * @param policyDefinitionVersion The policy set definition version. The format is x.y.z where x is - * the major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - deleteAtManagementGroup( - managementGroupName: string, - policySetDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicySetDefinitionVersionsDeleteAtManagementGroupOptionalParams, - ): Promise; - /** - * This operation retrieves the policy set definition version in the given management group with the - * given name and version. - * @param managementGroupName The name of the management group. The name is case insensitive. - * @param policySetDefinitionName The name of the policy set definition. - * @param policyDefinitionVersion The policy set definition version. The format is x.y.z where x is - * the major version number, y is the minor version number, and z is the patch number - * @param options The options parameters. - */ - getAtManagementGroup( - managementGroupName: string, - policySetDefinitionName: string, - policyDefinitionVersion: string, - options?: PolicySetDefinitionVersionsGetAtManagementGroupOptionalParams, - ): Promise; -} diff --git a/sdk/policy/arm-policy/src/operationsInterfaces/policySetDefinitions.ts b/sdk/policy/arm-policy/src/operationsInterfaces/policySetDefinitions.ts deleted file mode 100644 index 81b4e5b76240..000000000000 --- a/sdk/policy/arm-policy/src/operationsInterfaces/policySetDefinitions.ts +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { PagedAsyncIterableIterator } from "@azure/core-paging"; -import type { - PolicySetDefinition, - PolicySetDefinitionsListOptionalParams, - PolicySetDefinitionsListBuiltInOptionalParams, - PolicySetDefinitionsListByManagementGroupOptionalParams, - PolicySetDefinitionsCreateOrUpdateOptionalParams, - PolicySetDefinitionsCreateOrUpdateResponse, - PolicySetDefinitionsDeleteOptionalParams, - PolicySetDefinitionsGetOptionalParams, - PolicySetDefinitionsGetResponse, - PolicySetDefinitionsGetBuiltInOptionalParams, - PolicySetDefinitionsGetBuiltInResponse, - PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, - PolicySetDefinitionsCreateOrUpdateAtManagementGroupResponse, - PolicySetDefinitionsDeleteAtManagementGroupOptionalParams, - PolicySetDefinitionsGetAtManagementGroupOptionalParams, - PolicySetDefinitionsGetAtManagementGroupResponse, -} from "../models/index.js"; - -/// -/** Interface representing a PolicySetDefinitions. */ -export interface PolicySetDefinitions { - /** - * This operation retrieves a list of all the policy set definitions in a given subscription that match - * the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' - * or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set - * definitions associated with the subscription, including those that apply directly or from management - * groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list - * only includes all policy set definitions that at the given subscription. If $filter='policyType -eq - * {value}' is provided, the returned list only includes all policy set definitions whose type match - * the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category - * -eq {value}' is provided, the returned list only includes all policy set definitions whose category - * match the {value}. - * @param options The options parameters. - */ - list( - options?: PolicySetDefinitionsListOptionalParams, - ): PagedAsyncIterableIterator; - /** - * This operation retrieves a list of all the built-in policy set definitions that match the optional - * given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all - * built-in policy set definitions whose category match the {value}. - * @param options The options parameters. - */ - listBuiltIn( - options?: PolicySetDefinitionsListBuiltInOptionalParams, - ): PagedAsyncIterableIterator; - /** - * This operation retrieves a list of all the policy set definitions in a given management group that - * match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq - * {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all - * policy set definitions associated with the management group, including those that apply directly or - * from management groups that contain the given management group. If $filter=atExactScope() is - * provided, the returned list only includes all policy set definitions that at the given management - * group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy - * set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn - * and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all - * policy set definitions whose category match the {value}. - * @param managementGroupId The ID of the management group. - * @param options The options parameters. - */ - listByManagementGroup( - managementGroupId: string, - options?: PolicySetDefinitionsListByManagementGroupOptionalParams, - ): PagedAsyncIterableIterator; - /** - * This operation creates or updates a policy set definition in the given subscription with the given - * name. - * @param policySetDefinitionName The name of the policy set definition to create. - * @param parameters The policy set definition properties. - * @param options The options parameters. - */ - createOrUpdate( - policySetDefinitionName: string, - parameters: PolicySetDefinition, - options?: PolicySetDefinitionsCreateOrUpdateOptionalParams, - ): Promise; - /** - * This operation deletes the policy set definition in the given subscription with the given name. - * @param policySetDefinitionName The name of the policy set definition to delete. - * @param options The options parameters. - */ - delete( - policySetDefinitionName: string, - options?: PolicySetDefinitionsDeleteOptionalParams, - ): Promise; - /** - * This operation retrieves the policy set definition in the given subscription with the given name. - * @param policySetDefinitionName The name of the policy set definition to get. - * @param options The options parameters. - */ - get( - policySetDefinitionName: string, - options?: PolicySetDefinitionsGetOptionalParams, - ): Promise; - /** - * This operation retrieves the built-in policy set definition with the given name. - * @param policySetDefinitionName The name of the policy set definition to get. - * @param options The options parameters. - */ - getBuiltIn( - policySetDefinitionName: string, - options?: PolicySetDefinitionsGetBuiltInOptionalParams, - ): Promise; - /** - * This operation creates or updates a policy set definition in the given management group with the - * given name. - * @param managementGroupId The ID of the management group. - * @param policySetDefinitionName The name of the policy set definition to create. - * @param parameters The policy set definition properties. - * @param options The options parameters. - */ - createOrUpdateAtManagementGroup( - managementGroupId: string, - policySetDefinitionName: string, - parameters: PolicySetDefinition, - options?: PolicySetDefinitionsCreateOrUpdateAtManagementGroupOptionalParams, - ): Promise; - /** - * This operation deletes the policy set definition in the given management group with the given name. - * @param managementGroupId The ID of the management group. - * @param policySetDefinitionName The name of the policy set definition to delete. - * @param options The options parameters. - */ - deleteAtManagementGroup( - managementGroupId: string, - policySetDefinitionName: string, - options?: PolicySetDefinitionsDeleteAtManagementGroupOptionalParams, - ): Promise; - /** - * This operation retrieves the policy set definition in the given management group with the given - * name. - * @param managementGroupId The ID of the management group. - * @param policySetDefinitionName The name of the policy set definition to get. - * @param options The options parameters. - */ - getAtManagementGroup( - managementGroupId: string, - policySetDefinitionName: string, - options?: PolicySetDefinitionsGetAtManagementGroupOptionalParams, - ): Promise; -} diff --git a/sdk/policy/arm-policy/src/pagingHelper.ts b/sdk/policy/arm-policy/src/pagingHelper.ts deleted file mode 100644 index e362819bdfc4..000000000000 --- a/sdk/policy/arm-policy/src/pagingHelper.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export interface PageInfo { - continuationToken?: string; -} - -const pageMap = new WeakMap(); - -/** - * Given the last `.value` produced by the `byPage` iterator, - * returns a continuation token that can be used to begin paging from - * that point later. - * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator. - * @returns The continuation token that can be passed into byPage() during future calls. - */ -export function getContinuationToken(page: unknown): string | undefined { - if (typeof page !== "object" || page === null) { - return undefined; - } - return pageMap.get(page)?.continuationToken; -} - -export function setContinuationToken(page: unknown, continuationToken: string | undefined): void { - if (typeof page !== "object" || page === null || !continuationToken) { - return; - } - const pageInfo = pageMap.get(page) ?? {}; - pageInfo.continuationToken = continuationToken; - pageMap.set(page, pageInfo); -} diff --git a/sdk/policy/arm-policy/src/policyClient.ts b/sdk/policy/arm-policy/src/policyClient.ts index 7d8f3438a8fe..300b4a28a235 100644 --- a/sdk/policy/arm-policy/src/policyClient.ts +++ b/sdk/policy/arm-policy/src/policyClient.ts @@ -1,57 +1,42 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. -import * as coreClient from "@azure/core-client"; -import * as coreRestPipeline from "@azure/core-rest-pipeline"; -import type { PipelineRequest, PipelineResponse, SendRequest } from "@azure/core-rest-pipeline"; -import type * as coreAuth from "@azure/core-auth"; -import { - PolicyDefinitionsImpl, - PolicyDefinitionVersionsImpl, - PolicySetDefinitionsImpl, - PolicySetDefinitionVersionsImpl, - PolicyAssignmentsImpl, -} from "./operations/index.js"; -import type { - PolicyDefinitions, - PolicyDefinitionVersions, - PolicySetDefinitions, - PolicySetDefinitionVersions, - PolicyAssignments, -} from "./operationsInterfaces/index.js"; -import type { PolicyClientOptionalParams } from "./models/index.js"; +import type { PolicyContext, PolicyClientOptionalParams } from "./api/index.js"; +import { createPolicy } from "./api/index.js"; +import type { PolicyAssignmentsOperations } from "./classic/policyAssignments/index.js"; +import { _getPolicyAssignmentsOperations } from "./classic/policyAssignments/index.js"; +import type { PolicyDefinitionVersionsOperations } from "./classic/policyDefinitionVersions/index.js"; +import { _getPolicyDefinitionVersionsOperations } from "./classic/policyDefinitionVersions/index.js"; +import type { PolicyDefinitionsOperations } from "./classic/policyDefinitions/index.js"; +import { _getPolicyDefinitionsOperations } from "./classic/policyDefinitions/index.js"; +import type { PolicySetDefinitionVersionsOperations } from "./classic/policySetDefinitionVersions/index.js"; +import { _getPolicySetDefinitionVersionsOperations } from "./classic/policySetDefinitionVersions/index.js"; +import type { PolicySetDefinitionsOperations } from "./classic/policySetDefinitions/index.js"; +import { _getPolicySetDefinitionsOperations } from "./classic/policySetDefinitions/index.js"; +import type { PolicyTokensOperations } from "./classic/policyTokens/index.js"; +import { _getPolicyTokensOperations } from "./classic/policyTokens/index.js"; +import type { TokenCredential } from "@azure/core-auth"; +import type { Pipeline } from "@azure/core-rest-pipeline"; -export class PolicyClient extends coreClient.ServiceClient { - $host: string; - subscriptionId?: string; - apiVersion: string; +export { PolicyClientOptionalParams } from "./api/policyContext.js"; - /** - * Initializes a new instance of the PolicyClient class. - * @param credentials Subscription credentials which uniquely identify client subscription. - * @param subscriptionId The ID of the target subscription. The value must be an UUID. - * @param options The parameter options - */ +export class PolicyClient { + private _client: PolicyContext; + /** The pipeline used by this client to make requests */ + public readonly pipeline: Pipeline; + + constructor(credential: TokenCredential, options?: PolicyClientOptionalParams); constructor( - credentials: coreAuth.TokenCredential, + credential: TokenCredential, subscriptionId: string, options?: PolicyClientOptionalParams, ); - constructor(credentials: coreAuth.TokenCredential, options?: PolicyClientOptionalParams); + /** To manage and control access to your resources, you can define customized policies and assign them at a scope. */ constructor( - credentials: coreAuth.TokenCredential, - subscriptionIdOrOptions?: PolicyClientOptionalParams | string, + credential: TokenCredential, + subscriptionIdOrOptions?: string | PolicyClientOptionalParams, options?: PolicyClientOptionalParams, ) { - if (credentials === undefined) { - throw new Error("'credentials' cannot be null"); - } - let subscriptionId: string | undefined; if (typeof subscriptionIdOrOptions === "string") { @@ -60,102 +45,34 @@ export class PolicyClient extends coreClient.ServiceClient { options = subscriptionIdOrOptions; } - // Initializing default values for options - if (!options) { - options = {}; - } - const defaults: PolicyClientOptionalParams = { - requestContentType: "application/json; charset=utf-8", - credential: credentials, - }; - - const packageDetails = `azsdk-js-arm-policy/6.0.0`; - const userAgentPrefix = - options.userAgentOptions && options.userAgentOptions.userAgentPrefix - ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` - : `${packageDetails}`; - - const optionsWithDefaults = { - ...defaults, + options = options ?? {}; + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-client` + : `azsdk-js-client`; + this._client = createPolicy(credential, subscriptionId ?? "", { ...options, - userAgentOptions: { - userAgentPrefix, - }, - endpoint: options.endpoint ?? options.baseUri ?? "https://management.azure.com", - }; - super(optionsWithDefaults); - - let bearerTokenAuthenticationPolicyFound: boolean = false; - if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { - const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = - options.pipeline.getOrderedPolicies(); - bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( - (pipelinePolicy) => - pipelinePolicy.name === coreRestPipeline.bearerTokenAuthenticationPolicyName, - ); - } - if ( - !options || - !options.pipeline || - options.pipeline.getOrderedPolicies().length == 0 || - !bearerTokenAuthenticationPolicyFound - ) { - this.pipeline.removePolicy({ - name: coreRestPipeline.bearerTokenAuthenticationPolicyName, - }); - this.pipeline.addPolicy( - coreRestPipeline.bearerTokenAuthenticationPolicy({ - credential: credentials, - scopes: - optionsWithDefaults.credentialScopes ?? `${optionsWithDefaults.endpoint}/.default`, - challengeCallbacks: { - authorizeRequestOnChallenge: coreClient.authorizeRequestOnClaimChallenge, - }, - }), - ); - } - // Parameter assignments - this.subscriptionId = subscriptionId; - - // Assigning values to Constant parameters - this.$host = options.$host || "https://management.azure.com"; - this.apiVersion = options.apiVersion || "2024-05-01"; - this.policyDefinitions = new PolicyDefinitionsImpl(this); - this.policyDefinitionVersions = new PolicyDefinitionVersionsImpl(this); - this.policySetDefinitions = new PolicySetDefinitionsImpl(this); - this.policySetDefinitionVersions = new PolicySetDefinitionVersionsImpl(this); - this.policyAssignments = new PolicyAssignmentsImpl(this); - this.addCustomApiVersionPolicy(options.apiVersion); - } - - /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ - private addCustomApiVersionPolicy(apiVersion?: string) { - if (!apiVersion) { - return; - } - const apiVersionPolicy = { - name: "CustomApiVersionPolicy", - async sendRequest(request: PipelineRequest, next: SendRequest): Promise { - const param = request.url.split("?"); - if (param.length > 1) { - const newParams = param[1].split("&").map((item) => { - if (item.indexOf("api-version") > -1) { - return "api-version=" + apiVersion; - } else { - return item; - } - }); - request.url = param[0] + "?" + newParams.join("&"); - } - return next(request); - }, - }; - this.pipeline.addPolicy(apiVersionPolicy); + userAgentOptions: { userAgentPrefix }, + }); + this.pipeline = this._client.pipeline; + this.policyTokens = _getPolicyTokensOperations(this._client); + this.policySetDefinitionVersions = _getPolicySetDefinitionVersionsOperations(this._client); + this.policySetDefinitions = _getPolicySetDefinitionsOperations(this._client); + this.policyDefinitionVersions = _getPolicyDefinitionVersionsOperations(this._client); + this.policyDefinitions = _getPolicyDefinitionsOperations(this._client); + this.policyAssignments = _getPolicyAssignmentsOperations(this._client); } - policyDefinitions: PolicyDefinitions; - policyDefinitionVersions: PolicyDefinitionVersions; - policySetDefinitions: PolicySetDefinitions; - policySetDefinitionVersions: PolicySetDefinitionVersions; - policyAssignments: PolicyAssignments; + /** The operation groups for policyTokens */ + public readonly policyTokens: PolicyTokensOperations; + /** The operation groups for policySetDefinitionVersions */ + public readonly policySetDefinitionVersions: PolicySetDefinitionVersionsOperations; + /** The operation groups for policySetDefinitions */ + public readonly policySetDefinitions: PolicySetDefinitionsOperations; + /** The operation groups for policyDefinitionVersions */ + public readonly policyDefinitionVersions: PolicyDefinitionVersionsOperations; + /** The operation groups for policyDefinitions */ + public readonly policyDefinitions: PolicyDefinitionsOperations; + /** The operation groups for policyAssignments */ + public readonly policyAssignments: PolicyAssignmentsOperations; } diff --git a/sdk/policy/arm-policy/src/static-helpers/cloudSettingHelpers.ts b/sdk/policy/arm-policy/src/static-helpers/cloudSettingHelpers.ts new file mode 100644 index 000000000000..613112c6e397 --- /dev/null +++ b/sdk/policy/arm-policy/src/static-helpers/cloudSettingHelpers.ts @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * An enum to describe Azure Cloud environments. + * @enum {string} + */ +export enum AzureClouds { + /** Azure public cloud, which is the default cloud for Azure SDKs. */ + AZURE_PUBLIC_CLOUD = "AZURE_PUBLIC_CLOUD", + /** Azure China cloud */ + AZURE_CHINA_CLOUD = "AZURE_CHINA_CLOUD", + /** Azure US government cloud */ + AZURE_US_GOVERNMENT = "AZURE_US_GOVERNMENT", +} + +/** The supported values for cloud setting as a string literal type */ +export type AzureSupportedClouds = `${AzureClouds}`; + +/** + * Gets the Azure Resource Manager endpoint URL for the specified cloud setting. + * @param cloudSetting - The Azure cloud environment setting. Use one of the AzureClouds enum values. + * @returns The ARM endpoint URL for the specified cloud, or undefined if cloudSetting is undefined. + * @throws {Error} Throws an error if an unknown cloud setting is provided. + */ +export function getArmEndpoint(cloudSetting?: AzureSupportedClouds): string | undefined { + if (cloudSetting === undefined) { + return undefined; + } + const cloudEndpoints: Record = { + AZURE_CHINA_CLOUD: "https://management.chinacloudapi.cn/", + AZURE_US_GOVERNMENT: "https://management.usgovcloudapi.net/", + AZURE_PUBLIC_CLOUD: "https://management.azure.com/", + }; + if (cloudSetting in cloudEndpoints) { + return cloudEndpoints[cloudSetting]; + } else { + throw new Error( + `Unknown cloud setting: ${cloudSetting}. Please refer to the enum AzureClouds for possible values.`, + ); + } +} diff --git a/sdk/policy/arm-policy/src/static-helpers/pagingHelpers.ts b/sdk/policy/arm-policy/src/static-helpers/pagingHelpers.ts new file mode 100644 index 000000000000..9258ba95eda8 --- /dev/null +++ b/sdk/policy/arm-policy/src/static-helpers/pagingHelpers.ts @@ -0,0 +1,270 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { Client, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError } from "@azure-rest/core-client"; +import { RestError } from "@azure/core-rest-pipeline"; + +/** + * Options for the byPage method + */ +export interface PageSettings { + /** + * A reference to a specific page to start iterating from. + */ + continuationToken?: string; +} + +/** + * An interface that describes a page of results. + */ +export type ContinuablePage = TPage & { + /** + * The token that keeps track of where to continue the iterator + */ + continuationToken?: string; +}; + +/** + * An interface that allows async iterable iteration both to completion and by page. + */ +export interface PagedAsyncIterableIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + /** + * The next method, part of the iteration protocol + */ + next(): Promise>; + /** + * The connection to the async iterator, part of the iteration protocol + */ + [Symbol.asyncIterator](): PagedAsyncIterableIterator; + /** + * Return an AsyncIterableIterator that works a page at a time + */ + byPage: (settings?: TPageSettings) => AsyncIterableIterator>; +} + +/** + * An interface that describes how to communicate with the service. + */ +export interface PagedResult< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + /** + * Link to the first page of results. + */ + firstPageLink?: string; + /** + * A method that returns a page of results. + */ + getPage: (pageLink?: string) => Promise<{ page: TPage; nextPageLink?: string } | undefined>; + /** + * a function to implement the `byPage` method on the paged async iterator. + */ + byPage?: (settings?: TPageSettings) => AsyncIterableIterator>; + + /** + * A function to extract elements from a page. + */ + toElements?: (page: TPage) => TElement[]; +} + +/** + * Options for the paging helper + */ +export interface BuildPagedAsyncIteratorOptions { + itemName?: string; + nextLinkName?: string; + nextLinkMethod?: "GET" | "POST"; + apiVersion?: 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 nextLinkMethod = options.nextLinkMethod ?? "GET"; + const apiVersion = options.apiVersion; + const pagedResult: PagedResult = { + getPage: async (pageLink?: string) => { + let result; + if (pageLink === undefined) { + result = await getInitialResponse(); + } else { + const resolvedPageLink = apiVersion ? addApiVersionToUrl(pageLink, apiVersion) : pageLink; + result = + nextLinkMethod === "POST" + ? await client.pathUnchecked(resolvedPageLink).post() + : await client.pathUnchecked(resolvedPageLink).get(); + } + checkPagingRequest(result, expectedStatuses); + const results = await processResponseBody(result as TResponse); + const nextLink = getNextLink(results, nextLinkName); + const values = getElements(results, itemName) as TPage; + return { + page: values, + nextPageLink: nextLink, + }; + }, + byPage: (settings?: TPageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken, + }); + }, + }; + return getPagedAsyncIterator(pagedResult); +} + +/** + * returns an async iterator that iterates over results. It also has a `byPage` + * method that returns pages of items at once. + * + * @param pagedResult - an object that specifies how to get pages. + * @returns a paged async iterator that iterates over results. + */ + +function getPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +>( + pagedResult: PagedResult, +): PagedAsyncIterableIterator { + const iter = getItemAsyncIterator(pagedResult); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: + pagedResult?.byPage ?? + ((settings?: TPageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken, + }); + }), + }; +} + +async function* getItemAsyncIterator( + pagedResult: PagedResult, +): AsyncIterableIterator { + const pages = getPageAsyncIterator(pagedResult); + for await (const page of pages) { + yield* page as unknown as TElement[]; + } +} + +async function* getPageAsyncIterator( + pagedResult: PagedResult, + options: { + pageLink?: string; + } = {}, +): AsyncIterableIterator> { + const { pageLink } = options; + let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink); + if (!response) { + return; + } + let result = response.page as ContinuablePage; + result.continuationToken = response.nextPageLink; + yield result; + while (response.nextPageLink) { + response = await pagedResult.getPage(response.nextPageLink); + if (!response) { + return; + } + result = response.page as ContinuablePage; + result.continuationToken = response.nextPageLink; + yield result; + } +} + +/** + * Gets for the value of nextLink in the body + */ +function getNextLink(body: unknown, nextLinkName?: string): string | undefined { + if (!nextLinkName) { + return undefined; + } + + const nextLink = (body as Record)[nextLinkName]; + + if (typeof nextLink !== "string" && typeof nextLink !== "undefined" && nextLink !== null) { + throw new RestError( + `Body Property ${nextLinkName} should be a string or undefined or null but got ${typeof nextLink}`, + ); + } + + if (nextLink === null) { + return undefined; + } + + return nextLink; +} + +/** + * Gets the elements of the current request in the body. + */ +function getElements(body: unknown, itemName: string): T[] { + const value = (body as Record)[itemName] as T[]; + if (!Array.isArray(value)) { + throw new RestError( + `Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`, + ); + } + + return value ?? []; +} + +/** + * Checks if a request failed + */ +function checkPagingRequest(response: PathUncheckedResponse, expectedStatuses: string[]): void { + if (!expectedStatuses.includes(response.status)) { + throw createRestError( + `Pagination failed with unexpected statusCode ${response.status}`, + response, + ); + } +} + +/** + * Adds the api-version query parameter on a URL if it's not present. + * @param url - the URL to modify + * @param apiVersion - the API version to set + * @returns - the URL with the api-version query parameter set + */ +function addApiVersionToUrl(url: string, apiVersion: string): string { + // The base URL is only used for parsing and won't appear in the returned URL + const urlObj = new URL(url, "https://microsoft.com"); + if (!urlObj.searchParams.get("api-version")) { + // Append one if there is no apiVersion + return `${url}${ + Array.from(urlObj.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; + } + return url; +} diff --git a/sdk/policy/arm-policy/src/static-helpers/serialization/check-prop-undefined.ts b/sdk/policy/arm-policy/src/static-helpers/serialization/check-prop-undefined.ts new file mode 100644 index 000000000000..50f78829e491 --- /dev/null +++ b/sdk/policy/arm-policy/src/static-helpers/serialization/check-prop-undefined.ts @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * Returns true if all specified properties of the item are undefined. + * @param item The object to check. + * @param properties The list of property names to check on the item. + * @returns True if all specified properties are undefined, otherwise false. + */ +export function areAllPropsUndefined(item: Record, properties: string[]): boolean { + for (const property of properties) { + if (item[property] !== undefined) { + return false; + } + } + return true; +} diff --git a/sdk/policy/arm-policy/src/static-helpers/serialization/serialize-record.ts b/sdk/policy/arm-policy/src/static-helpers/serialization/serialize-record.ts new file mode 100644 index 000000000000..f2d3a221fef7 --- /dev/null +++ b/sdk/policy/arm-policy/src/static-helpers/serialization/serialize-record.ts @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export function serializeRecord(item: any, excludes?: string[], serializer?: (item: any) => any) { + excludes = excludes ?? []; + const res: any = {}; + for (const key of Object.keys(item)) { + if (excludes.includes(key) || item[key] === undefined) { + continue; + } + if (serializer) { + res[key] = serializer(item[key]); + } else { + res[key] = item[key] as any; + } + } + return res; +} diff --git a/sdk/policy/arm-policy/src/static-helpers/urlTemplate.ts b/sdk/policy/arm-policy/src/static-helpers/urlTemplate.ts new file mode 100644 index 000000000000..c7109898692a --- /dev/null +++ b/sdk/policy/arm-policy/src/static-helpers/urlTemplate.ts @@ -0,0 +1,227 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// --------------------- +// interfaces +// --------------------- +interface ValueOptions { + isFirst: boolean; // is first value in the expression + op?: string; // operator + varValue?: any; // variable value + varName?: string; // variable name + modifier?: string; // modifier e.g * + reserved?: boolean; // if true we'll keep reserved words with not encoding +} + +export interface UrlTemplateOptions { + // if set to true, reserved characters will not be encoded + allowReserved?: boolean; +} + +// --------------------- +// helpers +// --------------------- +function encodeComponent(val: string, reserved?: boolean, op?: string): string { + return (reserved ?? op === "+") || op === "#" + ? encodeReservedComponent(val) + : encodeRFC3986URIComponent(val); +} + +function encodeReservedComponent(str: string): string { + return str + .split(/(%[0-9A-Fa-f]{2})/g) + .map((part) => (!/%[0-9A-Fa-f]/.test(part) ? encodeURI(part) : part)) + .join(""); +} + +function encodeRFC3986URIComponent(str: string): string { + return encodeURIComponent(str).replace( + /[!'()*]/g, + (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`, + ); +} + +function isDefined(val: any): boolean { + return val !== undefined && val !== null; +} + +function getNamedAndIfEmpty(op?: string): [boolean, string] { + return [!!op && [";", "?", "&"].includes(op), !!op && ["?", "&"].includes(op) ? "=" : ""]; +} + +function getFirstOrSep(op?: string, isFirst = false): string { + if (isFirst) { + return !op || op === "+" ? "" : op; + } else if (!op || op === "+" || op === "#") { + return ","; + } else if (op === "?") { + return "&"; + } else { + return op; + } +} + +function getExpandedValue(option: ValueOptions): string { + let isFirst = option.isFirst; + const { op, varName, varValue: value, reserved } = option; + const vals: string[] = []; + const [named, ifEmpty] = getNamedAndIfEmpty(op); + + if (Array.isArray(value)) { + for (const val of value.filter(isDefined)) { + // prepare the following parts: separator, varName, value + vals.push(`${getFirstOrSep(op, isFirst)}`); + if (named && varName) { + vals.push(`${encodeURIComponent(varName)}`); + if (val === "") { + vals.push(ifEmpty); + } else { + vals.push("="); + } + } + vals.push(encodeComponent(val, reserved, op)); + isFirst = false; + } + } else if (typeof value === "object") { + for (const key of Object.keys(value)) { + const val = value[key]; + if (!isDefined(val)) { + continue; + } + // prepare the following parts: separator, key, value + vals.push(`${getFirstOrSep(op, isFirst)}`); + if (key) { + vals.push(`${encodeURIComponent(key)}`); + if (named && val === "") { + vals.push(ifEmpty); + } else { + vals.push("="); + } + } + vals.push(encodeComponent(val, reserved, op)); + isFirst = false; + } + } + return vals.join(""); +} + +function getNonExpandedValue(option: ValueOptions): string | undefined { + const { op, varName, varValue: value, isFirst, reserved } = option; + const vals: string[] = []; + const first = getFirstOrSep(op, isFirst); + const [named, ifEmpty] = getNamedAndIfEmpty(op); + if (named && varName) { + vals.push(encodeComponent(varName, reserved, op)); + if (value === "") { + if (!ifEmpty) { + vals.push(ifEmpty); + } + return !vals.join("") ? undefined : `${first}${vals.join("")}`; + } + vals.push("="); + } + + const items = []; + if (Array.isArray(value)) { + for (const val of value.filter(isDefined)) { + items.push(encodeComponent(val, reserved, op)); + } + } else if (typeof value === "object") { + for (const key of Object.keys(value)) { + if (!isDefined(value[key])) { + continue; + } + items.push(encodeRFC3986URIComponent(key)); + items.push(encodeComponent(value[key], reserved, op)); + } + } + vals.push(items.join(",")); + return !vals.join(",") ? undefined : `${first}${vals.join("")}`; +} + +function getVarValue(option: ValueOptions): string | undefined { + const { op, varName, modifier, isFirst, reserved, varValue: value } = option; + + if (!isDefined(value)) { + return undefined; + } else if (["string", "number", "boolean"].includes(typeof value)) { + let val = value.toString(); + const [named, ifEmpty] = getNamedAndIfEmpty(op); + const vals: string[] = [getFirstOrSep(op, isFirst)]; + if (named && varName) { + // No need to encode varName considering it is already encoded + vals.push(varName); + if (val === "") { + vals.push(ifEmpty); + } else { + vals.push("="); + } + } + if (modifier && modifier !== "*") { + val = val.substring(0, parseInt(modifier, 10)); + } + vals.push(encodeComponent(val, reserved, op)); + return vals.join(""); + } else if (modifier === "*") { + return getExpandedValue(option); + } else { + return getNonExpandedValue(option); + } +} + +// --------------------------------------------------------------------------------------------------- +// This is an implementation of RFC 6570 URI Template: https://datatracker.ietf.org/doc/html/rfc6570. +// --------------------------------------------------------------------------------------------------- +export function expandUrlTemplate( + template: string, + context: Record, + option?: UrlTemplateOptions, +): string { + const result = template.replace(/\{([^{}]+)\}|([^{}]+)/g, (_, expr, text) => { + if (!expr) { + return encodeReservedComponent(text); + } + let op; + if (["+", "#", ".", "/", ";", "?", "&"].includes(expr[0])) { + op = expr[0]; + expr = expr.slice(1); + } + const varList = expr.split(/,/g); + const result = []; + for (const varSpec of varList) { + const varMatch = /([^:*]*)(?::(\d+)|(\*))?/.exec(varSpec); + if (!varMatch || !varMatch[1]) { + continue; + } + const varValue = getVarValue({ + isFirst: result.length === 0, + op, + varValue: context[varMatch[1]], + varName: varMatch[1], + modifier: varMatch[2] || varMatch[3], + reserved: option?.allowReserved, + }); + if (varValue) { + result.push(varValue); + } + } + return result.join(""); + }); + + return normalizeUnreserved(result); +} + +/** + * Normalize an expanded URI by decoding percent-encoded unreserved characters. + * RFC 3986 unreserved: "-" / "." / "~" + */ +function normalizeUnreserved(uri: string): string { + return uri.replace(/%([0-9A-Fa-f]{2})/g, (match, hex) => { + const char = String.fromCharCode(parseInt(hex, 16)); + // Decode only if it's unreserved + if (/[\-.~]/.test(char)) { + return char; + } + return match; // leave other encodings intact + }); +} diff --git a/sdk/policy/arm-policy/test/snippets.spec.ts b/sdk/policy/arm-policy/test/snippets.spec.ts index 1d6650a015b4..1c7c61fa38f4 100644 --- a/sdk/policy/arm-policy/test/snippets.spec.ts +++ b/sdk/policy/arm-policy/test/snippets.spec.ts @@ -1,10 +1,5 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { PolicyClient } from "../src/index.js"; import { DefaultAzureCredential, InteractiveBrowserCredential } from "@azure/identity"; @@ -18,11 +13,11 @@ describe("snippets", () => { }); it("ReadmeSampleCreateClient_Browser", async () => { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; const credential = new InteractiveBrowserCredential({ tenantId: "", clientId: "", }); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; const client = new PolicyClient(credential, subscriptionId); }); diff --git a/sdk/policy/arm-policy/tsconfig.json b/sdk/policy/arm-policy/tsconfig.json index d466f1460665..0e57dbd186e5 100644 --- a/sdk/policy/arm-policy/tsconfig.json +++ b/sdk/policy/arm-policy/tsconfig.json @@ -12,6 +12,5 @@ { "path": "./tsconfig.snippets.json" } - ], - "files": [] + ] } diff --git a/sdk/policy/arm-policy/tsp-location.yaml b/sdk/policy/arm-policy/tsp-location.yaml new file mode 100644 index 000000000000..969f1aa78f15 --- /dev/null +++ b/sdk/policy/arm-policy/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/resources/resource-manager/Microsoft.Authorization/policy +commit: 93edc09ba3d879875fe0fcca6db36a61ff27b2d6 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/policy/arm-policy/vitest.esm.config.ts b/sdk/policy/arm-policy/vitest.esm.config.ts new file mode 100644 index 000000000000..5e9735e9b144 --- /dev/null +++ b/sdk/policy/arm-policy/vitest.esm.config.ts @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { mergeConfig } from "vitest/config"; +import vitestConfig from "./vitest.config.ts"; +import vitestEsmConfig from "../../../vitest.esm.shared.config.ts"; + +export default mergeConfig(vitestConfig, vitestEsmConfig); diff --git a/sdk/policy/ci.mgmt.yml b/sdk/policy/ci.mgmt.yml index f625b32e10bc..c97f591ce5b3 100644 --- a/sdk/policy/ci.mgmt.yml +++ b/sdk/policy/ci.mgmt.yml @@ -1,11 +1,13 @@ # NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. - + trigger: branches: include: - main - release/* - hotfix/* + exclude: + - feature/v4 paths: include: - sdk/policy/ci.mgmt.yml