From 64e859fc9a84f574f409464e8286b7f2f8eaf571 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot Date: Thu, 17 Oct 2019 11:12:20 +0800 Subject: [PATCH] [AutoPR policyinsights/resource-manager] Adding a baseline folder for PolicyInsights 2019-10-01. Contents are same as prior version, I will make changes once this PR is complete. (#6041) * Generated from 551a94e578553160c7a3ef54b75a2cdff76acc5a fix go build error * Generated from 964ec2957f79ce66ce1f0010e15d774904c753c7 Added spec json files for other resources to be added to the package. Also updated policyStates.json as per latest API changes. * Generated from 33073abb10a1576efd929ed0344af26b4db6037a Added new columns in the examples. Also, Removed metadata path. --- .../mgmt/policyinsights/models.go | 63 +- .../policyinsightsapi/models.go | 4 +- .../mgmt/policyinsights/models.go | 63 +- .../policyinsightsapi/models.go | 4 +- .../mgmt/2019-10-01/policyinsights/client.go | 49 + .../mgmt/2019-10-01/policyinsights/models.go | 1777 +++++++++++++ .../2019-10-01/policyinsights/operations.go | 109 + .../2019-10-01/policyinsights/policyevents.go | 1049 ++++++++ .../policyinsightsapi/interfaces.go | 108 + .../2019-10-01/policyinsights/policystates.go | 1813 +++++++++++++ .../policyinsights/policytrackedresources.go | 557 ++++ .../2019-10-01/policyinsights/remediations.go | 2308 +++++++++++++++++ .../mgmt/2019-10-01/policyinsights/version.go | 30 + 13 files changed, 7930 insertions(+), 4 deletions(-) create mode 100644 services/policyinsights/mgmt/2019-10-01/policyinsights/client.go create mode 100644 services/policyinsights/mgmt/2019-10-01/policyinsights/models.go create mode 100644 services/policyinsights/mgmt/2019-10-01/policyinsights/operations.go create mode 100644 services/policyinsights/mgmt/2019-10-01/policyinsights/policyevents.go create mode 100644 services/policyinsights/mgmt/2019-10-01/policyinsights/policyinsightsapi/interfaces.go create mode 100644 services/policyinsights/mgmt/2019-10-01/policyinsights/policystates.go create mode 100644 services/policyinsights/mgmt/2019-10-01/policyinsights/policytrackedresources.go create mode 100644 services/policyinsights/mgmt/2019-10-01/policyinsights/remediations.go create mode 100644 services/policyinsights/mgmt/2019-10-01/policyinsights/version.go diff --git a/profiles/latest/policyinsights/mgmt/policyinsights/models.go b/profiles/latest/policyinsights/mgmt/policyinsights/models.go index 86baa6dc324f..792fa9b13ca8 100644 --- a/profiles/latest/policyinsights/mgmt/policyinsights/models.go +++ b/profiles/latest/policyinsights/mgmt/policyinsights/models.go @@ -19,7 +19,11 @@ package policyinsights -import original "github.com/Azure/azure-sdk-for-go/services/policyinsights/mgmt/2018-04-04/policyinsights" +import ( + "context" + + original "github.com/Azure/azure-sdk-for-go/services/policyinsights/mgmt/2019-10-01/policyinsights" +) const ( DefaultBaseURI = original.DefaultBaseURI @@ -33,24 +37,51 @@ const ( ) type BaseClient = original.BaseClient +type ComplianceDetail = original.ComplianceDetail +type ErrorDefinition = original.ErrorDefinition +type ErrorResponse = original.ErrorResponse +type ExpressionEvaluationDetails = original.ExpressionEvaluationDetails +type IfNotExistsEvaluationDetails = original.IfNotExistsEvaluationDetails type Operation = original.Operation type OperationDisplay = original.OperationDisplay type OperationsClient = original.OperationsClient type OperationsListResults = original.OperationsListResults type PolicyAssignmentSummary = original.PolicyAssignmentSummary type PolicyDefinitionSummary = original.PolicyDefinitionSummary +type PolicyDetails = original.PolicyDetails +type PolicyEvaluationDetails = original.PolicyEvaluationDetails type PolicyEvent = original.PolicyEvent type PolicyEventsClient = original.PolicyEventsClient type PolicyEventsQueryResults = original.PolicyEventsQueryResults +type PolicyGroupSummary = original.PolicyGroupSummary type PolicyState = original.PolicyState type PolicyStatesClient = original.PolicyStatesClient type PolicyStatesQueryResults = original.PolicyStatesQueryResults +type PolicyTrackedResource = original.PolicyTrackedResource +type PolicyTrackedResourcesClient = original.PolicyTrackedResourcesClient +type PolicyTrackedResourcesQueryResults = original.PolicyTrackedResourcesQueryResults +type PolicyTrackedResourcesQueryResultsIterator = original.PolicyTrackedResourcesQueryResultsIterator +type PolicyTrackedResourcesQueryResultsPage = original.PolicyTrackedResourcesQueryResultsPage type QueryFailure = original.QueryFailure type QueryFailureError = original.QueryFailureError +type Remediation = original.Remediation +type RemediationDeployment = original.RemediationDeployment +type RemediationDeploymentSummary = original.RemediationDeploymentSummary +type RemediationDeploymentsListResult = original.RemediationDeploymentsListResult +type RemediationDeploymentsListResultIterator = original.RemediationDeploymentsListResultIterator +type RemediationDeploymentsListResultPage = original.RemediationDeploymentsListResultPage +type RemediationFilters = original.RemediationFilters +type RemediationListResult = original.RemediationListResult +type RemediationListResultIterator = original.RemediationListResultIterator +type RemediationListResultPage = original.RemediationListResultPage +type RemediationProperties = original.RemediationProperties +type RemediationsClient = original.RemediationsClient type String = original.String type SummarizeResults = original.SummarizeResults type Summary = original.Summary type SummaryResults = original.SummaryResults +type TrackedResourceModificationDetails = original.TrackedResourceModificationDetails +type TypedErrorInfo = original.TypedErrorInfo func New() BaseClient { return original.New() @@ -73,6 +104,36 @@ func NewPolicyStatesClient() PolicyStatesClient { func NewPolicyStatesClientWithBaseURI(baseURI string) PolicyStatesClient { return original.NewPolicyStatesClientWithBaseURI(baseURI) } +func NewPolicyTrackedResourcesClient() PolicyTrackedResourcesClient { + return original.NewPolicyTrackedResourcesClient() +} +func NewPolicyTrackedResourcesClientWithBaseURI(baseURI string) PolicyTrackedResourcesClient { + return original.NewPolicyTrackedResourcesClientWithBaseURI(baseURI) +} +func NewPolicyTrackedResourcesQueryResultsIterator(page PolicyTrackedResourcesQueryResultsPage) PolicyTrackedResourcesQueryResultsIterator { + return original.NewPolicyTrackedResourcesQueryResultsIterator(page) +} +func NewPolicyTrackedResourcesQueryResultsPage(getNextPage func(context.Context, PolicyTrackedResourcesQueryResults) (PolicyTrackedResourcesQueryResults, error)) PolicyTrackedResourcesQueryResultsPage { + return original.NewPolicyTrackedResourcesQueryResultsPage(getNextPage) +} +func NewRemediationDeploymentsListResultIterator(page RemediationDeploymentsListResultPage) RemediationDeploymentsListResultIterator { + return original.NewRemediationDeploymentsListResultIterator(page) +} +func NewRemediationDeploymentsListResultPage(getNextPage func(context.Context, RemediationDeploymentsListResult) (RemediationDeploymentsListResult, error)) RemediationDeploymentsListResultPage { + return original.NewRemediationDeploymentsListResultPage(getNextPage) +} +func NewRemediationListResultIterator(page RemediationListResultPage) RemediationListResultIterator { + return original.NewRemediationListResultIterator(page) +} +func NewRemediationListResultPage(getNextPage func(context.Context, RemediationListResult) (RemediationListResult, error)) RemediationListResultPage { + return original.NewRemediationListResultPage(getNextPage) +} +func NewRemediationsClient() RemediationsClient { + return original.NewRemediationsClient() +} +func NewRemediationsClientWithBaseURI(baseURI string) RemediationsClient { + return original.NewRemediationsClientWithBaseURI(baseURI) +} func NewWithBaseURI(baseURI string) BaseClient { return original.NewWithBaseURI(baseURI) } diff --git a/profiles/latest/policyinsights/mgmt/policyinsights/policyinsightsapi/models.go b/profiles/latest/policyinsights/mgmt/policyinsights/policyinsightsapi/models.go index 68f64baaefe8..3f4601162208 100644 --- a/profiles/latest/policyinsights/mgmt/policyinsights/policyinsightsapi/models.go +++ b/profiles/latest/policyinsights/mgmt/policyinsights/policyinsightsapi/models.go @@ -19,8 +19,10 @@ package policyinsightsapi -import original "github.com/Azure/azure-sdk-for-go/services/policyinsights/mgmt/2018-04-04/policyinsights/policyinsightsapi" +import original "github.com/Azure/azure-sdk-for-go/services/policyinsights/mgmt/2019-10-01/policyinsights/policyinsightsapi" type OperationsClientAPI = original.OperationsClientAPI type PolicyEventsClientAPI = original.PolicyEventsClientAPI type PolicyStatesClientAPI = original.PolicyStatesClientAPI +type PolicyTrackedResourcesClientAPI = original.PolicyTrackedResourcesClientAPI +type RemediationsClientAPI = original.RemediationsClientAPI diff --git a/profiles/preview/policyinsights/mgmt/policyinsights/models.go b/profiles/preview/policyinsights/mgmt/policyinsights/models.go index d6643c95eceb..b615e657622b 100644 --- a/profiles/preview/policyinsights/mgmt/policyinsights/models.go +++ b/profiles/preview/policyinsights/mgmt/policyinsights/models.go @@ -19,7 +19,11 @@ package policyinsights -import original "github.com/Azure/azure-sdk-for-go/services/policyinsights/mgmt/2018-04-04/policyinsights" +import ( + "context" + + original "github.com/Azure/azure-sdk-for-go/services/policyinsights/mgmt/2019-10-01/policyinsights" +) const ( DefaultBaseURI = original.DefaultBaseURI @@ -33,24 +37,51 @@ const ( ) type BaseClient = original.BaseClient +type ComplianceDetail = original.ComplianceDetail +type ErrorDefinition = original.ErrorDefinition +type ErrorResponse = original.ErrorResponse +type ExpressionEvaluationDetails = original.ExpressionEvaluationDetails +type IfNotExistsEvaluationDetails = original.IfNotExistsEvaluationDetails type Operation = original.Operation type OperationDisplay = original.OperationDisplay type OperationsClient = original.OperationsClient type OperationsListResults = original.OperationsListResults type PolicyAssignmentSummary = original.PolicyAssignmentSummary type PolicyDefinitionSummary = original.PolicyDefinitionSummary +type PolicyDetails = original.PolicyDetails +type PolicyEvaluationDetails = original.PolicyEvaluationDetails type PolicyEvent = original.PolicyEvent type PolicyEventsClient = original.PolicyEventsClient type PolicyEventsQueryResults = original.PolicyEventsQueryResults +type PolicyGroupSummary = original.PolicyGroupSummary type PolicyState = original.PolicyState type PolicyStatesClient = original.PolicyStatesClient type PolicyStatesQueryResults = original.PolicyStatesQueryResults +type PolicyTrackedResource = original.PolicyTrackedResource +type PolicyTrackedResourcesClient = original.PolicyTrackedResourcesClient +type PolicyTrackedResourcesQueryResults = original.PolicyTrackedResourcesQueryResults +type PolicyTrackedResourcesQueryResultsIterator = original.PolicyTrackedResourcesQueryResultsIterator +type PolicyTrackedResourcesQueryResultsPage = original.PolicyTrackedResourcesQueryResultsPage type QueryFailure = original.QueryFailure type QueryFailureError = original.QueryFailureError +type Remediation = original.Remediation +type RemediationDeployment = original.RemediationDeployment +type RemediationDeploymentSummary = original.RemediationDeploymentSummary +type RemediationDeploymentsListResult = original.RemediationDeploymentsListResult +type RemediationDeploymentsListResultIterator = original.RemediationDeploymentsListResultIterator +type RemediationDeploymentsListResultPage = original.RemediationDeploymentsListResultPage +type RemediationFilters = original.RemediationFilters +type RemediationListResult = original.RemediationListResult +type RemediationListResultIterator = original.RemediationListResultIterator +type RemediationListResultPage = original.RemediationListResultPage +type RemediationProperties = original.RemediationProperties +type RemediationsClient = original.RemediationsClient type String = original.String type SummarizeResults = original.SummarizeResults type Summary = original.Summary type SummaryResults = original.SummaryResults +type TrackedResourceModificationDetails = original.TrackedResourceModificationDetails +type TypedErrorInfo = original.TypedErrorInfo func New() BaseClient { return original.New() @@ -73,6 +104,36 @@ func NewPolicyStatesClient() PolicyStatesClient { func NewPolicyStatesClientWithBaseURI(baseURI string) PolicyStatesClient { return original.NewPolicyStatesClientWithBaseURI(baseURI) } +func NewPolicyTrackedResourcesClient() PolicyTrackedResourcesClient { + return original.NewPolicyTrackedResourcesClient() +} +func NewPolicyTrackedResourcesClientWithBaseURI(baseURI string) PolicyTrackedResourcesClient { + return original.NewPolicyTrackedResourcesClientWithBaseURI(baseURI) +} +func NewPolicyTrackedResourcesQueryResultsIterator(page PolicyTrackedResourcesQueryResultsPage) PolicyTrackedResourcesQueryResultsIterator { + return original.NewPolicyTrackedResourcesQueryResultsIterator(page) +} +func NewPolicyTrackedResourcesQueryResultsPage(getNextPage func(context.Context, PolicyTrackedResourcesQueryResults) (PolicyTrackedResourcesQueryResults, error)) PolicyTrackedResourcesQueryResultsPage { + return original.NewPolicyTrackedResourcesQueryResultsPage(getNextPage) +} +func NewRemediationDeploymentsListResultIterator(page RemediationDeploymentsListResultPage) RemediationDeploymentsListResultIterator { + return original.NewRemediationDeploymentsListResultIterator(page) +} +func NewRemediationDeploymentsListResultPage(getNextPage func(context.Context, RemediationDeploymentsListResult) (RemediationDeploymentsListResult, error)) RemediationDeploymentsListResultPage { + return original.NewRemediationDeploymentsListResultPage(getNextPage) +} +func NewRemediationListResultIterator(page RemediationListResultPage) RemediationListResultIterator { + return original.NewRemediationListResultIterator(page) +} +func NewRemediationListResultPage(getNextPage func(context.Context, RemediationListResult) (RemediationListResult, error)) RemediationListResultPage { + return original.NewRemediationListResultPage(getNextPage) +} +func NewRemediationsClient() RemediationsClient { + return original.NewRemediationsClient() +} +func NewRemediationsClientWithBaseURI(baseURI string) RemediationsClient { + return original.NewRemediationsClientWithBaseURI(baseURI) +} func NewWithBaseURI(baseURI string) BaseClient { return original.NewWithBaseURI(baseURI) } diff --git a/profiles/preview/policyinsights/mgmt/policyinsights/policyinsightsapi/models.go b/profiles/preview/policyinsights/mgmt/policyinsights/policyinsightsapi/models.go index 68f64baaefe8..3f4601162208 100644 --- a/profiles/preview/policyinsights/mgmt/policyinsights/policyinsightsapi/models.go +++ b/profiles/preview/policyinsights/mgmt/policyinsights/policyinsightsapi/models.go @@ -19,8 +19,10 @@ package policyinsightsapi -import original "github.com/Azure/azure-sdk-for-go/services/policyinsights/mgmt/2018-04-04/policyinsights/policyinsightsapi" +import original "github.com/Azure/azure-sdk-for-go/services/policyinsights/mgmt/2019-10-01/policyinsights/policyinsightsapi" type OperationsClientAPI = original.OperationsClientAPI type PolicyEventsClientAPI = original.PolicyEventsClientAPI type PolicyStatesClientAPI = original.PolicyStatesClientAPI +type PolicyTrackedResourcesClientAPI = original.PolicyTrackedResourcesClientAPI +type RemediationsClientAPI = original.RemediationsClientAPI diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/client.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/client.go new file mode 100644 index 000000000000..4687a8ef8675 --- /dev/null +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/client.go @@ -0,0 +1,49 @@ +// Package policyinsights implements the Azure ARM Policyinsights service API version . +// +// +package policyinsights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Policyinsights + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Policyinsights. +type BaseClient struct { + autorest.Client + BaseURI string +} + +// New creates an instance of the BaseClient client. +func New() BaseClient { + return NewWithBaseURI(DefaultBaseURI) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + } +} diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/models.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/models.go new file mode 100644 index 000000000000..214dcc0b1605 --- /dev/null +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/models.go @@ -0,0 +1,1777 @@ +package policyinsights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/policyinsights/mgmt/2019-10-01/policyinsights" + +// PolicyStatesResource enumerates the values for policy states resource. +type PolicyStatesResource string + +const ( + // Default ... + Default PolicyStatesResource = "default" + // Latest ... + Latest PolicyStatesResource = "latest" +) + +// PossiblePolicyStatesResourceValues returns an array of possible values for the PolicyStatesResource const type. +func PossiblePolicyStatesResourceValues() []PolicyStatesResource { + return []PolicyStatesResource{Default, Latest} +} + +// ComplianceDetail the compliance state rollup. +type ComplianceDetail struct { + // ComplianceState - The compliance state. + ComplianceState *string `json:"complianceState,omitempty"` + // Count - Summarized count value for this compliance state. + Count *int32 `json:"count,omitempty"` +} + +// ErrorDefinition error definition. +type ErrorDefinition struct { + // Code - READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; Description of the error. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The target of the error. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; Internal error details. + Details *[]ErrorDefinition `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; Additional scenario specific error details. + AdditionalInfo *[]TypedErrorInfo `json:"additionalInfo,omitempty"` +} + +// ErrorResponse error response. +type ErrorResponse struct { + // Error - The error details. + Error *ErrorDefinition `json:"error,omitempty"` +} + +// ExpressionEvaluationDetails evaluation details of policy language expressions. +type ExpressionEvaluationDetails struct { + // Result - Evaluation result. + Result *string `json:"result,omitempty"` + // Expression - Expression evaluated. + Expression *string `json:"expression,omitempty"` + // Path - Property path if the expression is a field or an alias. + Path *string `json:"path,omitempty"` + // ExpressionValue - Value of the expression. + ExpressionValue interface{} `json:"expressionValue,omitempty"` + // TargetValue - Target value to be compared with the expression value. + TargetValue interface{} `json:"targetValue,omitempty"` + // Operator - Operator to compare the expression value and the target value. + Operator *string `json:"operator,omitempty"` +} + +// IfNotExistsEvaluationDetails evaluation details of IfNotExists effect. +type IfNotExistsEvaluationDetails struct { + // ResourceID - ID of the last evaluated resource for IfNotExists effect. + ResourceID *string `json:"resourceId,omitempty"` + // TotalResources - Total number of resources to which the existence condition is applicable. + TotalResources *int32 `json:"totalResources,omitempty"` +} + +// Operation operation definition. +type Operation struct { + // Name - Operation name. + Name *string `json:"name,omitempty"` + // Display - Display metadata associated with the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay display metadata associated with the operation. +type OperationDisplay struct { + // Provider - Resource provider name. + Provider *string `json:"provider,omitempty"` + // Resource - Resource name on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Operation - Operation name. + Operation *string `json:"operation,omitempty"` + // Description - Operation description. + Description *string `json:"description,omitempty"` +} + +// OperationsListResults list of available operations. +type OperationsListResults struct { + autorest.Response `json:"-"` + // OdataCount - OData entity count; represents the number of operations returned. + OdataCount *int32 `json:"@odata.count,omitempty"` + // Value - List of available operations. + Value *[]Operation `json:"value,omitempty"` +} + +// PolicyAssignmentSummary policy assignment summary. +type PolicyAssignmentSummary struct { + // PolicyAssignmentID - Policy assignment ID. + PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"` + // PolicySetDefinitionID - Policy set definition ID, if the policy assignment is for a policy set. + PolicySetDefinitionID *string `json:"policySetDefinitionId,omitempty"` + // Results - Compliance summary for the policy assignment. + Results *SummaryResults `json:"results,omitempty"` + // PolicyDefinitions - Policy definitions summary. + PolicyDefinitions *[]PolicyDefinitionSummary `json:"policyDefinitions,omitempty"` + // PolicyGroups - Policy definition group summary. + PolicyGroups *[]PolicyGroupSummary `json:"policyGroups,omitempty"` +} + +// PolicyDefinitionSummary policy definition summary. +type PolicyDefinitionSummary struct { + // PolicyDefinitionID - Policy definition ID. + PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` + // PolicyDefinitionReferenceID - Policy definition reference ID. + PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` + // PolicyDefinitionGroupNames - Policy definition group names. + PolicyDefinitionGroupNames *[]string `json:"policyDefinitionGroupNames,omitempty"` + // Effect - Policy effect, i.e. policy definition action. + Effect *string `json:"effect,omitempty"` + // Results - Compliance summary for the policy definition. + Results *SummaryResults `json:"results,omitempty"` +} + +// PolicyDetails the policy details. +type PolicyDetails struct { + // PolicyDefinitionID - READ-ONLY; The ID of the policy definition. + PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` + // PolicyAssignmentID - READ-ONLY; The ID of the policy assignment. + PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"` + // PolicyAssignmentDisplayName - READ-ONLY; The display name of the policy assignment. + PolicyAssignmentDisplayName *string `json:"policyAssignmentDisplayName,omitempty"` + // PolicyAssignmentScope - READ-ONLY; The scope of the policy assignment. + PolicyAssignmentScope *string `json:"policyAssignmentScope,omitempty"` + // PolicySetDefinitionID - READ-ONLY; The ID of the policy set definition. + PolicySetDefinitionID *string `json:"policySetDefinitionId,omitempty"` + // PolicyDefinitionReferenceID - READ-ONLY; The policy definition reference ID within the policy set definition. + PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` +} + +// PolicyEvaluationDetails policy evaluation details. +type PolicyEvaluationDetails struct { + // EvaluatedExpressions - Details of the evaluated expressions. + EvaluatedExpressions *[]ExpressionEvaluationDetails `json:"evaluatedExpressions,omitempty"` + // IfNotExistsDetails - Evaluation details of IfNotExists effect. + IfNotExistsDetails *IfNotExistsEvaluationDetails `json:"ifNotExistsDetails,omitempty"` +} + +// PolicyEvent policy event record. +type PolicyEvent struct { + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // OdataID - OData entity ID; always set to null since policy event records do not have an entity ID. + OdataID *string `json:"@odata.id,omitempty"` + // OdataContext - OData context string; used by OData clients to resolve type information based on metadata. + OdataContext *string `json:"@odata.context,omitempty"` + // Timestamp - Timestamp for the policy event record. + Timestamp *date.Time `json:"timestamp,omitempty"` + // ResourceID - Resource ID. + ResourceID *string `json:"resourceId,omitempty"` + // PolicyAssignmentID - Policy assignment ID. + PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"` + // PolicyDefinitionID - Policy definition ID. + PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` + // EffectiveParameters - Effective parameters for the policy assignment. + EffectiveParameters *string `json:"effectiveParameters,omitempty"` + // IsCompliant - Flag which states whether the resource is compliant against the policy assignment it was evaluated against. + IsCompliant *bool `json:"isCompliant,omitempty"` + // SubscriptionID - Subscription ID. + SubscriptionID *string `json:"subscriptionId,omitempty"` + // ResourceType - Resource type. + ResourceType *string `json:"resourceType,omitempty"` + // ResourceLocation - Resource location. + ResourceLocation *string `json:"resourceLocation,omitempty"` + // ResourceGroup - Resource group name. + ResourceGroup *string `json:"resourceGroup,omitempty"` + // ResourceTags - List of resource tags. + ResourceTags *string `json:"resourceTags,omitempty"` + // PolicyAssignmentName - Policy assignment name. + PolicyAssignmentName *string `json:"policyAssignmentName,omitempty"` + // PolicyAssignmentOwner - Policy assignment owner. + PolicyAssignmentOwner *string `json:"policyAssignmentOwner,omitempty"` + // PolicyAssignmentParameters - Policy assignment parameters. + PolicyAssignmentParameters *string `json:"policyAssignmentParameters,omitempty"` + // PolicyAssignmentScope - Policy assignment scope. + PolicyAssignmentScope *string `json:"policyAssignmentScope,omitempty"` + // PolicyDefinitionName - Policy definition name. + PolicyDefinitionName *string `json:"policyDefinitionName,omitempty"` + // PolicyDefinitionAction - Policy definition action, i.e. effect. + PolicyDefinitionAction *string `json:"policyDefinitionAction,omitempty"` + // PolicyDefinitionCategory - Policy definition category. + PolicyDefinitionCategory *string `json:"policyDefinitionCategory,omitempty"` + // PolicySetDefinitionID - Policy set definition ID, if the policy assignment is for a policy set. + PolicySetDefinitionID *string `json:"policySetDefinitionId,omitempty"` + // PolicySetDefinitionName - Policy set definition name, if the policy assignment is for a policy set. + PolicySetDefinitionName *string `json:"policySetDefinitionName,omitempty"` + // PolicySetDefinitionOwner - Policy set definition owner, if the policy assignment is for a policy set. + PolicySetDefinitionOwner *string `json:"policySetDefinitionOwner,omitempty"` + // PolicySetDefinitionCategory - Policy set definition category, if the policy assignment is for a policy set. + PolicySetDefinitionCategory *string `json:"policySetDefinitionCategory,omitempty"` + // PolicySetDefinitionParameters - Policy set definition parameters, if the policy assignment is for a policy set. + PolicySetDefinitionParameters *string `json:"policySetDefinitionParameters,omitempty"` + // ManagementGroupIds - Comma separated list of management group IDs, which represent the hierarchy of the management groups the resource is under. + ManagementGroupIds *string `json:"managementGroupIds,omitempty"` + // PolicyDefinitionReferenceID - Reference ID for the policy definition inside the policy set, if the policy assignment is for a policy set. + PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` + // TenantID - Tenant ID for the policy event record. + TenantID *string `json:"tenantId,omitempty"` + // PrincipalOid - Principal object ID for the user who initiated the resource operation that triggered the policy event. + PrincipalOid *string `json:"principalOid,omitempty"` +} + +// MarshalJSON is the custom marshaler for PolicyEvent. +func (peVar PolicyEvent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if peVar.OdataID != nil { + objectMap["@odata.id"] = peVar.OdataID + } + if peVar.OdataContext != nil { + objectMap["@odata.context"] = peVar.OdataContext + } + if peVar.Timestamp != nil { + objectMap["timestamp"] = peVar.Timestamp + } + if peVar.ResourceID != nil { + objectMap["resourceId"] = peVar.ResourceID + } + if peVar.PolicyAssignmentID != nil { + objectMap["policyAssignmentId"] = peVar.PolicyAssignmentID + } + if peVar.PolicyDefinitionID != nil { + objectMap["policyDefinitionId"] = peVar.PolicyDefinitionID + } + if peVar.EffectiveParameters != nil { + objectMap["effectiveParameters"] = peVar.EffectiveParameters + } + if peVar.IsCompliant != nil { + objectMap["isCompliant"] = peVar.IsCompliant + } + if peVar.SubscriptionID != nil { + objectMap["subscriptionId"] = peVar.SubscriptionID + } + if peVar.ResourceType != nil { + objectMap["resourceType"] = peVar.ResourceType + } + if peVar.ResourceLocation != nil { + objectMap["resourceLocation"] = peVar.ResourceLocation + } + if peVar.ResourceGroup != nil { + objectMap["resourceGroup"] = peVar.ResourceGroup + } + if peVar.ResourceTags != nil { + objectMap["resourceTags"] = peVar.ResourceTags + } + if peVar.PolicyAssignmentName != nil { + objectMap["policyAssignmentName"] = peVar.PolicyAssignmentName + } + if peVar.PolicyAssignmentOwner != nil { + objectMap["policyAssignmentOwner"] = peVar.PolicyAssignmentOwner + } + if peVar.PolicyAssignmentParameters != nil { + objectMap["policyAssignmentParameters"] = peVar.PolicyAssignmentParameters + } + if peVar.PolicyAssignmentScope != nil { + objectMap["policyAssignmentScope"] = peVar.PolicyAssignmentScope + } + if peVar.PolicyDefinitionName != nil { + objectMap["policyDefinitionName"] = peVar.PolicyDefinitionName + } + if peVar.PolicyDefinitionAction != nil { + objectMap["policyDefinitionAction"] = peVar.PolicyDefinitionAction + } + if peVar.PolicyDefinitionCategory != nil { + objectMap["policyDefinitionCategory"] = peVar.PolicyDefinitionCategory + } + if peVar.PolicySetDefinitionID != nil { + objectMap["policySetDefinitionId"] = peVar.PolicySetDefinitionID + } + if peVar.PolicySetDefinitionName != nil { + objectMap["policySetDefinitionName"] = peVar.PolicySetDefinitionName + } + if peVar.PolicySetDefinitionOwner != nil { + objectMap["policySetDefinitionOwner"] = peVar.PolicySetDefinitionOwner + } + if peVar.PolicySetDefinitionCategory != nil { + objectMap["policySetDefinitionCategory"] = peVar.PolicySetDefinitionCategory + } + if peVar.PolicySetDefinitionParameters != nil { + objectMap["policySetDefinitionParameters"] = peVar.PolicySetDefinitionParameters + } + if peVar.ManagementGroupIds != nil { + objectMap["managementGroupIds"] = peVar.ManagementGroupIds + } + if peVar.PolicyDefinitionReferenceID != nil { + objectMap["policyDefinitionReferenceId"] = peVar.PolicyDefinitionReferenceID + } + if peVar.TenantID != nil { + objectMap["tenantId"] = peVar.TenantID + } + if peVar.PrincipalOid != nil { + objectMap["principalOid"] = peVar.PrincipalOid + } + for k, v := range peVar.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PolicyEvent struct. +func (peVar *PolicyEvent) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if peVar.AdditionalProperties == nil { + peVar.AdditionalProperties = make(map[string]interface{}) + } + peVar.AdditionalProperties[k] = additionalProperties + } + case "@odata.id": + if v != nil { + var odataID string + err = json.Unmarshal(*v, &odataID) + if err != nil { + return err + } + peVar.OdataID = &odataID + } + case "@odata.context": + if v != nil { + var odataContext string + err = json.Unmarshal(*v, &odataContext) + if err != nil { + return err + } + peVar.OdataContext = &odataContext + } + case "timestamp": + if v != nil { + var timestamp date.Time + err = json.Unmarshal(*v, ×tamp) + if err != nil { + return err + } + peVar.Timestamp = ×tamp + } + case "resourceId": + if v != nil { + var resourceID string + err = json.Unmarshal(*v, &resourceID) + if err != nil { + return err + } + peVar.ResourceID = &resourceID + } + case "policyAssignmentId": + if v != nil { + var policyAssignmentID string + err = json.Unmarshal(*v, &policyAssignmentID) + if err != nil { + return err + } + peVar.PolicyAssignmentID = &policyAssignmentID + } + case "policyDefinitionId": + if v != nil { + var policyDefinitionID string + err = json.Unmarshal(*v, &policyDefinitionID) + if err != nil { + return err + } + peVar.PolicyDefinitionID = &policyDefinitionID + } + case "effectiveParameters": + if v != nil { + var effectiveParameters string + err = json.Unmarshal(*v, &effectiveParameters) + if err != nil { + return err + } + peVar.EffectiveParameters = &effectiveParameters + } + case "isCompliant": + if v != nil { + var isCompliant bool + err = json.Unmarshal(*v, &isCompliant) + if err != nil { + return err + } + peVar.IsCompliant = &isCompliant + } + case "subscriptionId": + if v != nil { + var subscriptionID string + err = json.Unmarshal(*v, &subscriptionID) + if err != nil { + return err + } + peVar.SubscriptionID = &subscriptionID + } + case "resourceType": + if v != nil { + var resourceType string + err = json.Unmarshal(*v, &resourceType) + if err != nil { + return err + } + peVar.ResourceType = &resourceType + } + case "resourceLocation": + if v != nil { + var resourceLocation string + err = json.Unmarshal(*v, &resourceLocation) + if err != nil { + return err + } + peVar.ResourceLocation = &resourceLocation + } + case "resourceGroup": + if v != nil { + var resourceGroup string + err = json.Unmarshal(*v, &resourceGroup) + if err != nil { + return err + } + peVar.ResourceGroup = &resourceGroup + } + case "resourceTags": + if v != nil { + var resourceTags string + err = json.Unmarshal(*v, &resourceTags) + if err != nil { + return err + } + peVar.ResourceTags = &resourceTags + } + case "policyAssignmentName": + if v != nil { + var policyAssignmentName string + err = json.Unmarshal(*v, &policyAssignmentName) + if err != nil { + return err + } + peVar.PolicyAssignmentName = &policyAssignmentName + } + case "policyAssignmentOwner": + if v != nil { + var policyAssignmentOwner string + err = json.Unmarshal(*v, &policyAssignmentOwner) + if err != nil { + return err + } + peVar.PolicyAssignmentOwner = &policyAssignmentOwner + } + case "policyAssignmentParameters": + if v != nil { + var policyAssignmentParameters string + err = json.Unmarshal(*v, &policyAssignmentParameters) + if err != nil { + return err + } + peVar.PolicyAssignmentParameters = &policyAssignmentParameters + } + case "policyAssignmentScope": + if v != nil { + var policyAssignmentScope string + err = json.Unmarshal(*v, &policyAssignmentScope) + if err != nil { + return err + } + peVar.PolicyAssignmentScope = &policyAssignmentScope + } + case "policyDefinitionName": + if v != nil { + var policyDefinitionName string + err = json.Unmarshal(*v, &policyDefinitionName) + if err != nil { + return err + } + peVar.PolicyDefinitionName = &policyDefinitionName + } + case "policyDefinitionAction": + if v != nil { + var policyDefinitionAction string + err = json.Unmarshal(*v, &policyDefinitionAction) + if err != nil { + return err + } + peVar.PolicyDefinitionAction = &policyDefinitionAction + } + case "policyDefinitionCategory": + if v != nil { + var policyDefinitionCategory string + err = json.Unmarshal(*v, &policyDefinitionCategory) + if err != nil { + return err + } + peVar.PolicyDefinitionCategory = &policyDefinitionCategory + } + case "policySetDefinitionId": + if v != nil { + var policySetDefinitionID string + err = json.Unmarshal(*v, &policySetDefinitionID) + if err != nil { + return err + } + peVar.PolicySetDefinitionID = &policySetDefinitionID + } + case "policySetDefinitionName": + if v != nil { + var policySetDefinitionName string + err = json.Unmarshal(*v, &policySetDefinitionName) + if err != nil { + return err + } + peVar.PolicySetDefinitionName = &policySetDefinitionName + } + case "policySetDefinitionOwner": + if v != nil { + var policySetDefinitionOwner string + err = json.Unmarshal(*v, &policySetDefinitionOwner) + if err != nil { + return err + } + peVar.PolicySetDefinitionOwner = &policySetDefinitionOwner + } + case "policySetDefinitionCategory": + if v != nil { + var policySetDefinitionCategory string + err = json.Unmarshal(*v, &policySetDefinitionCategory) + if err != nil { + return err + } + peVar.PolicySetDefinitionCategory = &policySetDefinitionCategory + } + case "policySetDefinitionParameters": + if v != nil { + var policySetDefinitionParameters string + err = json.Unmarshal(*v, &policySetDefinitionParameters) + if err != nil { + return err + } + peVar.PolicySetDefinitionParameters = &policySetDefinitionParameters + } + case "managementGroupIds": + if v != nil { + var managementGroupIds string + err = json.Unmarshal(*v, &managementGroupIds) + if err != nil { + return err + } + peVar.ManagementGroupIds = &managementGroupIds + } + case "policyDefinitionReferenceId": + if v != nil { + var policyDefinitionReferenceID string + err = json.Unmarshal(*v, &policyDefinitionReferenceID) + if err != nil { + return err + } + peVar.PolicyDefinitionReferenceID = &policyDefinitionReferenceID + } + case "tenantId": + if v != nil { + var tenantID string + err = json.Unmarshal(*v, &tenantID) + if err != nil { + return err + } + peVar.TenantID = &tenantID + } + case "principalOid": + if v != nil { + var principalOid string + err = json.Unmarshal(*v, &principalOid) + if err != nil { + return err + } + peVar.PrincipalOid = &principalOid + } + } + } + + return nil +} + +// PolicyEventsQueryResults query results. +type PolicyEventsQueryResults struct { + autorest.Response `json:"-"` + // OdataContext - OData context string; used by OData clients to resolve type information based on metadata. + OdataContext *string `json:"@odata.context,omitempty"` + // OdataCount - OData entity count; represents the number of policy event records returned. + OdataCount *int32 `json:"@odata.count,omitempty"` + // Value - Query results. + Value *[]PolicyEvent `json:"value,omitempty"` +} + +// PolicyGroupSummary policy definition group summary. +type PolicyGroupSummary struct { + // PolicyGroupName - Policy group name. + PolicyGroupName *string `json:"policyGroupName,omitempty"` + // Results - Compliance summary for the policy definition group. + Results *SummaryResults `json:"results,omitempty"` +} + +// PolicyState policy state record. +type PolicyState struct { + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // OdataID - OData entity ID; always set to null since policy state records do not have an entity ID. + OdataID *string `json:"@odata.id,omitempty"` + // OdataContext - OData context string; used by OData clients to resolve type information based on metadata. + OdataContext *string `json:"@odata.context,omitempty"` + // Timestamp - Timestamp for the policy state record. + Timestamp *date.Time `json:"timestamp,omitempty"` + // ResourceID - Resource ID. + ResourceID *string `json:"resourceId,omitempty"` + // PolicyAssignmentID - Policy assignment ID. + PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"` + // PolicyDefinitionID - Policy definition ID. + PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` + // EffectiveParameters - Effective parameters for the policy assignment. + EffectiveParameters *string `json:"effectiveParameters,omitempty"` + // IsCompliant - Flag which states whether the resource is compliant against the policy assignment it was evaluated against. This property is deprecated; please use ComplianceState instead. + IsCompliant *bool `json:"isCompliant,omitempty"` + // SubscriptionID - Subscription ID. + SubscriptionID *string `json:"subscriptionId,omitempty"` + // ResourceType - Resource type. + ResourceType *string `json:"resourceType,omitempty"` + // ResourceLocation - Resource location. + ResourceLocation *string `json:"resourceLocation,omitempty"` + // ResourceGroup - Resource group name. + ResourceGroup *string `json:"resourceGroup,omitempty"` + // ResourceTags - List of resource tags. + ResourceTags *string `json:"resourceTags,omitempty"` + // PolicyAssignmentName - Policy assignment name. + PolicyAssignmentName *string `json:"policyAssignmentName,omitempty"` + // PolicyAssignmentOwner - Policy assignment owner. + PolicyAssignmentOwner *string `json:"policyAssignmentOwner,omitempty"` + // PolicyAssignmentParameters - Policy assignment parameters. + PolicyAssignmentParameters *string `json:"policyAssignmentParameters,omitempty"` + // PolicyAssignmentScope - Policy assignment scope. + PolicyAssignmentScope *string `json:"policyAssignmentScope,omitempty"` + // PolicyDefinitionName - Policy definition name. + PolicyDefinitionName *string `json:"policyDefinitionName,omitempty"` + // PolicyDefinitionAction - Policy definition action, i.e. effect. + PolicyDefinitionAction *string `json:"policyDefinitionAction,omitempty"` + // PolicyDefinitionCategory - Policy definition category. + PolicyDefinitionCategory *string `json:"policyDefinitionCategory,omitempty"` + // PolicySetDefinitionID - Policy set definition ID, if the policy assignment is for a policy set. + PolicySetDefinitionID *string `json:"policySetDefinitionId,omitempty"` + // PolicySetDefinitionName - Policy set definition name, if the policy assignment is for a policy set. + PolicySetDefinitionName *string `json:"policySetDefinitionName,omitempty"` + // PolicySetDefinitionOwner - Policy set definition owner, if the policy assignment is for a policy set. + PolicySetDefinitionOwner *string `json:"policySetDefinitionOwner,omitempty"` + // PolicySetDefinitionCategory - Policy set definition category, if the policy assignment is for a policy set. + PolicySetDefinitionCategory *string `json:"policySetDefinitionCategory,omitempty"` + // PolicySetDefinitionParameters - Policy set definition parameters, if the policy assignment is for a policy set. + PolicySetDefinitionParameters *string `json:"policySetDefinitionParameters,omitempty"` + // ManagementGroupIds - Comma separated list of management group IDs, which represent the hierarchy of the management groups the resource is under. + ManagementGroupIds *string `json:"managementGroupIds,omitempty"` + // PolicyDefinitionReferenceID - Reference ID for the policy definition inside the policy set, if the policy assignment is for a policy set. + PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` + // ComplianceState - Compliance state of the resource. + ComplianceState *string `json:"complianceState,omitempty"` + // PolicyEvaluationDetails - Policy evaluation details. + PolicyEvaluationDetails *PolicyEvaluationDetails `json:"policyEvaluationDetails,omitempty"` + // PolicyDefinitionGroupNames - Policy definition group names. + PolicyDefinitionGroupNames *[]string `json:"policyDefinitionGroupNames,omitempty"` +} + +// MarshalJSON is the custom marshaler for PolicyState. +func (ps PolicyState) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ps.OdataID != nil { + objectMap["@odata.id"] = ps.OdataID + } + if ps.OdataContext != nil { + objectMap["@odata.context"] = ps.OdataContext + } + if ps.Timestamp != nil { + objectMap["timestamp"] = ps.Timestamp + } + if ps.ResourceID != nil { + objectMap["resourceId"] = ps.ResourceID + } + if ps.PolicyAssignmentID != nil { + objectMap["policyAssignmentId"] = ps.PolicyAssignmentID + } + if ps.PolicyDefinitionID != nil { + objectMap["policyDefinitionId"] = ps.PolicyDefinitionID + } + if ps.EffectiveParameters != nil { + objectMap["effectiveParameters"] = ps.EffectiveParameters + } + if ps.IsCompliant != nil { + objectMap["isCompliant"] = ps.IsCompliant + } + if ps.SubscriptionID != nil { + objectMap["subscriptionId"] = ps.SubscriptionID + } + if ps.ResourceType != nil { + objectMap["resourceType"] = ps.ResourceType + } + if ps.ResourceLocation != nil { + objectMap["resourceLocation"] = ps.ResourceLocation + } + if ps.ResourceGroup != nil { + objectMap["resourceGroup"] = ps.ResourceGroup + } + if ps.ResourceTags != nil { + objectMap["resourceTags"] = ps.ResourceTags + } + if ps.PolicyAssignmentName != nil { + objectMap["policyAssignmentName"] = ps.PolicyAssignmentName + } + if ps.PolicyAssignmentOwner != nil { + objectMap["policyAssignmentOwner"] = ps.PolicyAssignmentOwner + } + if ps.PolicyAssignmentParameters != nil { + objectMap["policyAssignmentParameters"] = ps.PolicyAssignmentParameters + } + if ps.PolicyAssignmentScope != nil { + objectMap["policyAssignmentScope"] = ps.PolicyAssignmentScope + } + if ps.PolicyDefinitionName != nil { + objectMap["policyDefinitionName"] = ps.PolicyDefinitionName + } + if ps.PolicyDefinitionAction != nil { + objectMap["policyDefinitionAction"] = ps.PolicyDefinitionAction + } + if ps.PolicyDefinitionCategory != nil { + objectMap["policyDefinitionCategory"] = ps.PolicyDefinitionCategory + } + if ps.PolicySetDefinitionID != nil { + objectMap["policySetDefinitionId"] = ps.PolicySetDefinitionID + } + if ps.PolicySetDefinitionName != nil { + objectMap["policySetDefinitionName"] = ps.PolicySetDefinitionName + } + if ps.PolicySetDefinitionOwner != nil { + objectMap["policySetDefinitionOwner"] = ps.PolicySetDefinitionOwner + } + if ps.PolicySetDefinitionCategory != nil { + objectMap["policySetDefinitionCategory"] = ps.PolicySetDefinitionCategory + } + if ps.PolicySetDefinitionParameters != nil { + objectMap["policySetDefinitionParameters"] = ps.PolicySetDefinitionParameters + } + if ps.ManagementGroupIds != nil { + objectMap["managementGroupIds"] = ps.ManagementGroupIds + } + if ps.PolicyDefinitionReferenceID != nil { + objectMap["policyDefinitionReferenceId"] = ps.PolicyDefinitionReferenceID + } + if ps.ComplianceState != nil { + objectMap["complianceState"] = ps.ComplianceState + } + if ps.PolicyEvaluationDetails != nil { + objectMap["policyEvaluationDetails"] = ps.PolicyEvaluationDetails + } + if ps.PolicyDefinitionGroupNames != nil { + objectMap["policyDefinitionGroupNames"] = ps.PolicyDefinitionGroupNames + } + for k, v := range ps.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PolicyState struct. +func (ps *PolicyState) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if ps.AdditionalProperties == nil { + ps.AdditionalProperties = make(map[string]interface{}) + } + ps.AdditionalProperties[k] = additionalProperties + } + case "@odata.id": + if v != nil { + var odataID string + err = json.Unmarshal(*v, &odataID) + if err != nil { + return err + } + ps.OdataID = &odataID + } + case "@odata.context": + if v != nil { + var odataContext string + err = json.Unmarshal(*v, &odataContext) + if err != nil { + return err + } + ps.OdataContext = &odataContext + } + case "timestamp": + if v != nil { + var timestamp date.Time + err = json.Unmarshal(*v, ×tamp) + if err != nil { + return err + } + ps.Timestamp = ×tamp + } + case "resourceId": + if v != nil { + var resourceID string + err = json.Unmarshal(*v, &resourceID) + if err != nil { + return err + } + ps.ResourceID = &resourceID + } + case "policyAssignmentId": + if v != nil { + var policyAssignmentID string + err = json.Unmarshal(*v, &policyAssignmentID) + if err != nil { + return err + } + ps.PolicyAssignmentID = &policyAssignmentID + } + case "policyDefinitionId": + if v != nil { + var policyDefinitionID string + err = json.Unmarshal(*v, &policyDefinitionID) + if err != nil { + return err + } + ps.PolicyDefinitionID = &policyDefinitionID + } + case "effectiveParameters": + if v != nil { + var effectiveParameters string + err = json.Unmarshal(*v, &effectiveParameters) + if err != nil { + return err + } + ps.EffectiveParameters = &effectiveParameters + } + case "isCompliant": + if v != nil { + var isCompliant bool + err = json.Unmarshal(*v, &isCompliant) + if err != nil { + return err + } + ps.IsCompliant = &isCompliant + } + case "subscriptionId": + if v != nil { + var subscriptionID string + err = json.Unmarshal(*v, &subscriptionID) + if err != nil { + return err + } + ps.SubscriptionID = &subscriptionID + } + case "resourceType": + if v != nil { + var resourceType string + err = json.Unmarshal(*v, &resourceType) + if err != nil { + return err + } + ps.ResourceType = &resourceType + } + case "resourceLocation": + if v != nil { + var resourceLocation string + err = json.Unmarshal(*v, &resourceLocation) + if err != nil { + return err + } + ps.ResourceLocation = &resourceLocation + } + case "resourceGroup": + if v != nil { + var resourceGroup string + err = json.Unmarshal(*v, &resourceGroup) + if err != nil { + return err + } + ps.ResourceGroup = &resourceGroup + } + case "resourceTags": + if v != nil { + var resourceTags string + err = json.Unmarshal(*v, &resourceTags) + if err != nil { + return err + } + ps.ResourceTags = &resourceTags + } + case "policyAssignmentName": + if v != nil { + var policyAssignmentName string + err = json.Unmarshal(*v, &policyAssignmentName) + if err != nil { + return err + } + ps.PolicyAssignmentName = &policyAssignmentName + } + case "policyAssignmentOwner": + if v != nil { + var policyAssignmentOwner string + err = json.Unmarshal(*v, &policyAssignmentOwner) + if err != nil { + return err + } + ps.PolicyAssignmentOwner = &policyAssignmentOwner + } + case "policyAssignmentParameters": + if v != nil { + var policyAssignmentParameters string + err = json.Unmarshal(*v, &policyAssignmentParameters) + if err != nil { + return err + } + ps.PolicyAssignmentParameters = &policyAssignmentParameters + } + case "policyAssignmentScope": + if v != nil { + var policyAssignmentScope string + err = json.Unmarshal(*v, &policyAssignmentScope) + if err != nil { + return err + } + ps.PolicyAssignmentScope = &policyAssignmentScope + } + case "policyDefinitionName": + if v != nil { + var policyDefinitionName string + err = json.Unmarshal(*v, &policyDefinitionName) + if err != nil { + return err + } + ps.PolicyDefinitionName = &policyDefinitionName + } + case "policyDefinitionAction": + if v != nil { + var policyDefinitionAction string + err = json.Unmarshal(*v, &policyDefinitionAction) + if err != nil { + return err + } + ps.PolicyDefinitionAction = &policyDefinitionAction + } + case "policyDefinitionCategory": + if v != nil { + var policyDefinitionCategory string + err = json.Unmarshal(*v, &policyDefinitionCategory) + if err != nil { + return err + } + ps.PolicyDefinitionCategory = &policyDefinitionCategory + } + case "policySetDefinitionId": + if v != nil { + var policySetDefinitionID string + err = json.Unmarshal(*v, &policySetDefinitionID) + if err != nil { + return err + } + ps.PolicySetDefinitionID = &policySetDefinitionID + } + case "policySetDefinitionName": + if v != nil { + var policySetDefinitionName string + err = json.Unmarshal(*v, &policySetDefinitionName) + if err != nil { + return err + } + ps.PolicySetDefinitionName = &policySetDefinitionName + } + case "policySetDefinitionOwner": + if v != nil { + var policySetDefinitionOwner string + err = json.Unmarshal(*v, &policySetDefinitionOwner) + if err != nil { + return err + } + ps.PolicySetDefinitionOwner = &policySetDefinitionOwner + } + case "policySetDefinitionCategory": + if v != nil { + var policySetDefinitionCategory string + err = json.Unmarshal(*v, &policySetDefinitionCategory) + if err != nil { + return err + } + ps.PolicySetDefinitionCategory = &policySetDefinitionCategory + } + case "policySetDefinitionParameters": + if v != nil { + var policySetDefinitionParameters string + err = json.Unmarshal(*v, &policySetDefinitionParameters) + if err != nil { + return err + } + ps.PolicySetDefinitionParameters = &policySetDefinitionParameters + } + case "managementGroupIds": + if v != nil { + var managementGroupIds string + err = json.Unmarshal(*v, &managementGroupIds) + if err != nil { + return err + } + ps.ManagementGroupIds = &managementGroupIds + } + case "policyDefinitionReferenceId": + if v != nil { + var policyDefinitionReferenceID string + err = json.Unmarshal(*v, &policyDefinitionReferenceID) + if err != nil { + return err + } + ps.PolicyDefinitionReferenceID = &policyDefinitionReferenceID + } + case "complianceState": + if v != nil { + var complianceState string + err = json.Unmarshal(*v, &complianceState) + if err != nil { + return err + } + ps.ComplianceState = &complianceState + } + case "policyEvaluationDetails": + if v != nil { + var policyEvaluationDetails PolicyEvaluationDetails + err = json.Unmarshal(*v, &policyEvaluationDetails) + if err != nil { + return err + } + ps.PolicyEvaluationDetails = &policyEvaluationDetails + } + case "policyDefinitionGroupNames": + if v != nil { + var policyDefinitionGroupNames []string + err = json.Unmarshal(*v, &policyDefinitionGroupNames) + if err != nil { + return err + } + ps.PolicyDefinitionGroupNames = &policyDefinitionGroupNames + } + } + } + + return nil +} + +// PolicyStatesQueryResults query results. +type PolicyStatesQueryResults struct { + autorest.Response `json:"-"` + // OdataContext - OData context string; used by OData clients to resolve type information based on metadata. + OdataContext *string `json:"@odata.context,omitempty"` + // OdataCount - OData entity count; represents the number of policy state records returned. + OdataCount *int32 `json:"@odata.count,omitempty"` + // Value - Query results. + Value *[]PolicyState `json:"value,omitempty"` +} + +// PolicyTrackedResource policy tracked resource record. +type PolicyTrackedResource struct { + // TrackedResourceID - READ-ONLY; The ID of the policy tracked resource. + TrackedResourceID *string `json:"trackedResourceId,omitempty"` + // PolicyDetails - READ-ONLY; The details of the policy that require the tracked resource. + PolicyDetails *PolicyDetails `json:"policyDetails,omitempty"` + // CreatedBy - READ-ONLY; The details of the policy triggered deployment that created the tracked resource. + CreatedBy *TrackedResourceModificationDetails `json:"createdBy,omitempty"` + // LastModifiedBy - READ-ONLY; The details of the policy triggered deployment that modified the tracked resource. + LastModifiedBy *TrackedResourceModificationDetails `json:"lastModifiedBy,omitempty"` + // LastUpdateUtc - READ-ONLY; Timestamp of the last update to the tracked resource. + LastUpdateUtc *date.Time `json:"lastUpdateUtc,omitempty"` +} + +// PolicyTrackedResourcesQueryResults query results. +type PolicyTrackedResourcesQueryResults struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Query results. + Value *[]PolicyTrackedResource `json:"value,omitempty"` + // NextLink - READ-ONLY; The URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// PolicyTrackedResourcesQueryResultsIterator provides access to a complete listing of +// PolicyTrackedResource values. +type PolicyTrackedResourcesQueryResultsIterator struct { + i int + page PolicyTrackedResourcesQueryResultsPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PolicyTrackedResourcesQueryResultsIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyTrackedResourcesQueryResultsIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PolicyTrackedResourcesQueryResultsIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PolicyTrackedResourcesQueryResultsIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PolicyTrackedResourcesQueryResultsIterator) Response() PolicyTrackedResourcesQueryResults { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PolicyTrackedResourcesQueryResultsIterator) Value() PolicyTrackedResource { + if !iter.page.NotDone() { + return PolicyTrackedResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PolicyTrackedResourcesQueryResultsIterator type. +func NewPolicyTrackedResourcesQueryResultsIterator(page PolicyTrackedResourcesQueryResultsPage) PolicyTrackedResourcesQueryResultsIterator { + return PolicyTrackedResourcesQueryResultsIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ptrqr PolicyTrackedResourcesQueryResults) IsEmpty() bool { + return ptrqr.Value == nil || len(*ptrqr.Value) == 0 +} + +// policyTrackedResourcesQueryResultsPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ptrqr PolicyTrackedResourcesQueryResults) policyTrackedResourcesQueryResultsPreparer(ctx context.Context) (*http.Request, error) { + if ptrqr.NextLink == nil || len(to.String(ptrqr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ptrqr.NextLink))) +} + +// PolicyTrackedResourcesQueryResultsPage contains a page of PolicyTrackedResource values. +type PolicyTrackedResourcesQueryResultsPage struct { + fn func(context.Context, PolicyTrackedResourcesQueryResults) (PolicyTrackedResourcesQueryResults, error) + ptrqr PolicyTrackedResourcesQueryResults +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PolicyTrackedResourcesQueryResultsPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyTrackedResourcesQueryResultsPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.ptrqr) + if err != nil { + return err + } + page.ptrqr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PolicyTrackedResourcesQueryResultsPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PolicyTrackedResourcesQueryResultsPage) NotDone() bool { + return !page.ptrqr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PolicyTrackedResourcesQueryResultsPage) Response() PolicyTrackedResourcesQueryResults { + return page.ptrqr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PolicyTrackedResourcesQueryResultsPage) Values() []PolicyTrackedResource { + if page.ptrqr.IsEmpty() { + return nil + } + return *page.ptrqr.Value +} + +// Creates a new instance of the PolicyTrackedResourcesQueryResultsPage type. +func NewPolicyTrackedResourcesQueryResultsPage(getNextPage func(context.Context, PolicyTrackedResourcesQueryResults) (PolicyTrackedResourcesQueryResults, error)) PolicyTrackedResourcesQueryResultsPage { + return PolicyTrackedResourcesQueryResultsPage{fn: getNextPage} +} + +// QueryFailure error response. +type QueryFailure struct { + // Error - Error definition. + Error *QueryFailureError `json:"error,omitempty"` +} + +// QueryFailureError error definition. +type QueryFailureError struct { + // Code - READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; Description of the error. + Message *string `json:"message,omitempty"` +} + +// Remediation the remediation definition. +type Remediation struct { + autorest.Response `json:"-"` + // RemediationProperties - Properties for the remediation. + *RemediationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The ID of the remediation. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; The type of the remediation. + Type *string `json:"type,omitempty"` + // Name - READ-ONLY; The name of the remediation. + Name *string `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for Remediation. +func (r Remediation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.RemediationProperties != nil { + objectMap["properties"] = r.RemediationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Remediation struct. +func (r *Remediation) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var remediationProperties RemediationProperties + err = json.Unmarshal(*v, &remediationProperties) + if err != nil { + return err + } + r.RemediationProperties = &remediationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + r.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + r.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + r.Name = &name + } + } + } + + return nil +} + +// RemediationDeployment details of a single deployment created by the remediation. +type RemediationDeployment struct { + // RemediatedResourceID - READ-ONLY; Resource ID of the resource that is being remediated by the deployment. + RemediatedResourceID *string `json:"remediatedResourceId,omitempty"` + // DeploymentID - READ-ONLY; Resource ID of the template deployment that will remediate the resource. + DeploymentID *string `json:"deploymentId,omitempty"` + // Status - READ-ONLY; Status of the remediation deployment. + Status *string `json:"status,omitempty"` + // ResourceLocation - READ-ONLY; Location of the resource that is being remediated. + ResourceLocation *string `json:"resourceLocation,omitempty"` + // Error - READ-ONLY; Error encountered while remediated the resource. + Error *ErrorDefinition `json:"error,omitempty"` + // CreatedOn - READ-ONLY; The time at which the remediation was created. + CreatedOn *date.Time `json:"createdOn,omitempty"` + // LastUpdatedOn - READ-ONLY; The time at which the remediation deployment was last updated. + LastUpdatedOn *date.Time `json:"lastUpdatedOn,omitempty"` +} + +// RemediationDeploymentsListResult list of deployments for a remediation. +type RemediationDeploymentsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of deployments for the remediation. + Value *[]RemediationDeployment `json:"value,omitempty"` + // NextLink - READ-ONLY; The URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// RemediationDeploymentsListResultIterator provides access to a complete listing of RemediationDeployment +// values. +type RemediationDeploymentsListResultIterator struct { + i int + page RemediationDeploymentsListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RemediationDeploymentsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationDeploymentsListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RemediationDeploymentsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RemediationDeploymentsListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RemediationDeploymentsListResultIterator) Response() RemediationDeploymentsListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RemediationDeploymentsListResultIterator) Value() RemediationDeployment { + if !iter.page.NotDone() { + return RemediationDeployment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RemediationDeploymentsListResultIterator type. +func NewRemediationDeploymentsListResultIterator(page RemediationDeploymentsListResultPage) RemediationDeploymentsListResultIterator { + return RemediationDeploymentsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rdlr RemediationDeploymentsListResult) IsEmpty() bool { + return rdlr.Value == nil || len(*rdlr.Value) == 0 +} + +// remediationDeploymentsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rdlr RemediationDeploymentsListResult) remediationDeploymentsListResultPreparer(ctx context.Context) (*http.Request, error) { + if rdlr.NextLink == nil || len(to.String(rdlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rdlr.NextLink))) +} + +// RemediationDeploymentsListResultPage contains a page of RemediationDeployment values. +type RemediationDeploymentsListResultPage struct { + fn func(context.Context, RemediationDeploymentsListResult) (RemediationDeploymentsListResult, error) + rdlr RemediationDeploymentsListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RemediationDeploymentsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationDeploymentsListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.rdlr) + if err != nil { + return err + } + page.rdlr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RemediationDeploymentsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RemediationDeploymentsListResultPage) NotDone() bool { + return !page.rdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RemediationDeploymentsListResultPage) Response() RemediationDeploymentsListResult { + return page.rdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RemediationDeploymentsListResultPage) Values() []RemediationDeployment { + if page.rdlr.IsEmpty() { + return nil + } + return *page.rdlr.Value +} + +// Creates a new instance of the RemediationDeploymentsListResultPage type. +func NewRemediationDeploymentsListResultPage(getNextPage func(context.Context, RemediationDeploymentsListResult) (RemediationDeploymentsListResult, error)) RemediationDeploymentsListResultPage { + return RemediationDeploymentsListResultPage{fn: getNextPage} +} + +// RemediationDeploymentSummary the deployment status summary for all deployments created by the +// remediation. +type RemediationDeploymentSummary struct { + // TotalDeployments - The number of deployments required by the remediation. + TotalDeployments *int32 `json:"totalDeployments,omitempty"` + // SuccessfulDeployments - The number of deployments required by the remediation that have succeeded. + SuccessfulDeployments *int32 `json:"successfulDeployments,omitempty"` + // FailedDeployments - The number of deployments required by the remediation that have failed. + FailedDeployments *int32 `json:"failedDeployments,omitempty"` +} + +// RemediationFilters the filters that will be applied to determine which resources to remediate. +type RemediationFilters struct { + // Locations - The resource locations that will be remediated. + Locations *[]string `json:"locations,omitempty"` +} + +// RemediationListResult list of remediations. +type RemediationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of remediation definitions. + Value *[]Remediation `json:"value,omitempty"` + // NextLink - READ-ONLY; The URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// RemediationListResultIterator provides access to a complete listing of Remediation values. +type RemediationListResultIterator struct { + i int + page RemediationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RemediationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RemediationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RemediationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RemediationListResultIterator) Response() RemediationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RemediationListResultIterator) Value() Remediation { + if !iter.page.NotDone() { + return Remediation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RemediationListResultIterator type. +func NewRemediationListResultIterator(page RemediationListResultPage) RemediationListResultIterator { + return RemediationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rlr RemediationListResult) IsEmpty() bool { + return rlr.Value == nil || len(*rlr.Value) == 0 +} + +// remediationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rlr RemediationListResult) remediationListResultPreparer(ctx context.Context) (*http.Request, error) { + if rlr.NextLink == nil || len(to.String(rlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rlr.NextLink))) +} + +// RemediationListResultPage contains a page of Remediation values. +type RemediationListResultPage struct { + fn func(context.Context, RemediationListResult) (RemediationListResult, error) + rlr RemediationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RemediationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.rlr) + if err != nil { + return err + } + page.rlr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RemediationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RemediationListResultPage) NotDone() bool { + return !page.rlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RemediationListResultPage) Response() RemediationListResult { + return page.rlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RemediationListResultPage) Values() []Remediation { + if page.rlr.IsEmpty() { + return nil + } + return *page.rlr.Value +} + +// Creates a new instance of the RemediationListResultPage type. +func NewRemediationListResultPage(getNextPage func(context.Context, RemediationListResult) (RemediationListResult, error)) RemediationListResultPage { + return RemediationListResultPage{fn: getNextPage} +} + +// RemediationProperties the remediation properties. +type RemediationProperties struct { + // PolicyAssignmentID - The resource ID of the policy assignment that should be remediated. + PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"` + // PolicyDefinitionReferenceID - The policy definition reference ID of the individual definition that should be remediated. Required when the policy assignment being remediated assigns a policy set definition. + PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` + // ProvisioningState - READ-ONLY; The status of the remediation. + ProvisioningState *string `json:"provisioningState,omitempty"` + // CreatedOn - READ-ONLY; The time at which the remediation was created. + CreatedOn *date.Time `json:"createdOn,omitempty"` + // LastUpdatedOn - READ-ONLY; The time at which the remediation was last updated. + LastUpdatedOn *date.Time `json:"lastUpdatedOn,omitempty"` + // Filters - The filters that will be applied to determine which resources to remediate. + Filters *RemediationFilters `json:"filters,omitempty"` + // DeploymentStatus - The deployment status summary for all deployments created by the remediation. + DeploymentStatus *RemediationDeploymentSummary `json:"deploymentStatus,omitempty"` +} + +// String ... +type String struct { + autorest.Response `json:"-"` + Value *string `json:"value,omitempty"` +} + +// SummarizeResults summarize action results. +type SummarizeResults struct { + autorest.Response `json:"-"` + // OdataContext - OData context string; used by OData clients to resolve type information based on metadata. + OdataContext *string `json:"@odata.context,omitempty"` + // OdataCount - OData entity count; represents the number of summaries returned; always set to 1. + OdataCount *int32 `json:"@odata.count,omitempty"` + // Value - Summarize action results. + Value *[]Summary `json:"value,omitempty"` +} + +// Summary summary results. +type Summary struct { + // OdataID - OData entity ID; always set to null since summaries do not have an entity ID. + OdataID *string `json:"@odata.id,omitempty"` + // OdataContext - OData context string; used by OData clients to resolve type information based on metadata. + OdataContext *string `json:"@odata.context,omitempty"` + // Results - Compliance summary for all policy assignments. + Results *SummaryResults `json:"results,omitempty"` + // PolicyAssignments - Policy assignments summary. + PolicyAssignments *[]PolicyAssignmentSummary `json:"policyAssignments,omitempty"` +} + +// SummaryResults compliance summary on a particular summary level. +type SummaryResults struct { + // QueryResultsURI - HTTP POST URI for queryResults action on Microsoft.PolicyInsights to retrieve raw results for the compliance summary. This property will not be available by default in future API versions, but could be queried explicitly. + QueryResultsURI *string `json:"queryResultsUri,omitempty"` + // NonCompliantResources - Number of non-compliant resources. + NonCompliantResources *int32 `json:"nonCompliantResources,omitempty"` + // NonCompliantPolicies - Number of non-compliant policies. + NonCompliantPolicies *int32 `json:"nonCompliantPolicies,omitempty"` + // ResourceDetails - The resources summary at this level. + ResourceDetails *[]ComplianceDetail `json:"resourceDetails,omitempty"` + // PolicyDetails - The policy artifact summary at this level. For query scope level, it represents policy assignment summary. For policy assignment level, it represents policy definitions summary. + PolicyDetails *[]ComplianceDetail `json:"policyDetails,omitempty"` + // PolicyGroupDetails - The policy definition group summary at this level. + PolicyGroupDetails *[]ComplianceDetail `json:"policyGroupDetails,omitempty"` +} + +// TrackedResourceModificationDetails the details of the policy triggered deployment that created or +// modified the tracked resource. +type TrackedResourceModificationDetails struct { + // PolicyDetails - READ-ONLY; The details of the policy that created or modified the tracked resource. + PolicyDetails *PolicyDetails `json:"policyDetails,omitempty"` + // DeploymentID - READ-ONLY; The ID of the deployment that created or modified the tracked resource. + DeploymentID *string `json:"deploymentId,omitempty"` + // DeploymentTime - READ-ONLY; Timestamp of the deployment that created or modified the tracked resource. + DeploymentTime *date.Time `json:"deploymentTime,omitempty"` +} + +// TypedErrorInfo scenario specific error details. +type TypedErrorInfo struct { + // Type - READ-ONLY; The type of included error details. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The scenario specific error details. + Info interface{} `json:"info,omitempty"` +} diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/operations.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/operations.go new file mode 100644 index 000000000000..3b7784383db2 --- /dev/null +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/operations.go @@ -0,0 +1,109 @@ +package policyinsights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the client for the Operations methods of the Policyinsights service. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient() OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. +func NewOperationsClientWithBaseURI(baseURI string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI)} +} + +// List lists available operations. +func (client OperationsClient) List(ctx context.Context) (result OperationsListResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.PolicyInsights/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationsListResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/policyevents.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/policyevents.go new file mode 100644 index 000000000000..d4c4421f66e2 --- /dev/null +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/policyevents.go @@ -0,0 +1,1049 @@ +package policyinsights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PolicyEventsClient is the client for the PolicyEvents methods of the Policyinsights service. +type PolicyEventsClient struct { + BaseClient +} + +// NewPolicyEventsClient creates an instance of the PolicyEventsClient client. +func NewPolicyEventsClient() PolicyEventsClient { + return NewPolicyEventsClientWithBaseURI(DefaultBaseURI) +} + +// NewPolicyEventsClientWithBaseURI creates an instance of the PolicyEventsClient client. +func NewPolicyEventsClientWithBaseURI(baseURI string) PolicyEventsClient { + return PolicyEventsClient{NewWithBaseURI(baseURI)} +} + +// GetMetadata gets OData metadata XML document. +// Parameters: +// scope - a valid scope, i.e. management group, subscription, resource group, or resource ID. Scope used has +// no effect on metadata returned. +func (client PolicyEventsClient) GetMetadata(ctx context.Context, scope string) (result String, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsClient.GetMetadata") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetMetadataPreparer(ctx, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "GetMetadata", nil, "Failure preparing request") + return + } + + resp, err := client.GetMetadataSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "GetMetadata", resp, "Failure sending request") + return + } + + result, err = client.GetMetadataResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "GetMetadata", resp, "Failure responding to request") + } + + return +} + +// GetMetadataPreparer prepares the GetMetadata request. +func (client PolicyEventsClient) GetMetadataPreparer(ctx context.Context, scope string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2018-04-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.PolicyInsights/policyEvents/$metadata", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetMetadataSender sends the GetMetadata request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyEventsClient) GetMetadataSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetMetadataResponder handles the response to the GetMetadata request. The method always +// closes the http.Response Body. +func (client PolicyEventsClient) GetMetadataResponder(resp *http.Response) (result String, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListQueryResultsForManagementGroup queries policy events for the resources under the management group. +// Parameters: +// managementGroupName - management group name. +// top - maximum number of records to return. +// orderBy - ordering expression using OData notation. One or more comma-separated column names with an +// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". +// selectParameter - select expression using OData notation. Limits the columns on each record to just those +// requested, e.g. "$select=PolicyAssignmentId, ResourceId". +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +// apply - oData apply expression for aggregations. +func (client PolicyEventsClient) ListQueryResultsForManagementGroup(ctx context.Context, managementGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyEventsQueryResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsClient.ListQueryResultsForManagementGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyEventsClient", "ListQueryResultsForManagementGroup", err.Error()) + } + + req, err := client.ListQueryResultsForManagementGroupPreparer(ctx, managementGroupName, top, orderBy, selectParameter, from, toParameter, filter, apply) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForManagementGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForManagementGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForManagementGroup", resp, "Failure sending request") + return + } + + result, err = client.ListQueryResultsForManagementGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForManagementGroup", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForManagementGroupPreparer prepares the ListQueryResultsForManagementGroup request. +func (client PolicyEventsClient) ListQueryResultsForManagementGroupPreparer(ctx context.Context, managementGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managementGroupName": autorest.Encode("path", managementGroupName), + "managementGroupsNamespace": autorest.Encode("path", "Microsoft.Management"), + "policyEventsResource": autorest.Encode("path", "default"), + } + + const APIVersion = "2018-04-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderBy) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderBy) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(apply) > 0 { + queryParameters["$apply"] = autorest.Encode("query", apply) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForManagementGroupSender sends the ListQueryResultsForManagementGroup request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyEventsClient) ListQueryResultsForManagementGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForManagementGroupResponder handles the response to the ListQueryResultsForManagementGroup request. The method always +// closes the http.Response Body. +func (client PolicyEventsClient) ListQueryResultsForManagementGroupResponder(resp *http.Response) (result PolicyEventsQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListQueryResultsForPolicyDefinition queries policy events for the subscription level policy definition. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// policyDefinitionName - policy definition name. +// top - maximum number of records to return. +// orderBy - ordering expression using OData notation. One or more comma-separated column names with an +// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". +// selectParameter - select expression using OData notation. Limits the columns on each record to just those +// requested, e.g. "$select=PolicyAssignmentId, ResourceId". +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +// apply - oData apply expression for aggregations. +func (client PolicyEventsClient) ListQueryResultsForPolicyDefinition(ctx context.Context, subscriptionID string, policyDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyEventsQueryResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsClient.ListQueryResultsForPolicyDefinition") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyEventsClient", "ListQueryResultsForPolicyDefinition", err.Error()) + } + + req, err := client.ListQueryResultsForPolicyDefinitionPreparer(ctx, subscriptionID, policyDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForPolicyDefinition", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForPolicyDefinitionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForPolicyDefinition", resp, "Failure sending request") + return + } + + result, err = client.ListQueryResultsForPolicyDefinitionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForPolicyDefinition", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForPolicyDefinitionPreparer prepares the ListQueryResultsForPolicyDefinition request. +func (client PolicyEventsClient) ListQueryResultsForPolicyDefinitionPreparer(ctx context.Context, subscriptionID string, policyDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), + "policyDefinitionName": autorest.Encode("path", policyDefinitionName), + "policyEventsResource": autorest.Encode("path", "default"), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-04-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderBy) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderBy) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(apply) > 0 { + queryParameters["$apply"] = autorest.Encode("query", apply) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForPolicyDefinitionSender sends the ListQueryResultsForPolicyDefinition request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyEventsClient) ListQueryResultsForPolicyDefinitionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForPolicyDefinitionResponder handles the response to the ListQueryResultsForPolicyDefinition request. The method always +// closes the http.Response Body. +func (client PolicyEventsClient) ListQueryResultsForPolicyDefinitionResponder(resp *http.Response) (result PolicyEventsQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListQueryResultsForPolicySetDefinition queries policy events for the subscription level policy set definition. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// policySetDefinitionName - policy set definition name. +// top - maximum number of records to return. +// orderBy - ordering expression using OData notation. One or more comma-separated column names with an +// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". +// selectParameter - select expression using OData notation. Limits the columns on each record to just those +// requested, e.g. "$select=PolicyAssignmentId, ResourceId". +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +// apply - oData apply expression for aggregations. +func (client PolicyEventsClient) ListQueryResultsForPolicySetDefinition(ctx context.Context, subscriptionID string, policySetDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyEventsQueryResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsClient.ListQueryResultsForPolicySetDefinition") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyEventsClient", "ListQueryResultsForPolicySetDefinition", err.Error()) + } + + req, err := client.ListQueryResultsForPolicySetDefinitionPreparer(ctx, subscriptionID, policySetDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForPolicySetDefinition", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForPolicySetDefinitionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForPolicySetDefinition", resp, "Failure sending request") + return + } + + result, err = client.ListQueryResultsForPolicySetDefinitionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForPolicySetDefinition", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForPolicySetDefinitionPreparer prepares the ListQueryResultsForPolicySetDefinition request. +func (client PolicyEventsClient) ListQueryResultsForPolicySetDefinitionPreparer(ctx context.Context, subscriptionID string, policySetDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), + "policyEventsResource": autorest.Encode("path", "default"), + "policySetDefinitionName": autorest.Encode("path", policySetDefinitionName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-04-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderBy) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderBy) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(apply) > 0 { + queryParameters["$apply"] = autorest.Encode("query", apply) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForPolicySetDefinitionSender sends the ListQueryResultsForPolicySetDefinition request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyEventsClient) ListQueryResultsForPolicySetDefinitionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForPolicySetDefinitionResponder handles the response to the ListQueryResultsForPolicySetDefinition request. The method always +// closes the http.Response Body. +func (client PolicyEventsClient) ListQueryResultsForPolicySetDefinitionResponder(resp *http.Response) (result PolicyEventsQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListQueryResultsForResource queries policy events for the resource. +// Parameters: +// resourceID - resource ID. +// top - maximum number of records to return. +// orderBy - ordering expression using OData notation. One or more comma-separated column names with an +// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". +// selectParameter - select expression using OData notation. Limits the columns on each record to just those +// requested, e.g. "$select=PolicyAssignmentId, ResourceId". +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +// apply - oData apply expression for aggregations. +func (client PolicyEventsClient) ListQueryResultsForResource(ctx context.Context, resourceID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyEventsQueryResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsClient.ListQueryResultsForResource") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyEventsClient", "ListQueryResultsForResource", err.Error()) + } + + req, err := client.ListQueryResultsForResourcePreparer(ctx, resourceID, top, orderBy, selectParameter, from, toParameter, filter, apply) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResource", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResource", resp, "Failure sending request") + return + } + + result, err = client.ListQueryResultsForResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResource", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForResourcePreparer prepares the ListQueryResultsForResource request. +func (client PolicyEventsClient) ListQueryResultsForResourcePreparer(ctx context.Context, resourceID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyEventsResource": autorest.Encode("path", "default"), + "resourceId": resourceID, + } + + const APIVersion = "2018-04-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderBy) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderBy) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(apply) > 0 { + queryParameters["$apply"] = autorest.Encode("query", apply) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForResourceSender sends the ListQueryResultsForResource request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyEventsClient) ListQueryResultsForResourceSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForResourceResponder handles the response to the ListQueryResultsForResource request. The method always +// closes the http.Response Body. +func (client PolicyEventsClient) ListQueryResultsForResourceResponder(resp *http.Response) (result PolicyEventsQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListQueryResultsForResourceGroup queries policy events for the resources under the resource group. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// resourceGroupName - resource group name. +// top - maximum number of records to return. +// orderBy - ordering expression using OData notation. One or more comma-separated column names with an +// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". +// selectParameter - select expression using OData notation. Limits the columns on each record to just those +// requested, e.g. "$select=PolicyAssignmentId, ResourceId". +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +// apply - oData apply expression for aggregations. +func (client PolicyEventsClient) ListQueryResultsForResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyEventsQueryResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsClient.ListQueryResultsForResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyEventsClient", "ListQueryResultsForResourceGroup", err.Error()) + } + + req, err := client.ListQueryResultsForResourceGroupPreparer(ctx, subscriptionID, resourceGroupName, top, orderBy, selectParameter, from, toParameter, filter, apply) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListQueryResultsForResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForResourceGroupPreparer prepares the ListQueryResultsForResourceGroup request. +func (client PolicyEventsClient) ListQueryResultsForResourceGroupPreparer(ctx context.Context, subscriptionID string, resourceGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyEventsResource": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-04-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderBy) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderBy) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(apply) > 0 { + queryParameters["$apply"] = autorest.Encode("query", apply) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForResourceGroupSender sends the ListQueryResultsForResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyEventsClient) ListQueryResultsForResourceGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForResourceGroupResponder handles the response to the ListQueryResultsForResourceGroup request. The method always +// closes the http.Response Body. +func (client PolicyEventsClient) ListQueryResultsForResourceGroupResponder(resp *http.Response) (result PolicyEventsQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignment queries policy events for the resource group level policy +// assignment. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// resourceGroupName - resource group name. +// policyAssignmentName - policy assignment name. +// top - maximum number of records to return. +// orderBy - ordering expression using OData notation. One or more comma-separated column names with an +// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". +// selectParameter - select expression using OData notation. Limits the columns on each record to just those +// requested, e.g. "$select=PolicyAssignmentId, ResourceId". +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +// apply - oData apply expression for aggregations. +func (client PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssignment(ctx context.Context, subscriptionID string, resourceGroupName string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyEventsQueryResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsClient.ListQueryResultsForResourceGroupLevelPolicyAssignment") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyEventsClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", err.Error()) + } + + req, err := client.ListQueryResultsForResourceGroupLevelPolicyAssignmentPreparer(ctx, subscriptionID, resourceGroupName, policyAssignmentName, top, orderBy, selectParameter, from, toParameter, filter, apply) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForResourceGroupLevelPolicyAssignmentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", resp, "Failure sending request") + return + } + + result, err = client.ListQueryResultsForResourceGroupLevelPolicyAssignmentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignmentPreparer prepares the ListQueryResultsForResourceGroupLevelPolicyAssignment request. +func (client PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssignmentPreparer(ctx context.Context, subscriptionID string, resourceGroupName string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), + "policyAssignmentName": autorest.Encode("path", policyAssignmentName), + "policyEventsResource": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-04-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderBy) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderBy) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(apply) > 0 { + queryParameters["$apply"] = autorest.Encode("query", apply) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignmentSender sends the ListQueryResultsForResourceGroupLevelPolicyAssignment request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssignmentSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignmentResponder handles the response to the ListQueryResultsForResourceGroupLevelPolicyAssignment request. The method always +// closes the http.Response Body. +func (client PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssignmentResponder(resp *http.Response) (result PolicyEventsQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListQueryResultsForSubscription queries policy events for the resources under the subscription. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// top - maximum number of records to return. +// orderBy - ordering expression using OData notation. One or more comma-separated column names with an +// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". +// selectParameter - select expression using OData notation. Limits the columns on each record to just those +// requested, e.g. "$select=PolicyAssignmentId, ResourceId". +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +// apply - oData apply expression for aggregations. +func (client PolicyEventsClient) ListQueryResultsForSubscription(ctx context.Context, subscriptionID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyEventsQueryResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsClient.ListQueryResultsForSubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyEventsClient", "ListQueryResultsForSubscription", err.Error()) + } + + req, err := client.ListQueryResultsForSubscriptionPreparer(ctx, subscriptionID, top, orderBy, selectParameter, from, toParameter, filter, apply) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForSubscription", resp, "Failure sending request") + return + } + + result, err = client.ListQueryResultsForSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForSubscription", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForSubscriptionPreparer prepares the ListQueryResultsForSubscription request. +func (client PolicyEventsClient) ListQueryResultsForSubscriptionPreparer(ctx context.Context, subscriptionID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyEventsResource": autorest.Encode("path", "default"), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-04-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderBy) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderBy) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(apply) > 0 { + queryParameters["$apply"] = autorest.Encode("query", apply) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForSubscriptionSender sends the ListQueryResultsForSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyEventsClient) ListQueryResultsForSubscriptionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForSubscriptionResponder handles the response to the ListQueryResultsForSubscription request. The method always +// closes the http.Response Body. +func (client PolicyEventsClient) ListQueryResultsForSubscriptionResponder(resp *http.Response) (result PolicyEventsQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignment queries policy events for the subscription level policy +// assignment. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// policyAssignmentName - policy assignment name. +// top - maximum number of records to return. +// orderBy - ordering expression using OData notation. One or more comma-separated column names with an +// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". +// selectParameter - select expression using OData notation. Limits the columns on each record to just those +// requested, e.g. "$select=PolicyAssignmentId, ResourceId". +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +// apply - oData apply expression for aggregations. +func (client PolicyEventsClient) ListQueryResultsForSubscriptionLevelPolicyAssignment(ctx context.Context, subscriptionID string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyEventsQueryResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsClient.ListQueryResultsForSubscriptionLevelPolicyAssignment") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyEventsClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", err.Error()) + } + + req, err := client.ListQueryResultsForSubscriptionLevelPolicyAssignmentPreparer(ctx, subscriptionID, policyAssignmentName, top, orderBy, selectParameter, from, toParameter, filter, apply) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForSubscriptionLevelPolicyAssignmentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", resp, "Failure sending request") + return + } + + result, err = client.ListQueryResultsForSubscriptionLevelPolicyAssignmentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignmentPreparer prepares the ListQueryResultsForSubscriptionLevelPolicyAssignment request. +func (client PolicyEventsClient) ListQueryResultsForSubscriptionLevelPolicyAssignmentPreparer(ctx context.Context, subscriptionID string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), + "policyAssignmentName": autorest.Encode("path", policyAssignmentName), + "policyEventsResource": autorest.Encode("path", "default"), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-04-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderBy) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderBy) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(apply) > 0 { + queryParameters["$apply"] = autorest.Encode("query", apply) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignmentSender sends the ListQueryResultsForSubscriptionLevelPolicyAssignment request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyEventsClient) ListQueryResultsForSubscriptionLevelPolicyAssignmentSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignmentResponder handles the response to the ListQueryResultsForSubscriptionLevelPolicyAssignment request. The method always +// closes the http.Response Body. +func (client PolicyEventsClient) ListQueryResultsForSubscriptionLevelPolicyAssignmentResponder(resp *http.Response) (result PolicyEventsQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/policyinsightsapi/interfaces.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/policyinsightsapi/interfaces.go new file mode 100644 index 000000000000..aeb5b3244156 --- /dev/null +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/policyinsightsapi/interfaces.go @@ -0,0 +1,108 @@ +package policyinsightsapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/policyinsights/mgmt/2019-10-01/policyinsights" + "github.com/Azure/go-autorest/autorest/date" +) + +// PolicyTrackedResourcesClientAPI contains the set of methods on the PolicyTrackedResourcesClient type. +type PolicyTrackedResourcesClientAPI interface { + ListQueryResultsForManagementGroup(ctx context.Context, managementGroupName string, top *int32, filter string) (result policyinsights.PolicyTrackedResourcesQueryResultsPage, err error) + ListQueryResultsForResource(ctx context.Context, resourceID string, top *int32, filter string) (result policyinsights.PolicyTrackedResourcesQueryResultsPage, err error) + ListQueryResultsForResourceGroup(ctx context.Context, resourceGroupName string, subscriptionID string, top *int32, filter string) (result policyinsights.PolicyTrackedResourcesQueryResultsPage, err error) + ListQueryResultsForSubscription(ctx context.Context, subscriptionID string, top *int32, filter string) (result policyinsights.PolicyTrackedResourcesQueryResultsPage, err error) +} + +var _ PolicyTrackedResourcesClientAPI = (*policyinsights.PolicyTrackedResourcesClient)(nil) + +// RemediationsClientAPI contains the set of methods on the RemediationsClient type. +type RemediationsClientAPI interface { + CancelAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string) (result policyinsights.Remediation, err error) + CancelAtResource(ctx context.Context, resourceID string, remediationName string) (result policyinsights.Remediation, err error) + CancelAtResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, remediationName string) (result policyinsights.Remediation, err error) + CancelAtSubscription(ctx context.Context, subscriptionID string, remediationName string) (result policyinsights.Remediation, err error) + CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string, parameters policyinsights.Remediation) (result policyinsights.Remediation, err error) + CreateOrUpdateAtResource(ctx context.Context, resourceID string, remediationName string, parameters policyinsights.Remediation) (result policyinsights.Remediation, err error) + CreateOrUpdateAtResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, remediationName string, parameters policyinsights.Remediation) (result policyinsights.Remediation, err error) + CreateOrUpdateAtSubscription(ctx context.Context, subscriptionID string, remediationName string, parameters policyinsights.Remediation) (result policyinsights.Remediation, err error) + DeleteAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string) (result policyinsights.Remediation, err error) + DeleteAtResource(ctx context.Context, resourceID string, remediationName string) (result policyinsights.Remediation, err error) + DeleteAtResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, remediationName string) (result policyinsights.Remediation, err error) + DeleteAtSubscription(ctx context.Context, subscriptionID string, remediationName string) (result policyinsights.Remediation, err error) + GetAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string) (result policyinsights.Remediation, err error) + GetAtResource(ctx context.Context, resourceID string, remediationName string) (result policyinsights.Remediation, err error) + GetAtResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, remediationName string) (result policyinsights.Remediation, err error) + GetAtSubscription(ctx context.Context, subscriptionID string, remediationName string) (result policyinsights.Remediation, err error) + ListDeploymentsAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string, top *int32) (result policyinsights.RemediationDeploymentsListResultPage, err error) + ListDeploymentsAtResource(ctx context.Context, resourceID string, remediationName string, top *int32) (result policyinsights.RemediationDeploymentsListResultPage, err error) + ListDeploymentsAtResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, remediationName string, top *int32) (result policyinsights.RemediationDeploymentsListResultPage, err error) + ListDeploymentsAtSubscription(ctx context.Context, subscriptionID string, remediationName string, top *int32) (result policyinsights.RemediationDeploymentsListResultPage, err error) + ListForManagementGroup(ctx context.Context, managementGroupID string, top *int32, filter string) (result policyinsights.RemediationListResultPage, err error) + ListForResource(ctx context.Context, resourceID string, top *int32, filter string) (result policyinsights.RemediationListResultPage, err error) + ListForResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, top *int32, filter string) (result policyinsights.RemediationListResultPage, err error) + ListForSubscription(ctx context.Context, subscriptionID string, top *int32, filter string) (result policyinsights.RemediationListResultPage, err error) +} + +var _ RemediationsClientAPI = (*policyinsights.RemediationsClient)(nil) + +// PolicyEventsClientAPI contains the set of methods on the PolicyEventsClient type. +type PolicyEventsClientAPI interface { + GetMetadata(ctx context.Context, scope string) (result policyinsights.String, err error) + ListQueryResultsForManagementGroup(ctx context.Context, managementGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result policyinsights.PolicyEventsQueryResults, err error) + ListQueryResultsForPolicyDefinition(ctx context.Context, subscriptionID string, policyDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result policyinsights.PolicyEventsQueryResults, err error) + ListQueryResultsForPolicySetDefinition(ctx context.Context, subscriptionID string, policySetDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result policyinsights.PolicyEventsQueryResults, err error) + ListQueryResultsForResource(ctx context.Context, resourceID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result policyinsights.PolicyEventsQueryResults, err error) + ListQueryResultsForResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result policyinsights.PolicyEventsQueryResults, err error) + ListQueryResultsForResourceGroupLevelPolicyAssignment(ctx context.Context, subscriptionID string, resourceGroupName string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result policyinsights.PolicyEventsQueryResults, err error) + ListQueryResultsForSubscription(ctx context.Context, subscriptionID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result policyinsights.PolicyEventsQueryResults, err error) + ListQueryResultsForSubscriptionLevelPolicyAssignment(ctx context.Context, subscriptionID string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result policyinsights.PolicyEventsQueryResults, err error) +} + +var _ PolicyEventsClientAPI = (*policyinsights.PolicyEventsClient)(nil) + +// PolicyStatesClientAPI contains the set of methods on the PolicyStatesClient type. +type PolicyStatesClientAPI interface { + ListQueryResultsForManagementGroup(ctx context.Context, policyStatesResource policyinsights.PolicyStatesResource, managementGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result policyinsights.PolicyStatesQueryResults, err error) + ListQueryResultsForPolicyDefinition(ctx context.Context, policyStatesResource policyinsights.PolicyStatesResource, subscriptionID string, policyDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result policyinsights.PolicyStatesQueryResults, err error) + ListQueryResultsForPolicySetDefinition(ctx context.Context, policyStatesResource policyinsights.PolicyStatesResource, subscriptionID string, policySetDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result policyinsights.PolicyStatesQueryResults, err error) + ListQueryResultsForResource(ctx context.Context, policyStatesResource policyinsights.PolicyStatesResource, resourceID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, expand string) (result policyinsights.PolicyStatesQueryResults, err error) + ListQueryResultsForResourceGroup(ctx context.Context, policyStatesResource policyinsights.PolicyStatesResource, subscriptionID string, resourceGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result policyinsights.PolicyStatesQueryResults, err error) + ListQueryResultsForResourceGroupLevelPolicyAssignment(ctx context.Context, policyStatesResource policyinsights.PolicyStatesResource, subscriptionID string, resourceGroupName string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result policyinsights.PolicyStatesQueryResults, err error) + ListQueryResultsForSubscription(ctx context.Context, policyStatesResource policyinsights.PolicyStatesResource, subscriptionID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result policyinsights.PolicyStatesQueryResults, err error) + ListQueryResultsForSubscriptionLevelPolicyAssignment(ctx context.Context, policyStatesResource policyinsights.PolicyStatesResource, subscriptionID string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result policyinsights.PolicyStatesQueryResults, err error) + SummarizeForManagementGroup(ctx context.Context, managementGroupName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result policyinsights.SummarizeResults, err error) + SummarizeForPolicyDefinition(ctx context.Context, subscriptionID string, policyDefinitionName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result policyinsights.SummarizeResults, err error) + SummarizeForPolicySetDefinition(ctx context.Context, subscriptionID string, policySetDefinitionName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result policyinsights.SummarizeResults, err error) + SummarizeForResource(ctx context.Context, resourceID string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result policyinsights.SummarizeResults, err error) + SummarizeForResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result policyinsights.SummarizeResults, err error) + SummarizeForResourceGroupLevelPolicyAssignment(ctx context.Context, subscriptionID string, resourceGroupName string, policyAssignmentName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result policyinsights.SummarizeResults, err error) + SummarizeForSubscription(ctx context.Context, subscriptionID string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result policyinsights.SummarizeResults, err error) + SummarizeForSubscriptionLevelPolicyAssignment(ctx context.Context, subscriptionID string, policyAssignmentName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result policyinsights.SummarizeResults, err error) +} + +var _ PolicyStatesClientAPI = (*policyinsights.PolicyStatesClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result policyinsights.OperationsListResults, err error) +} + +var _ OperationsClientAPI = (*policyinsights.OperationsClient)(nil) diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/policystates.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/policystates.go new file mode 100644 index 000000000000..3ddb69eb24dc --- /dev/null +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/policystates.go @@ -0,0 +1,1813 @@ +package policyinsights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PolicyStatesClient is the client for the PolicyStates methods of the Policyinsights service. +type PolicyStatesClient struct { + BaseClient +} + +// NewPolicyStatesClient creates an instance of the PolicyStatesClient client. +func NewPolicyStatesClient() PolicyStatesClient { + return NewPolicyStatesClientWithBaseURI(DefaultBaseURI) +} + +// NewPolicyStatesClientWithBaseURI creates an instance of the PolicyStatesClient client. +func NewPolicyStatesClientWithBaseURI(baseURI string) PolicyStatesClient { + return PolicyStatesClient{NewWithBaseURI(baseURI)} +} + +// ListQueryResultsForManagementGroup queries policy states for the resources under the management group. +// Parameters: +// policyStatesResource - the virtual resource under PolicyStates resource type. In a given time range, +// 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). +// managementGroupName - management group name. +// top - maximum number of records to return. +// orderBy - ordering expression using OData notation. One or more comma-separated column names with an +// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". +// selectParameter - select expression using OData notation. Limits the columns on each record to just those +// requested, e.g. "$select=PolicyAssignmentId, ResourceId". +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +// apply - oData apply expression for aggregations. +func (client PolicyStatesClient) ListQueryResultsForManagementGroup(ctx context.Context, policyStatesResource PolicyStatesResource, managementGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyStatesQueryResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForManagementGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForManagementGroup", err.Error()) + } + + req, err := client.ListQueryResultsForManagementGroupPreparer(ctx, policyStatesResource, managementGroupName, top, orderBy, selectParameter, from, toParameter, filter, apply) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForManagementGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForManagementGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForManagementGroup", resp, "Failure sending request") + return + } + + result, err = client.ListQueryResultsForManagementGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForManagementGroup", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForManagementGroupPreparer prepares the ListQueryResultsForManagementGroup request. +func (client PolicyStatesClient) ListQueryResultsForManagementGroupPreparer(ctx context.Context, policyStatesResource PolicyStatesResource, managementGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managementGroupName": autorest.Encode("path", managementGroupName), + "managementGroupsNamespace": autorest.Encode("path", "Microsoft.Management"), + "policyStatesResource": autorest.Encode("path", policyStatesResource), + } + + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderBy) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderBy) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(apply) > 0 { + queryParameters["$apply"] = autorest.Encode("query", apply) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForManagementGroupSender sends the ListQueryResultsForManagementGroup request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyStatesClient) ListQueryResultsForManagementGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForManagementGroupResponder handles the response to the ListQueryResultsForManagementGroup request. The method always +// closes the http.Response Body. +func (client PolicyStatesClient) ListQueryResultsForManagementGroupResponder(resp *http.Response) (result PolicyStatesQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListQueryResultsForPolicyDefinition queries policy states for the subscription level policy definition. +// Parameters: +// policyStatesResource - the virtual resource under PolicyStates resource type. In a given time range, +// 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). +// subscriptionID - microsoft Azure subscription ID. +// policyDefinitionName - policy definition name. +// top - maximum number of records to return. +// orderBy - ordering expression using OData notation. One or more comma-separated column names with an +// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". +// selectParameter - select expression using OData notation. Limits the columns on each record to just those +// requested, e.g. "$select=PolicyAssignmentId, ResourceId". +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +// apply - oData apply expression for aggregations. +func (client PolicyStatesClient) ListQueryResultsForPolicyDefinition(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, policyDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyStatesQueryResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForPolicyDefinition") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForPolicyDefinition", err.Error()) + } + + req, err := client.ListQueryResultsForPolicyDefinitionPreparer(ctx, policyStatesResource, subscriptionID, policyDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicyDefinition", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForPolicyDefinitionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicyDefinition", resp, "Failure sending request") + return + } + + result, err = client.ListQueryResultsForPolicyDefinitionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicyDefinition", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForPolicyDefinitionPreparer prepares the ListQueryResultsForPolicyDefinition request. +func (client PolicyStatesClient) ListQueryResultsForPolicyDefinitionPreparer(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, policyDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), + "policyDefinitionName": autorest.Encode("path", policyDefinitionName), + "policyStatesResource": autorest.Encode("path", policyStatesResource), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderBy) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderBy) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(apply) > 0 { + queryParameters["$apply"] = autorest.Encode("query", apply) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForPolicyDefinitionSender sends the ListQueryResultsForPolicyDefinition request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyStatesClient) ListQueryResultsForPolicyDefinitionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForPolicyDefinitionResponder handles the response to the ListQueryResultsForPolicyDefinition request. The method always +// closes the http.Response Body. +func (client PolicyStatesClient) ListQueryResultsForPolicyDefinitionResponder(resp *http.Response) (result PolicyStatesQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListQueryResultsForPolicySetDefinition queries policy states for the subscription level policy set definition. +// Parameters: +// policyStatesResource - the virtual resource under PolicyStates resource type. In a given time range, +// 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). +// subscriptionID - microsoft Azure subscription ID. +// policySetDefinitionName - policy set definition name. +// top - maximum number of records to return. +// orderBy - ordering expression using OData notation. One or more comma-separated column names with an +// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". +// selectParameter - select expression using OData notation. Limits the columns on each record to just those +// requested, e.g. "$select=PolicyAssignmentId, ResourceId". +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +// apply - oData apply expression for aggregations. +func (client PolicyStatesClient) ListQueryResultsForPolicySetDefinition(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, policySetDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyStatesQueryResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForPolicySetDefinition") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForPolicySetDefinition", err.Error()) + } + + req, err := client.ListQueryResultsForPolicySetDefinitionPreparer(ctx, policyStatesResource, subscriptionID, policySetDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicySetDefinition", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForPolicySetDefinitionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicySetDefinition", resp, "Failure sending request") + return + } + + result, err = client.ListQueryResultsForPolicySetDefinitionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicySetDefinition", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForPolicySetDefinitionPreparer prepares the ListQueryResultsForPolicySetDefinition request. +func (client PolicyStatesClient) ListQueryResultsForPolicySetDefinitionPreparer(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, policySetDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), + "policySetDefinitionName": autorest.Encode("path", policySetDefinitionName), + "policyStatesResource": autorest.Encode("path", policyStatesResource), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderBy) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderBy) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(apply) > 0 { + queryParameters["$apply"] = autorest.Encode("query", apply) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForPolicySetDefinitionSender sends the ListQueryResultsForPolicySetDefinition request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyStatesClient) ListQueryResultsForPolicySetDefinitionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForPolicySetDefinitionResponder handles the response to the ListQueryResultsForPolicySetDefinition request. The method always +// closes the http.Response Body. +func (client PolicyStatesClient) ListQueryResultsForPolicySetDefinitionResponder(resp *http.Response) (result PolicyStatesQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListQueryResultsForResource queries policy states for the resource. +// Parameters: +// policyStatesResource - the virtual resource under PolicyStates resource type. In a given time range, +// 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). +// resourceID - resource ID. +// top - maximum number of records to return. +// orderBy - ordering expression using OData notation. One or more comma-separated column names with an +// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". +// selectParameter - select expression using OData notation. Limits the columns on each record to just those +// requested, e.g. "$select=PolicyAssignmentId, ResourceId". +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +// apply - oData apply expression for aggregations. +// expand - the $expand query parameter. For example, to expand policyEvaluationDetails, use +// $expand=policyEvaluationDetails +func (client PolicyStatesClient) ListQueryResultsForResource(ctx context.Context, policyStatesResource PolicyStatesResource, resourceID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, expand string) (result PolicyStatesQueryResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForResource") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForResource", err.Error()) + } + + req, err := client.ListQueryResultsForResourcePreparer(ctx, policyStatesResource, resourceID, top, orderBy, selectParameter, from, toParameter, filter, apply, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResource", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResource", resp, "Failure sending request") + return + } + + result, err = client.ListQueryResultsForResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResource", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForResourcePreparer prepares the ListQueryResultsForResource request. +func (client PolicyStatesClient) ListQueryResultsForResourcePreparer(ctx context.Context, policyStatesResource PolicyStatesResource, resourceID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyStatesResource": autorest.Encode("path", policyStatesResource), + "resourceId": resourceID, + } + + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderBy) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderBy) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(apply) > 0 { + queryParameters["$apply"] = autorest.Encode("query", apply) + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForResourceSender sends the ListQueryResultsForResource request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyStatesClient) ListQueryResultsForResourceSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForResourceResponder handles the response to the ListQueryResultsForResource request. The method always +// closes the http.Response Body. +func (client PolicyStatesClient) ListQueryResultsForResourceResponder(resp *http.Response) (result PolicyStatesQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListQueryResultsForResourceGroup queries policy states for the resources under the resource group. +// Parameters: +// policyStatesResource - the virtual resource under PolicyStates resource type. In a given time range, +// 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). +// subscriptionID - microsoft Azure subscription ID. +// resourceGroupName - resource group name. +// top - maximum number of records to return. +// orderBy - ordering expression using OData notation. One or more comma-separated column names with an +// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". +// selectParameter - select expression using OData notation. Limits the columns on each record to just those +// requested, e.g. "$select=PolicyAssignmentId, ResourceId". +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +// apply - oData apply expression for aggregations. +func (client PolicyStatesClient) ListQueryResultsForResourceGroup(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, resourceGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyStatesQueryResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroup", err.Error()) + } + + req, err := client.ListQueryResultsForResourceGroupPreparer(ctx, policyStatesResource, subscriptionID, resourceGroupName, top, orderBy, selectParameter, from, toParameter, filter, apply) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListQueryResultsForResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForResourceGroupPreparer prepares the ListQueryResultsForResourceGroup request. +func (client PolicyStatesClient) ListQueryResultsForResourceGroupPreparer(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, resourceGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyStatesResource": autorest.Encode("path", policyStatesResource), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderBy) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderBy) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(apply) > 0 { + queryParameters["$apply"] = autorest.Encode("query", apply) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForResourceGroupSender sends the ListQueryResultsForResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyStatesClient) ListQueryResultsForResourceGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForResourceGroupResponder handles the response to the ListQueryResultsForResourceGroup request. The method always +// closes the http.Response Body. +func (client PolicyStatesClient) ListQueryResultsForResourceGroupResponder(resp *http.Response) (result PolicyStatesQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignment queries policy states for the resource group level policy +// assignment. +// Parameters: +// policyStatesResource - the virtual resource under PolicyStates resource type. In a given time range, +// 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). +// subscriptionID - microsoft Azure subscription ID. +// resourceGroupName - resource group name. +// policyAssignmentName - policy assignment name. +// top - maximum number of records to return. +// orderBy - ordering expression using OData notation. One or more comma-separated column names with an +// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". +// selectParameter - select expression using OData notation. Limits the columns on each record to just those +// requested, e.g. "$select=PolicyAssignmentId, ResourceId". +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +// apply - oData apply expression for aggregations. +func (client PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssignment(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, resourceGroupName string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyStatesQueryResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForResourceGroupLevelPolicyAssignment") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", err.Error()) + } + + req, err := client.ListQueryResultsForResourceGroupLevelPolicyAssignmentPreparer(ctx, policyStatesResource, subscriptionID, resourceGroupName, policyAssignmentName, top, orderBy, selectParameter, from, toParameter, filter, apply) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForResourceGroupLevelPolicyAssignmentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", resp, "Failure sending request") + return + } + + result, err = client.ListQueryResultsForResourceGroupLevelPolicyAssignmentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignmentPreparer prepares the ListQueryResultsForResourceGroupLevelPolicyAssignment request. +func (client PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssignmentPreparer(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, resourceGroupName string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), + "policyAssignmentName": autorest.Encode("path", policyAssignmentName), + "policyStatesResource": autorest.Encode("path", policyStatesResource), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderBy) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderBy) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(apply) > 0 { + queryParameters["$apply"] = autorest.Encode("query", apply) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignmentSender sends the ListQueryResultsForResourceGroupLevelPolicyAssignment request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssignmentSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignmentResponder handles the response to the ListQueryResultsForResourceGroupLevelPolicyAssignment request. The method always +// closes the http.Response Body. +func (client PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssignmentResponder(resp *http.Response) (result PolicyStatesQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListQueryResultsForSubscription queries policy states for the resources under the subscription. +// Parameters: +// policyStatesResource - the virtual resource under PolicyStates resource type. In a given time range, +// 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). +// subscriptionID - microsoft Azure subscription ID. +// top - maximum number of records to return. +// orderBy - ordering expression using OData notation. One or more comma-separated column names with an +// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". +// selectParameter - select expression using OData notation. Limits the columns on each record to just those +// requested, e.g. "$select=PolicyAssignmentId, ResourceId". +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +// apply - oData apply expression for aggregations. +func (client PolicyStatesClient) ListQueryResultsForSubscription(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyStatesQueryResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForSubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForSubscription", err.Error()) + } + + req, err := client.ListQueryResultsForSubscriptionPreparer(ctx, policyStatesResource, subscriptionID, top, orderBy, selectParameter, from, toParameter, filter, apply) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscription", resp, "Failure sending request") + return + } + + result, err = client.ListQueryResultsForSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscription", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForSubscriptionPreparer prepares the ListQueryResultsForSubscription request. +func (client PolicyStatesClient) ListQueryResultsForSubscriptionPreparer(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyStatesResource": autorest.Encode("path", policyStatesResource), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderBy) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderBy) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(apply) > 0 { + queryParameters["$apply"] = autorest.Encode("query", apply) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForSubscriptionSender sends the ListQueryResultsForSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyStatesClient) ListQueryResultsForSubscriptionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForSubscriptionResponder handles the response to the ListQueryResultsForSubscription request. The method always +// closes the http.Response Body. +func (client PolicyStatesClient) ListQueryResultsForSubscriptionResponder(resp *http.Response) (result PolicyStatesQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignment queries policy states for the subscription level policy +// assignment. +// Parameters: +// policyStatesResource - the virtual resource under PolicyStates resource type. In a given time range, +// 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). +// subscriptionID - microsoft Azure subscription ID. +// policyAssignmentName - policy assignment name. +// top - maximum number of records to return. +// orderBy - ordering expression using OData notation. One or more comma-separated column names with an +// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". +// selectParameter - select expression using OData notation. Limits the columns on each record to just those +// requested, e.g. "$select=PolicyAssignmentId, ResourceId". +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +// apply - oData apply expression for aggregations. +func (client PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssignment(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyStatesQueryResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForSubscriptionLevelPolicyAssignment") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", err.Error()) + } + + req, err := client.ListQueryResultsForSubscriptionLevelPolicyAssignmentPreparer(ctx, policyStatesResource, subscriptionID, policyAssignmentName, top, orderBy, selectParameter, from, toParameter, filter, apply) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForSubscriptionLevelPolicyAssignmentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", resp, "Failure sending request") + return + } + + result, err = client.ListQueryResultsForSubscriptionLevelPolicyAssignmentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignmentPreparer prepares the ListQueryResultsForSubscriptionLevelPolicyAssignment request. +func (client PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssignmentPreparer(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), + "policyAssignmentName": autorest.Encode("path", policyAssignmentName), + "policyStatesResource": autorest.Encode("path", policyStatesResource), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderBy) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderBy) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(apply) > 0 { + queryParameters["$apply"] = autorest.Encode("query", apply) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignmentSender sends the ListQueryResultsForSubscriptionLevelPolicyAssignment request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssignmentSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignmentResponder handles the response to the ListQueryResultsForSubscriptionLevelPolicyAssignment request. The method always +// closes the http.Response Body. +func (client PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssignmentResponder(resp *http.Response) (result PolicyStatesQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// SummarizeForManagementGroup summarizes policy states for the resources under the management group. +// Parameters: +// managementGroupName - management group name. +// top - maximum number of records to return. +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +func (client PolicyStatesClient) SummarizeForManagementGroup(ctx context.Context, managementGroupName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result SummarizeResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.SummarizeForManagementGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyStatesClient", "SummarizeForManagementGroup", err.Error()) + } + + req, err := client.SummarizeForManagementGroupPreparer(ctx, managementGroupName, top, from, toParameter, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForManagementGroup", nil, "Failure preparing request") + return + } + + resp, err := client.SummarizeForManagementGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForManagementGroup", resp, "Failure sending request") + return + } + + result, err = client.SummarizeForManagementGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForManagementGroup", resp, "Failure responding to request") + } + + return +} + +// SummarizeForManagementGroupPreparer prepares the SummarizeForManagementGroup request. +func (client PolicyStatesClient) SummarizeForManagementGroupPreparer(ctx context.Context, managementGroupName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managementGroupName": autorest.Encode("path", managementGroupName), + "managementGroupsNamespace": autorest.Encode("path", "Microsoft.Management"), + "policyStatesSummaryResource": autorest.Encode("path", "latest"), + } + + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SummarizeForManagementGroupSender sends the SummarizeForManagementGroup request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyStatesClient) SummarizeForManagementGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// SummarizeForManagementGroupResponder handles the response to the SummarizeForManagementGroup request. The method always +// closes the http.Response Body. +func (client PolicyStatesClient) SummarizeForManagementGroupResponder(resp *http.Response) (result SummarizeResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// SummarizeForPolicyDefinition summarizes policy states for the subscription level policy definition. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// policyDefinitionName - policy definition name. +// top - maximum number of records to return. +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +func (client PolicyStatesClient) SummarizeForPolicyDefinition(ctx context.Context, subscriptionID string, policyDefinitionName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result SummarizeResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.SummarizeForPolicyDefinition") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyStatesClient", "SummarizeForPolicyDefinition", err.Error()) + } + + req, err := client.SummarizeForPolicyDefinitionPreparer(ctx, subscriptionID, policyDefinitionName, top, from, toParameter, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForPolicyDefinition", nil, "Failure preparing request") + return + } + + resp, err := client.SummarizeForPolicyDefinitionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForPolicyDefinition", resp, "Failure sending request") + return + } + + result, err = client.SummarizeForPolicyDefinitionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForPolicyDefinition", resp, "Failure responding to request") + } + + return +} + +// SummarizeForPolicyDefinitionPreparer prepares the SummarizeForPolicyDefinition request. +func (client PolicyStatesClient) SummarizeForPolicyDefinitionPreparer(ctx context.Context, subscriptionID string, policyDefinitionName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), + "policyDefinitionName": autorest.Encode("path", policyDefinitionName), + "policyStatesSummaryResource": autorest.Encode("path", "latest"), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SummarizeForPolicyDefinitionSender sends the SummarizeForPolicyDefinition request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyStatesClient) SummarizeForPolicyDefinitionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// SummarizeForPolicyDefinitionResponder handles the response to the SummarizeForPolicyDefinition request. The method always +// closes the http.Response Body. +func (client PolicyStatesClient) SummarizeForPolicyDefinitionResponder(resp *http.Response) (result SummarizeResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// SummarizeForPolicySetDefinition summarizes policy states for the subscription level policy set definition. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// policySetDefinitionName - policy set definition name. +// top - maximum number of records to return. +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +func (client PolicyStatesClient) SummarizeForPolicySetDefinition(ctx context.Context, subscriptionID string, policySetDefinitionName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result SummarizeResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.SummarizeForPolicySetDefinition") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyStatesClient", "SummarizeForPolicySetDefinition", err.Error()) + } + + req, err := client.SummarizeForPolicySetDefinitionPreparer(ctx, subscriptionID, policySetDefinitionName, top, from, toParameter, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForPolicySetDefinition", nil, "Failure preparing request") + return + } + + resp, err := client.SummarizeForPolicySetDefinitionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForPolicySetDefinition", resp, "Failure sending request") + return + } + + result, err = client.SummarizeForPolicySetDefinitionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForPolicySetDefinition", resp, "Failure responding to request") + } + + return +} + +// SummarizeForPolicySetDefinitionPreparer prepares the SummarizeForPolicySetDefinition request. +func (client PolicyStatesClient) SummarizeForPolicySetDefinitionPreparer(ctx context.Context, subscriptionID string, policySetDefinitionName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), + "policySetDefinitionName": autorest.Encode("path", policySetDefinitionName), + "policyStatesSummaryResource": autorest.Encode("path", "latest"), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SummarizeForPolicySetDefinitionSender sends the SummarizeForPolicySetDefinition request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyStatesClient) SummarizeForPolicySetDefinitionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// SummarizeForPolicySetDefinitionResponder handles the response to the SummarizeForPolicySetDefinition request. The method always +// closes the http.Response Body. +func (client PolicyStatesClient) SummarizeForPolicySetDefinitionResponder(resp *http.Response) (result SummarizeResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// SummarizeForResource summarizes policy states for the resource. +// Parameters: +// resourceID - resource ID. +// top - maximum number of records to return. +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +func (client PolicyStatesClient) SummarizeForResource(ctx context.Context, resourceID string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result SummarizeResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.SummarizeForResource") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyStatesClient", "SummarizeForResource", err.Error()) + } + + req, err := client.SummarizeForResourcePreparer(ctx, resourceID, top, from, toParameter, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResource", nil, "Failure preparing request") + return + } + + resp, err := client.SummarizeForResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResource", resp, "Failure sending request") + return + } + + result, err = client.SummarizeForResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResource", resp, "Failure responding to request") + } + + return +} + +// SummarizeForResourcePreparer prepares the SummarizeForResource request. +func (client PolicyStatesClient) SummarizeForResourcePreparer(ctx context.Context, resourceID string, top *int32, from *date.Time, toParameter *date.Time, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyStatesSummaryResource": autorest.Encode("path", "latest"), + "resourceId": resourceID, + } + + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SummarizeForResourceSender sends the SummarizeForResource request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyStatesClient) SummarizeForResourceSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// SummarizeForResourceResponder handles the response to the SummarizeForResource request. The method always +// closes the http.Response Body. +func (client PolicyStatesClient) SummarizeForResourceResponder(resp *http.Response) (result SummarizeResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// SummarizeForResourceGroup summarizes policy states for the resources under the resource group. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// resourceGroupName - resource group name. +// top - maximum number of records to return. +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +func (client PolicyStatesClient) SummarizeForResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result SummarizeResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.SummarizeForResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyStatesClient", "SummarizeForResourceGroup", err.Error()) + } + + req, err := client.SummarizeForResourceGroupPreparer(ctx, subscriptionID, resourceGroupName, top, from, toParameter, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.SummarizeForResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.SummarizeForResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResourceGroup", resp, "Failure responding to request") + } + + return +} + +// SummarizeForResourceGroupPreparer prepares the SummarizeForResourceGroup request. +func (client PolicyStatesClient) SummarizeForResourceGroupPreparer(ctx context.Context, subscriptionID string, resourceGroupName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyStatesSummaryResource": autorest.Encode("path", "latest"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SummarizeForResourceGroupSender sends the SummarizeForResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyStatesClient) SummarizeForResourceGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// SummarizeForResourceGroupResponder handles the response to the SummarizeForResourceGroup request. The method always +// closes the http.Response Body. +func (client PolicyStatesClient) SummarizeForResourceGroupResponder(resp *http.Response) (result SummarizeResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// SummarizeForResourceGroupLevelPolicyAssignment summarizes policy states for the resource group level policy +// assignment. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// resourceGroupName - resource group name. +// policyAssignmentName - policy assignment name. +// top - maximum number of records to return. +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +func (client PolicyStatesClient) SummarizeForResourceGroupLevelPolicyAssignment(ctx context.Context, subscriptionID string, resourceGroupName string, policyAssignmentName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result SummarizeResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.SummarizeForResourceGroupLevelPolicyAssignment") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyStatesClient", "SummarizeForResourceGroupLevelPolicyAssignment", err.Error()) + } + + req, err := client.SummarizeForResourceGroupLevelPolicyAssignmentPreparer(ctx, subscriptionID, resourceGroupName, policyAssignmentName, top, from, toParameter, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResourceGroupLevelPolicyAssignment", nil, "Failure preparing request") + return + } + + resp, err := client.SummarizeForResourceGroupLevelPolicyAssignmentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResourceGroupLevelPolicyAssignment", resp, "Failure sending request") + return + } + + result, err = client.SummarizeForResourceGroupLevelPolicyAssignmentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResourceGroupLevelPolicyAssignment", resp, "Failure responding to request") + } + + return +} + +// SummarizeForResourceGroupLevelPolicyAssignmentPreparer prepares the SummarizeForResourceGroupLevelPolicyAssignment request. +func (client PolicyStatesClient) SummarizeForResourceGroupLevelPolicyAssignmentPreparer(ctx context.Context, subscriptionID string, resourceGroupName string, policyAssignmentName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), + "policyAssignmentName": autorest.Encode("path", policyAssignmentName), + "policyStatesSummaryResource": autorest.Encode("path", "latest"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SummarizeForResourceGroupLevelPolicyAssignmentSender sends the SummarizeForResourceGroupLevelPolicyAssignment request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyStatesClient) SummarizeForResourceGroupLevelPolicyAssignmentSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// SummarizeForResourceGroupLevelPolicyAssignmentResponder handles the response to the SummarizeForResourceGroupLevelPolicyAssignment request. The method always +// closes the http.Response Body. +func (client PolicyStatesClient) SummarizeForResourceGroupLevelPolicyAssignmentResponder(resp *http.Response) (result SummarizeResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// SummarizeForSubscription summarizes policy states for the resources under the subscription. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// top - maximum number of records to return. +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +func (client PolicyStatesClient) SummarizeForSubscription(ctx context.Context, subscriptionID string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result SummarizeResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.SummarizeForSubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyStatesClient", "SummarizeForSubscription", err.Error()) + } + + req, err := client.SummarizeForSubscriptionPreparer(ctx, subscriptionID, top, from, toParameter, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.SummarizeForSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForSubscription", resp, "Failure sending request") + return + } + + result, err = client.SummarizeForSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForSubscription", resp, "Failure responding to request") + } + + return +} + +// SummarizeForSubscriptionPreparer prepares the SummarizeForSubscription request. +func (client PolicyStatesClient) SummarizeForSubscriptionPreparer(ctx context.Context, subscriptionID string, top *int32, from *date.Time, toParameter *date.Time, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyStatesSummaryResource": autorest.Encode("path", "latest"), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SummarizeForSubscriptionSender sends the SummarizeForSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyStatesClient) SummarizeForSubscriptionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// SummarizeForSubscriptionResponder handles the response to the SummarizeForSubscription request. The method always +// closes the http.Response Body. +func (client PolicyStatesClient) SummarizeForSubscriptionResponder(resp *http.Response) (result SummarizeResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// SummarizeForSubscriptionLevelPolicyAssignment summarizes policy states for the subscription level policy assignment. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// policyAssignmentName - policy assignment name. +// top - maximum number of records to return. +// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, +// the service uses ($to - 1-day). +// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not +// specified, the service uses request time. +// filter - oData filter expression. +func (client PolicyStatesClient) SummarizeForSubscriptionLevelPolicyAssignment(ctx context.Context, subscriptionID string, policyAssignmentName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result SummarizeResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.SummarizeForSubscriptionLevelPolicyAssignment") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyStatesClient", "SummarizeForSubscriptionLevelPolicyAssignment", err.Error()) + } + + req, err := client.SummarizeForSubscriptionLevelPolicyAssignmentPreparer(ctx, subscriptionID, policyAssignmentName, top, from, toParameter, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForSubscriptionLevelPolicyAssignment", nil, "Failure preparing request") + return + } + + resp, err := client.SummarizeForSubscriptionLevelPolicyAssignmentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForSubscriptionLevelPolicyAssignment", resp, "Failure sending request") + return + } + + result, err = client.SummarizeForSubscriptionLevelPolicyAssignmentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForSubscriptionLevelPolicyAssignment", resp, "Failure responding to request") + } + + return +} + +// SummarizeForSubscriptionLevelPolicyAssignmentPreparer prepares the SummarizeForSubscriptionLevelPolicyAssignment request. +func (client PolicyStatesClient) SummarizeForSubscriptionLevelPolicyAssignmentPreparer(ctx context.Context, subscriptionID string, policyAssignmentName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), + "policyAssignmentName": autorest.Encode("path", policyAssignmentName), + "policyStatesSummaryResource": autorest.Encode("path", "latest"), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if from != nil { + queryParameters["$from"] = autorest.Encode("query", *from) + } + if toParameter != nil { + queryParameters["$to"] = autorest.Encode("query", *toParameter) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SummarizeForSubscriptionLevelPolicyAssignmentSender sends the SummarizeForSubscriptionLevelPolicyAssignment request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyStatesClient) SummarizeForSubscriptionLevelPolicyAssignmentSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// SummarizeForSubscriptionLevelPolicyAssignmentResponder handles the response to the SummarizeForSubscriptionLevelPolicyAssignment request. The method always +// closes the http.Response Body. +func (client PolicyStatesClient) SummarizeForSubscriptionLevelPolicyAssignmentResponder(resp *http.Response) (result SummarizeResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/policytrackedresources.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/policytrackedresources.go new file mode 100644 index 000000000000..cfcb71c32715 --- /dev/null +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/policytrackedresources.go @@ -0,0 +1,557 @@ +package policyinsights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PolicyTrackedResourcesClient is the client for the PolicyTrackedResources methods of the Policyinsights service. +type PolicyTrackedResourcesClient struct { + BaseClient +} + +// NewPolicyTrackedResourcesClient creates an instance of the PolicyTrackedResourcesClient client. +func NewPolicyTrackedResourcesClient() PolicyTrackedResourcesClient { + return NewPolicyTrackedResourcesClientWithBaseURI(DefaultBaseURI) +} + +// NewPolicyTrackedResourcesClientWithBaseURI creates an instance of the PolicyTrackedResourcesClient client. +func NewPolicyTrackedResourcesClientWithBaseURI(baseURI string) PolicyTrackedResourcesClient { + return PolicyTrackedResourcesClient{NewWithBaseURI(baseURI)} +} + +// ListQueryResultsForManagementGroup queries policy tracked resources under the management group. +// Parameters: +// managementGroupName - management group name. +// top - maximum number of records to return. +// filter - oData filter expression. +func (client PolicyTrackedResourcesClient) ListQueryResultsForManagementGroup(ctx context.Context, managementGroupName string, top *int32, filter string) (result PolicyTrackedResourcesQueryResultsPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup") + defer func() { + sc := -1 + if result.ptrqr.Response.Response != nil { + sc = result.ptrqr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForManagementGroup", err.Error()) + } + + result.fn = client.listQueryResultsForManagementGroupNextResults + req, err := client.ListQueryResultsForManagementGroupPreparer(ctx, managementGroupName, top, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForManagementGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForManagementGroupSender(req) + if err != nil { + result.ptrqr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForManagementGroup", resp, "Failure sending request") + return + } + + result.ptrqr, err = client.ListQueryResultsForManagementGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForManagementGroup", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForManagementGroupPreparer prepares the ListQueryResultsForManagementGroup request. +func (client PolicyTrackedResourcesClient) ListQueryResultsForManagementGroupPreparer(ctx context.Context, managementGroupName string, top *int32, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managementGroupName": autorest.Encode("path", managementGroupName), + "managementGroupsNamespace": autorest.Encode("path", "Microsoft.Management"), + "policyTrackedResourcesResource": autorest.Encode("path", "default"), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForManagementGroupSender sends the ListQueryResultsForManagementGroup request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyTrackedResourcesClient) ListQueryResultsForManagementGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForManagementGroupResponder handles the response to the ListQueryResultsForManagementGroup request. The method always +// closes the http.Response Body. +func (client PolicyTrackedResourcesClient) ListQueryResultsForManagementGroupResponder(resp *http.Response) (result PolicyTrackedResourcesQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listQueryResultsForManagementGroupNextResults retrieves the next set of results, if any. +func (client PolicyTrackedResourcesClient) listQueryResultsForManagementGroupNextResults(ctx context.Context, lastResults PolicyTrackedResourcesQueryResults) (result PolicyTrackedResourcesQueryResults, err error) { + req, err := lastResults.policyTrackedResourcesQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "listQueryResultsForManagementGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListQueryResultsForManagementGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "listQueryResultsForManagementGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForManagementGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "listQueryResultsForManagementGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForManagementGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyTrackedResourcesClient) ListQueryResultsForManagementGroupComplete(ctx context.Context, managementGroupName string, top *int32, filter string) (result PolicyTrackedResourcesQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListQueryResultsForManagementGroup(ctx, managementGroupName, top, filter) + return +} + +// ListQueryResultsForResource queries policy tracked resources under the resource. +// Parameters: +// resourceID - resource ID. +// top - maximum number of records to return. +// filter - oData filter expression. +func (client PolicyTrackedResourcesClient) ListQueryResultsForResource(ctx context.Context, resourceID string, top *int32, filter string) (result PolicyTrackedResourcesQueryResultsPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyTrackedResourcesClient.ListQueryResultsForResource") + defer func() { + sc := -1 + if result.ptrqr.Response.Response != nil { + sc = result.ptrqr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForResource", err.Error()) + } + + result.fn = client.listQueryResultsForResourceNextResults + req, err := client.ListQueryResultsForResourcePreparer(ctx, resourceID, top, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForResource", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForResourceSender(req) + if err != nil { + result.ptrqr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForResource", resp, "Failure sending request") + return + } + + result.ptrqr, err = client.ListQueryResultsForResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForResource", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForResourcePreparer prepares the ListQueryResultsForResource request. +func (client PolicyTrackedResourcesClient) ListQueryResultsForResourcePreparer(ctx context.Context, resourceID string, top *int32, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyTrackedResourcesResource": autorest.Encode("path", "default"), + "resourceId": resourceID, + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForResourceSender sends the ListQueryResultsForResource request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyTrackedResourcesClient) ListQueryResultsForResourceSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForResourceResponder handles the response to the ListQueryResultsForResource request. The method always +// closes the http.Response Body. +func (client PolicyTrackedResourcesClient) ListQueryResultsForResourceResponder(resp *http.Response) (result PolicyTrackedResourcesQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listQueryResultsForResourceNextResults retrieves the next set of results, if any. +func (client PolicyTrackedResourcesClient) listQueryResultsForResourceNextResults(ctx context.Context, lastResults PolicyTrackedResourcesQueryResults) (result PolicyTrackedResourcesQueryResults, err error) { + req, err := lastResults.policyTrackedResourcesQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "listQueryResultsForResourceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListQueryResultsForResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "listQueryResultsForResourceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "listQueryResultsForResourceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForResourceComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyTrackedResourcesClient) ListQueryResultsForResourceComplete(ctx context.Context, resourceID string, top *int32, filter string) (result PolicyTrackedResourcesQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyTrackedResourcesClient.ListQueryResultsForResource") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListQueryResultsForResource(ctx, resourceID, top, filter) + return +} + +// ListQueryResultsForResourceGroup queries policy tracked resources under the resource group. +// Parameters: +// resourceGroupName - resource group name. +// subscriptionID - microsoft Azure subscription ID. +// top - maximum number of records to return. +// filter - oData filter expression. +func (client PolicyTrackedResourcesClient) ListQueryResultsForResourceGroup(ctx context.Context, resourceGroupName string, subscriptionID string, top *int32, filter string) (result PolicyTrackedResourcesQueryResultsPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyTrackedResourcesClient.ListQueryResultsForResourceGroup") + defer func() { + sc := -1 + if result.ptrqr.Response.Response != nil { + sc = result.ptrqr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForResourceGroup", err.Error()) + } + + result.fn = client.listQueryResultsForResourceGroupNextResults + req, err := client.ListQueryResultsForResourceGroupPreparer(ctx, resourceGroupName, subscriptionID, top, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForResourceGroupSender(req) + if err != nil { + result.ptrqr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForResourceGroup", resp, "Failure sending request") + return + } + + result.ptrqr, err = client.ListQueryResultsForResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForResourceGroupPreparer prepares the ListQueryResultsForResourceGroup request. +func (client PolicyTrackedResourcesClient) ListQueryResultsForResourceGroupPreparer(ctx context.Context, resourceGroupName string, subscriptionID string, top *int32, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyTrackedResourcesResource": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForResourceGroupSender sends the ListQueryResultsForResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyTrackedResourcesClient) ListQueryResultsForResourceGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForResourceGroupResponder handles the response to the ListQueryResultsForResourceGroup request. The method always +// closes the http.Response Body. +func (client PolicyTrackedResourcesClient) ListQueryResultsForResourceGroupResponder(resp *http.Response) (result PolicyTrackedResourcesQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listQueryResultsForResourceGroupNextResults retrieves the next set of results, if any. +func (client PolicyTrackedResourcesClient) listQueryResultsForResourceGroupNextResults(ctx context.Context, lastResults PolicyTrackedResourcesQueryResults) (result PolicyTrackedResourcesQueryResults, err error) { + req, err := lastResults.policyTrackedResourcesQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "listQueryResultsForResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListQueryResultsForResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "listQueryResultsForResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "listQueryResultsForResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyTrackedResourcesClient) ListQueryResultsForResourceGroupComplete(ctx context.Context, resourceGroupName string, subscriptionID string, top *int32, filter string) (result PolicyTrackedResourcesQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyTrackedResourcesClient.ListQueryResultsForResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListQueryResultsForResourceGroup(ctx, resourceGroupName, subscriptionID, top, filter) + return +} + +// ListQueryResultsForSubscription queries policy tracked resources under the subscription. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// top - maximum number of records to return. +// filter - oData filter expression. +func (client PolicyTrackedResourcesClient) ListQueryResultsForSubscription(ctx context.Context, subscriptionID string, top *int32, filter string) (result PolicyTrackedResourcesQueryResultsPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyTrackedResourcesClient.ListQueryResultsForSubscription") + defer func() { + sc := -1 + if result.ptrqr.Response.Response != nil { + sc = result.ptrqr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForSubscription", err.Error()) + } + + result.fn = client.listQueryResultsForSubscriptionNextResults + req, err := client.ListQueryResultsForSubscriptionPreparer(ctx, subscriptionID, top, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListQueryResultsForSubscriptionSender(req) + if err != nil { + result.ptrqr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForSubscription", resp, "Failure sending request") + return + } + + result.ptrqr, err = client.ListQueryResultsForSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForSubscription", resp, "Failure responding to request") + } + + return +} + +// ListQueryResultsForSubscriptionPreparer prepares the ListQueryResultsForSubscription request. +func (client PolicyTrackedResourcesClient) ListQueryResultsForSubscriptionPreparer(ctx context.Context, subscriptionID string, top *int32, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyTrackedResourcesResource": autorest.Encode("path", "default"), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListQueryResultsForSubscriptionSender sends the ListQueryResultsForSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyTrackedResourcesClient) ListQueryResultsForSubscriptionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListQueryResultsForSubscriptionResponder handles the response to the ListQueryResultsForSubscription request. The method always +// closes the http.Response Body. +func (client PolicyTrackedResourcesClient) ListQueryResultsForSubscriptionResponder(resp *http.Response) (result PolicyTrackedResourcesQueryResults, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listQueryResultsForSubscriptionNextResults retrieves the next set of results, if any. +func (client PolicyTrackedResourcesClient) listQueryResultsForSubscriptionNextResults(ctx context.Context, lastResults PolicyTrackedResourcesQueryResults) (result PolicyTrackedResourcesQueryResults, err error) { + req, err := lastResults.policyTrackedResourcesQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "listQueryResultsForSubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListQueryResultsForSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "listQueryResultsForSubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "listQueryResultsForSubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForSubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyTrackedResourcesClient) ListQueryResultsForSubscriptionComplete(ctx context.Context, subscriptionID string, top *int32, filter string) (result PolicyTrackedResourcesQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyTrackedResourcesClient.ListQueryResultsForSubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListQueryResultsForSubscription(ctx, subscriptionID, top, filter) + return +} diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/remediations.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/remediations.go new file mode 100644 index 000000000000..84f777ab2c87 --- /dev/null +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/remediations.go @@ -0,0 +1,2308 @@ +package policyinsights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RemediationsClient is the client for the Remediations methods of the Policyinsights service. +type RemediationsClient struct { + BaseClient +} + +// NewRemediationsClient creates an instance of the RemediationsClient client. +func NewRemediationsClient() RemediationsClient { + return NewRemediationsClientWithBaseURI(DefaultBaseURI) +} + +// NewRemediationsClientWithBaseURI creates an instance of the RemediationsClient client. +func NewRemediationsClientWithBaseURI(baseURI string) RemediationsClient { + return RemediationsClient{NewWithBaseURI(baseURI)} +} + +// CancelAtManagementGroup cancels a remediation at management group scope. +// Parameters: +// managementGroupID - management group ID. +// remediationName - the name of the remediation. +func (client RemediationsClient) CancelAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string) (result Remediation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.CancelAtManagementGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelAtManagementGroupPreparer(ctx, managementGroupID, remediationName) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CancelAtManagementGroup", nil, "Failure preparing request") + return + } + + resp, err := client.CancelAtManagementGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CancelAtManagementGroup", resp, "Failure sending request") + return + } + + result, err = client.CancelAtManagementGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CancelAtManagementGroup", resp, "Failure responding to request") + } + + return +} + +// CancelAtManagementGroupPreparer prepares the CancelAtManagementGroup request. +func (client RemediationsClient) CancelAtManagementGroupPreparer(ctx context.Context, managementGroupID string, remediationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managementGroupId": autorest.Encode("path", managementGroupID), + "managementGroupsNamespace": autorest.Encode("path", "Microsoft.Management"), + "remediationName": autorest.Encode("path", remediationName), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CancelAtManagementGroupSender sends the CancelAtManagementGroup request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) CancelAtManagementGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// CancelAtManagementGroupResponder handles the response to the CancelAtManagementGroup request. The method always +// closes the http.Response Body. +func (client RemediationsClient) CancelAtManagementGroupResponder(resp *http.Response) (result Remediation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CancelAtResource cancel a remediation at resource scope. +// Parameters: +// resourceID - resource ID. +// remediationName - the name of the remediation. +func (client RemediationsClient) CancelAtResource(ctx context.Context, resourceID string, remediationName string) (result Remediation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.CancelAtResource") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelAtResourcePreparer(ctx, resourceID, remediationName) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CancelAtResource", nil, "Failure preparing request") + return + } + + resp, err := client.CancelAtResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CancelAtResource", resp, "Failure sending request") + return + } + + result, err = client.CancelAtResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CancelAtResource", resp, "Failure responding to request") + } + + return +} + +// CancelAtResourcePreparer prepares the CancelAtResource request. +func (client RemediationsClient) CancelAtResourcePreparer(ctx context.Context, resourceID string, remediationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "remediationName": autorest.Encode("path", remediationName), + "resourceId": resourceID, + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CancelAtResourceSender sends the CancelAtResource request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) CancelAtResourceSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// CancelAtResourceResponder handles the response to the CancelAtResource request. The method always +// closes the http.Response Body. +func (client RemediationsClient) CancelAtResourceResponder(resp *http.Response) (result Remediation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CancelAtResourceGroup cancels a remediation at resource group scope. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// resourceGroupName - resource group name. +// remediationName - the name of the remediation. +func (client RemediationsClient) CancelAtResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, remediationName string) (result Remediation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.CancelAtResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelAtResourceGroupPreparer(ctx, subscriptionID, resourceGroupName, remediationName) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CancelAtResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.CancelAtResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CancelAtResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.CancelAtResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CancelAtResourceGroup", resp, "Failure responding to request") + } + + return +} + +// CancelAtResourceGroupPreparer prepares the CancelAtResourceGroup request. +func (client RemediationsClient) CancelAtResourceGroupPreparer(ctx context.Context, subscriptionID string, resourceGroupName string, remediationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "remediationName": autorest.Encode("path", remediationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CancelAtResourceGroupSender sends the CancelAtResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) CancelAtResourceGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// CancelAtResourceGroupResponder handles the response to the CancelAtResourceGroup request. The method always +// closes the http.Response Body. +func (client RemediationsClient) CancelAtResourceGroupResponder(resp *http.Response) (result Remediation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CancelAtSubscription cancels a remediation at subscription scope. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// remediationName - the name of the remediation. +func (client RemediationsClient) CancelAtSubscription(ctx context.Context, subscriptionID string, remediationName string) (result Remediation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.CancelAtSubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelAtSubscriptionPreparer(ctx, subscriptionID, remediationName) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CancelAtSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.CancelAtSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CancelAtSubscription", resp, "Failure sending request") + return + } + + result, err = client.CancelAtSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CancelAtSubscription", resp, "Failure responding to request") + } + + return +} + +// CancelAtSubscriptionPreparer prepares the CancelAtSubscription request. +func (client RemediationsClient) CancelAtSubscriptionPreparer(ctx context.Context, subscriptionID string, remediationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "remediationName": autorest.Encode("path", remediationName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CancelAtSubscriptionSender sends the CancelAtSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) CancelAtSubscriptionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// CancelAtSubscriptionResponder handles the response to the CancelAtSubscription request. The method always +// closes the http.Response Body. +func (client RemediationsClient) CancelAtSubscriptionResponder(resp *http.Response) (result Remediation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdateAtManagementGroup creates or updates a remediation at management group scope. +// Parameters: +// managementGroupID - management group ID. +// remediationName - the name of the remediation. +// parameters - the remediation parameters. +func (client RemediationsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string, parameters Remediation) (result Remediation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.CreateOrUpdateAtManagementGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdateAtManagementGroupPreparer(ctx, managementGroupID, remediationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CreateOrUpdateAtManagementGroup", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateAtManagementGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CreateOrUpdateAtManagementGroup", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateAtManagementGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CreateOrUpdateAtManagementGroup", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdateAtManagementGroupPreparer prepares the CreateOrUpdateAtManagementGroup request. +func (client RemediationsClient) CreateOrUpdateAtManagementGroupPreparer(ctx context.Context, managementGroupID string, remediationName string, parameters Remediation) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managementGroupId": autorest.Encode("path", managementGroupID), + "managementGroupsNamespace": autorest.Encode("path", "Microsoft.Management"), + "remediationName": autorest.Encode("path", remediationName), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.ID = nil + parameters.Type = nil + parameters.Name = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateAtManagementGroupSender sends the CreateOrUpdateAtManagementGroup request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) CreateOrUpdateAtManagementGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// CreateOrUpdateAtManagementGroupResponder handles the response to the CreateOrUpdateAtManagementGroup request. The method always +// closes the http.Response Body. +func (client RemediationsClient) CreateOrUpdateAtManagementGroupResponder(resp *http.Response) (result Remediation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdateAtResource creates or updates a remediation at resource scope. +// Parameters: +// resourceID - resource ID. +// remediationName - the name of the remediation. +// parameters - the remediation parameters. +func (client RemediationsClient) CreateOrUpdateAtResource(ctx context.Context, resourceID string, remediationName string, parameters Remediation) (result Remediation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.CreateOrUpdateAtResource") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdateAtResourcePreparer(ctx, resourceID, remediationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CreateOrUpdateAtResource", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateAtResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CreateOrUpdateAtResource", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateAtResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CreateOrUpdateAtResource", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdateAtResourcePreparer prepares the CreateOrUpdateAtResource request. +func (client RemediationsClient) CreateOrUpdateAtResourcePreparer(ctx context.Context, resourceID string, remediationName string, parameters Remediation) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "remediationName": autorest.Encode("path", remediationName), + "resourceId": resourceID, + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.ID = nil + parameters.Type = nil + parameters.Name = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateAtResourceSender sends the CreateOrUpdateAtResource request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) CreateOrUpdateAtResourceSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// CreateOrUpdateAtResourceResponder handles the response to the CreateOrUpdateAtResource request. The method always +// closes the http.Response Body. +func (client RemediationsClient) CreateOrUpdateAtResourceResponder(resp *http.Response) (result Remediation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdateAtResourceGroup creates or updates a remediation at resource group scope. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// resourceGroupName - resource group name. +// remediationName - the name of the remediation. +// parameters - the remediation parameters. +func (client RemediationsClient) CreateOrUpdateAtResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, remediationName string, parameters Remediation) (result Remediation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.CreateOrUpdateAtResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdateAtResourceGroupPreparer(ctx, subscriptionID, resourceGroupName, remediationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CreateOrUpdateAtResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateAtResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CreateOrUpdateAtResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateAtResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CreateOrUpdateAtResourceGroup", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdateAtResourceGroupPreparer prepares the CreateOrUpdateAtResourceGroup request. +func (client RemediationsClient) CreateOrUpdateAtResourceGroupPreparer(ctx context.Context, subscriptionID string, resourceGroupName string, remediationName string, parameters Remediation) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "remediationName": autorest.Encode("path", remediationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.ID = nil + parameters.Type = nil + parameters.Name = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateAtResourceGroupSender sends the CreateOrUpdateAtResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) CreateOrUpdateAtResourceGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// CreateOrUpdateAtResourceGroupResponder handles the response to the CreateOrUpdateAtResourceGroup request. The method always +// closes the http.Response Body. +func (client RemediationsClient) CreateOrUpdateAtResourceGroupResponder(resp *http.Response) (result Remediation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdateAtSubscription creates or updates a remediation at subscription scope. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// remediationName - the name of the remediation. +// parameters - the remediation parameters. +func (client RemediationsClient) CreateOrUpdateAtSubscription(ctx context.Context, subscriptionID string, remediationName string, parameters Remediation) (result Remediation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.CreateOrUpdateAtSubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdateAtSubscriptionPreparer(ctx, subscriptionID, remediationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CreateOrUpdateAtSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateAtSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CreateOrUpdateAtSubscription", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateAtSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "CreateOrUpdateAtSubscription", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdateAtSubscriptionPreparer prepares the CreateOrUpdateAtSubscription request. +func (client RemediationsClient) CreateOrUpdateAtSubscriptionPreparer(ctx context.Context, subscriptionID string, remediationName string, parameters Remediation) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "remediationName": autorest.Encode("path", remediationName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.ID = nil + parameters.Type = nil + parameters.Name = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateAtSubscriptionSender sends the CreateOrUpdateAtSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) CreateOrUpdateAtSubscriptionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// CreateOrUpdateAtSubscriptionResponder handles the response to the CreateOrUpdateAtSubscription request. The method always +// closes the http.Response Body. +func (client RemediationsClient) CreateOrUpdateAtSubscriptionResponder(resp *http.Response) (result Remediation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteAtManagementGroup deletes an existing remediation at management group scope. +// Parameters: +// managementGroupID - management group ID. +// remediationName - the name of the remediation. +func (client RemediationsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string) (result Remediation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.DeleteAtManagementGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteAtManagementGroupPreparer(ctx, managementGroupID, remediationName) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "DeleteAtManagementGroup", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteAtManagementGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "DeleteAtManagementGroup", resp, "Failure sending request") + return + } + + result, err = client.DeleteAtManagementGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "DeleteAtManagementGroup", resp, "Failure responding to request") + } + + return +} + +// DeleteAtManagementGroupPreparer prepares the DeleteAtManagementGroup request. +func (client RemediationsClient) DeleteAtManagementGroupPreparer(ctx context.Context, managementGroupID string, remediationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managementGroupId": autorest.Encode("path", managementGroupID), + "managementGroupsNamespace": autorest.Encode("path", "Microsoft.Management"), + "remediationName": autorest.Encode("path", remediationName), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteAtManagementGroupSender sends the DeleteAtManagementGroup request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) DeleteAtManagementGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// DeleteAtManagementGroupResponder handles the response to the DeleteAtManagementGroup request. The method always +// closes the http.Response Body. +func (client RemediationsClient) DeleteAtManagementGroupResponder(resp *http.Response) (result Remediation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteAtResource deletes an existing remediation at individual resource scope. +// Parameters: +// resourceID - resource ID. +// remediationName - the name of the remediation. +func (client RemediationsClient) DeleteAtResource(ctx context.Context, resourceID string, remediationName string) (result Remediation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.DeleteAtResource") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteAtResourcePreparer(ctx, resourceID, remediationName) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "DeleteAtResource", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteAtResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "DeleteAtResource", resp, "Failure sending request") + return + } + + result, err = client.DeleteAtResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "DeleteAtResource", resp, "Failure responding to request") + } + + return +} + +// DeleteAtResourcePreparer prepares the DeleteAtResource request. +func (client RemediationsClient) DeleteAtResourcePreparer(ctx context.Context, resourceID string, remediationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "remediationName": autorest.Encode("path", remediationName), + "resourceId": resourceID, + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteAtResourceSender sends the DeleteAtResource request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) DeleteAtResourceSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// DeleteAtResourceResponder handles the response to the DeleteAtResource request. The method always +// closes the http.Response Body. +func (client RemediationsClient) DeleteAtResourceResponder(resp *http.Response) (result Remediation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteAtResourceGroup deletes an existing remediation at resource group scope. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// resourceGroupName - resource group name. +// remediationName - the name of the remediation. +func (client RemediationsClient) DeleteAtResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, remediationName string) (result Remediation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.DeleteAtResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteAtResourceGroupPreparer(ctx, subscriptionID, resourceGroupName, remediationName) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "DeleteAtResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteAtResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "DeleteAtResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.DeleteAtResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "DeleteAtResourceGroup", resp, "Failure responding to request") + } + + return +} + +// DeleteAtResourceGroupPreparer prepares the DeleteAtResourceGroup request. +func (client RemediationsClient) DeleteAtResourceGroupPreparer(ctx context.Context, subscriptionID string, resourceGroupName string, remediationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "remediationName": autorest.Encode("path", remediationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteAtResourceGroupSender sends the DeleteAtResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) DeleteAtResourceGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// DeleteAtResourceGroupResponder handles the response to the DeleteAtResourceGroup request. The method always +// closes the http.Response Body. +func (client RemediationsClient) DeleteAtResourceGroupResponder(resp *http.Response) (result Remediation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteAtSubscription deletes an existing remediation at subscription scope. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// remediationName - the name of the remediation. +func (client RemediationsClient) DeleteAtSubscription(ctx context.Context, subscriptionID string, remediationName string) (result Remediation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.DeleteAtSubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteAtSubscriptionPreparer(ctx, subscriptionID, remediationName) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "DeleteAtSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteAtSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "DeleteAtSubscription", resp, "Failure sending request") + return + } + + result, err = client.DeleteAtSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "DeleteAtSubscription", resp, "Failure responding to request") + } + + return +} + +// DeleteAtSubscriptionPreparer prepares the DeleteAtSubscription request. +func (client RemediationsClient) DeleteAtSubscriptionPreparer(ctx context.Context, subscriptionID string, remediationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "remediationName": autorest.Encode("path", remediationName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteAtSubscriptionSender sends the DeleteAtSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) DeleteAtSubscriptionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// DeleteAtSubscriptionResponder handles the response to the DeleteAtSubscription request. The method always +// closes the http.Response Body. +func (client RemediationsClient) DeleteAtSubscriptionResponder(resp *http.Response) (result Remediation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetAtManagementGroup gets an existing remediation at management group scope. +// Parameters: +// managementGroupID - management group ID. +// remediationName - the name of the remediation. +func (client RemediationsClient) GetAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string) (result Remediation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.GetAtManagementGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetAtManagementGroupPreparer(ctx, managementGroupID, remediationName) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "GetAtManagementGroup", nil, "Failure preparing request") + return + } + + resp, err := client.GetAtManagementGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "GetAtManagementGroup", resp, "Failure sending request") + return + } + + result, err = client.GetAtManagementGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "GetAtManagementGroup", resp, "Failure responding to request") + } + + return +} + +// GetAtManagementGroupPreparer prepares the GetAtManagementGroup request. +func (client RemediationsClient) GetAtManagementGroupPreparer(ctx context.Context, managementGroupID string, remediationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managementGroupId": autorest.Encode("path", managementGroupID), + "managementGroupsNamespace": autorest.Encode("path", "Microsoft.Management"), + "remediationName": autorest.Encode("path", remediationName), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetAtManagementGroupSender sends the GetAtManagementGroup request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) GetAtManagementGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetAtManagementGroupResponder handles the response to the GetAtManagementGroup request. The method always +// closes the http.Response Body. +func (client RemediationsClient) GetAtManagementGroupResponder(resp *http.Response) (result Remediation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetAtResource gets an existing remediation at resource scope. +// Parameters: +// resourceID - resource ID. +// remediationName - the name of the remediation. +func (client RemediationsClient) GetAtResource(ctx context.Context, resourceID string, remediationName string) (result Remediation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.GetAtResource") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetAtResourcePreparer(ctx, resourceID, remediationName) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "GetAtResource", nil, "Failure preparing request") + return + } + + resp, err := client.GetAtResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "GetAtResource", resp, "Failure sending request") + return + } + + result, err = client.GetAtResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "GetAtResource", resp, "Failure responding to request") + } + + return +} + +// GetAtResourcePreparer prepares the GetAtResource request. +func (client RemediationsClient) GetAtResourcePreparer(ctx context.Context, resourceID string, remediationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "remediationName": autorest.Encode("path", remediationName), + "resourceId": resourceID, + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetAtResourceSender sends the GetAtResource request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) GetAtResourceSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetAtResourceResponder handles the response to the GetAtResource request. The method always +// closes the http.Response Body. +func (client RemediationsClient) GetAtResourceResponder(resp *http.Response) (result Remediation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetAtResourceGroup gets an existing remediation at resource group scope. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// resourceGroupName - resource group name. +// remediationName - the name of the remediation. +func (client RemediationsClient) GetAtResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, remediationName string) (result Remediation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.GetAtResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetAtResourceGroupPreparer(ctx, subscriptionID, resourceGroupName, remediationName) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "GetAtResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.GetAtResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "GetAtResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.GetAtResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "GetAtResourceGroup", resp, "Failure responding to request") + } + + return +} + +// GetAtResourceGroupPreparer prepares the GetAtResourceGroup request. +func (client RemediationsClient) GetAtResourceGroupPreparer(ctx context.Context, subscriptionID string, resourceGroupName string, remediationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "remediationName": autorest.Encode("path", remediationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetAtResourceGroupSender sends the GetAtResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) GetAtResourceGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetAtResourceGroupResponder handles the response to the GetAtResourceGroup request. The method always +// closes the http.Response Body. +func (client RemediationsClient) GetAtResourceGroupResponder(resp *http.Response) (result Remediation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetAtSubscription gets an existing remediation at subscription scope. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// remediationName - the name of the remediation. +func (client RemediationsClient) GetAtSubscription(ctx context.Context, subscriptionID string, remediationName string) (result Remediation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.GetAtSubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetAtSubscriptionPreparer(ctx, subscriptionID, remediationName) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "GetAtSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.GetAtSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "GetAtSubscription", resp, "Failure sending request") + return + } + + result, err = client.GetAtSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "GetAtSubscription", resp, "Failure responding to request") + } + + return +} + +// GetAtSubscriptionPreparer prepares the GetAtSubscription request. +func (client RemediationsClient) GetAtSubscriptionPreparer(ctx context.Context, subscriptionID string, remediationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "remediationName": autorest.Encode("path", remediationName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetAtSubscriptionSender sends the GetAtSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) GetAtSubscriptionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetAtSubscriptionResponder handles the response to the GetAtSubscription request. The method always +// closes the http.Response Body. +func (client RemediationsClient) GetAtSubscriptionResponder(resp *http.Response) (result Remediation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListDeploymentsAtManagementGroup gets all deployments for a remediation at management group scope. +// Parameters: +// managementGroupID - management group ID. +// remediationName - the name of the remediation. +// top - maximum number of records to return. +func (client RemediationsClient) ListDeploymentsAtManagementGroup(ctx context.Context, managementGroupID string, remediationName string, top *int32) (result RemediationDeploymentsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.ListDeploymentsAtManagementGroup") + defer func() { + sc := -1 + if result.rdlr.Response.Response != nil { + sc = result.rdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.RemediationsClient", "ListDeploymentsAtManagementGroup", err.Error()) + } + + result.fn = client.listDeploymentsAtManagementGroupNextResults + req, err := client.ListDeploymentsAtManagementGroupPreparer(ctx, managementGroupID, remediationName, top) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListDeploymentsAtManagementGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListDeploymentsAtManagementGroupSender(req) + if err != nil { + result.rdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListDeploymentsAtManagementGroup", resp, "Failure sending request") + return + } + + result.rdlr, err = client.ListDeploymentsAtManagementGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListDeploymentsAtManagementGroup", resp, "Failure responding to request") + } + + return +} + +// ListDeploymentsAtManagementGroupPreparer prepares the ListDeploymentsAtManagementGroup request. +func (client RemediationsClient) ListDeploymentsAtManagementGroupPreparer(ctx context.Context, managementGroupID string, remediationName string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managementGroupId": autorest.Encode("path", managementGroupID), + "managementGroupsNamespace": autorest.Encode("path", "Microsoft.Management"), + "remediationName": autorest.Encode("path", remediationName), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListDeploymentsAtManagementGroupSender sends the ListDeploymentsAtManagementGroup request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) ListDeploymentsAtManagementGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListDeploymentsAtManagementGroupResponder handles the response to the ListDeploymentsAtManagementGroup request. The method always +// closes the http.Response Body. +func (client RemediationsClient) ListDeploymentsAtManagementGroupResponder(resp *http.Response) (result RemediationDeploymentsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listDeploymentsAtManagementGroupNextResults retrieves the next set of results, if any. +func (client RemediationsClient) listDeploymentsAtManagementGroupNextResults(ctx context.Context, lastResults RemediationDeploymentsListResult) (result RemediationDeploymentsListResult, err error) { + req, err := lastResults.remediationDeploymentsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listDeploymentsAtManagementGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListDeploymentsAtManagementGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listDeploymentsAtManagementGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListDeploymentsAtManagementGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listDeploymentsAtManagementGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListDeploymentsAtManagementGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client RemediationsClient) ListDeploymentsAtManagementGroupComplete(ctx context.Context, managementGroupID string, remediationName string, top *int32) (result RemediationDeploymentsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.ListDeploymentsAtManagementGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListDeploymentsAtManagementGroup(ctx, managementGroupID, remediationName, top) + return +} + +// ListDeploymentsAtResource gets all deployments for a remediation at resource scope. +// Parameters: +// resourceID - resource ID. +// remediationName - the name of the remediation. +// top - maximum number of records to return. +func (client RemediationsClient) ListDeploymentsAtResource(ctx context.Context, resourceID string, remediationName string, top *int32) (result RemediationDeploymentsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.ListDeploymentsAtResource") + defer func() { + sc := -1 + if result.rdlr.Response.Response != nil { + sc = result.rdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.RemediationsClient", "ListDeploymentsAtResource", err.Error()) + } + + result.fn = client.listDeploymentsAtResourceNextResults + req, err := client.ListDeploymentsAtResourcePreparer(ctx, resourceID, remediationName, top) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListDeploymentsAtResource", nil, "Failure preparing request") + return + } + + resp, err := client.ListDeploymentsAtResourceSender(req) + if err != nil { + result.rdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListDeploymentsAtResource", resp, "Failure sending request") + return + } + + result.rdlr, err = client.ListDeploymentsAtResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListDeploymentsAtResource", resp, "Failure responding to request") + } + + return +} + +// ListDeploymentsAtResourcePreparer prepares the ListDeploymentsAtResource request. +func (client RemediationsClient) ListDeploymentsAtResourcePreparer(ctx context.Context, resourceID string, remediationName string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "remediationName": autorest.Encode("path", remediationName), + "resourceId": resourceID, + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListDeploymentsAtResourceSender sends the ListDeploymentsAtResource request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) ListDeploymentsAtResourceSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListDeploymentsAtResourceResponder handles the response to the ListDeploymentsAtResource request. The method always +// closes the http.Response Body. +func (client RemediationsClient) ListDeploymentsAtResourceResponder(resp *http.Response) (result RemediationDeploymentsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listDeploymentsAtResourceNextResults retrieves the next set of results, if any. +func (client RemediationsClient) listDeploymentsAtResourceNextResults(ctx context.Context, lastResults RemediationDeploymentsListResult) (result RemediationDeploymentsListResult, err error) { + req, err := lastResults.remediationDeploymentsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listDeploymentsAtResourceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListDeploymentsAtResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listDeploymentsAtResourceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListDeploymentsAtResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listDeploymentsAtResourceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListDeploymentsAtResourceComplete enumerates all values, automatically crossing page boundaries as required. +func (client RemediationsClient) ListDeploymentsAtResourceComplete(ctx context.Context, resourceID string, remediationName string, top *int32) (result RemediationDeploymentsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.ListDeploymentsAtResource") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListDeploymentsAtResource(ctx, resourceID, remediationName, top) + return +} + +// ListDeploymentsAtResourceGroup gets all deployments for a remediation at resource group scope. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// resourceGroupName - resource group name. +// remediationName - the name of the remediation. +// top - maximum number of records to return. +func (client RemediationsClient) ListDeploymentsAtResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, remediationName string, top *int32) (result RemediationDeploymentsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.ListDeploymentsAtResourceGroup") + defer func() { + sc := -1 + if result.rdlr.Response.Response != nil { + sc = result.rdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.RemediationsClient", "ListDeploymentsAtResourceGroup", err.Error()) + } + + result.fn = client.listDeploymentsAtResourceGroupNextResults + req, err := client.ListDeploymentsAtResourceGroupPreparer(ctx, subscriptionID, resourceGroupName, remediationName, top) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListDeploymentsAtResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListDeploymentsAtResourceGroupSender(req) + if err != nil { + result.rdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListDeploymentsAtResourceGroup", resp, "Failure sending request") + return + } + + result.rdlr, err = client.ListDeploymentsAtResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListDeploymentsAtResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListDeploymentsAtResourceGroupPreparer prepares the ListDeploymentsAtResourceGroup request. +func (client RemediationsClient) ListDeploymentsAtResourceGroupPreparer(ctx context.Context, subscriptionID string, resourceGroupName string, remediationName string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "remediationName": autorest.Encode("path", remediationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListDeploymentsAtResourceGroupSender sends the ListDeploymentsAtResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) ListDeploymentsAtResourceGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListDeploymentsAtResourceGroupResponder handles the response to the ListDeploymentsAtResourceGroup request. The method always +// closes the http.Response Body. +func (client RemediationsClient) ListDeploymentsAtResourceGroupResponder(resp *http.Response) (result RemediationDeploymentsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listDeploymentsAtResourceGroupNextResults retrieves the next set of results, if any. +func (client RemediationsClient) listDeploymentsAtResourceGroupNextResults(ctx context.Context, lastResults RemediationDeploymentsListResult) (result RemediationDeploymentsListResult, err error) { + req, err := lastResults.remediationDeploymentsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listDeploymentsAtResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListDeploymentsAtResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listDeploymentsAtResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListDeploymentsAtResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listDeploymentsAtResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListDeploymentsAtResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client RemediationsClient) ListDeploymentsAtResourceGroupComplete(ctx context.Context, subscriptionID string, resourceGroupName string, remediationName string, top *int32) (result RemediationDeploymentsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.ListDeploymentsAtResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListDeploymentsAtResourceGroup(ctx, subscriptionID, resourceGroupName, remediationName, top) + return +} + +// ListDeploymentsAtSubscription gets all deployments for a remediation at subscription scope. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// remediationName - the name of the remediation. +// top - maximum number of records to return. +func (client RemediationsClient) ListDeploymentsAtSubscription(ctx context.Context, subscriptionID string, remediationName string, top *int32) (result RemediationDeploymentsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.ListDeploymentsAtSubscription") + defer func() { + sc := -1 + if result.rdlr.Response.Response != nil { + sc = result.rdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.RemediationsClient", "ListDeploymentsAtSubscription", err.Error()) + } + + result.fn = client.listDeploymentsAtSubscriptionNextResults + req, err := client.ListDeploymentsAtSubscriptionPreparer(ctx, subscriptionID, remediationName, top) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListDeploymentsAtSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListDeploymentsAtSubscriptionSender(req) + if err != nil { + result.rdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListDeploymentsAtSubscription", resp, "Failure sending request") + return + } + + result.rdlr, err = client.ListDeploymentsAtSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListDeploymentsAtSubscription", resp, "Failure responding to request") + } + + return +} + +// ListDeploymentsAtSubscriptionPreparer prepares the ListDeploymentsAtSubscription request. +func (client RemediationsClient) ListDeploymentsAtSubscriptionPreparer(ctx context.Context, subscriptionID string, remediationName string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "remediationName": autorest.Encode("path", remediationName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListDeploymentsAtSubscriptionSender sends the ListDeploymentsAtSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) ListDeploymentsAtSubscriptionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListDeploymentsAtSubscriptionResponder handles the response to the ListDeploymentsAtSubscription request. The method always +// closes the http.Response Body. +func (client RemediationsClient) ListDeploymentsAtSubscriptionResponder(resp *http.Response) (result RemediationDeploymentsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listDeploymentsAtSubscriptionNextResults retrieves the next set of results, if any. +func (client RemediationsClient) listDeploymentsAtSubscriptionNextResults(ctx context.Context, lastResults RemediationDeploymentsListResult) (result RemediationDeploymentsListResult, err error) { + req, err := lastResults.remediationDeploymentsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listDeploymentsAtSubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListDeploymentsAtSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listDeploymentsAtSubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListDeploymentsAtSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listDeploymentsAtSubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListDeploymentsAtSubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client RemediationsClient) ListDeploymentsAtSubscriptionComplete(ctx context.Context, subscriptionID string, remediationName string, top *int32) (result RemediationDeploymentsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.ListDeploymentsAtSubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListDeploymentsAtSubscription(ctx, subscriptionID, remediationName, top) + return +} + +// ListForManagementGroup gets all remediations for the management group. +// Parameters: +// managementGroupID - management group ID. +// top - maximum number of records to return. +// filter - oData filter expression. +func (client RemediationsClient) ListForManagementGroup(ctx context.Context, managementGroupID string, top *int32, filter string) (result RemediationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.ListForManagementGroup") + defer func() { + sc := -1 + if result.rlr.Response.Response != nil { + sc = result.rlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.RemediationsClient", "ListForManagementGroup", err.Error()) + } + + result.fn = client.listForManagementGroupNextResults + req, err := client.ListForManagementGroupPreparer(ctx, managementGroupID, top, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListForManagementGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListForManagementGroupSender(req) + if err != nil { + result.rlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListForManagementGroup", resp, "Failure sending request") + return + } + + result.rlr, err = client.ListForManagementGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListForManagementGroup", resp, "Failure responding to request") + } + + return +} + +// ListForManagementGroupPreparer prepares the ListForManagementGroup request. +func (client RemediationsClient) ListForManagementGroupPreparer(ctx context.Context, managementGroupID string, top *int32, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managementGroupId": autorest.Encode("path", managementGroupID), + "managementGroupsNamespace": autorest.Encode("path", "Microsoft.Management"), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListForManagementGroupSender sends the ListForManagementGroup request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) ListForManagementGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListForManagementGroupResponder handles the response to the ListForManagementGroup request. The method always +// closes the http.Response Body. +func (client RemediationsClient) ListForManagementGroupResponder(resp *http.Response) (result RemediationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listForManagementGroupNextResults retrieves the next set of results, if any. +func (client RemediationsClient) listForManagementGroupNextResults(ctx context.Context, lastResults RemediationListResult) (result RemediationListResult, err error) { + req, err := lastResults.remediationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listForManagementGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListForManagementGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listForManagementGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForManagementGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listForManagementGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForManagementGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client RemediationsClient) ListForManagementGroupComplete(ctx context.Context, managementGroupID string, top *int32, filter string) (result RemediationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.ListForManagementGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListForManagementGroup(ctx, managementGroupID, top, filter) + return +} + +// ListForResource gets all remediations for a resource. +// Parameters: +// resourceID - resource ID. +// top - maximum number of records to return. +// filter - oData filter expression. +func (client RemediationsClient) ListForResource(ctx context.Context, resourceID string, top *int32, filter string) (result RemediationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.ListForResource") + defer func() { + sc := -1 + if result.rlr.Response.Response != nil { + sc = result.rlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.RemediationsClient", "ListForResource", err.Error()) + } + + result.fn = client.listForResourceNextResults + req, err := client.ListForResourcePreparer(ctx, resourceID, top, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListForResource", nil, "Failure preparing request") + return + } + + resp, err := client.ListForResourceSender(req) + if err != nil { + result.rlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListForResource", resp, "Failure sending request") + return + } + + result.rlr, err = client.ListForResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListForResource", resp, "Failure responding to request") + } + + return +} + +// ListForResourcePreparer prepares the ListForResource request. +func (client RemediationsClient) ListForResourcePreparer(ctx context.Context, resourceID string, top *int32, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceId": resourceID, + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.PolicyInsights/remediations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListForResourceSender sends the ListForResource request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) ListForResourceSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListForResourceResponder handles the response to the ListForResource request. The method always +// closes the http.Response Body. +func (client RemediationsClient) ListForResourceResponder(resp *http.Response) (result RemediationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listForResourceNextResults retrieves the next set of results, if any. +func (client RemediationsClient) listForResourceNextResults(ctx context.Context, lastResults RemediationListResult) (result RemediationListResult, err error) { + req, err := lastResults.remediationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listForResourceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListForResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listForResourceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listForResourceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForResourceComplete enumerates all values, automatically crossing page boundaries as required. +func (client RemediationsClient) ListForResourceComplete(ctx context.Context, resourceID string, top *int32, filter string) (result RemediationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.ListForResource") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListForResource(ctx, resourceID, top, filter) + return +} + +// ListForResourceGroup gets all remediations for the subscription. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// resourceGroupName - resource group name. +// top - maximum number of records to return. +// filter - oData filter expression. +func (client RemediationsClient) ListForResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, top *int32, filter string) (result RemediationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.ListForResourceGroup") + defer func() { + sc := -1 + if result.rlr.Response.Response != nil { + sc = result.rlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.RemediationsClient", "ListForResourceGroup", err.Error()) + } + + result.fn = client.listForResourceGroupNextResults + req, err := client.ListForResourceGroupPreparer(ctx, subscriptionID, resourceGroupName, top, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListForResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListForResourceGroupSender(req) + if err != nil { + result.rlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListForResourceGroup", resp, "Failure sending request") + return + } + + result.rlr, err = client.ListForResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListForResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListForResourceGroupPreparer prepares the ListForResourceGroup request. +func (client RemediationsClient) ListForResourceGroupPreparer(ctx context.Context, subscriptionID string, resourceGroupName string, top *int32, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListForResourceGroupSender sends the ListForResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) ListForResourceGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListForResourceGroupResponder handles the response to the ListForResourceGroup request. The method always +// closes the http.Response Body. +func (client RemediationsClient) ListForResourceGroupResponder(resp *http.Response) (result RemediationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listForResourceGroupNextResults retrieves the next set of results, if any. +func (client RemediationsClient) listForResourceGroupNextResults(ctx context.Context, lastResults RemediationListResult) (result RemediationListResult, err error) { + req, err := lastResults.remediationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listForResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListForResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listForResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listForResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client RemediationsClient) ListForResourceGroupComplete(ctx context.Context, subscriptionID string, resourceGroupName string, top *int32, filter string) (result RemediationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.ListForResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListForResourceGroup(ctx, subscriptionID, resourceGroupName, top, filter) + return +} + +// ListForSubscription gets all remediations for the subscription. +// Parameters: +// subscriptionID - microsoft Azure subscription ID. +// top - maximum number of records to return. +// filter - oData filter expression. +func (client RemediationsClient) ListForSubscription(ctx context.Context, subscriptionID string, top *int32, filter string) (result RemediationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.ListForSubscription") + defer func() { + sc := -1 + if result.rlr.Response.Response != nil { + sc = result.rlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("policyinsights.RemediationsClient", "ListForSubscription", err.Error()) + } + + result.fn = client.listForSubscriptionNextResults + req, err := client.ListForSubscriptionPreparer(ctx, subscriptionID, top, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListForSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListForSubscriptionSender(req) + if err != nil { + result.rlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListForSubscription", resp, "Failure sending request") + return + } + + result.rlr, err = client.ListForSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListForSubscription", resp, "Failure responding to request") + } + + return +} + +// ListForSubscriptionPreparer prepares the ListForSubscription request. +func (client RemediationsClient) ListForSubscriptionPreparer(ctx context.Context, subscriptionID string, top *int32, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", subscriptionID), + } + + const APIVersion = "2018-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListForSubscriptionSender sends the ListForSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client RemediationsClient) ListForSubscriptionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListForSubscriptionResponder handles the response to the ListForSubscription request. The method always +// closes the http.Response Body. +func (client RemediationsClient) ListForSubscriptionResponder(resp *http.Response) (result RemediationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listForSubscriptionNextResults retrieves the next set of results, if any. +func (client RemediationsClient) listForSubscriptionNextResults(ctx context.Context, lastResults RemediationListResult) (result RemediationListResult, err error) { + req, err := lastResults.remediationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listForSubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListForSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listForSubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListForSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "listForSubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListForSubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client RemediationsClient) ListForSubscriptionComplete(ctx context.Context, subscriptionID string, top *int32, filter string) (result RemediationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RemediationsClient.ListForSubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListForSubscription(ctx, subscriptionID, top, filter) + return +} diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/version.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/version.go new file mode 100644 index 000000000000..18cce08f4d74 --- /dev/null +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/version.go @@ -0,0 +1,30 @@ +package policyinsights + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " policyinsights/2019-10-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}