diff --git a/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/client.go b/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/client.go index dba65fe987a4..f007719ab2f9 100644 --- a/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/client.go +++ b/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/client.go @@ -1,4 +1,4 @@ -// Package policyinsights implements the Azure ARM Policyinsights service API version . +// Package policyinsights implements the Azure ARM Policyinsights service API version 2018-07-01-preview. // // package policyinsights diff --git a/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/models.go b/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/models.go index 952d8d7c9f41..f5c14f9d34e8 100644 --- a/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/models.go +++ b/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/models.go @@ -621,10 +621,149 @@ type PolicyEventsQueryResults struct { 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 +} + +// 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.OdataNextLink == nil || len(to.String(peqr.OdataNextLink)) < 1 { + 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) + }() + } + next, err := page.fn(ctx, page.peqr) + if err != nil { + return err + } + page.peqr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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} +} + // PolicyState policy state record. type PolicyState struct { // AdditionalProperties - Unmatched properties from the message are deserialized this collection @@ -1080,10 +1219,149 @@ 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"` } +// 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 +} + +// 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.OdataNextLink == nil || len(to.String(psqr.OdataNextLink)) < 1 { + 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) + }() + } + next, err := page.fn(ctx, page.psqr) + if err != nil { + return err + } + page.psqr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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} +} + // PolicyTrackedResource policy tracked resource record. type PolicyTrackedResource struct { // TrackedResourceID - READ-ONLY; The ID of the policy tracked resource. diff --git a/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/operations.go b/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/operations.go index 8a866c7563b1..b9adf0c568a0 100644 --- a/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/operations.go +++ b/services/preview/policyinsights/mgmt/2018-07-01-preview/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/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/policyevents.go b/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/policyevents.go index a20596f95cc9..83c3a724c3bb 100644 --- a/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/policyevents.go +++ b/services/preview/policyinsights/mgmt/2018-07-01-preview/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,12 +86,12 @@ 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") } @@ -171,14 +100,14 @@ func (client PolicyEventsClient) ListQueryResultsForManagementGroup(ctx context. } // 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 = "2018-07-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -203,6 +132,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 +155,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 +162,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 +214,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 +234,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,12 +243,12 @@ 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") } @@ -286,7 +257,7 @@ func (client PolicyEventsClient) ListQueryResultsForPolicyDefinition(ctx context } // 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 +265,7 @@ func (client PolicyEventsClient) ListQueryResultsForPolicyDefinitionPreparer(ctx "subscriptionId": autorest.Encode("path", subscriptionID), } - const APIVersion = "2018-04-04" + const APIVersion = "2018-07-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -319,6 +290,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 +313,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 +320,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 +372,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 +392,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,12 +401,12 @@ 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") } @@ -402,7 +415,7 @@ func (client PolicyEventsClient) ListQueryResultsForPolicySetDefinition(ctx cont } // 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 +423,7 @@ func (client PolicyEventsClient) ListQueryResultsForPolicySetDefinitionPreparer( "subscriptionId": autorest.Encode("path", subscriptionID), } - const APIVersion = "2018-04-04" + const APIVersion = "2018-07-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -435,6 +448,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 +471,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 +478,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 +529,15 @@ 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) { +// 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, 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 +549,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, skipToken) if err != nil { err = autorest.NewErrorWithError(err, "policyinsights.PolicyEventsClient", "ListQueryResultsForResource", nil, "Failure preparing request") return @@ -503,12 +558,12 @@ 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") } @@ -517,13 +572,13 @@ func (client PolicyEventsClient) ListQueryResultsForResource(ctx context.Context } // 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, skipToken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "policyEventsResource": autorest.Encode("path", "default"), "resourceId": resourceID, } - const APIVersion = "2018-04-04" + const APIVersion = "2018-07-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -548,6 +603,9 @@ func (client PolicyEventsClient) ListQueryResultsForResourcePreparer(ctx context 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(), @@ -568,7 +626,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 +633,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, 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, skipToken) + return +} + // ListQueryResultsForResourceGroup queries policy events for the resources under the resource group. // Parameters: // subscriptionID - microsoft Azure subscription ID. @@ -591,13 +685,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 +705,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,12 +714,12 @@ 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") } @@ -631,14 +728,14 @@ func (client PolicyEventsClient) ListQueryResultsForResourceGroup(ctx context.Co } // 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 = "2018-07-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -663,6 +760,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 +783,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 +790,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 +844,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 +864,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,12 +873,12 @@ 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") } @@ -748,7 +887,7 @@ func (client PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssi } // 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 +896,7 @@ func (client PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssi "subscriptionId": autorest.Encode("path", subscriptionID), } - const APIVersion = "2018-04-04" + const APIVersion = "2018-07-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -782,6 +921,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 +944,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 +951,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 +1002,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 +1022,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,12 +1031,12 @@ 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") } @@ -864,13 +1045,13 @@ func (client PolicyEventsClient) ListQueryResultsForSubscription(ctx context.Con } // 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 = "2018-07-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -895,6 +1076,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 +1099,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 +1106,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 +1159,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 +1179,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,12 +1188,12 @@ 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") } @@ -979,7 +1202,7 @@ func (client PolicyEventsClient) ListQueryResultsForSubscriptionLevelPolicyAssig } // 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 +1210,7 @@ func (client PolicyEventsClient) ListQueryResultsForSubscriptionLevelPolicyAssig "subscriptionId": autorest.Encode("path", subscriptionID), } - const APIVersion = "2018-04-04" + const APIVersion = "2018-07-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1012,6 +1235,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 +1258,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/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/policyinsightsapi/interfaces.go b/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/policyinsightsapi/interfaces.go index 4f86ebd5641e..df7ea268d3e3 100644 --- a/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/policyinsightsapi/interfaces.go +++ b/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/policyinsightsapi/interfaces.go @@ -77,15 +77,22 @@ 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, 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, 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) @@ -93,14 +100,22 @@ var _ PolicyEventsClientAPI = (*policyinsights.PolicyEventsClient)(nil) // PolicyStatesClientAPI contains the set of methods on the PolicyStatesClient type. type PolicyStatesClientAPI interface { GetMetadata(ctx context.Context, scope string) (result policyinsights.String, 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) (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/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/policystates.go b/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/policystates.go index 03651671fe80..6aa73ec2fd81 100644 --- a/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/policystates.go +++ b/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/policystates.go @@ -109,7 +109,6 @@ func (client PolicyStatesClient) GetMetadataSender(req *http.Request) (*http.Res func (client PolicyStatesClient) GetMetadataResponder(resp *http.Response) (result String, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result.Value), autorest.ByClosing()) @@ -133,13 +132,15 @@ func (client PolicyStatesClient) GetMetadataResponder(resp *http.Response) (resu // 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) }() @@ -151,7 +152,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 @@ -159,12 +161,12 @@ 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") } @@ -173,7 +175,7 @@ func (client PolicyStatesClient) ListQueryResultsForManagementGroup(ctx context. } // 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"), @@ -205,6 +207,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(), @@ -225,7 +230,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()) @@ -233,6 +237,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, @@ -250,13 +291,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) }() @@ -268,7 +311,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 @@ -276,12 +320,12 @@ 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") } @@ -290,7 +334,7 @@ func (client PolicyStatesClient) ListQueryResultsForPolicyDefinition(ctx context } // 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), @@ -323,6 +367,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(), @@ -343,7 +390,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()) @@ -351,6 +397,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, @@ -368,13 +451,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) }() @@ -386,7 +471,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 @@ -394,12 +480,12 @@ 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") } @@ -408,7 +494,7 @@ func (client PolicyStatesClient) ListQueryResultsForPolicySetDefinition(ctx cont } // 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), @@ -441,6 +527,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(), @@ -461,7 +550,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()) @@ -469,6 +557,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, @@ -487,13 +612,15 @@ func (client PolicyStatesClient) ListQueryResultsForPolicySetDefinitionResponder // 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) { +// 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) }() @@ -505,7 +632,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 @@ -513,12 +641,12 @@ 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") } @@ -527,7 +655,7 @@ func (client PolicyStatesClient) ListQueryResultsForResource(ctx context.Context } // 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, @@ -561,6 +689,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(), @@ -581,7 +712,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()) @@ -589,6 +719,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, @@ -606,13 +773,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) }() @@ -624,7 +793,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 @@ -632,12 +802,12 @@ 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") } @@ -646,7 +816,7 @@ func (client PolicyStatesClient) ListQueryResultsForResourceGroup(ctx context.Co } // 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), @@ -678,6 +848,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(), @@ -698,7 +871,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()) @@ -706,6 +878,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: @@ -725,13 +934,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) }() @@ -743,7 +954,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 @@ -751,12 +963,12 @@ 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") } @@ -765,7 +977,7 @@ func (client PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssi } // 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), @@ -799,6 +1011,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(), @@ -819,7 +1034,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()) @@ -827,6 +1041,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, @@ -843,13 +1094,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) }() @@ -861,7 +1114,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 @@ -869,12 +1123,12 @@ 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") } @@ -883,7 +1137,7 @@ func (client PolicyStatesClient) ListQueryResultsForSubscription(ctx context.Con } // 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), @@ -914,6 +1168,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(), @@ -934,7 +1191,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()) @@ -942,6 +1198,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: @@ -960,13 +1253,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) }() @@ -978,7 +1273,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 @@ -986,12 +1282,12 @@ 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") } @@ -1000,7 +1296,7 @@ func (client PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssig } // 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), @@ -1033,6 +1329,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(), @@ -1053,7 +1352,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()) @@ -1061,6 +1359,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. @@ -1153,7 +1488,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()) @@ -1255,7 +1589,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()) @@ -1357,7 +1690,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()) @@ -1456,7 +1788,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()) @@ -1557,7 +1888,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()) @@ -1662,7 +1992,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()) @@ -1761,7 +2090,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()) @@ -1863,7 +2191,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()) diff --git a/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/policytrackedresources.go b/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/policytrackedresources.go index 3769c5dfea52..a670f09d70e9 100644 --- a/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/policytrackedresources.go +++ b/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/policytrackedresources.go @@ -126,7 +126,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()) @@ -253,7 +252,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()) @@ -382,7 +380,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()) @@ -509,7 +506,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/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/remediations.go b/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/remediations.go index 0df34c2b7bc9..a1c20f70b846 100644 --- a/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/remediations.go +++ b/services/preview/policyinsights/mgmt/2018-07-01-preview/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()) @@ -1358,7 +1342,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()) @@ -1482,7 +1465,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()) @@ -1608,7 +1590,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()) @@ -1732,7 +1713,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()) @@ -1859,7 +1839,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()) @@ -1985,7 +1964,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()) @@ -2113,7 +2091,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()) @@ -2239,7 +2216,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/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/version.go b/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/version.go index 29cca1b536f7..6963d00a2f56 100644 --- a/services/preview/policyinsights/mgmt/2018-07-01-preview/policyinsights/version.go +++ b/services/preview/policyinsights/mgmt/2018-07-01-preview/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/2018-07-01-preview" + return "Azure-SDK-For-Go/" + Version() + " policyinsights/2018-07-01-preview" } // Version returns the semantic version (see http://semver.org) of the client.