From 211c046e37912e2d3d2bbc12433354847d113900 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 10 Apr 2023 20:51:51 +0000 Subject: [PATCH] CodeGen from PR 22789 in Azure/azure-rest-api-specs Merge 1bb6878b3227f270495cc4f0ecc15442b3d5eafc into 1f22d4dbd99b0fe347ad79e79d4eb1ed44a87291 --- common/config/rush/pnpm-lock.yaml | 14 ++-- .../arm-policyinsights/CHANGELOG.md | 68 ++++++++-------- .../arm-policyinsights/_meta.json | 8 +- .../arm-policyinsights/package.json | 20 ++--- .../review/arm-policyinsights.api.md | 33 ++++++-- .../arm-policyinsights/src/lroImpl.ts | 54 +++++++------ .../arm-policyinsights/src/models/index.ts | 54 +++++++++++-- .../arm-policyinsights/src/models/mappers.ts | 81 ++++++++++++++++++- .../src/models/parameters.ts | 2 +- .../src/operations/attestations.ts | 77 ++++++++++-------- .../src/operations/policyStates.ts | 48 ++++++----- .../src/operationsInterfaces/attestations.ts | 14 ++-- .../src/operationsInterfaces/policyStates.ts | 6 +- .../arm-policyinsights/test/sampleTest.ts | 43 ++++++++++ .../arm-policyinsights/tsconfig.json | 10 +-- 15 files changed, 361 insertions(+), 171 deletions(-) create mode 100644 sdk/policyinsights/arm-policyinsights/test/sampleTest.ts diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index ce833a105246..3f428f979705 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -3999,7 +3999,7 @@ packages: dependencies: semver: 7.3.8 shelljs: 0.8.5 - typescript: 5.1.0-dev.20230409 + typescript: 5.1.0-dev.20230410 dev: false /ecdsa-sig-formatter/1.0.11: @@ -8862,8 +8862,8 @@ packages: hasBin: true dev: false - /typescript/5.1.0-dev.20230409: - resolution: {integrity: sha512-97xdCsU+nUtaHW7mFi7x6KfRz4ragV0WGI/Z5uoW0pelxP1l6NYM/0VJ3Gs2X8fer09TDflGF/oL8k4YR9eroQ==} + /typescript/5.1.0-dev.20230410: + resolution: {integrity: sha512-7aQS6nNYt3XVJic6FBmnxasor6MZFwi5Odj0Z0UtHode4ID21KgCjFgJcdtiWrmSIZ/PLfrp6QiE179hwbB5tQ==} engines: {node: '>=12.20'} hasBin: true dev: false @@ -13869,7 +13869,7 @@ packages: dev: false file:projects/arm-policyinsights.tgz: - resolution: {integrity: sha512-s7T9ucPnp1TppXoMI0ATpBBp9VEEztwmOGFVxYuakYcvGBuMSxoVKt7zIJI1l2c1QW4UPnpAlh77Z3EurRR6Tg==, tarball: file:projects/arm-policyinsights.tgz} + resolution: {integrity: sha512-32cIN5jkyB06A+9WTwrKrxH90WTLR5piO+y7Np2TSPQXq4bVBOtXsgylmxtD2mlwMPqTLXiJMT0xmEVaMn+kUg==, tarball: file:projects/arm-policyinsights.tgz} name: '@rush-temp/arm-policyinsights' version: 0.0.0 dependencies: @@ -13883,8 +13883,8 @@ packages: '@types/node': 14.18.42 chai: 4.3.7 cross-env: 7.0.3 - dotenv: 8.6.0 - mkdirp: 1.0.4 + dotenv: 16.0.3 + mkdirp: 2.1.6 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.79.1 @@ -16306,7 +16306,7 @@ packages: dev: false file:projects/container-registry.tgz: - resolution: {integrity: sha512-A5YXB1oeGqoFPG68lXJtKpxack6DD11c+7Ysgu/w7R2r1BPMAhCYjNXM9uHxj1jQRm77UWE5Ngy5uLIgFJeyEg==, tarball: file:projects/container-registry.tgz} + resolution: {integrity: sha512-pWipLCUwNNpKjqh/MmLBG9lS3mgIXHq09E0+XAfodzcWd4Y1qcNqryKbK+qFLSs9objuHa9HO6t0k8x3CI7okA==, tarball: file:projects/container-registry.tgz} name: '@rush-temp/container-registry' version: 0.0.0 dependencies: diff --git a/sdk/policyinsights/arm-policyinsights/CHANGELOG.md b/sdk/policyinsights/arm-policyinsights/CHANGELOG.md index 4ed4d4a3f3d8..ab6ada17c7c6 100644 --- a/sdk/policyinsights/arm-policyinsights/CHANGELOG.md +++ b/sdk/policyinsights/arm-policyinsights/CHANGELOG.md @@ -1,16 +1,6 @@ # Release History - -## 6.0.0-beta.4 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - -## 6.0.0-beta.3 (2023-01-30) + +## 6.0.0-beta.4 (2023-04-10) **Features** @@ -18,6 +8,7 @@ - Added operation PolicyRestrictions.checkAtManagementGroupScope - Added Interface Attestation - Added Interface CheckManagementGroupRestrictionsRequest + - Added Interface CheckRestrictionEvaluationDetails - Added Interface ComponentExpressionEvaluationDetails - Added Interface ComponentPolicyEvaluationDetails - Added Interface ComponentPolicyState @@ -28,6 +19,7 @@ - Added Interface ComponentPolicyStatesListQueryResultsForSubscriptionLevelPolicyAssignmentOptionalParams - Added Interface ComponentPolicyStatesListQueryResultsForSubscriptionOptionalParams - Added Interface ComponentPolicyStatesQueryResults + - Added Interface PolicyEffectDetails - Added Interface PolicyMetadataProperties - Added Interface PolicyRestrictionsCheckAtManagementGroupScopeOptionalParams - Added Type Alias ComponentPolicyStatesListQueryResultsForPolicyDefinitionResponse @@ -41,12 +33,40 @@ - Added Type Alias PolicyRestrictionsCheckAtManagementGroupScopeResponse - Added Type Alias PolicyStatesSummaryResourceType - Added Type Alias PolicyTrackedResourcesResourceType + - Interface CheckRestrictionsRequest has a new optional parameter includeAuditEffect + - Interface FieldRestriction has a new optional parameter policyEffect + - Interface FieldRestriction has a new optional parameter reason - Interface Operation has a new optional parameter isDataAction + - Interface PolicyEvaluationResult has a new optional parameter effectDetails - Added Enum KnownComponentPolicyStatesResource - Added Enum KnownPolicyEventsResourceType - Added Enum KnownPolicyStatesSummaryResourceType - Added Enum KnownPolicyTrackedResourcesResourceType + - Enum KnownFieldRestrictionResult has a new value Audit - Added function getContinuationToken + +**Breaking Changes** + + - Operation PolicyEvents.listQueryResultsForManagementGroup has a new signature + - Operation PolicyEvents.listQueryResultsForPolicyDefinition has a new signature + - Operation PolicyEvents.listQueryResultsForPolicySetDefinition has a new signature + - Operation PolicyEvents.listQueryResultsForResource has a new signature + - Operation PolicyEvents.listQueryResultsForResourceGroup has a new signature + - Operation PolicyEvents.listQueryResultsForResourceGroupLevelPolicyAssignment has a new signature + - Operation PolicyEvents.listQueryResultsForSubscription has a new signature + - Operation PolicyEvents.listQueryResultsForSubscriptionLevelPolicyAssignment has a new signature + - Operation PolicyStates.summarizeForManagementGroup has a new signature + - Operation PolicyStates.summarizeForPolicyDefinition has a new signature + - Operation PolicyStates.summarizeForPolicySetDefinition has a new signature + - Operation PolicyStates.summarizeForResource has a new signature + - Operation PolicyStates.summarizeForResourceGroup has a new signature + - Operation PolicyStates.summarizeForResourceGroupLevelPolicyAssignment has a new signature + - Operation PolicyStates.summarizeForSubscription has a new signature + - Operation PolicyStates.summarizeForSubscriptionLevelPolicyAssignment has a new signature + - Operation PolicyTrackedResources.listQueryResultsForManagementGroup has a new signature + - Operation PolicyTrackedResources.listQueryResultsForResource has a new signature + - Operation PolicyTrackedResources.listQueryResultsForResourceGroup has a new signature + - Operation PolicyTrackedResources.listQueryResultsForSubscription has a new signature - Interface AttestationsListForResourceGroupNextOptionalParams no longer has parameter queryOptions - Interface AttestationsListForResourceNextOptionalParams no longer has parameter queryOptions - Interface AttestationsListForSubscriptionNextOptionalParams no longer has parameter queryOptions @@ -79,29 +99,7 @@ - Interface RemediationsListForResourceGroupNextOptionalParams no longer has parameter queryOptions - Interface RemediationsListForResourceNextOptionalParams no longer has parameter queryOptions - Interface RemediationsListForSubscriptionNextOptionalParams no longer has parameter queryOptions - -**Breaking Changes** - - - Operation PolicyEvents.listQueryResultsForManagementGroup has a new signature - - Operation PolicyEvents.listQueryResultsForPolicyDefinition has a new signature - - Operation PolicyEvents.listQueryResultsForPolicySetDefinition has a new signature - - Operation PolicyEvents.listQueryResultsForResource has a new signature - - Operation PolicyEvents.listQueryResultsForResourceGroup has a new signature - - Operation PolicyEvents.listQueryResultsForResourceGroupLevelPolicyAssignment has a new signature - - Operation PolicyEvents.listQueryResultsForSubscription has a new signature - - Operation PolicyEvents.listQueryResultsForSubscriptionLevelPolicyAssignment has a new signature - - Operation PolicyStates.summarizeForManagementGroup has a new signature - - Operation PolicyStates.summarizeForPolicyDefinition has a new signature - - Operation PolicyStates.summarizeForPolicySetDefinition has a new signature - - Operation PolicyStates.summarizeForResource has a new signature - - Operation PolicyStates.summarizeForResourceGroup has a new signature - - Operation PolicyStates.summarizeForResourceGroupLevelPolicyAssignment has a new signature - - Operation PolicyStates.summarizeForSubscription has a new signature - - Operation PolicyStates.summarizeForSubscriptionLevelPolicyAssignment has a new signature - - Operation PolicyTrackedResources.listQueryResultsForManagementGroup has a new signature - - Operation PolicyTrackedResources.listQueryResultsForResource has a new signature - - Operation PolicyTrackedResources.listQueryResultsForResourceGroup has a new signature - - Operation PolicyTrackedResources.listQueryResultsForSubscription has a new signature + - Type of parameter evaluationDetails of interface PolicyEvaluationResult is changed from PolicyEvaluationDetails to CheckRestrictionEvaluationDetails ## 5.0.0 (2022-01-24) diff --git a/sdk/policyinsights/arm-policyinsights/_meta.json b/sdk/policyinsights/arm-policyinsights/_meta.json index f5fffa925508..98bf2b1749f6 100644 --- a/sdk/policyinsights/arm-policyinsights/_meta.json +++ b/sdk/policyinsights/arm-policyinsights/_meta.json @@ -1,8 +1,8 @@ { - "commit": "78ec1b99699a4bf44869bd13f1b0ed7d92a99c27", + "commit": "025ca2395b5eb78212fd89d6470ddf6c96415d1d", "readme": "specification/policyinsights/resource-manager/readme.md", - "autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=F:\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\policyinsights\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.7 --generate-sample=true", + "autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-js ../azure-rest-api-specs/specification/policyinsights/resource-manager/readme.md --use=@autorest/typescript@6.0.0-rc.10", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "release_tool": "@azure-tools/js-sdk-release-tools@2.6.0", - "use": "@autorest/typescript@6.0.0-rc.7" + "release_tool": "@azure-tools/js-sdk-release-tools@2.7.0", + "use": "@autorest/typescript@6.0.0-rc.10" } \ No newline at end of file diff --git a/sdk/policyinsights/arm-policyinsights/package.json b/sdk/policyinsights/arm-policyinsights/package.json index 596259c9b221..5d54461523a8 100644 --- a/sdk/policyinsights/arm-policyinsights/package.json +++ b/sdk/policyinsights/arm-policyinsights/package.json @@ -8,10 +8,10 @@ "node": ">=14.0.0" }, "dependencies": { - "@azure/core-lro": "^2.2.0", + "@azure/core-lro": "^2.5.0", "@azure/abort-controller": "^1.0.0", "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.6.1", + "@azure/core-client": "^1.7.0", "@azure/core-auth": "^1.3.0", "@azure/core-rest-pipeline": "^1.8.0", "tslib": "^2.2.0" @@ -33,13 +33,13 @@ "@rollup/plugin-json": "^6.0.0", "@rollup/plugin-multi-entry": "^6.0.0", "@rollup/plugin-node-resolve": "^13.1.3", - "mkdirp": "^1.0.4", + "mkdirp": "^2.1.2", "rollup": "^2.66.1", "rollup-plugin-sourcemaps": "^0.6.3", "typescript": "~4.8.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", - "dotenv": "^8.2.0", + "dotenv": "^16.0.0", "@azure/identity": "^2.0.1", "@azure-tools/test-recorder": "^3.0.0", "@azure-tools/test-credential": "^1.0.0", @@ -111,13 +111,5 @@ ] }, "autoPublish": true, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/policyinsights/arm-policyinsights", - "//sampleConfiguration": { - "productName": "", - "productSlugs": [ - "azure" - ], - "disableDocsMs": true, - "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-policyinsights?view=azure-node-preview" - } -} + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/policyinsights/arm-policyinsights" +} \ No newline at end of file diff --git a/sdk/policyinsights/arm-policyinsights/review/arm-policyinsights.api.md b/sdk/policyinsights/arm-policyinsights/review/arm-policyinsights.api.md index 93c77f70091d..05e0ee9478b9 100644 --- a/sdk/policyinsights/arm-policyinsights/review/arm-policyinsights.api.md +++ b/sdk/policyinsights/arm-policyinsights/review/arm-policyinsights.api.md @@ -6,9 +6,9 @@ import * as coreAuth from '@azure/core-auth'; import * as coreClient from '@azure/core-client'; +import { OperationState } from '@azure/core-lro'; import { PagedAsyncIterableIterator } from '@azure/core-paging'; -import { PollerLike } from '@azure/core-lro'; -import { PollOperationState } from '@azure/core-lro'; +import { SimplePollerLike } from '@azure/core-lro'; // @public export interface Attestation extends Resource { @@ -40,11 +40,11 @@ export interface AttestationListResult { // @public export interface Attestations { - beginCreateOrUpdateAtResource(resourceId: string, attestationName: string, parameters: Attestation, options?: AttestationsCreateOrUpdateAtResourceOptionalParams): Promise, AttestationsCreateOrUpdateAtResourceResponse>>; + beginCreateOrUpdateAtResource(resourceId: string, attestationName: string, parameters: Attestation, options?: AttestationsCreateOrUpdateAtResourceOptionalParams): Promise, AttestationsCreateOrUpdateAtResourceResponse>>; beginCreateOrUpdateAtResourceAndWait(resourceId: string, attestationName: string, parameters: Attestation, options?: AttestationsCreateOrUpdateAtResourceOptionalParams): Promise; - beginCreateOrUpdateAtResourceGroup(resourceGroupName: string, attestationName: string, parameters: Attestation, options?: AttestationsCreateOrUpdateAtResourceGroupOptionalParams): Promise, AttestationsCreateOrUpdateAtResourceGroupResponse>>; + beginCreateOrUpdateAtResourceGroup(resourceGroupName: string, attestationName: string, parameters: Attestation, options?: AttestationsCreateOrUpdateAtResourceGroupOptionalParams): Promise, AttestationsCreateOrUpdateAtResourceGroupResponse>>; beginCreateOrUpdateAtResourceGroupAndWait(resourceGroupName: string, attestationName: string, parameters: Attestation, options?: AttestationsCreateOrUpdateAtResourceGroupOptionalParams): Promise; - beginCreateOrUpdateAtSubscription(attestationName: string, parameters: Attestation, options?: AttestationsCreateOrUpdateAtSubscriptionOptionalParams): Promise, AttestationsCreateOrUpdateAtSubscriptionResponse>>; + beginCreateOrUpdateAtSubscription(attestationName: string, parameters: Attestation, options?: AttestationsCreateOrUpdateAtSubscriptionOptionalParams): Promise, AttestationsCreateOrUpdateAtSubscriptionResponse>>; beginCreateOrUpdateAtSubscriptionAndWait(attestationName: string, parameters: Attestation, options?: AttestationsCreateOrUpdateAtSubscriptionOptionalParams): Promise; deleteAtResource(resourceId: string, attestationName: string, options?: AttestationsDeleteAtResourceOptionalParams): Promise; deleteAtResourceGroup(resourceGroupName: string, attestationName: string, options?: AttestationsDeleteAtResourceGroupOptionalParams): Promise; @@ -168,8 +168,16 @@ export interface CheckManagementGroupRestrictionsRequest { resourceDetails?: CheckRestrictionsResourceDetails; } +// @public +export interface CheckRestrictionEvaluationDetails { + evaluatedExpressions?: ExpressionEvaluationDetails[]; + ifNotExistsDetails?: IfNotExistsEvaluationDetails; + readonly reason?: string; +} + // @public export interface CheckRestrictionsRequest { + includeAuditEffect?: boolean; pendingFields?: PendingField[]; resourceDetails: CheckRestrictionsResourceDetails; } @@ -442,6 +450,8 @@ export interface ExpressionEvaluationDetails { export interface FieldRestriction { readonly defaultValue?: string; readonly policy?: PolicyReference; + readonly policyEffect?: string; + readonly reason?: string; readonly result?: FieldRestrictionResult; readonly values?: string[]; } @@ -486,6 +496,7 @@ export enum KnownCreatedByType { // @public export enum KnownFieldRestrictionResult { + Audit = "Audit", Deny = "Deny", Removed = "Removed", Required = "Required" @@ -585,6 +596,11 @@ export interface PolicyDetails { readonly policySetDefinitionId?: string; } +// @public +export interface PolicyEffectDetails { + readonly policyEffect?: string; +} + // @public export interface PolicyEvaluationDetails { evaluatedExpressions?: ExpressionEvaluationDetails[]; @@ -593,7 +609,8 @@ export interface PolicyEvaluationDetails { // @public export interface PolicyEvaluationResult { - readonly evaluationDetails?: PolicyEvaluationDetails; + readonly effectDetails?: PolicyEffectDetails; + readonly evaluationDetails?: CheckRestrictionEvaluationDetails; readonly evaluationResult?: string; readonly policyInfo?: PolicyReference; } @@ -958,9 +975,9 @@ export interface PolicyState { // @public export interface PolicyStates { - beginTriggerResourceGroupEvaluation(subscriptionId: string, resourceGroupName: string, options?: PolicyStatesTriggerResourceGroupEvaluationOptionalParams): Promise, void>>; + beginTriggerResourceGroupEvaluation(subscriptionId: string, resourceGroupName: string, options?: PolicyStatesTriggerResourceGroupEvaluationOptionalParams): Promise, void>>; beginTriggerResourceGroupEvaluationAndWait(subscriptionId: string, resourceGroupName: string, options?: PolicyStatesTriggerResourceGroupEvaluationOptionalParams): Promise; - beginTriggerSubscriptionEvaluation(subscriptionId: string, options?: PolicyStatesTriggerSubscriptionEvaluationOptionalParams): Promise, void>>; + beginTriggerSubscriptionEvaluation(subscriptionId: string, options?: PolicyStatesTriggerSubscriptionEvaluationOptionalParams): Promise, void>>; beginTriggerSubscriptionEvaluationAndWait(subscriptionId: string, options?: PolicyStatesTriggerSubscriptionEvaluationOptionalParams): Promise; listQueryResultsForManagementGroup(policyStatesResource: PolicyStatesResource, managementGroupName: string, options?: PolicyStatesListQueryResultsForManagementGroupOptionalParams): PagedAsyncIterableIterator; listQueryResultsForPolicyDefinition(policyStatesResource: PolicyStatesResource, subscriptionId: string, policyDefinitionName: string, options?: PolicyStatesListQueryResultsForPolicyDefinitionOptionalParams): PagedAsyncIterableIterator; diff --git a/sdk/policyinsights/arm-policyinsights/src/lroImpl.ts b/sdk/policyinsights/arm-policyinsights/src/lroImpl.ts index 518d5f053b4e..dd803cd5e28c 100644 --- a/sdk/policyinsights/arm-policyinsights/src/lroImpl.ts +++ b/sdk/policyinsights/arm-policyinsights/src/lroImpl.ts @@ -6,29 +6,37 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { AbortSignalLike } from "@azure/abort-controller"; import { LongRunningOperation, LroResponse } from "@azure/core-lro"; -export class LroImpl implements LongRunningOperation { - constructor( - private sendOperationFn: (args: any, spec: any) => Promise>, - private args: Record, - private spec: { - readonly requestBody?: unknown; - readonly path?: string; - readonly httpMethod: string; - } & Record, - public requestPath: string = spec.path!, - public requestMethod: string = spec.httpMethod - ) {} - public async sendInitialRequest(): Promise> { - return this.sendOperationFn(this.args, this.spec); - } - public async sendPollRequest(path: string): Promise> { - const { requestBody, ...restSpec } = this.spec; - return this.sendOperationFn(this.args, { - ...restSpec, - path, - httpMethod: "GET" - }); - } +export function createLroSpec(inputs: { + sendOperationFn: (args: any, spec: any) => Promise>; + args: Record; + spec: { + readonly requestBody?: unknown; + readonly path?: string; + readonly httpMethod: string; + } & Record; +}): LongRunningOperation { + const { args, spec, sendOperationFn } = inputs; + return { + requestMethod: spec.httpMethod, + requestPath: spec.path!, + sendInitialRequest: () => sendOperationFn(args, spec), + sendPollRequest: ( + path: string, + options?: { abortSignal?: AbortSignalLike } + ) => { + const { requestBody, ...restSpec } = spec; + return sendOperationFn(args, { + ...restSpec, + httpMethod: "GET", + path, + abortSignal: options?.abortSignal + }); + } + }; } diff --git a/sdk/policyinsights/arm-policyinsights/src/models/index.ts b/sdk/policyinsights/arm-policyinsights/src/models/index.ts index 15795227f608..c85b68094cc1 100644 --- a/sdk/policyinsights/arm-policyinsights/src/models/index.ts +++ b/sdk/policyinsights/arm-policyinsights/src/models/index.ts @@ -255,7 +255,7 @@ export interface Remediation { /** The way resources to remediate are discovered. Defaults to ExistingNonCompliant if not specified. */ resourceDiscoveryMode?: ResourceDiscoveryMode; /** - * The status of the remediation. + * The status of the remediation. This refers to the entire remediation task, not individual deployments. Allowed values are Evaluating, Canceled, Cancelling, Failed, Complete, or Succeeded. * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly provisioningState?: string; @@ -882,6 +882,8 @@ export interface CheckRestrictionsRequest { resourceDetails: CheckRestrictionsResourceDetails; /** The list of fields and values that should be evaluated for potential restrictions. */ pendingFields?: PendingField[]; + /** Whether to include policies with the 'audit' effect in the results. Defaults to false. */ + includeAuditEffect?: boolean; } /** The information about the resource that will be evaluated. */ @@ -949,6 +951,16 @@ export interface FieldRestriction { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly policy?: PolicyReference; + /** + * The effect of the policy that is causing the field restriction. http://aka.ms/policyeffects + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly policyEffect?: string; + /** + * The reason for the restriction. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly reason?: string; } /** Resource identifiers for a policy. */ @@ -997,7 +1009,34 @@ export interface PolicyEvaluationResult { * The detailed results of the policy expressions and values that were evaluated. * NOTE: This property will not be serialized. It can only be populated by the server. */ - readonly evaluationDetails?: PolicyEvaluationDetails; + readonly evaluationDetails?: CheckRestrictionEvaluationDetails; + /** + * The details of the effect that was applied to the resource. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly effectDetails?: PolicyEffectDetails; +} + +/** Policy evaluation details. */ +export interface CheckRestrictionEvaluationDetails { + /** Details of the evaluated expressions. */ + evaluatedExpressions?: ExpressionEvaluationDetails[]; + /** Evaluation details of IfNotExists effect. */ + ifNotExistsDetails?: IfNotExistsEvaluationDetails; + /** + * The reason for the evaluation result. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly reason?: string; +} + +/** The details of the effect that was applied to the resource. */ +export interface PolicyEffectDetails { + /** + * The effect that was applied to the resource. http://aka.ms/policyeffects + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly policyEffect?: string; } /** The check policy restrictions parameters describing the resource that is being evaluated. */ @@ -1514,12 +1553,14 @@ export type PolicyStatesSummaryResourceType = string; /** Known values of {@link FieldRestrictionResult} that the service accepts. */ export enum KnownFieldRestrictionResult { - /** The field and/or values are required by policy. */ + /** The field and\/or values are required by policy. */ Required = "Required", /** The field will be removed by policy. */ Removed = "Removed", - /** The field and/or values will be denied by policy. */ - Deny = "Deny" + /** The field and\/or values will be denied by policy. */ + Deny = "Deny", + /** The field and\/or values will be audited by policy. */ + Audit = "Audit" } /** @@ -1529,7 +1570,8 @@ export enum KnownFieldRestrictionResult { * ### Known values supported by the service * **Required**: The field and\/or values are required by policy. \ * **Removed**: The field will be removed by policy. \ - * **Deny**: The field and\/or values will be denied by policy. + * **Deny**: The field and\/or values will be denied by policy. \ + * **Audit**: The field and\/or values will be audited by policy. */ export type FieldRestrictionResult = string; diff --git a/sdk/policyinsights/arm-policyinsights/src/models/mappers.ts b/sdk/policyinsights/arm-policyinsights/src/models/mappers.ts index e67767353f32..ee451cb7ceae 100644 --- a/sdk/policyinsights/arm-policyinsights/src/models/mappers.ts +++ b/sdk/policyinsights/arm-policyinsights/src/models/mappers.ts @@ -1977,6 +1977,13 @@ export const CheckRestrictionsRequest: coreClient.CompositeMapper = { } } } + }, + includeAuditEffect: { + defaultValue: false, + serializedName: "includeAuditEffect", + type: { + name: "Boolean" + } } } } @@ -2132,6 +2139,20 @@ export const FieldRestriction: coreClient.CompositeMapper = { name: "Composite", className: "PolicyReference" } + }, + policyEffect: { + serializedName: "policyEffect", + readOnly: true, + type: { + name: "String" + } + }, + reason: { + serializedName: "reason", + readOnly: true, + type: { + name: "String" + } } } } @@ -2218,7 +2239,65 @@ export const PolicyEvaluationResult: coreClient.CompositeMapper = { serializedName: "evaluationDetails", type: { name: "Composite", - className: "PolicyEvaluationDetails" + className: "CheckRestrictionEvaluationDetails" + } + }, + effectDetails: { + serializedName: "effectDetails", + type: { + name: "Composite", + className: "PolicyEffectDetails" + } + } + } + } +}; + +export const CheckRestrictionEvaluationDetails: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CheckRestrictionEvaluationDetails", + modelProperties: { + evaluatedExpressions: { + serializedName: "evaluatedExpressions", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ExpressionEvaluationDetails" + } + } + } + }, + ifNotExistsDetails: { + serializedName: "ifNotExistsDetails", + type: { + name: "Composite", + className: "IfNotExistsEvaluationDetails" + } + }, + reason: { + serializedName: "reason", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const PolicyEffectDetails: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "PolicyEffectDetails", + modelProperties: { + policyEffect: { + serializedName: "policyEffect", + readOnly: true, + type: { + name: "String" } } } diff --git a/sdk/policyinsights/arm-policyinsights/src/models/parameters.ts b/sdk/policyinsights/arm-policyinsights/src/models/parameters.ts index 5e44031a555a..831b70849ffa 100644 --- a/sdk/policyinsights/arm-policyinsights/src/models/parameters.ts +++ b/sdk/policyinsights/arm-policyinsights/src/models/parameters.ts @@ -399,7 +399,7 @@ export const parameters1: OperationParameter = { export const apiVersion3: OperationQueryParameter = { parameterPath: "apiVersion", mapper: { - defaultValue: "2022-03-01", + defaultValue: "2023-03-01", isConstant: true, serializedName: "api-version", type: { diff --git a/sdk/policyinsights/arm-policyinsights/src/operations/attestations.ts b/sdk/policyinsights/arm-policyinsights/src/operations/attestations.ts index c9d18df0ce72..1c2d75582686 100644 --- a/sdk/policyinsights/arm-policyinsights/src/operations/attestations.ts +++ b/sdk/policyinsights/arm-policyinsights/src/operations/attestations.ts @@ -13,8 +13,12 @@ import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { PolicyInsightsClient } from "../policyInsightsClient"; -import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; -import { LroImpl } from "../lroImpl"; +import { + SimplePollerLike, + OperationState, + createHttpPoller +} from "@azure/core-lro"; +import { createLroSpec } from "../lroImpl"; import { Attestation, AttestationsListForSubscriptionNextOptionalParams, @@ -271,8 +275,8 @@ export class AttestationsImpl implements Attestations { parameters: Attestation, options?: AttestationsCreateOrUpdateAtSubscriptionOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, AttestationsCreateOrUpdateAtSubscriptionResponse > > { @@ -282,7 +286,7 @@ export class AttestationsImpl implements Attestations { ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -315,13 +319,16 @@ export class AttestationsImpl implements Attestations { }; }; - const lro = new LroImpl( - sendOperation, - { attestationName, parameters, options }, - createOrUpdateAtSubscriptionOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + const lro = createLroSpec({ + sendOperationFn, + args: { attestationName, parameters, options }, + spec: createOrUpdateAtSubscriptionOperationSpec + }); + const poller = await createHttpPoller< + AttestationsCreateOrUpdateAtSubscriptionResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); @@ -405,8 +412,8 @@ export class AttestationsImpl implements Attestations { parameters: Attestation, options?: AttestationsCreateOrUpdateAtResourceGroupOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, AttestationsCreateOrUpdateAtResourceGroupResponse > > { @@ -416,7 +423,7 @@ export class AttestationsImpl implements Attestations { ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -449,13 +456,16 @@ export class AttestationsImpl implements Attestations { }; }; - const lro = new LroImpl( - sendOperation, - { resourceGroupName, attestationName, parameters, options }, - createOrUpdateAtResourceGroupOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + const lro = createLroSpec({ + sendOperationFn, + args: { resourceGroupName, attestationName, parameters, options }, + spec: createOrUpdateAtResourceGroupOperationSpec + }); + const poller = await createHttpPoller< + AttestationsCreateOrUpdateAtResourceGroupResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); @@ -546,8 +556,8 @@ export class AttestationsImpl implements Attestations { parameters: Attestation, options?: AttestationsCreateOrUpdateAtResourceOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, AttestationsCreateOrUpdateAtResourceResponse > > { @@ -557,7 +567,7 @@ export class AttestationsImpl implements Attestations { ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -590,13 +600,16 @@ export class AttestationsImpl implements Attestations { }; }; - const lro = new LroImpl( - sendOperation, - { resourceId, attestationName, parameters, options }, - createOrUpdateAtResourceOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + const lro = createLroSpec({ + sendOperationFn, + args: { resourceId, attestationName, parameters, options }, + spec: createOrUpdateAtResourceOperationSpec + }); + const poller = await createHttpPoller< + AttestationsCreateOrUpdateAtResourceResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); diff --git a/sdk/policyinsights/arm-policyinsights/src/operations/policyStates.ts b/sdk/policyinsights/arm-policyinsights/src/operations/policyStates.ts index b2e860fe2da7..451b47f8080b 100644 --- a/sdk/policyinsights/arm-policyinsights/src/operations/policyStates.ts +++ b/sdk/policyinsights/arm-policyinsights/src/operations/policyStates.ts @@ -13,8 +13,12 @@ import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { PolicyInsightsClient } from "../policyInsightsClient"; -import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; -import { LroImpl } from "../lroImpl"; +import { + SimplePollerLike, + OperationState, + createHttpPoller +} from "@azure/core-lro"; +import { createLroSpec } from "../lroImpl"; import { PolicyState, PolicyStatesResource, @@ -995,14 +999,14 @@ export class PolicyStatesImpl implements PolicyStates { async beginTriggerSubscriptionEvaluation( subscriptionId: string, options?: PolicyStatesTriggerSubscriptionEvaluationOptionalParams - ): Promise, void>> { + ): Promise, void>> { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -1035,15 +1039,15 @@ export class PolicyStatesImpl implements PolicyStates { }; }; - const lro = new LroImpl( - sendOperation, - { subscriptionId, options }, - triggerSubscriptionEvaluationOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + const lro = createLroSpec({ + sendOperationFn, + args: { subscriptionId, options }, + spec: triggerSubscriptionEvaluationOperationSpec + }); + const poller = await createHttpPoller>(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, - lroResourceLocationConfig: "location" + resourceLocationConfig: "location" }); await poller.poll(); return poller; @@ -1075,14 +1079,14 @@ export class PolicyStatesImpl implements PolicyStates { subscriptionId: string, resourceGroupName: string, options?: PolicyStatesTriggerResourceGroupEvaluationOptionalParams - ): Promise, void>> { + ): Promise, void>> { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -1115,15 +1119,15 @@ export class PolicyStatesImpl implements PolicyStates { }; }; - const lro = new LroImpl( - sendOperation, - { subscriptionId, resourceGroupName, options }, - triggerResourceGroupEvaluationOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + const lro = createLroSpec({ + sendOperationFn, + args: { subscriptionId, resourceGroupName, options }, + spec: triggerResourceGroupEvaluationOperationSpec + }); + const poller = await createHttpPoller>(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, - lroResourceLocationConfig: "location" + resourceLocationConfig: "location" }); await poller.poll(); return poller; diff --git a/sdk/policyinsights/arm-policyinsights/src/operationsInterfaces/attestations.ts b/sdk/policyinsights/arm-policyinsights/src/operationsInterfaces/attestations.ts index 4c24305dc940..c93606e36d30 100644 --- a/sdk/policyinsights/arm-policyinsights/src/operationsInterfaces/attestations.ts +++ b/sdk/policyinsights/arm-policyinsights/src/operationsInterfaces/attestations.ts @@ -7,7 +7,7 @@ */ import { PagedAsyncIterableIterator } from "@azure/core-paging"; -import { PollerLike, PollOperationState } from "@azure/core-lro"; +import { SimplePollerLike, OperationState } from "@azure/core-lro"; import { Attestation, AttestationsListForSubscriptionOptionalParams, @@ -69,8 +69,8 @@ export interface Attestations { parameters: Attestation, options?: AttestationsCreateOrUpdateAtSubscriptionOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, AttestationsCreateOrUpdateAtSubscriptionResponse > >; @@ -116,8 +116,8 @@ export interface Attestations { parameters: Attestation, options?: AttestationsCreateOrUpdateAtResourceGroupOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, AttestationsCreateOrUpdateAtResourceGroupResponse > >; @@ -169,8 +169,8 @@ export interface Attestations { parameters: Attestation, options?: AttestationsCreateOrUpdateAtResourceOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, AttestationsCreateOrUpdateAtResourceResponse > >; diff --git a/sdk/policyinsights/arm-policyinsights/src/operationsInterfaces/policyStates.ts b/sdk/policyinsights/arm-policyinsights/src/operationsInterfaces/policyStates.ts index ac0bd6a62595..e255c21ca012 100644 --- a/sdk/policyinsights/arm-policyinsights/src/operationsInterfaces/policyStates.ts +++ b/sdk/policyinsights/arm-policyinsights/src/operationsInterfaces/policyStates.ts @@ -7,7 +7,7 @@ */ import { PagedAsyncIterableIterator } from "@azure/core-paging"; -import { PollerLike, PollOperationState } from "@azure/core-lro"; +import { SimplePollerLike, OperationState } from "@azure/core-lro"; import { PolicyState, PolicyStatesResource, @@ -221,7 +221,7 @@ export interface PolicyStates { beginTriggerSubscriptionEvaluation( subscriptionId: string, options?: PolicyStatesTriggerSubscriptionEvaluationOptionalParams - ): Promise, void>>; + ): Promise, void>>; /** * Triggers a policy evaluation scan for all the resources under the subscription * @param subscriptionId Microsoft Azure subscription ID. @@ -241,7 +241,7 @@ export interface PolicyStates { subscriptionId: string, resourceGroupName: string, options?: PolicyStatesTriggerResourceGroupEvaluationOptionalParams - ): Promise, void>>; + ): Promise, void>>; /** * Triggers a policy evaluation scan for all the resources under the resource group. * @param subscriptionId Microsoft Azure subscription ID. diff --git a/sdk/policyinsights/arm-policyinsights/test/sampleTest.ts b/sdk/policyinsights/arm-policyinsights/test/sampleTest.ts new file mode 100644 index 000000000000..25aeb3ebcc36 --- /dev/null +++ b/sdk/policyinsights/arm-policyinsights/test/sampleTest.ts @@ -0,0 +1,43 @@ +/* + * 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 { + Recorder, + RecorderStartOptions, + env +} from "@azure-tools/test-recorder"; +import { assert } from "chai"; +import { Context } from "mocha"; + +const replaceableVariables: Record = { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id" +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables +}; + +describe("My test", () => { + let recorder: Recorder; + + beforeEach(async function(this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); + }); + + afterEach(async function() { + await recorder.stop(); + }); + + it("sample test", async function() { + console.log("Hi, I'm a test!"); + }); +}); diff --git a/sdk/policyinsights/arm-policyinsights/tsconfig.json b/sdk/policyinsights/arm-policyinsights/tsconfig.json index 41da3f3f38bc..3e6ae96443f3 100644 --- a/sdk/policyinsights/arm-policyinsights/tsconfig.json +++ b/sdk/policyinsights/arm-policyinsights/tsconfig.json @@ -15,17 +15,11 @@ ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true, - "paths": { - "@azure/arm-policyinsights": [ - "./src/index" - ] - } + "importHelpers": true }, "include": [ "./src/**/*.ts", - "./test/**/*.ts", - "samples-dev/**/*.ts" + "./test/**/*.ts" ], "exclude": [ "node_modules"