diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/enums.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/enums.go new file mode 100644 index 000000000000..194d96902705 --- /dev/null +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/enums.go @@ -0,0 +1,49 @@ +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. + +// 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} +} + +// ResourceDiscoveryMode enumerates the values for resource discovery mode. +type ResourceDiscoveryMode string + +const ( + // ExistingNonCompliant Remediate resources that are already known to be non-compliant. + ExistingNonCompliant ResourceDiscoveryMode = "ExistingNonCompliant" + // ReEvaluateCompliance Re-evaluate the compliance state of resources and then remediate the resources + // found to be non-compliant. + ReEvaluateCompliance ResourceDiscoveryMode = "ReEvaluateCompliance" +) + +// PossibleResourceDiscoveryModeValues returns an array of possible values for the ResourceDiscoveryMode const type. +func PossibleResourceDiscoveryModeValues() []ResourceDiscoveryMode { + return []ResourceDiscoveryMode{ExistingNonCompliant, ReEvaluateCompliance} +} diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/models.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/models.go index 852afc7ef6b4..4313078a1361 100644 --- a/services/policyinsights/mgmt/2019-10-01/policyinsights/models.go +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/models.go @@ -31,43 +31,264 @@ import ( // 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" -) +// 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"` +} -// PossiblePolicyStatesResourceValues returns an array of possible values for the PolicyStatesResource const type. -func PossiblePolicyStatesResourceValues() []PolicyStatesResource { - return []PolicyStatesResource{Default, Latest} +// ComponentEventDetails component event details. +type ComponentEventDetails struct { + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // ID - Component Id. + ID *string `json:"id,omitempty"` + // Type - Component type. + Type *string `json:"type,omitempty"` + // Name - Component name. + Name *string `json:"name,omitempty"` + // Timestamp - Timestamp for component policy event record. + Timestamp *date.Time `json:"timestamp,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 component operation that triggered the policy event. + PrincipalOid *string `json:"principalOid,omitempty"` + // PolicyDefinitionAction - Policy definition action, i.e. effect. + PolicyDefinitionAction *string `json:"policyDefinitionAction,omitempty"` } -// ResourceDiscoveryMode enumerates the values for resource discovery mode. -type ResourceDiscoveryMode string +// MarshalJSON is the custom marshaler for ComponentEventDetails. +func (ced ComponentEventDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ced.ID != nil { + objectMap["id"] = ced.ID + } + if ced.Type != nil { + objectMap["type"] = ced.Type + } + if ced.Name != nil { + objectMap["name"] = ced.Name + } + if ced.Timestamp != nil { + objectMap["timestamp"] = ced.Timestamp + } + if ced.TenantID != nil { + objectMap["tenantId"] = ced.TenantID + } + if ced.PrincipalOid != nil { + objectMap["principalOid"] = ced.PrincipalOid + } + if ced.PolicyDefinitionAction != nil { + objectMap["policyDefinitionAction"] = ced.PolicyDefinitionAction + } + for k, v := range ced.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} -const ( - // ExistingNonCompliant Remediate resources that are already known to be non-compliant. - ExistingNonCompliant ResourceDiscoveryMode = "ExistingNonCompliant" - // ReEvaluateCompliance Re-evaluate the compliance state of resources and then remediate the resources - // found to be non-compliant. - ReEvaluateCompliance ResourceDiscoveryMode = "ReEvaluateCompliance" -) +// UnmarshalJSON is the custom unmarshaler for ComponentEventDetails struct. +func (ced *ComponentEventDetails) 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 ced.AdditionalProperties == nil { + ced.AdditionalProperties = make(map[string]interface{}) + } + ced.AdditionalProperties[k] = additionalProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ced.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ced.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ced.Name = &name + } + case "timestamp": + if v != nil { + var timestamp date.Time + err = json.Unmarshal(*v, ×tamp) + if err != nil { + return err + } + ced.Timestamp = ×tamp + } + case "tenantId": + if v != nil { + var tenantID string + err = json.Unmarshal(*v, &tenantID) + if err != nil { + return err + } + ced.TenantID = &tenantID + } + case "principalOid": + if v != nil { + var principalOid string + err = json.Unmarshal(*v, &principalOid) + if err != nil { + return err + } + ced.PrincipalOid = &principalOid + } + case "policyDefinitionAction": + if v != nil { + var policyDefinitionAction string + err = json.Unmarshal(*v, &policyDefinitionAction) + if err != nil { + return err + } + ced.PolicyDefinitionAction = &policyDefinitionAction + } + } + } -// PossibleResourceDiscoveryModeValues returns an array of possible values for the ResourceDiscoveryMode const type. -func PossibleResourceDiscoveryModeValues() []ResourceDiscoveryMode { - return []ResourceDiscoveryMode{ExistingNonCompliant, ReEvaluateCompliance} + return nil } -// ComplianceDetail the compliance state rollup. -type ComplianceDetail struct { - // ComplianceState - The compliance state. +// ComponentStateDetails component state details. +type ComponentStateDetails struct { + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // ID - Component Id. + ID *string `json:"id,omitempty"` + // Type - Component type. + Type *string `json:"type,omitempty"` + // Name - Component name. + Name *string `json:"name,omitempty"` + // Timestamp - Component compliance evaluation timestamp. + Timestamp *date.Time `json:"timestamp,omitempty"` + // ComplianceState - Component compliance state. ComplianceState *string `json:"complianceState,omitempty"` - // Count - Summarized count value for this compliance state. - Count *int32 `json:"count,omitempty"` +} + +// MarshalJSON is the custom marshaler for ComponentStateDetails. +func (csd ComponentStateDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if csd.ID != nil { + objectMap["id"] = csd.ID + } + if csd.Type != nil { + objectMap["type"] = csd.Type + } + if csd.Name != nil { + objectMap["name"] = csd.Name + } + if csd.Timestamp != nil { + objectMap["timestamp"] = csd.Timestamp + } + if csd.ComplianceState != nil { + objectMap["complianceState"] = csd.ComplianceState + } + for k, v := range csd.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ComponentStateDetails struct. +func (csd *ComponentStateDetails) 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 csd.AdditionalProperties == nil { + csd.AdditionalProperties = make(map[string]interface{}) + } + csd.AdditionalProperties[k] = additionalProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + csd.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + csd.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + csd.Name = &name + } + case "timestamp": + if v != nil { + var timestamp date.Time + err = json.Unmarshal(*v, ×tamp) + if err != nil { + return err + } + csd.Timestamp = ×tamp + } + case "complianceState": + if v != nil { + var complianceState string + err = json.Unmarshal(*v, &complianceState) + if err != nil { + return err + } + csd.ComplianceState = &complianceState + } + } + } + + return nil } // ErrorDefinition error definition. @@ -84,6 +305,12 @@ type ErrorDefinition struct { AdditionalInfo *[]TypedErrorInfo `json:"additionalInfo,omitempty"` } +// MarshalJSON is the custom marshaler for ErrorDefinition. +func (ed ErrorDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + // ErrorResponse error response. type ErrorResponse struct { // Error - The error details. @@ -187,6 +414,12 @@ type PolicyDetails struct { PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` } +// MarshalJSON is the custom marshaler for PolicyDetails. +func (pd PolicyDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + // PolicyEvaluationDetails policy evaluation details. type PolicyEvaluationDetails struct { // EvaluatedExpressions - Details of the evaluated expressions. @@ -253,10 +486,14 @@ type PolicyEvent struct { 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"` // 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"` + // Components - Components events records populated only when URL contains $expand=components clause. + Components *[]ComponentEventDetails `json:"components,omitempty"` } // MarshalJSON is the custom marshaler for PolicyEvent. @@ -343,12 +580,18 @@ func (peVar PolicyEvent) MarshalJSON() ([]byte, error) { if peVar.PolicyDefinitionReferenceID != nil { objectMap["policyDefinitionReferenceId"] = peVar.PolicyDefinitionReferenceID } + if peVar.ComplianceState != nil { + objectMap["complianceState"] = peVar.ComplianceState + } if peVar.TenantID != nil { objectMap["tenantId"] = peVar.TenantID } if peVar.PrincipalOid != nil { objectMap["principalOid"] = peVar.PrincipalOid } + if peVar.Components != nil { + objectMap["components"] = peVar.Components + } for k, v := range peVar.AdditionalProperties { objectMap[k] = v } @@ -619,6 +862,15 @@ func (peVar *PolicyEvent) UnmarshalJSON(body []byte) error { } peVar.PolicyDefinitionReferenceID = &policyDefinitionReferenceID } + case "complianceState": + if v != nil { + var complianceState string + err = json.Unmarshal(*v, &complianceState) + if err != nil { + return err + } + peVar.ComplianceState = &complianceState + } case "tenantId": if v != nil { var tenantID string @@ -637,21 +889,179 @@ func (peVar *PolicyEvent) UnmarshalJSON(body []byte) error { } peVar.PrincipalOid = &principalOid } + case "components": + if v != nil { + var components []ComponentEventDetails + err = json.Unmarshal(*v, &components) + if err != nil { + return err + } + peVar.Components = &components + } + } + } + + 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"` + // OdataNextLink - Odata next link; URL to get the next set of results. + OdataNextLink *string `json:"@odata.nextLink,omitempty"` + // Value - Query results. + Value *[]PolicyEvent `json:"value,omitempty"` +} + +// PolicyEventsQueryResultsIterator provides access to a complete listing of PolicyEvent values. +type PolicyEventsQueryResultsIterator struct { + i int + page PolicyEventsQueryResultsPage +} + +// 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 *PolicyEventsQueryResultsIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsQueryResultsIterator.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 *PolicyEventsQueryResultsIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PolicyEventsQueryResultsIterator) 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 PolicyEventsQueryResultsIterator) Response() PolicyEventsQueryResults { + 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 PolicyEventsQueryResultsIterator) Value() PolicyEvent { + if !iter.page.NotDone() { + return PolicyEvent{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PolicyEventsQueryResultsIterator type. +func NewPolicyEventsQueryResultsIterator(page PolicyEventsQueryResultsPage) PolicyEventsQueryResultsIterator { + return PolicyEventsQueryResultsIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (peqr PolicyEventsQueryResults) IsEmpty() bool { + return peqr.Value == nil || len(*peqr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (peqr PolicyEventsQueryResults) hasNextLink() bool { + return peqr.OdataNextLink != nil && len(*peqr.OdataNextLink) != 0 +} + +// policyEventsQueryResultsPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (peqr PolicyEventsQueryResults) policyEventsQueryResultsPreparer(ctx context.Context) (*http.Request, error) { + if !peqr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(peqr.OdataNextLink))) +} + +// PolicyEventsQueryResultsPage contains a page of PolicyEvent values. +type PolicyEventsQueryResultsPage struct { + fn func(context.Context, PolicyEventsQueryResults) (PolicyEventsQueryResults, error) + peqr PolicyEventsQueryResults +} + +// 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 *PolicyEventsQueryResultsPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsQueryResultsPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.peqr) + if err != nil { + return err + } + page.peqr = next + if !next.hasNextLink() || !next.IsEmpty() { + break } } - 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"` +// 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 *PolicyEventsQueryResultsPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PolicyEventsQueryResultsPage) NotDone() bool { + return !page.peqr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PolicyEventsQueryResultsPage) Response() PolicyEventsQueryResults { + return page.peqr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PolicyEventsQueryResultsPage) Values() []PolicyEvent { + if page.peqr.IsEmpty() { + return nil + } + return *page.peqr.Value +} + +// Creates a new instance of the PolicyEventsQueryResultsPage type. +func NewPolicyEventsQueryResultsPage(getNextPage func(context.Context, PolicyEventsQueryResults) (PolicyEventsQueryResults, error)) PolicyEventsQueryResultsPage { + return PolicyEventsQueryResultsPage{fn: getNextPage} } // PolicyGroupSummary policy definition group summary. @@ -744,6 +1154,12 @@ type PolicyMetadataCollection struct { NextLink *string `json:"nextLink,omitempty"` } +// MarshalJSON is the custom marshaler for PolicyMetadataCollection. +func (pmc PolicyMetadataCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + // PolicyMetadataCollectionIterator provides access to a complete listing of SlimPolicyMetadata values. type PolicyMetadataCollectionIterator struct { i int @@ -812,10 +1228,15 @@ func (pmc PolicyMetadataCollection) IsEmpty() bool { return pmc.Value == nil || len(*pmc.Value) == 0 } +// hasNextLink returns true if the NextLink is not empty. +func (pmc PolicyMetadataCollection) hasNextLink() bool { + return pmc.NextLink != nil && len(*pmc.NextLink) != 0 +} + // policyMetadataCollectionPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. func (pmc PolicyMetadataCollection) policyMetadataCollectionPreparer(ctx context.Context) (*http.Request, error) { - if pmc.NextLink == nil || len(to.String(pmc.NextLink)) < 1 { + if !pmc.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), @@ -843,11 +1264,16 @@ func (page *PolicyMetadataCollectionPage) NextWithContext(ctx context.Context) ( tracing.EndSpan(ctx, sc, err) }() } - next, err := page.fn(ctx, page.pmc) - if err != nil { - return err + for { + next, err := page.fn(ctx, page.pmc) + if err != nil { + return err + } + page.pmc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } } - page.pmc = next return nil } @@ -901,8 +1327,14 @@ type PolicyMetadataProperties struct { Metadata interface{} `json:"metadata,omitempty"` } -// PolicyMetadataSlimProperties the properties of the policy metadata, excluding properties containing -// large strings +// MarshalJSON is the custom marshaler for PolicyMetadataProperties. +func (pmp PolicyMetadataProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PolicyMetadataSlimProperties the properties of the policy metadata, excluding properties containing large +// strings type PolicyMetadataSlimProperties struct { // MetadataID - READ-ONLY; The policy metadata identifier. MetadataID *string `json:"metadataId,omitempty"` @@ -918,6 +1350,12 @@ type PolicyMetadataSlimProperties struct { Metadata interface{} `json:"metadata,omitempty"` } +// MarshalJSON is the custom marshaler for PolicyMetadataSlimProperties. +func (pmsp PolicyMetadataSlimProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + // PolicyState policy state record. type PolicyState struct { // AdditionalProperties - Unmatched properties from the message are deserialized this collection @@ -982,6 +1420,14 @@ type PolicyState struct { PolicyEvaluationDetails *PolicyEvaluationDetails `json:"policyEvaluationDetails,omitempty"` // PolicyDefinitionGroupNames - Policy definition group names. PolicyDefinitionGroupNames *[]string `json:"policyDefinitionGroupNames,omitempty"` + // Components - Components state compliance records populated only when URL contains $expand=components clause. + Components *[]ComponentStateDetails `json:"components,omitempty"` + // PolicyDefinitionVersion - READ-ONLY; Evaluated policy definition version. + PolicyDefinitionVersion *string `json:"policyDefinitionVersion,omitempty"` + // PolicySetDefinitionVersion - READ-ONLY; Evaluated policy set definition version. + PolicySetDefinitionVersion *string `json:"policySetDefinitionVersion,omitempty"` + // PolicyAssignmentVersion - READ-ONLY; Evaluated policy assignment version. + PolicyAssignmentVersion *string `json:"policyAssignmentVersion,omitempty"` } // MarshalJSON is the custom marshaler for PolicyState. @@ -1077,6 +1523,9 @@ func (ps PolicyState) MarshalJSON() ([]byte, error) { if ps.PolicyDefinitionGroupNames != nil { objectMap["policyDefinitionGroupNames"] = ps.PolicyDefinitionGroupNames } + if ps.Components != nil { + objectMap["components"] = ps.Components + } for k, v := range ps.AdditionalProperties { objectMap[k] = v } @@ -1374,6 +1823,42 @@ func (ps *PolicyState) UnmarshalJSON(body []byte) error { } ps.PolicyDefinitionGroupNames = &policyDefinitionGroupNames } + case "components": + if v != nil { + var components []ComponentStateDetails + err = json.Unmarshal(*v, &components) + if err != nil { + return err + } + ps.Components = &components + } + case "policyDefinitionVersion": + if v != nil { + var policyDefinitionVersion string + err = json.Unmarshal(*v, &policyDefinitionVersion) + if err != nil { + return err + } + ps.PolicyDefinitionVersion = &policyDefinitionVersion + } + case "policySetDefinitionVersion": + if v != nil { + var policySetDefinitionVersion string + err = json.Unmarshal(*v, &policySetDefinitionVersion) + if err != nil { + return err + } + ps.PolicySetDefinitionVersion = &policySetDefinitionVersion + } + case "policyAssignmentVersion": + if v != nil { + var policyAssignmentVersion string + err = json.Unmarshal(*v, &policyAssignmentVersion) + if err != nil { + return err + } + ps.PolicyAssignmentVersion = &policyAssignmentVersion + } } } @@ -1387,12 +1872,161 @@ type PolicyStatesQueryResults struct { OdataContext *string `json:"@odata.context,omitempty"` // OdataCount - OData entity count; represents the number of policy state records returned. OdataCount *int32 `json:"@odata.count,omitempty"` + // OdataNextLink - Odata next link; URL to get the next set of results. + OdataNextLink *string `json:"@odata.nextLink,omitempty"` // Value - Query results. Value *[]PolicyState `json:"value,omitempty"` } -// PolicyStatesTriggerResourceGroupEvaluationFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. +// PolicyStatesQueryResultsIterator provides access to a complete listing of PolicyState values. +type PolicyStatesQueryResultsIterator struct { + i int + page PolicyStatesQueryResultsPage +} + +// 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 *PolicyStatesQueryResultsIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesQueryResultsIterator.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 *PolicyStatesQueryResultsIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PolicyStatesQueryResultsIterator) 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 PolicyStatesQueryResultsIterator) Response() PolicyStatesQueryResults { + 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 PolicyStatesQueryResultsIterator) Value() PolicyState { + if !iter.page.NotDone() { + return PolicyState{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PolicyStatesQueryResultsIterator type. +func NewPolicyStatesQueryResultsIterator(page PolicyStatesQueryResultsPage) PolicyStatesQueryResultsIterator { + return PolicyStatesQueryResultsIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (psqr PolicyStatesQueryResults) IsEmpty() bool { + return psqr.Value == nil || len(*psqr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (psqr PolicyStatesQueryResults) hasNextLink() bool { + return psqr.OdataNextLink != nil && len(*psqr.OdataNextLink) != 0 +} + +// policyStatesQueryResultsPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (psqr PolicyStatesQueryResults) policyStatesQueryResultsPreparer(ctx context.Context) (*http.Request, error) { + if !psqr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(psqr.OdataNextLink))) +} + +// PolicyStatesQueryResultsPage contains a page of PolicyState values. +type PolicyStatesQueryResultsPage struct { + fn func(context.Context, PolicyStatesQueryResults) (PolicyStatesQueryResults, error) + psqr PolicyStatesQueryResults +} + +// 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 *PolicyStatesQueryResultsPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesQueryResultsPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.psqr) + if err != nil { + return err + } + page.psqr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + 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 *PolicyStatesQueryResultsPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PolicyStatesQueryResultsPage) NotDone() bool { + return !page.psqr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PolicyStatesQueryResultsPage) Response() PolicyStatesQueryResults { + return page.psqr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PolicyStatesQueryResultsPage) Values() []PolicyState { + if page.psqr.IsEmpty() { + return nil + } + return *page.psqr.Value +} + +// Creates a new instance of the PolicyStatesQueryResultsPage type. +func NewPolicyStatesQueryResultsPage(getNextPage func(context.Context, PolicyStatesQueryResults) (PolicyStatesQueryResults, error)) PolicyStatesQueryResultsPage { + return PolicyStatesQueryResultsPage{fn: getNextPage} +} + +// PolicyStatesTriggerResourceGroupEvaluationFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. type PolicyStatesTriggerResourceGroupEvaluationFuture struct { azure.Future } @@ -1414,8 +2048,8 @@ func (future *PolicyStatesTriggerResourceGroupEvaluationFuture) Result(client Po return } -// PolicyStatesTriggerSubscriptionEvaluationFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. +// PolicyStatesTriggerSubscriptionEvaluationFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. type PolicyStatesTriggerSubscriptionEvaluationFuture struct { azure.Future } @@ -1451,6 +2085,12 @@ type PolicyTrackedResource struct { LastUpdateUtc *date.Time `json:"lastUpdateUtc,omitempty"` } +// MarshalJSON is the custom marshaler for PolicyTrackedResource. +func (ptr PolicyTrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + // PolicyTrackedResourcesQueryResults query results. type PolicyTrackedResourcesQueryResults struct { autorest.Response `json:"-"` @@ -1460,8 +2100,14 @@ type PolicyTrackedResourcesQueryResults struct { NextLink *string `json:"nextLink,omitempty"` } -// PolicyTrackedResourcesQueryResultsIterator provides access to a complete listing of -// PolicyTrackedResource values. +// MarshalJSON is the custom marshaler for PolicyTrackedResourcesQueryResults. +func (ptrqr PolicyTrackedResourcesQueryResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PolicyTrackedResourcesQueryResultsIterator provides access to a complete listing of PolicyTrackedResource +// values. type PolicyTrackedResourcesQueryResultsIterator struct { i int page PolicyTrackedResourcesQueryResultsPage @@ -1529,10 +2175,15 @@ func (ptrqr PolicyTrackedResourcesQueryResults) IsEmpty() bool { return ptrqr.Value == nil || len(*ptrqr.Value) == 0 } +// hasNextLink returns true if the NextLink is not empty. +func (ptrqr PolicyTrackedResourcesQueryResults) hasNextLink() bool { + return ptrqr.NextLink != nil && len(*ptrqr.NextLink) != 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 { + if !ptrqr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), @@ -1560,11 +2211,16 @@ func (page *PolicyTrackedResourcesQueryResultsPage) NextWithContext(ctx context. tracing.EndSpan(ctx, sc, err) }() } - next, err := page.fn(ctx, page.ptrqr) - if err != nil { - return err + for { + next, err := page.fn(ctx, page.ptrqr) + if err != nil { + return err + } + page.ptrqr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } } - page.ptrqr = next return nil } @@ -1612,6 +2268,12 @@ type QueryFailureError struct { Message *string `json:"message,omitempty"` } +// MarshalJSON is the custom marshaler for QueryFailureError. +func (qf QueryFailureError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + // Remediation the remediation definition. type Remediation struct { autorest.Response `json:"-"` @@ -1703,6 +2365,12 @@ type RemediationDeployment struct { LastUpdatedOn *date.Time `json:"lastUpdatedOn,omitempty"` } +// MarshalJSON is the custom marshaler for RemediationDeployment. +func (rd RemediationDeployment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + // RemediationDeploymentsListResult list of deployments for a remediation. type RemediationDeploymentsListResult struct { autorest.Response `json:"-"` @@ -1712,6 +2380,12 @@ type RemediationDeploymentsListResult struct { NextLink *string `json:"nextLink,omitempty"` } +// MarshalJSON is the custom marshaler for RemediationDeploymentsListResult. +func (rdlr RemediationDeploymentsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + // RemediationDeploymentsListResultIterator provides access to a complete listing of RemediationDeployment // values. type RemediationDeploymentsListResultIterator struct { @@ -1781,10 +2455,15 @@ func (rdlr RemediationDeploymentsListResult) IsEmpty() bool { return rdlr.Value == nil || len(*rdlr.Value) == 0 } +// hasNextLink returns true if the NextLink is not empty. +func (rdlr RemediationDeploymentsListResult) hasNextLink() bool { + return rdlr.NextLink != nil && len(*rdlr.NextLink) != 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 { + if !rdlr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), @@ -1812,11 +2491,16 @@ func (page *RemediationDeploymentsListResultPage) NextWithContext(ctx context.Co tracing.EndSpan(ctx, sc, err) }() } - next, err := page.fn(ctx, page.rdlr) - if err != nil { - return err + for { + next, err := page.fn(ctx, page.rdlr) + if err != nil { + return err + } + page.rdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } } - page.rdlr = next return nil } @@ -1850,8 +2534,7 @@ func NewRemediationDeploymentsListResultPage(getNextPage func(context.Context, R return RemediationDeploymentsListResultPage{fn: getNextPage} } -// RemediationDeploymentSummary the deployment status summary for all deployments created by the -// remediation. +// RemediationDeploymentSummary the deployment status summary for all deployments created by the remediation. type RemediationDeploymentSummary struct { // TotalDeployments - READ-ONLY; The number of deployments required by the remediation. TotalDeployments *int32 `json:"totalDeployments,omitempty"` @@ -1861,6 +2544,12 @@ type RemediationDeploymentSummary struct { FailedDeployments *int32 `json:"failedDeployments,omitempty"` } +// MarshalJSON is the custom marshaler for RemediationDeploymentSummary. +func (rds RemediationDeploymentSummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + // RemediationFilters the filters that will be applied to determine which resources to remediate. type RemediationFilters struct { // Locations - The resource locations that will be remediated. @@ -1876,6 +2565,12 @@ type RemediationListResult struct { NextLink *string `json:"nextLink,omitempty"` } +// MarshalJSON is the custom marshaler for RemediationListResult. +func (rlr RemediationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + // RemediationListResultIterator provides access to a complete listing of Remediation values. type RemediationListResultIterator struct { i int @@ -1944,10 +2639,15 @@ func (rlr RemediationListResult) IsEmpty() bool { return rlr.Value == nil || len(*rlr.Value) == 0 } +// hasNextLink returns true if the NextLink is not empty. +func (rlr RemediationListResult) hasNextLink() bool { + return rlr.NextLink != nil && len(*rlr.NextLink) != 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 { + if !rlr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), @@ -1975,11 +2675,16 @@ func (page *RemediationListResultPage) NextWithContext(ctx context.Context) (err tracing.EndSpan(ctx, sc, err) }() } - next, err := page.fn(ctx, page.rlr) - if err != nil { - return err + for { + next, err := page.fn(ctx, page.rlr) + if err != nil { + return err + } + page.rlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } } - page.rlr = next return nil } @@ -2033,6 +2738,24 @@ type RemediationProperties struct { DeploymentStatus *RemediationDeploymentSummary `json:"deploymentStatus,omitempty"` } +// MarshalJSON is the custom marshaler for RemediationProperties. +func (rp RemediationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rp.PolicyAssignmentID != nil { + objectMap["policyAssignmentId"] = rp.PolicyAssignmentID + } + if rp.PolicyDefinitionReferenceID != nil { + objectMap["policyDefinitionReferenceId"] = rp.PolicyDefinitionReferenceID + } + if rp.ResourceDiscoveryMode != "" { + objectMap["resourceDiscoveryMode"] = rp.ResourceDiscoveryMode + } + if rp.Filters != nil { + objectMap["filters"] = rp.Filters + } + return json.Marshal(objectMap) +} + // SlimPolicyMetadata slim version of policy metadata resource definition, excluding properties with large // strings type SlimPolicyMetadata struct { @@ -2106,12 +2829,6 @@ func (spm *SlimPolicyMetadata) UnmarshalJSON(body []byte) error { return nil } -// String ... -type String struct { - autorest.Response `json:"-"` - Value *string `json:"value,omitempty"` -} - // SummarizeResults summarize action results. type SummarizeResults struct { autorest.Response `json:"-"` @@ -2151,8 +2868,8 @@ type SummaryResults struct { PolicyGroupDetails *[]ComplianceDetail `json:"policyGroupDetails,omitempty"` } -// TrackedResourceModificationDetails the details of the policy triggered deployment that created or -// modified the tracked resource. +// 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"` @@ -2162,6 +2879,12 @@ type TrackedResourceModificationDetails struct { DeploymentTime *date.Time `json:"deploymentTime,omitempty"` } +// MarshalJSON is the custom marshaler for TrackedResourceModificationDetails. +func (trmd TrackedResourceModificationDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + // TypedErrorInfo scenario specific error details. type TypedErrorInfo struct { // Type - READ-ONLY; The type of included error details. @@ -2169,3 +2892,9 @@ type TypedErrorInfo struct { // Info - READ-ONLY; The scenario specific error details. Info interface{} `json:"info,omitempty"` } + +// MarshalJSON is the custom marshaler for TypedErrorInfo. +func (tei TypedErrorInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/operations.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/operations.go index 5a638589a2c2..67068855ff39 100644 --- a/services/policyinsights/mgmt/2019-10-01/policyinsights/operations.go +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/operations.go @@ -100,7 +100,6 @@ func (client OperationsClient) ListSender(req *http.Request) (*http.Response, er 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()) diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/policyevents.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/policyevents.go index a20596f95cc9..1841990830f8 100644 --- a/services/policyinsights/mgmt/2019-10-01/policyinsights/policyevents.go +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/policyevents.go @@ -43,80 +43,6 @@ 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) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// 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. @@ -131,13 +57,15 @@ func (client PolicyEventsClient) GetMetadataResponder(resp *http.Response) (resu // 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) { +// skipToken - skiptoken is only provided if a previous response returned a partial result as a part of +// nextLink element. +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, skipToken string) (result PolicyEventsQueryResultsPage, 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 + if result.peqr.Response.Response != nil { + sc = result.peqr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -149,7 +77,8 @@ func (client PolicyEventsClient) ListQueryResultsForManagementGroup(ctx context. return result, validation.NewError("policyinsights.PolicyEventsClient", "ListQueryResultsForManagementGroup", err.Error()) } - req, err := client.ListQueryResultsForManagementGroupPreparer(ctx, managementGroupName, top, orderBy, selectParameter, from, toParameter, filter, apply) + result.fn = client.listQueryResultsForManagementGroupNextResults + req, err := client.ListQueryResultsForManagementGroupPreparer(ctx, managementGroupName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForManagementGroup", nil, "Failure preparing request") return @@ -157,28 +86,31 @@ func (client PolicyEventsClient) ListQueryResultsForManagementGroup(ctx context. resp, err := client.ListQueryResultsForManagementGroupSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.peqr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForManagementGroup", resp, "Failure sending request") return } - result, err = client.ListQueryResultsForManagementGroupResponder(resp) + result.peqr, err = client.ListQueryResultsForManagementGroupResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForManagementGroup", resp, "Failure responding to request") } + if result.peqr.hasNextLink() && result.peqr.IsEmpty() { + err = result.NextWithContext(ctx) + } 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) { +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, skipToken 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" + const APIVersion = "2019-10-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -203,6 +135,9 @@ func (client PolicyEventsClient) ListQueryResultsForManagementGroupPreparer(ctx if len(apply) > 0 { queryParameters["$apply"] = autorest.Encode("query", apply) } + if len(skipToken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skipToken) + } preparer := autorest.CreatePreparer( autorest.AsPost(), @@ -223,7 +158,6 @@ func (client PolicyEventsClient) ListQueryResultsForManagementGroupSender(req *h 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()) @@ -231,6 +165,43 @@ func (client PolicyEventsClient) ListQueryResultsForManagementGroupResponder(res return } +// listQueryResultsForManagementGroupNextResults retrieves the next set of results, if any. +func (client PolicyEventsClient) listQueryResultsForManagementGroupNextResults(ctx context.Context, lastResults PolicyEventsQueryResults) (result PolicyEventsQueryResults, err error) { + req, err := lastResults.policyEventsQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "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.PolicyEventsClient", "listQueryResultsForManagementGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForManagementGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "listQueryResultsForManagementGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForManagementGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyEventsClient) ListQueryResultsForManagementGroupComplete(ctx context.Context, managementGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result PolicyEventsQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsClient.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, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) + return +} + // ListQueryResultsForPolicyDefinition queries policy events for the subscription level policy definition. // Parameters: // subscriptionID - microsoft Azure subscription ID. @@ -246,13 +217,15 @@ func (client PolicyEventsClient) ListQueryResultsForManagementGroupResponder(res // 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) { +// skipToken - skiptoken is only provided if a previous response returned a partial result as a part of +// nextLink element. +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, skipToken string) (result PolicyEventsQueryResultsPage, 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 + if result.peqr.Response.Response != nil { + sc = result.peqr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -264,7 +237,8 @@ func (client PolicyEventsClient) ListQueryResultsForPolicyDefinition(ctx context return result, validation.NewError("policyinsights.PolicyEventsClient", "ListQueryResultsForPolicyDefinition", err.Error()) } - req, err := client.ListQueryResultsForPolicyDefinitionPreparer(ctx, subscriptionID, policyDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply) + result.fn = client.listQueryResultsForPolicyDefinitionNextResults + req, err := client.ListQueryResultsForPolicyDefinitionPreparer(ctx, subscriptionID, policyDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForPolicyDefinition", nil, "Failure preparing request") return @@ -272,21 +246,24 @@ func (client PolicyEventsClient) ListQueryResultsForPolicyDefinition(ctx context resp, err := client.ListQueryResultsForPolicyDefinitionSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.peqr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForPolicyDefinition", resp, "Failure sending request") return } - result, err = client.ListQueryResultsForPolicyDefinitionResponder(resp) + result.peqr, err = client.ListQueryResultsForPolicyDefinitionResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForPolicyDefinition", resp, "Failure responding to request") } + if result.peqr.hasNextLink() && result.peqr.IsEmpty() { + err = result.NextWithContext(ctx) + } 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) { +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, skipToken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), "policyDefinitionName": autorest.Encode("path", policyDefinitionName), @@ -294,7 +271,7 @@ func (client PolicyEventsClient) ListQueryResultsForPolicyDefinitionPreparer(ctx "subscriptionId": autorest.Encode("path", subscriptionID), } - const APIVersion = "2018-04-04" + const APIVersion = "2019-10-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -319,6 +296,9 @@ func (client PolicyEventsClient) ListQueryResultsForPolicyDefinitionPreparer(ctx if len(apply) > 0 { queryParameters["$apply"] = autorest.Encode("query", apply) } + if len(skipToken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skipToken) + } preparer := autorest.CreatePreparer( autorest.AsPost(), @@ -339,7 +319,6 @@ func (client PolicyEventsClient) ListQueryResultsForPolicyDefinitionSender(req * 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()) @@ -347,6 +326,43 @@ func (client PolicyEventsClient) ListQueryResultsForPolicyDefinitionResponder(re return } +// listQueryResultsForPolicyDefinitionNextResults retrieves the next set of results, if any. +func (client PolicyEventsClient) listQueryResultsForPolicyDefinitionNextResults(ctx context.Context, lastResults PolicyEventsQueryResults) (result PolicyEventsQueryResults, err error) { + req, err := lastResults.policyEventsQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "listQueryResultsForPolicyDefinitionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListQueryResultsForPolicyDefinitionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "listQueryResultsForPolicyDefinitionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForPolicyDefinitionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "listQueryResultsForPolicyDefinitionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForPolicyDefinitionComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyEventsClient) ListQueryResultsForPolicyDefinitionComplete(ctx context.Context, subscriptionID string, policyDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result PolicyEventsQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsClient.ListQueryResultsForPolicyDefinition") + 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.ListQueryResultsForPolicyDefinition(ctx, subscriptionID, policyDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) + return +} + // ListQueryResultsForPolicySetDefinition queries policy events for the subscription level policy set definition. // Parameters: // subscriptionID - microsoft Azure subscription ID. @@ -362,13 +378,15 @@ func (client PolicyEventsClient) ListQueryResultsForPolicyDefinitionResponder(re // 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) { +// skipToken - skiptoken is only provided if a previous response returned a partial result as a part of +// nextLink element. +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, skipToken string) (result PolicyEventsQueryResultsPage, 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 + if result.peqr.Response.Response != nil { + sc = result.peqr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -380,7 +398,8 @@ func (client PolicyEventsClient) ListQueryResultsForPolicySetDefinition(ctx cont return result, validation.NewError("policyinsights.PolicyEventsClient", "ListQueryResultsForPolicySetDefinition", err.Error()) } - req, err := client.ListQueryResultsForPolicySetDefinitionPreparer(ctx, subscriptionID, policySetDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply) + result.fn = client.listQueryResultsForPolicySetDefinitionNextResults + req, err := client.ListQueryResultsForPolicySetDefinitionPreparer(ctx, subscriptionID, policySetDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForPolicySetDefinition", nil, "Failure preparing request") return @@ -388,21 +407,24 @@ func (client PolicyEventsClient) ListQueryResultsForPolicySetDefinition(ctx cont resp, err := client.ListQueryResultsForPolicySetDefinitionSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.peqr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForPolicySetDefinition", resp, "Failure sending request") return } - result, err = client.ListQueryResultsForPolicySetDefinitionResponder(resp) + result.peqr, err = client.ListQueryResultsForPolicySetDefinitionResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForPolicySetDefinition", resp, "Failure responding to request") } + if result.peqr.hasNextLink() && result.peqr.IsEmpty() { + err = result.NextWithContext(ctx) + } 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) { +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, skipToken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), "policyEventsResource": autorest.Encode("path", "default"), @@ -410,7 +432,7 @@ func (client PolicyEventsClient) ListQueryResultsForPolicySetDefinitionPreparer( "subscriptionId": autorest.Encode("path", subscriptionID), } - const APIVersion = "2018-04-04" + const APIVersion = "2019-10-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -435,6 +457,9 @@ func (client PolicyEventsClient) ListQueryResultsForPolicySetDefinitionPreparer( if len(apply) > 0 { queryParameters["$apply"] = autorest.Encode("query", apply) } + if len(skipToken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skipToken) + } preparer := autorest.CreatePreparer( autorest.AsPost(), @@ -455,7 +480,6 @@ func (client PolicyEventsClient) ListQueryResultsForPolicySetDefinitionSender(re 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()) @@ -463,6 +487,43 @@ func (client PolicyEventsClient) ListQueryResultsForPolicySetDefinitionResponder return } +// listQueryResultsForPolicySetDefinitionNextResults retrieves the next set of results, if any. +func (client PolicyEventsClient) listQueryResultsForPolicySetDefinitionNextResults(ctx context.Context, lastResults PolicyEventsQueryResults) (result PolicyEventsQueryResults, err error) { + req, err := lastResults.policyEventsQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "listQueryResultsForPolicySetDefinitionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListQueryResultsForPolicySetDefinitionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "listQueryResultsForPolicySetDefinitionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForPolicySetDefinitionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "listQueryResultsForPolicySetDefinitionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForPolicySetDefinitionComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyEventsClient) ListQueryResultsForPolicySetDefinitionComplete(ctx context.Context, subscriptionID string, policySetDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result PolicyEventsQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsClient.ListQueryResultsForPolicySetDefinition") + 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.ListQueryResultsForPolicySetDefinition(ctx, subscriptionID, policySetDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) + return +} + // ListQueryResultsForResource queries policy events for the resource. // Parameters: // resourceID - resource ID. @@ -477,13 +538,16 @@ func (client PolicyEventsClient) ListQueryResultsForPolicySetDefinitionResponder // 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) { +// expand - the $expand query parameter. For example, to expand components use $expand=components +// skipToken - skiptoken is only provided if a previous response returned a partial result as a part of +// nextLink element. +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, expand string, skipToken string) (result PolicyEventsQueryResultsPage, 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 + if result.peqr.Response.Response != nil { + sc = result.peqr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -495,7 +559,8 @@ func (client PolicyEventsClient) ListQueryResultsForResource(ctx context.Context return result, validation.NewError("policyinsights.PolicyEventsClient", "ListQueryResultsForResource", err.Error()) } - req, err := client.ListQueryResultsForResourcePreparer(ctx, resourceID, top, orderBy, selectParameter, from, toParameter, filter, apply) + result.fn = client.listQueryResultsForResourceNextResults + req, err := client.ListQueryResultsForResourcePreparer(ctx, resourceID, top, orderBy, selectParameter, from, toParameter, filter, apply, expand, skipToken) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResource", nil, "Failure preparing request") return @@ -503,27 +568,30 @@ func (client PolicyEventsClient) ListQueryResultsForResource(ctx context.Context resp, err := client.ListQueryResultsForResourceSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.peqr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResource", resp, "Failure sending request") return } - result, err = client.ListQueryResultsForResourceResponder(resp) + result.peqr, err = client.ListQueryResultsForResourceResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResource", resp, "Failure responding to request") } + if result.peqr.hasNextLink() && result.peqr.IsEmpty() { + err = result.NextWithContext(ctx) + } 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) { +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, expand string, skipToken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "policyEventsResource": autorest.Encode("path", "default"), "resourceId": resourceID, } - const APIVersion = "2018-04-04" + const APIVersion = "2019-10-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -548,6 +616,12 @@ func (client PolicyEventsClient) ListQueryResultsForResourcePreparer(ctx context if len(apply) > 0 { queryParameters["$apply"] = autorest.Encode("query", apply) } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(skipToken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skipToken) + } preparer := autorest.CreatePreparer( autorest.AsPost(), @@ -568,7 +642,6 @@ func (client PolicyEventsClient) ListQueryResultsForResourceSender(req *http.Req 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()) @@ -576,6 +649,43 @@ func (client PolicyEventsClient) ListQueryResultsForResourceResponder(resp *http return } +// listQueryResultsForResourceNextResults retrieves the next set of results, if any. +func (client PolicyEventsClient) listQueryResultsForResourceNextResults(ctx context.Context, lastResults PolicyEventsQueryResults) (result PolicyEventsQueryResults, err error) { + req, err := lastResults.policyEventsQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "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.PolicyEventsClient", "listQueryResultsForResourceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "listQueryResultsForResourceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForResourceComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyEventsClient) ListQueryResultsForResourceComplete(ctx context.Context, resourceID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, expand string, skipToken string) (result PolicyEventsQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsClient.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, orderBy, selectParameter, from, toParameter, filter, apply, expand, skipToken) + return +} + // ListQueryResultsForResourceGroup queries policy events for the resources under the resource group. // Parameters: // subscriptionID - microsoft Azure subscription ID. @@ -591,13 +701,15 @@ func (client PolicyEventsClient) ListQueryResultsForResourceResponder(resp *http // 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) { +// skipToken - skiptoken is only provided if a previous response returned a partial result as a part of +// nextLink element. +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, skipToken string) (result PolicyEventsQueryResultsPage, 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 + if result.peqr.Response.Response != nil { + sc = result.peqr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -609,7 +721,8 @@ func (client PolicyEventsClient) ListQueryResultsForResourceGroup(ctx context.Co return result, validation.NewError("policyinsights.PolicyEventsClient", "ListQueryResultsForResourceGroup", err.Error()) } - req, err := client.ListQueryResultsForResourceGroupPreparer(ctx, subscriptionID, resourceGroupName, top, orderBy, selectParameter, from, toParameter, filter, apply) + result.fn = client.listQueryResultsForResourceGroupNextResults + req, err := client.ListQueryResultsForResourceGroupPreparer(ctx, subscriptionID, resourceGroupName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResourceGroup", nil, "Failure preparing request") return @@ -617,28 +730,31 @@ func (client PolicyEventsClient) ListQueryResultsForResourceGroup(ctx context.Co resp, err := client.ListQueryResultsForResourceGroupSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.peqr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResourceGroup", resp, "Failure sending request") return } - result, err = client.ListQueryResultsForResourceGroupResponder(resp) + result.peqr, err = client.ListQueryResultsForResourceGroupResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResourceGroup", resp, "Failure responding to request") } + if result.peqr.hasNextLink() && result.peqr.IsEmpty() { + err = result.NextWithContext(ctx) + } 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) { +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, skipToken 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" + const APIVersion = "2019-10-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -663,6 +779,9 @@ func (client PolicyEventsClient) ListQueryResultsForResourceGroupPreparer(ctx co if len(apply) > 0 { queryParameters["$apply"] = autorest.Encode("query", apply) } + if len(skipToken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skipToken) + } preparer := autorest.CreatePreparer( autorest.AsPost(), @@ -683,7 +802,6 @@ func (client PolicyEventsClient) ListQueryResultsForResourceGroupSender(req *htt 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()) @@ -691,6 +809,43 @@ func (client PolicyEventsClient) ListQueryResultsForResourceGroupResponder(resp return } +// listQueryResultsForResourceGroupNextResults retrieves the next set of results, if any. +func (client PolicyEventsClient) listQueryResultsForResourceGroupNextResults(ctx context.Context, lastResults PolicyEventsQueryResults) (result PolicyEventsQueryResults, err error) { + req, err := lastResults.policyEventsQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "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.PolicyEventsClient", "listQueryResultsForResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "listQueryResultsForResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyEventsClient) ListQueryResultsForResourceGroupComplete(ctx context.Context, subscriptionID string, resourceGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result PolicyEventsQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsClient.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, subscriptionID, resourceGroupName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) + return +} + // ListQueryResultsForResourceGroupLevelPolicyAssignment queries policy events for the resource group level policy // assignment. // Parameters: @@ -708,13 +863,15 @@ func (client PolicyEventsClient) ListQueryResultsForResourceGroupResponder(resp // 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) { +// skipToken - skiptoken is only provided if a previous response returned a partial result as a part of +// nextLink element. +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, skipToken string) (result PolicyEventsQueryResultsPage, 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 + if result.peqr.Response.Response != nil { + sc = result.peqr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -726,7 +883,8 @@ func (client PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssi return result, validation.NewError("policyinsights.PolicyEventsClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", err.Error()) } - req, err := client.ListQueryResultsForResourceGroupLevelPolicyAssignmentPreparer(ctx, subscriptionID, resourceGroupName, policyAssignmentName, top, orderBy, selectParameter, from, toParameter, filter, apply) + result.fn = client.listQueryResultsForResourceGroupLevelPolicyAssignmentNextResults + req, err := client.ListQueryResultsForResourceGroupLevelPolicyAssignmentPreparer(ctx, subscriptionID, resourceGroupName, policyAssignmentName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", nil, "Failure preparing request") return @@ -734,21 +892,24 @@ func (client PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssi resp, err := client.ListQueryResultsForResourceGroupLevelPolicyAssignmentSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.peqr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", resp, "Failure sending request") return } - result, err = client.ListQueryResultsForResourceGroupLevelPolicyAssignmentResponder(resp) + result.peqr, err = client.ListQueryResultsForResourceGroupLevelPolicyAssignmentResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", resp, "Failure responding to request") } + if result.peqr.hasNextLink() && result.peqr.IsEmpty() { + err = result.NextWithContext(ctx) + } 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) { +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, skipToken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), "policyAssignmentName": autorest.Encode("path", policyAssignmentName), @@ -757,7 +918,7 @@ func (client PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssi "subscriptionId": autorest.Encode("path", subscriptionID), } - const APIVersion = "2018-04-04" + const APIVersion = "2019-10-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -782,6 +943,9 @@ func (client PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssi if len(apply) > 0 { queryParameters["$apply"] = autorest.Encode("query", apply) } + if len(skipToken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skipToken) + } preparer := autorest.CreatePreparer( autorest.AsPost(), @@ -802,7 +966,6 @@ func (client PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssi 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()) @@ -810,6 +973,43 @@ func (client PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssi return } +// listQueryResultsForResourceGroupLevelPolicyAssignmentNextResults retrieves the next set of results, if any. +func (client PolicyEventsClient) listQueryResultsForResourceGroupLevelPolicyAssignmentNextResults(ctx context.Context, lastResults PolicyEventsQueryResults) (result PolicyEventsQueryResults, err error) { + req, err := lastResults.policyEventsQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "listQueryResultsForResourceGroupLevelPolicyAssignmentNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListQueryResultsForResourceGroupLevelPolicyAssignmentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "listQueryResultsForResourceGroupLevelPolicyAssignmentNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForResourceGroupLevelPolicyAssignmentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "listQueryResultsForResourceGroupLevelPolicyAssignmentNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignmentComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssignmentComplete(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, skipToken string) (result PolicyEventsQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsClient.ListQueryResultsForResourceGroupLevelPolicyAssignment") + 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.ListQueryResultsForResourceGroupLevelPolicyAssignment(ctx, subscriptionID, resourceGroupName, policyAssignmentName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) + return +} + // ListQueryResultsForSubscription queries policy events for the resources under the subscription. // Parameters: // subscriptionID - microsoft Azure subscription ID. @@ -824,13 +1024,15 @@ func (client PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssi // 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) { +// skipToken - skiptoken is only provided if a previous response returned a partial result as a part of +// nextLink element. +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, skipToken string) (result PolicyEventsQueryResultsPage, 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 + if result.peqr.Response.Response != nil { + sc = result.peqr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -842,7 +1044,8 @@ func (client PolicyEventsClient) ListQueryResultsForSubscription(ctx context.Con return result, validation.NewError("policyinsights.PolicyEventsClient", "ListQueryResultsForSubscription", err.Error()) } - req, err := client.ListQueryResultsForSubscriptionPreparer(ctx, subscriptionID, top, orderBy, selectParameter, from, toParameter, filter, apply) + result.fn = client.listQueryResultsForSubscriptionNextResults + req, err := client.ListQueryResultsForSubscriptionPreparer(ctx, subscriptionID, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForSubscription", nil, "Failure preparing request") return @@ -850,27 +1053,30 @@ func (client PolicyEventsClient) ListQueryResultsForSubscription(ctx context.Con resp, err := client.ListQueryResultsForSubscriptionSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.peqr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForSubscription", resp, "Failure sending request") return } - result, err = client.ListQueryResultsForSubscriptionResponder(resp) + result.peqr, err = client.ListQueryResultsForSubscriptionResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForSubscription", resp, "Failure responding to request") } + if result.peqr.hasNextLink() && result.peqr.IsEmpty() { + err = result.NextWithContext(ctx) + } 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) { +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, skipToken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "policyEventsResource": autorest.Encode("path", "default"), "subscriptionId": autorest.Encode("path", subscriptionID), } - const APIVersion = "2018-04-04" + const APIVersion = "2019-10-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -895,6 +1101,9 @@ func (client PolicyEventsClient) ListQueryResultsForSubscriptionPreparer(ctx con if len(apply) > 0 { queryParameters["$apply"] = autorest.Encode("query", apply) } + if len(skipToken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skipToken) + } preparer := autorest.CreatePreparer( autorest.AsPost(), @@ -915,7 +1124,6 @@ func (client PolicyEventsClient) ListQueryResultsForSubscriptionSender(req *http 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()) @@ -923,6 +1131,43 @@ func (client PolicyEventsClient) ListQueryResultsForSubscriptionResponder(resp * return } +// listQueryResultsForSubscriptionNextResults retrieves the next set of results, if any. +func (client PolicyEventsClient) listQueryResultsForSubscriptionNextResults(ctx context.Context, lastResults PolicyEventsQueryResults) (result PolicyEventsQueryResults, err error) { + req, err := lastResults.policyEventsQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "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.PolicyEventsClient", "listQueryResultsForSubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "listQueryResultsForSubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForSubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyEventsClient) ListQueryResultsForSubscriptionComplete(ctx context.Context, subscriptionID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result PolicyEventsQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsClient.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, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) + return +} + // ListQueryResultsForSubscriptionLevelPolicyAssignment queries policy events for the subscription level policy // assignment. // Parameters: @@ -939,13 +1184,15 @@ func (client PolicyEventsClient) ListQueryResultsForSubscriptionResponder(resp * // 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) { +// skipToken - skiptoken is only provided if a previous response returned a partial result as a part of +// nextLink element. +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, skipToken string) (result PolicyEventsQueryResultsPage, 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 + if result.peqr.Response.Response != nil { + sc = result.peqr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -957,7 +1204,8 @@ func (client PolicyEventsClient) ListQueryResultsForSubscriptionLevelPolicyAssig return result, validation.NewError("policyinsights.PolicyEventsClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", err.Error()) } - req, err := client.ListQueryResultsForSubscriptionLevelPolicyAssignmentPreparer(ctx, subscriptionID, policyAssignmentName, top, orderBy, selectParameter, from, toParameter, filter, apply) + result.fn = client.listQueryResultsForSubscriptionLevelPolicyAssignmentNextResults + req, err := client.ListQueryResultsForSubscriptionLevelPolicyAssignmentPreparer(ctx, subscriptionID, policyAssignmentName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", nil, "Failure preparing request") return @@ -965,21 +1213,24 @@ func (client PolicyEventsClient) ListQueryResultsForSubscriptionLevelPolicyAssig resp, err := client.ListQueryResultsForSubscriptionLevelPolicyAssignmentSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.peqr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", resp, "Failure sending request") return } - result, err = client.ListQueryResultsForSubscriptionLevelPolicyAssignmentResponder(resp) + result.peqr, err = client.ListQueryResultsForSubscriptionLevelPolicyAssignmentResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", resp, "Failure responding to request") } + if result.peqr.hasNextLink() && result.peqr.IsEmpty() { + err = result.NextWithContext(ctx) + } 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) { +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, skipToken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), "policyAssignmentName": autorest.Encode("path", policyAssignmentName), @@ -987,7 +1238,7 @@ func (client PolicyEventsClient) ListQueryResultsForSubscriptionLevelPolicyAssig "subscriptionId": autorest.Encode("path", subscriptionID), } - const APIVersion = "2018-04-04" + const APIVersion = "2019-10-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1012,6 +1263,9 @@ func (client PolicyEventsClient) ListQueryResultsForSubscriptionLevelPolicyAssig if len(apply) > 0 { queryParameters["$apply"] = autorest.Encode("query", apply) } + if len(skipToken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skipToken) + } preparer := autorest.CreatePreparer( autorest.AsPost(), @@ -1032,10 +1286,46 @@ func (client PolicyEventsClient) ListQueryResultsForSubscriptionLevelPolicyAssig 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 } + +// listQueryResultsForSubscriptionLevelPolicyAssignmentNextResults retrieves the next set of results, if any. +func (client PolicyEventsClient) listQueryResultsForSubscriptionLevelPolicyAssignmentNextResults(ctx context.Context, lastResults PolicyEventsQueryResults) (result PolicyEventsQueryResults, err error) { + req, err := lastResults.policyEventsQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "listQueryResultsForSubscriptionLevelPolicyAssignmentNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListQueryResultsForSubscriptionLevelPolicyAssignmentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "listQueryResultsForSubscriptionLevelPolicyAssignmentNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForSubscriptionLevelPolicyAssignmentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "listQueryResultsForSubscriptionLevelPolicyAssignmentNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignmentComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyEventsClient) ListQueryResultsForSubscriptionLevelPolicyAssignmentComplete(ctx context.Context, subscriptionID string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result PolicyEventsQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsClient.ListQueryResultsForSubscriptionLevelPolicyAssignment") + 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.ListQueryResultsForSubscriptionLevelPolicyAssignment(ctx, subscriptionID, policyAssignmentName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) + 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 index a93d7a61ce04..d7d7f40524a3 100644 --- a/services/policyinsights/mgmt/2019-10-01/policyinsights/policyinsightsapi/interfaces.go +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/policyinsightsapi/interfaces.go @@ -77,29 +77,44 @@ 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) + ListQueryResultsForManagementGroup(ctx context.Context, managementGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result policyinsights.PolicyEventsQueryResultsPage, err error) + ListQueryResultsForManagementGroupComplete(ctx context.Context, managementGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result policyinsights.PolicyEventsQueryResultsIterator, 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, skipToken string) (result policyinsights.PolicyEventsQueryResultsPage, err error) + ListQueryResultsForPolicyDefinitionComplete(ctx context.Context, subscriptionID string, policyDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result policyinsights.PolicyEventsQueryResultsIterator, 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, skipToken string) (result policyinsights.PolicyEventsQueryResultsPage, err error) + ListQueryResultsForPolicySetDefinitionComplete(ctx context.Context, subscriptionID string, policySetDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result policyinsights.PolicyEventsQueryResultsIterator, err error) + ListQueryResultsForResource(ctx context.Context, resourceID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, expand string, skipToken string) (result policyinsights.PolicyEventsQueryResultsPage, err error) + ListQueryResultsForResourceComplete(ctx context.Context, resourceID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, expand string, skipToken string) (result policyinsights.PolicyEventsQueryResultsIterator, 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, skipToken string) (result policyinsights.PolicyEventsQueryResultsPage, err error) + ListQueryResultsForResourceGroupComplete(ctx context.Context, subscriptionID string, resourceGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result policyinsights.PolicyEventsQueryResultsIterator, 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, skipToken string) (result policyinsights.PolicyEventsQueryResultsPage, err error) + ListQueryResultsForResourceGroupLevelPolicyAssignmentComplete(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, skipToken string) (result policyinsights.PolicyEventsQueryResultsIterator, err error) + ListQueryResultsForSubscription(ctx context.Context, subscriptionID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result policyinsights.PolicyEventsQueryResultsPage, err error) + ListQueryResultsForSubscriptionComplete(ctx context.Context, subscriptionID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result policyinsights.PolicyEventsQueryResultsIterator, 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, skipToken string) (result policyinsights.PolicyEventsQueryResultsPage, err error) + ListQueryResultsForSubscriptionLevelPolicyAssignmentComplete(ctx context.Context, subscriptionID string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result policyinsights.PolicyEventsQueryResultsIterator, 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) + 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, skipToken string) (result policyinsights.PolicyStatesQueryResultsPage, err error) + ListQueryResultsForManagementGroupComplete(ctx context.Context, policyStatesResource policyinsights.PolicyStatesResource, managementGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result policyinsights.PolicyStatesQueryResultsIterator, 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, skipToken string) (result policyinsights.PolicyStatesQueryResultsPage, err error) + ListQueryResultsForPolicyDefinitionComplete(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, skipToken string) (result policyinsights.PolicyStatesQueryResultsIterator, 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, skipToken string) (result policyinsights.PolicyStatesQueryResultsPage, err error) + ListQueryResultsForPolicySetDefinitionComplete(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, skipToken string) (result policyinsights.PolicyStatesQueryResultsIterator, 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, skipToken string) (result policyinsights.PolicyStatesQueryResultsPage, err error) + ListQueryResultsForResourceComplete(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, skipToken string) (result policyinsights.PolicyStatesQueryResultsIterator, 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, skipToken string) (result policyinsights.PolicyStatesQueryResultsPage, err error) + ListQueryResultsForResourceGroupComplete(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, skipToken string) (result policyinsights.PolicyStatesQueryResultsIterator, 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, skipToken string) (result policyinsights.PolicyStatesQueryResultsPage, err error) + ListQueryResultsForResourceGroupLevelPolicyAssignmentComplete(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, skipToken string) (result policyinsights.PolicyStatesQueryResultsIterator, 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, skipToken string) (result policyinsights.PolicyStatesQueryResultsPage, err error) + ListQueryResultsForSubscriptionComplete(ctx context.Context, policyStatesResource policyinsights.PolicyStatesResource, subscriptionID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result policyinsights.PolicyStatesQueryResultsIterator, 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, skipToken string) (result policyinsights.PolicyStatesQueryResultsPage, err error) + ListQueryResultsForSubscriptionLevelPolicyAssignmentComplete(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, skipToken string) (result policyinsights.PolicyStatesQueryResultsIterator, 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) diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/policymetadata.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/policymetadata.go index 58409923e447..b288102a2d66 100644 --- a/services/policyinsights/mgmt/2019-10-01/policyinsights/policymetadata.go +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/policymetadata.go @@ -107,7 +107,6 @@ func (client PolicyMetadataClient) GetResourceSender(req *http.Request) (*http.R func (client PolicyMetadataClient) GetResourceResponder(resp *http.Response) (result PolicyMetadata, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -154,6 +153,9 @@ func (client PolicyMetadataClient) List(ctx context.Context, top *int32) (result if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyMetadataClient", "List", resp, "Failure responding to request") } + if result.pmc.hasNextLink() && result.pmc.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -187,7 +189,6 @@ func (client PolicyMetadataClient) ListSender(req *http.Request) (*http.Response func (client PolicyMetadataClient) ListResponder(resp *http.Response) (result PolicyMetadataCollection, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/policystates.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/policystates.go index 27dd4a337dbf..a2bd4d29eb90 100644 --- a/services/policyinsights/mgmt/2019-10-01/policyinsights/policystates.go +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/policystates.go @@ -59,13 +59,15 @@ func NewPolicyStatesClientWithBaseURI(baseURI string) PolicyStatesClient { // 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) { +// skipToken - skiptoken is only provided if a previous response returned a partial result as a part of +// nextLink element. +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, skipToken string) (result PolicyStatesQueryResultsPage, 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 + if result.psqr.Response.Response != nil { + sc = result.psqr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -77,7 +79,8 @@ func (client PolicyStatesClient) ListQueryResultsForManagementGroup(ctx context. return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForManagementGroup", err.Error()) } - req, err := client.ListQueryResultsForManagementGroupPreparer(ctx, policyStatesResource, managementGroupName, top, orderBy, selectParameter, from, toParameter, filter, apply) + result.fn = client.listQueryResultsForManagementGroupNextResults + req, err := client.ListQueryResultsForManagementGroupPreparer(ctx, policyStatesResource, managementGroupName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForManagementGroup", nil, "Failure preparing request") return @@ -85,21 +88,24 @@ func (client PolicyStatesClient) ListQueryResultsForManagementGroup(ctx context. resp, err := client.ListQueryResultsForManagementGroupSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.psqr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForManagementGroup", resp, "Failure sending request") return } - result, err = client.ListQueryResultsForManagementGroupResponder(resp) + result.psqr, err = client.ListQueryResultsForManagementGroupResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForManagementGroup", resp, "Failure responding to request") } + if result.psqr.hasNextLink() && result.psqr.IsEmpty() { + err = result.NextWithContext(ctx) + } 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) { +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, skipToken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "managementGroupName": autorest.Encode("path", managementGroupName), "managementGroupsNamespace": autorest.Encode("path", "Microsoft.Management"), @@ -131,6 +137,9 @@ func (client PolicyStatesClient) ListQueryResultsForManagementGroupPreparer(ctx if len(apply) > 0 { queryParameters["$apply"] = autorest.Encode("query", apply) } + if len(skipToken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skipToken) + } preparer := autorest.CreatePreparer( autorest.AsPost(), @@ -151,7 +160,6 @@ func (client PolicyStatesClient) ListQueryResultsForManagementGroupSender(req *h 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()) @@ -159,6 +167,43 @@ func (client PolicyStatesClient) ListQueryResultsForManagementGroupResponder(res return } +// listQueryResultsForManagementGroupNextResults retrieves the next set of results, if any. +func (client PolicyStatesClient) listQueryResultsForManagementGroupNextResults(ctx context.Context, lastResults PolicyStatesQueryResults) (result PolicyStatesQueryResults, err error) { + req, err := lastResults.policyStatesQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "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.PolicyStatesClient", "listQueryResultsForManagementGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForManagementGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "listQueryResultsForManagementGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForManagementGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyStatesClient) ListQueryResultsForManagementGroupComplete(ctx context.Context, policyStatesResource PolicyStatesResource, managementGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result PolicyStatesQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.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, policyStatesResource, managementGroupName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) + 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, @@ -176,13 +221,15 @@ func (client PolicyStatesClient) ListQueryResultsForManagementGroupResponder(res // 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) { +// skipToken - skiptoken is only provided if a previous response returned a partial result as a part of +// nextLink element. +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, skipToken string) (result PolicyStatesQueryResultsPage, 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 + if result.psqr.Response.Response != nil { + sc = result.psqr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -194,7 +241,8 @@ func (client PolicyStatesClient) ListQueryResultsForPolicyDefinition(ctx context return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForPolicyDefinition", err.Error()) } - req, err := client.ListQueryResultsForPolicyDefinitionPreparer(ctx, policyStatesResource, subscriptionID, policyDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply) + result.fn = client.listQueryResultsForPolicyDefinitionNextResults + req, err := client.ListQueryResultsForPolicyDefinitionPreparer(ctx, policyStatesResource, subscriptionID, policyDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicyDefinition", nil, "Failure preparing request") return @@ -202,21 +250,24 @@ func (client PolicyStatesClient) ListQueryResultsForPolicyDefinition(ctx context resp, err := client.ListQueryResultsForPolicyDefinitionSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.psqr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicyDefinition", resp, "Failure sending request") return } - result, err = client.ListQueryResultsForPolicyDefinitionResponder(resp) + result.psqr, err = client.ListQueryResultsForPolicyDefinitionResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicyDefinition", resp, "Failure responding to request") } + if result.psqr.hasNextLink() && result.psqr.IsEmpty() { + err = result.NextWithContext(ctx) + } 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) { +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, skipToken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), "policyDefinitionName": autorest.Encode("path", policyDefinitionName), @@ -249,6 +300,9 @@ func (client PolicyStatesClient) ListQueryResultsForPolicyDefinitionPreparer(ctx if len(apply) > 0 { queryParameters["$apply"] = autorest.Encode("query", apply) } + if len(skipToken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skipToken) + } preparer := autorest.CreatePreparer( autorest.AsPost(), @@ -269,7 +323,6 @@ func (client PolicyStatesClient) ListQueryResultsForPolicyDefinitionSender(req * 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()) @@ -277,6 +330,43 @@ func (client PolicyStatesClient) ListQueryResultsForPolicyDefinitionResponder(re return } +// listQueryResultsForPolicyDefinitionNextResults retrieves the next set of results, if any. +func (client PolicyStatesClient) listQueryResultsForPolicyDefinitionNextResults(ctx context.Context, lastResults PolicyStatesQueryResults) (result PolicyStatesQueryResults, err error) { + req, err := lastResults.policyStatesQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "listQueryResultsForPolicyDefinitionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListQueryResultsForPolicyDefinitionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "listQueryResultsForPolicyDefinitionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForPolicyDefinitionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "listQueryResultsForPolicyDefinitionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForPolicyDefinitionComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyStatesClient) ListQueryResultsForPolicyDefinitionComplete(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, skipToken string) (result PolicyStatesQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForPolicyDefinition") + 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.ListQueryResultsForPolicyDefinition(ctx, policyStatesResource, subscriptionID, policyDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) + 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, @@ -294,13 +384,15 @@ func (client PolicyStatesClient) ListQueryResultsForPolicyDefinitionResponder(re // 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) { +// skipToken - skiptoken is only provided if a previous response returned a partial result as a part of +// nextLink element. +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, skipToken string) (result PolicyStatesQueryResultsPage, 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 + if result.psqr.Response.Response != nil { + sc = result.psqr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -312,7 +404,8 @@ func (client PolicyStatesClient) ListQueryResultsForPolicySetDefinition(ctx cont return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForPolicySetDefinition", err.Error()) } - req, err := client.ListQueryResultsForPolicySetDefinitionPreparer(ctx, policyStatesResource, subscriptionID, policySetDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply) + result.fn = client.listQueryResultsForPolicySetDefinitionNextResults + req, err := client.ListQueryResultsForPolicySetDefinitionPreparer(ctx, policyStatesResource, subscriptionID, policySetDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicySetDefinition", nil, "Failure preparing request") return @@ -320,21 +413,24 @@ func (client PolicyStatesClient) ListQueryResultsForPolicySetDefinition(ctx cont resp, err := client.ListQueryResultsForPolicySetDefinitionSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.psqr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicySetDefinition", resp, "Failure sending request") return } - result, err = client.ListQueryResultsForPolicySetDefinitionResponder(resp) + result.psqr, err = client.ListQueryResultsForPolicySetDefinitionResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicySetDefinition", resp, "Failure responding to request") } + if result.psqr.hasNextLink() && result.psqr.IsEmpty() { + err = result.NextWithContext(ctx) + } 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) { +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, skipToken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), "policySetDefinitionName": autorest.Encode("path", policySetDefinitionName), @@ -367,6 +463,9 @@ func (client PolicyStatesClient) ListQueryResultsForPolicySetDefinitionPreparer( if len(apply) > 0 { queryParameters["$apply"] = autorest.Encode("query", apply) } + if len(skipToken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skipToken) + } preparer := autorest.CreatePreparer( autorest.AsPost(), @@ -387,7 +486,6 @@ func (client PolicyStatesClient) ListQueryResultsForPolicySetDefinitionSender(re 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()) @@ -395,6 +493,43 @@ func (client PolicyStatesClient) ListQueryResultsForPolicySetDefinitionResponder return } +// listQueryResultsForPolicySetDefinitionNextResults retrieves the next set of results, if any. +func (client PolicyStatesClient) listQueryResultsForPolicySetDefinitionNextResults(ctx context.Context, lastResults PolicyStatesQueryResults) (result PolicyStatesQueryResults, err error) { + req, err := lastResults.policyStatesQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "listQueryResultsForPolicySetDefinitionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListQueryResultsForPolicySetDefinitionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "listQueryResultsForPolicySetDefinitionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForPolicySetDefinitionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "listQueryResultsForPolicySetDefinitionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForPolicySetDefinitionComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyStatesClient) ListQueryResultsForPolicySetDefinitionComplete(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, skipToken string) (result PolicyStatesQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForPolicySetDefinition") + 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.ListQueryResultsForPolicySetDefinition(ctx, policyStatesResource, subscriptionID, policySetDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) + return +} + // ListQueryResultsForResource queries policy states for the resource. // Parameters: // policyStatesResource - the virtual resource under PolicyStates resource type. In a given time range, @@ -411,15 +546,16 @@ func (client PolicyStatesClient) ListQueryResultsForPolicySetDefinitionResponder // 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) { +// expand - the $expand query parameter. For example, to expand components use $expand=components +// skipToken - skiptoken is only provided if a previous response returned a partial result as a part of +// nextLink element. +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, skipToken string) (result PolicyStatesQueryResultsPage, 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 + if result.psqr.Response.Response != nil { + sc = result.psqr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -431,7 +567,8 @@ func (client PolicyStatesClient) ListQueryResultsForResource(ctx context.Context return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForResource", err.Error()) } - req, err := client.ListQueryResultsForResourcePreparer(ctx, policyStatesResource, resourceID, top, orderBy, selectParameter, from, toParameter, filter, apply, expand) + result.fn = client.listQueryResultsForResourceNextResults + req, err := client.ListQueryResultsForResourcePreparer(ctx, policyStatesResource, resourceID, top, orderBy, selectParameter, from, toParameter, filter, apply, expand, skipToken) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResource", nil, "Failure preparing request") return @@ -439,21 +576,24 @@ func (client PolicyStatesClient) ListQueryResultsForResource(ctx context.Context resp, err := client.ListQueryResultsForResourceSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.psqr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResource", resp, "Failure sending request") return } - result, err = client.ListQueryResultsForResourceResponder(resp) + result.psqr, err = client.ListQueryResultsForResourceResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResource", resp, "Failure responding to request") } + if result.psqr.hasNextLink() && result.psqr.IsEmpty() { + err = result.NextWithContext(ctx) + } 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) { +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, skipToken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "policyStatesResource": autorest.Encode("path", policyStatesResource), "resourceId": resourceID, @@ -487,6 +627,9 @@ func (client PolicyStatesClient) ListQueryResultsForResourcePreparer(ctx context if len(expand) > 0 { queryParameters["$expand"] = autorest.Encode("query", expand) } + if len(skipToken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skipToken) + } preparer := autorest.CreatePreparer( autorest.AsPost(), @@ -507,7 +650,6 @@ func (client PolicyStatesClient) ListQueryResultsForResourceSender(req *http.Req 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()) @@ -515,6 +657,43 @@ func (client PolicyStatesClient) ListQueryResultsForResourceResponder(resp *http return } +// listQueryResultsForResourceNextResults retrieves the next set of results, if any. +func (client PolicyStatesClient) listQueryResultsForResourceNextResults(ctx context.Context, lastResults PolicyStatesQueryResults) (result PolicyStatesQueryResults, err error) { + req, err := lastResults.policyStatesQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "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.PolicyStatesClient", "listQueryResultsForResourceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "listQueryResultsForResourceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForResourceComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyStatesClient) ListQueryResultsForResourceComplete(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, skipToken string) (result PolicyStatesQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.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, policyStatesResource, resourceID, top, orderBy, selectParameter, from, toParameter, filter, apply, expand, skipToken) + 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, @@ -532,13 +711,15 @@ func (client PolicyStatesClient) ListQueryResultsForResourceResponder(resp *http // 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) { +// skipToken - skiptoken is only provided if a previous response returned a partial result as a part of +// nextLink element. +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, skipToken string) (result PolicyStatesQueryResultsPage, 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 + if result.psqr.Response.Response != nil { + sc = result.psqr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -550,7 +731,8 @@ func (client PolicyStatesClient) ListQueryResultsForResourceGroup(ctx context.Co return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroup", err.Error()) } - req, err := client.ListQueryResultsForResourceGroupPreparer(ctx, policyStatesResource, subscriptionID, resourceGroupName, top, orderBy, selectParameter, from, toParameter, filter, apply) + result.fn = client.listQueryResultsForResourceGroupNextResults + req, err := client.ListQueryResultsForResourceGroupPreparer(ctx, policyStatesResource, subscriptionID, resourceGroupName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroup", nil, "Failure preparing request") return @@ -558,21 +740,24 @@ func (client PolicyStatesClient) ListQueryResultsForResourceGroup(ctx context.Co resp, err := client.ListQueryResultsForResourceGroupSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.psqr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroup", resp, "Failure sending request") return } - result, err = client.ListQueryResultsForResourceGroupResponder(resp) + result.psqr, err = client.ListQueryResultsForResourceGroupResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroup", resp, "Failure responding to request") } + if result.psqr.hasNextLink() && result.psqr.IsEmpty() { + err = result.NextWithContext(ctx) + } 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) { +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, skipToken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "policyStatesResource": autorest.Encode("path", policyStatesResource), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -604,6 +789,9 @@ func (client PolicyStatesClient) ListQueryResultsForResourceGroupPreparer(ctx co if len(apply) > 0 { queryParameters["$apply"] = autorest.Encode("query", apply) } + if len(skipToken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skipToken) + } preparer := autorest.CreatePreparer( autorest.AsPost(), @@ -624,7 +812,6 @@ func (client PolicyStatesClient) ListQueryResultsForResourceGroupSender(req *htt 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()) @@ -632,6 +819,43 @@ func (client PolicyStatesClient) ListQueryResultsForResourceGroupResponder(resp return } +// listQueryResultsForResourceGroupNextResults retrieves the next set of results, if any. +func (client PolicyStatesClient) listQueryResultsForResourceGroupNextResults(ctx context.Context, lastResults PolicyStatesQueryResults) (result PolicyStatesQueryResults, err error) { + req, err := lastResults.policyStatesQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "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.PolicyStatesClient", "listQueryResultsForResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "listQueryResultsForResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyStatesClient) ListQueryResultsForResourceGroupComplete(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, skipToken string) (result PolicyStatesQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.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, policyStatesResource, subscriptionID, resourceGroupName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) + return +} + // ListQueryResultsForResourceGroupLevelPolicyAssignment queries policy states for the resource group level policy // assignment. // Parameters: @@ -651,13 +875,15 @@ func (client PolicyStatesClient) ListQueryResultsForResourceGroupResponder(resp // 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) { +// skipToken - skiptoken is only provided if a previous response returned a partial result as a part of +// nextLink element. +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, skipToken string) (result PolicyStatesQueryResultsPage, 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 + if result.psqr.Response.Response != nil { + sc = result.psqr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -669,7 +895,8 @@ func (client PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssi 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) + result.fn = client.listQueryResultsForResourceGroupLevelPolicyAssignmentNextResults + req, err := client.ListQueryResultsForResourceGroupLevelPolicyAssignmentPreparer(ctx, policyStatesResource, subscriptionID, resourceGroupName, policyAssignmentName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", nil, "Failure preparing request") return @@ -677,21 +904,24 @@ func (client PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssi resp, err := client.ListQueryResultsForResourceGroupLevelPolicyAssignmentSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.psqr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", resp, "Failure sending request") return } - result, err = client.ListQueryResultsForResourceGroupLevelPolicyAssignmentResponder(resp) + result.psqr, err = client.ListQueryResultsForResourceGroupLevelPolicyAssignmentResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", resp, "Failure responding to request") } + if result.psqr.hasNextLink() && result.psqr.IsEmpty() { + err = result.NextWithContext(ctx) + } 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) { +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, skipToken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), "policyAssignmentName": autorest.Encode("path", policyAssignmentName), @@ -725,6 +955,9 @@ func (client PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssi if len(apply) > 0 { queryParameters["$apply"] = autorest.Encode("query", apply) } + if len(skipToken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skipToken) + } preparer := autorest.CreatePreparer( autorest.AsPost(), @@ -745,7 +978,6 @@ func (client PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssi 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()) @@ -753,6 +985,43 @@ func (client PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssi return } +// listQueryResultsForResourceGroupLevelPolicyAssignmentNextResults retrieves the next set of results, if any. +func (client PolicyStatesClient) listQueryResultsForResourceGroupLevelPolicyAssignmentNextResults(ctx context.Context, lastResults PolicyStatesQueryResults) (result PolicyStatesQueryResults, err error) { + req, err := lastResults.policyStatesQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "listQueryResultsForResourceGroupLevelPolicyAssignmentNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListQueryResultsForResourceGroupLevelPolicyAssignmentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "listQueryResultsForResourceGroupLevelPolicyAssignmentNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForResourceGroupLevelPolicyAssignmentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "listQueryResultsForResourceGroupLevelPolicyAssignmentNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignmentComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssignmentComplete(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, skipToken string) (result PolicyStatesQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForResourceGroupLevelPolicyAssignment") + 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.ListQueryResultsForResourceGroupLevelPolicyAssignment(ctx, policyStatesResource, subscriptionID, resourceGroupName, policyAssignmentName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) + 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, @@ -769,13 +1038,15 @@ func (client PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssi // 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) { +// skipToken - skiptoken is only provided if a previous response returned a partial result as a part of +// nextLink element. +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, skipToken string) (result PolicyStatesQueryResultsPage, 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 + if result.psqr.Response.Response != nil { + sc = result.psqr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -787,7 +1058,8 @@ func (client PolicyStatesClient) ListQueryResultsForSubscription(ctx context.Con return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForSubscription", err.Error()) } - req, err := client.ListQueryResultsForSubscriptionPreparer(ctx, policyStatesResource, subscriptionID, top, orderBy, selectParameter, from, toParameter, filter, apply) + result.fn = client.listQueryResultsForSubscriptionNextResults + req, err := client.ListQueryResultsForSubscriptionPreparer(ctx, policyStatesResource, subscriptionID, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscription", nil, "Failure preparing request") return @@ -795,21 +1067,24 @@ func (client PolicyStatesClient) ListQueryResultsForSubscription(ctx context.Con resp, err := client.ListQueryResultsForSubscriptionSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.psqr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscription", resp, "Failure sending request") return } - result, err = client.ListQueryResultsForSubscriptionResponder(resp) + result.psqr, err = client.ListQueryResultsForSubscriptionResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscription", resp, "Failure responding to request") } + if result.psqr.hasNextLink() && result.psqr.IsEmpty() { + err = result.NextWithContext(ctx) + } 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) { +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, skipToken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "policyStatesResource": autorest.Encode("path", policyStatesResource), "subscriptionId": autorest.Encode("path", subscriptionID), @@ -840,6 +1115,9 @@ func (client PolicyStatesClient) ListQueryResultsForSubscriptionPreparer(ctx con if len(apply) > 0 { queryParameters["$apply"] = autorest.Encode("query", apply) } + if len(skipToken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skipToken) + } preparer := autorest.CreatePreparer( autorest.AsPost(), @@ -860,7 +1138,6 @@ func (client PolicyStatesClient) ListQueryResultsForSubscriptionSender(req *http 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()) @@ -868,6 +1145,43 @@ func (client PolicyStatesClient) ListQueryResultsForSubscriptionResponder(resp * return } +// listQueryResultsForSubscriptionNextResults retrieves the next set of results, if any. +func (client PolicyStatesClient) listQueryResultsForSubscriptionNextResults(ctx context.Context, lastResults PolicyStatesQueryResults) (result PolicyStatesQueryResults, err error) { + req, err := lastResults.policyStatesQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "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.PolicyStatesClient", "listQueryResultsForSubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "listQueryResultsForSubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForSubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyStatesClient) ListQueryResultsForSubscriptionComplete(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string, skipToken string) (result PolicyStatesQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.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, policyStatesResource, subscriptionID, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) + return +} + // ListQueryResultsForSubscriptionLevelPolicyAssignment queries policy states for the subscription level policy // assignment. // Parameters: @@ -886,13 +1200,15 @@ func (client PolicyStatesClient) ListQueryResultsForSubscriptionResponder(resp * // 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) { +// skipToken - skiptoken is only provided if a previous response returned a partial result as a part of +// nextLink element. +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, skipToken string) (result PolicyStatesQueryResultsPage, 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 + if result.psqr.Response.Response != nil { + sc = result.psqr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -904,7 +1220,8 @@ func (client PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssig return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", err.Error()) } - req, err := client.ListQueryResultsForSubscriptionLevelPolicyAssignmentPreparer(ctx, policyStatesResource, subscriptionID, policyAssignmentName, top, orderBy, selectParameter, from, toParameter, filter, apply) + result.fn = client.listQueryResultsForSubscriptionLevelPolicyAssignmentNextResults + req, err := client.ListQueryResultsForSubscriptionLevelPolicyAssignmentPreparer(ctx, policyStatesResource, subscriptionID, policyAssignmentName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", nil, "Failure preparing request") return @@ -912,21 +1229,24 @@ func (client PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssig resp, err := client.ListQueryResultsForSubscriptionLevelPolicyAssignmentSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.psqr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", resp, "Failure sending request") return } - result, err = client.ListQueryResultsForSubscriptionLevelPolicyAssignmentResponder(resp) + result.psqr, err = client.ListQueryResultsForSubscriptionLevelPolicyAssignmentResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", resp, "Failure responding to request") } + if result.psqr.hasNextLink() && result.psqr.IsEmpty() { + err = result.NextWithContext(ctx) + } 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) { +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, skipToken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), "policyAssignmentName": autorest.Encode("path", policyAssignmentName), @@ -959,6 +1279,9 @@ func (client PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssig if len(apply) > 0 { queryParameters["$apply"] = autorest.Encode("query", apply) } + if len(skipToken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skipToken) + } preparer := autorest.CreatePreparer( autorest.AsPost(), @@ -979,7 +1302,6 @@ func (client PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssig 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()) @@ -987,6 +1309,43 @@ func (client PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssig return } +// listQueryResultsForSubscriptionLevelPolicyAssignmentNextResults retrieves the next set of results, if any. +func (client PolicyStatesClient) listQueryResultsForSubscriptionLevelPolicyAssignmentNextResults(ctx context.Context, lastResults PolicyStatesQueryResults) (result PolicyStatesQueryResults, err error) { + req, err := lastResults.policyStatesQueryResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "listQueryResultsForSubscriptionLevelPolicyAssignmentNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListQueryResultsForSubscriptionLevelPolicyAssignmentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "listQueryResultsForSubscriptionLevelPolicyAssignmentNextResults", resp, "Failure sending next results request") + } + result, err = client.ListQueryResultsForSubscriptionLevelPolicyAssignmentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "listQueryResultsForSubscriptionLevelPolicyAssignmentNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignmentComplete enumerates all values, automatically crossing page boundaries as required. +func (client PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssignmentComplete(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, skipToken string) (result PolicyStatesQueryResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForSubscriptionLevelPolicyAssignment") + 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.ListQueryResultsForSubscriptionLevelPolicyAssignment(ctx, policyStatesResource, subscriptionID, policyAssignmentName, top, orderBy, selectParameter, from, toParameter, filter, apply, skipToken) + return +} + // SummarizeForManagementGroup summarizes policy states for the resources under the management group. // Parameters: // managementGroupName - management group name. @@ -1079,7 +1438,6 @@ func (client PolicyStatesClient) SummarizeForManagementGroupSender(req *http.Req 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()) @@ -1181,7 +1539,6 @@ func (client PolicyStatesClient) SummarizeForPolicyDefinitionSender(req *http.Re 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()) @@ -1283,7 +1640,6 @@ func (client PolicyStatesClient) SummarizeForPolicySetDefinitionSender(req *http 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()) @@ -1382,7 +1738,6 @@ func (client PolicyStatesClient) SummarizeForResourceSender(req *http.Request) ( 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()) @@ -1483,7 +1838,6 @@ func (client PolicyStatesClient) SummarizeForResourceGroupSender(req *http.Reque 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()) @@ -1588,7 +1942,6 @@ func (client PolicyStatesClient) SummarizeForResourceGroupLevelPolicyAssignmentS 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()) @@ -1687,7 +2040,6 @@ func (client PolicyStatesClient) SummarizeForSubscriptionSender(req *http.Reques 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()) @@ -1789,7 +2141,6 @@ func (client PolicyStatesClient) SummarizeForSubscriptionLevelPolicyAssignmentSe 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()) @@ -1864,7 +2215,6 @@ func (client PolicyStatesClient) TriggerResourceGroupEvaluationSender(req *http. func (client PolicyStatesClient) TriggerResourceGroupEvaluationResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByClosing()) result.Response = resp @@ -1936,7 +2286,6 @@ func (client PolicyStatesClient) TriggerSubscriptionEvaluationSender(req *http.R func (client PolicyStatesClient) TriggerSubscriptionEvaluationResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByClosing()) result.Response = resp diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/policytrackedresources.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/policytrackedresources.go index 3769c5dfea52..e879618a624c 100644 --- a/services/policyinsights/mgmt/2019-10-01/policyinsights/policytrackedresources.go +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/policytrackedresources.go @@ -84,6 +84,9 @@ func (client PolicyTrackedResourcesClient) ListQueryResultsForManagementGroup(ct if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForManagementGroup", resp, "Failure responding to request") } + if result.ptrqr.hasNextLink() && result.ptrqr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -126,7 +129,6 @@ func (client PolicyTrackedResourcesClient) ListQueryResultsForManagementGroupSen 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()) @@ -212,6 +214,9 @@ func (client PolicyTrackedResourcesClient) ListQueryResultsForResource(ctx conte if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForResource", resp, "Failure responding to request") } + if result.ptrqr.hasNextLink() && result.ptrqr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -253,7 +258,6 @@ func (client PolicyTrackedResourcesClient) ListQueryResultsForResourceSender(req 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()) @@ -340,6 +344,9 @@ func (client PolicyTrackedResourcesClient) ListQueryResultsForResourceGroup(ctx if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForResourceGroup", resp, "Failure responding to request") } + if result.ptrqr.hasNextLink() && result.ptrqr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -382,7 +389,6 @@ func (client PolicyTrackedResourcesClient) ListQueryResultsForResourceGroupSende 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()) @@ -468,6 +474,9 @@ func (client PolicyTrackedResourcesClient) ListQueryResultsForSubscription(ctx c if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyTrackedResourcesClient", "ListQueryResultsForSubscription", resp, "Failure responding to request") } + if result.ptrqr.hasNextLink() && result.ptrqr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -509,7 +518,6 @@ func (client PolicyTrackedResourcesClient) ListQueryResultsForSubscriptionSender 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()) diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/remediations.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/remediations.go index f030228e34e2..78e7816a244d 100644 --- a/services/policyinsights/mgmt/2019-10-01/policyinsights/remediations.go +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/remediations.go @@ -110,7 +110,6 @@ func (client RemediationsClient) CancelAtManagementGroupSender(req *http.Request 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()) @@ -185,7 +184,6 @@ func (client RemediationsClient) CancelAtResourceSender(req *http.Request) (*htt 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()) @@ -262,7 +260,6 @@ func (client RemediationsClient) CancelAtResourceGroupSender(req *http.Request) 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()) @@ -337,7 +334,6 @@ func (client RemediationsClient) CancelAtSubscriptionSender(req *http.Request) ( 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()) @@ -419,7 +415,6 @@ func (client RemediationsClient) CreateOrUpdateAtManagementGroupSender(req *http 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()) @@ -500,7 +495,6 @@ func (client RemediationsClient) CreateOrUpdateAtResourceSender(req *http.Reques 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()) @@ -583,7 +577,6 @@ func (client RemediationsClient) CreateOrUpdateAtResourceGroupSender(req *http.R 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()) @@ -664,7 +657,6 @@ func (client RemediationsClient) CreateOrUpdateAtSubscriptionSender(req *http.Re 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()) @@ -740,7 +732,6 @@ func (client RemediationsClient) DeleteAtManagementGroupSender(req *http.Request 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()) @@ -815,7 +806,6 @@ func (client RemediationsClient) DeleteAtResourceSender(req *http.Request) (*htt 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()) @@ -892,7 +882,6 @@ func (client RemediationsClient) DeleteAtResourceGroupSender(req *http.Request) 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()) @@ -967,7 +956,6 @@ func (client RemediationsClient) DeleteAtSubscriptionSender(req *http.Request) ( 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()) @@ -1043,7 +1031,6 @@ func (client RemediationsClient) GetAtManagementGroupSender(req *http.Request) ( 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()) @@ -1118,7 +1105,6 @@ func (client RemediationsClient) GetAtResourceSender(req *http.Request) (*http.R 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()) @@ -1195,7 +1181,6 @@ func (client RemediationsClient) GetAtResourceGroupSender(req *http.Request) (*h 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()) @@ -1270,7 +1255,6 @@ func (client RemediationsClient) GetAtSubscriptionSender(req *http.Request) (*ht 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()) @@ -1319,6 +1303,9 @@ func (client RemediationsClient) ListDeploymentsAtManagementGroup(ctx context.Co if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListDeploymentsAtManagementGroup", resp, "Failure responding to request") } + if result.rdlr.hasNextLink() && result.rdlr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -1358,7 +1345,6 @@ func (client RemediationsClient) ListDeploymentsAtManagementGroupSender(req *htt 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()) @@ -1444,6 +1430,9 @@ func (client RemediationsClient) ListDeploymentsAtResource(ctx context.Context, if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListDeploymentsAtResource", resp, "Failure responding to request") } + if result.rdlr.hasNextLink() && result.rdlr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -1482,7 +1471,6 @@ func (client RemediationsClient) ListDeploymentsAtResourceSender(req *http.Reque 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()) @@ -1569,6 +1557,9 @@ func (client RemediationsClient) ListDeploymentsAtResourceGroup(ctx context.Cont if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListDeploymentsAtResourceGroup", resp, "Failure responding to request") } + if result.rdlr.hasNextLink() && result.rdlr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -1608,7 +1599,6 @@ func (client RemediationsClient) ListDeploymentsAtResourceGroupSender(req *http. 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()) @@ -1694,6 +1684,9 @@ func (client RemediationsClient) ListDeploymentsAtSubscription(ctx context.Conte if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListDeploymentsAtSubscription", resp, "Failure responding to request") } + if result.rdlr.hasNextLink() && result.rdlr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -1732,7 +1725,6 @@ func (client RemediationsClient) ListDeploymentsAtSubscriptionSender(req *http.R 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()) @@ -1818,6 +1810,9 @@ func (client RemediationsClient) ListForManagementGroup(ctx context.Context, man if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListForManagementGroup", resp, "Failure responding to request") } + if result.rlr.hasNextLink() && result.rlr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -1859,7 +1854,6 @@ func (client RemediationsClient) ListForManagementGroupSender(req *http.Request) 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()) @@ -1945,6 +1939,9 @@ func (client RemediationsClient) ListForResource(ctx context.Context, resourceID if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListForResource", resp, "Failure responding to request") } + if result.rlr.hasNextLink() && result.rlr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -1985,7 +1982,6 @@ func (client RemediationsClient) ListForResourceSender(req *http.Request) (*http 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()) @@ -2072,6 +2068,9 @@ func (client RemediationsClient) ListForResourceGroup(ctx context.Context, subsc if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListForResourceGroup", resp, "Failure responding to request") } + if result.rlr.hasNextLink() && result.rlr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -2113,7 +2112,6 @@ func (client RemediationsClient) ListForResourceGroupSender(req *http.Request) ( 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()) @@ -2199,6 +2197,9 @@ func (client RemediationsClient) ListForSubscription(ctx context.Context, subscr if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.RemediationsClient", "ListForSubscription", resp, "Failure responding to request") } + if result.rlr.hasNextLink() && result.rlr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -2239,7 +2240,6 @@ func (client RemediationsClient) ListForSubscriptionSender(req *http.Request) (* 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()) diff --git a/services/policyinsights/mgmt/2019-10-01/policyinsights/version.go b/services/policyinsights/mgmt/2019-10-01/policyinsights/version.go index 18cce08f4d74..91918ecf44e5 100644 --- a/services/policyinsights/mgmt/2019-10-01/policyinsights/version.go +++ b/services/policyinsights/mgmt/2019-10-01/policyinsights/version.go @@ -21,7 +21,7 @@ import "github.com/Azure/azure-sdk-for-go/version" // 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" + return "Azure-SDK-For-Go/" + Version() + " policyinsights/2019-10-01" } // Version returns the semantic version (see http://semver.org) of the client.