diff --git a/sdk/policyinsights/arm-policyinsights/LICENSE.txt b/sdk/policyinsights/arm-policyinsights/LICENSE.txt index b73b4a1293c3..ea8fb1516028 100644 --- a/sdk/policyinsights/arm-policyinsights/LICENSE.txt +++ b/sdk/policyinsights/arm-policyinsights/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2019 Microsoft +Copyright (c) 2020 Microsoft Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/sdk/policyinsights/arm-policyinsights/src/models/index.ts b/sdk/policyinsights/arm-policyinsights/src/models/index.ts index 9dfba0ad1c33..091f0a349986 100644 --- a/sdk/policyinsights/arm-policyinsights/src/models/index.ts +++ b/sdk/policyinsights/arm-policyinsights/src/models/index.ts @@ -646,6 +646,21 @@ export interface PolicyState { * Policy definition group names. */ policyDefinitionGroupNames?: string[]; + /** + * Evaluated policy definition version. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly policyDefinitionVersion?: string; + /** + * Evaluated policy set definition version. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly policySetDefinitionVersion?: string; + /** + * Evaluated policy assignment version. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly policyAssignmentVersion?: string; /** * Describes unknown properties. The value of an unknown property can be of "any" type. */ diff --git a/sdk/policyinsights/arm-policyinsights/src/models/mappers.ts b/sdk/policyinsights/arm-policyinsights/src/models/mappers.ts index 8dd3e033ae5f..909fcae126c3 100644 --- a/sdk/policyinsights/arm-policyinsights/src/models/mappers.ts +++ b/sdk/policyinsights/arm-policyinsights/src/models/mappers.ts @@ -999,6 +999,27 @@ export const PolicyState: msRest.CompositeMapper = { } } } + }, + policyDefinitionVersion: { + readOnly: true, + serializedName: "policyDefinitionVersion", + type: { + name: "String" + } + }, + policySetDefinitionVersion: { + readOnly: true, + serializedName: "policySetDefinitionVersion", + type: { + name: "String" + } + }, + policyAssignmentVersion: { + readOnly: true, + serializedName: "policyAssignmentVersion", + type: { + name: "String" + } } }, additionalProperties: { diff --git a/sdk/policyinsights/arm-policyinsights/src/operations/policyStates.ts b/sdk/policyinsights/arm-policyinsights/src/operations/policyStates.ts index aee3af18c6d1..6dc820943728 100644 --- a/sdk/policyinsights/arm-policyinsights/src/operations/policyStates.ts +++ b/sdk/policyinsights/arm-policyinsights/src/operations/policyStates.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import * as msRestAzure from "@azure/ms-rest-azure-js"; import * as Models from "../models"; import * as Mappers from "../models/policyStatesMappers"; import * as Parameters from "../models/parameters"; @@ -298,6 +299,29 @@ export class PolicyStates { callback) as Promise; } + /** + * Triggers a policy evaluation scan for all the resources under the subscription + * @param subscriptionId Microsoft Azure subscription ID. + * @param [options] The optional parameters + * @returns Promise + */ + triggerSubscriptionEvaluation(subscriptionId: string, options?: msRest.RequestOptionsBase): Promise { + return this.beginTriggerSubscriptionEvaluation(subscriptionId,options) + .then(lroPoller => lroPoller.pollUntilFinished()); + } + + /** + * Triggers a policy evaluation scan for all the resources under the resource group. + * @param subscriptionId Microsoft Azure subscription ID. + * @param resourceGroupName Resource group name. + * @param [options] The optional parameters + * @returns Promise + */ + triggerResourceGroupEvaluation(subscriptionId: string, resourceGroupName: string, options?: msRest.RequestOptionsBase): Promise { + return this.beginTriggerResourceGroupEvaluation(subscriptionId,resourceGroupName,options) + .then(lroPoller => lroPoller.pollUntilFinished()); + } + /** * Queries policy states for the subscription level policy set definition. * @param policyStatesResource The virtual resource under PolicyStates resource type. In a given @@ -603,6 +627,40 @@ export class PolicyStates { summarizeForResourceGroupLevelPolicyAssignmentOperationSpec, callback) as Promise; } + + /** + * Triggers a policy evaluation scan for all the resources under the subscription + * @param subscriptionId Microsoft Azure subscription ID. + * @param [options] The optional parameters + * @returns Promise + */ + beginTriggerSubscriptionEvaluation(subscriptionId: string, options?: msRest.RequestOptionsBase): Promise { + return this.client.sendLRORequest( + { + subscriptionId, + options + }, + beginTriggerSubscriptionEvaluationOperationSpec, + options); + } + + /** + * Triggers a policy evaluation scan for all the resources under the resource group. + * @param subscriptionId Microsoft Azure subscription ID. + * @param resourceGroupName Resource group name. + * @param [options] The optional parameters + * @returns Promise + */ + beginTriggerResourceGroupEvaluation(subscriptionId: string, resourceGroupName: string, options?: msRest.RequestOptionsBase): Promise { + return this.client.sendLRORequest( + { + subscriptionId, + resourceGroupName, + options + }, + beginTriggerResourceGroupEvaluationOperationSpec, + options); + } } // Operation Specifications @@ -1101,3 +1159,48 @@ const summarizeForResourceGroupLevelPolicyAssignmentOperationSpec: msRest.Operat }, serializer }; + +const beginTriggerSubscriptionEvaluationOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation", + urlParameters: [ + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion3 + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: {}, + 202: {}, + default: { + bodyMapper: Mappers.QueryFailure + } + }, + serializer +}; + +const beginTriggerResourceGroupEvaluationOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation", + urlParameters: [ + Parameters.subscriptionId, + Parameters.resourceGroupName + ], + queryParameters: [ + Parameters.apiVersion3 + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: {}, + 202: {}, + default: { + bodyMapper: Mappers.QueryFailure + } + }, + serializer +}; diff --git a/sdk/policyinsights/arm-policyinsights/src/policyInsightsClientContext.ts b/sdk/policyinsights/arm-policyinsights/src/policyInsightsClientContext.ts index d5d57f5536e4..75ab8f0ef0ba 100644 --- a/sdk/policyinsights/arm-policyinsights/src/policyInsightsClientContext.ts +++ b/sdk/policyinsights/arm-policyinsights/src/policyInsightsClientContext.ts @@ -31,7 +31,7 @@ export class PolicyInsightsClientContext extends msRestAzure.AzureServiceClient if (!options) { options = {}; } - if (!options.userAgent) { + if(!options.userAgent) { const defaultUserAgent = msRestAzure.getDefaultUserAgentValue(); options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; } @@ -44,10 +44,10 @@ export class PolicyInsightsClientContext extends msRestAzure.AzureServiceClient this.requestContentType = "application/json; charset=utf-8"; this.credentials = credentials; - if (options.acceptLanguage !== null && options.acceptLanguage !== undefined) { + if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { this.acceptLanguage = options.acceptLanguage; } - if (options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { + if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout; } }