From cb9b0596fb23aab4a6d78ec27baaaa7ce8b34ad9 Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Thu, 30 Jul 2020 02:42:26 +0000 Subject: [PATCH] Generated from 222c6820550f2d760710701b21c2ac8dc9f30e73 Address PR comments --- .../mgmt/2016-04-01/policy/assignments.go | 18 +++--- .../mgmt/2016-04-01/policy/definitions.go | 7 +-- .../resources/mgmt/2016-04-01/policy/enums.go | 35 ++++++++++++ .../mgmt/2016-04-01/policy/models.go | 57 ++++++++++--------- .../mgmt/2016-04-01/policy/version.go | 2 +- 5 files changed, 78 insertions(+), 41 deletions(-) create mode 100644 services/resources/mgmt/2016-04-01/policy/enums.go diff --git a/services/resources/mgmt/2016-04-01/policy/assignments.go b/services/resources/mgmt/2016-04-01/policy/assignments.go index 3b3ebc79bc95..a3f93d22696e 100644 --- a/services/resources/mgmt/2016-04-01/policy/assignments.go +++ b/services/resources/mgmt/2016-04-01/policy/assignments.go @@ -114,7 +114,6 @@ func (client AssignmentsClient) CreateSender(req *http.Request) (*http.Response, func (client AssignmentsClient) CreateResponder(resp *http.Response) (result Assignment, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -196,7 +195,6 @@ func (client AssignmentsClient) CreateByIDSender(req *http.Request) (*http.Respo func (client AssignmentsClient) CreateByIDResponder(resp *http.Response) (result Assignment, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -271,7 +269,6 @@ func (client AssignmentsClient) DeleteSender(req *http.Request) (*http.Response, func (client AssignmentsClient) DeleteResponder(resp *http.Response) (result Assignment, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -348,7 +345,6 @@ func (client AssignmentsClient) DeleteByIDSender(req *http.Request) (*http.Respo func (client AssignmentsClient) DeleteByIDResponder(resp *http.Response) (result Assignment, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -423,7 +419,6 @@ func (client AssignmentsClient) GetSender(req *http.Request) (*http.Response, er func (client AssignmentsClient) GetResponder(resp *http.Response) (result Assignment, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -500,7 +495,6 @@ func (client AssignmentsClient) GetByIDSender(req *http.Request) (*http.Response func (client AssignmentsClient) GetByIDResponder(resp *http.Response) (result Assignment, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -540,6 +534,9 @@ func (client AssignmentsClient) List(ctx context.Context, filter string) (result if err != nil { err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "List", resp, "Failure responding to request") } + if result.alr.hasNextLink() && result.alr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -577,7 +574,6 @@ func (client AssignmentsClient) ListSender(req *http.Request) (*http.Response, e func (client AssignmentsClient) ListResponder(resp *http.Response) (result AssignmentListResult, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -667,6 +663,9 @@ func (client AssignmentsClient) ListForResource(ctx context.Context, resourceGro if err != nil { err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "ListForResource", resp, "Failure responding to request") } + if result.alr.hasNextLink() && result.alr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -709,7 +708,6 @@ func (client AssignmentsClient) ListForResourceSender(req *http.Request) (*http. func (client AssignmentsClient) ListForResourceResponder(resp *http.Response) (result AssignmentListResult, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -795,6 +793,9 @@ func (client AssignmentsClient) ListForResourceGroup(ctx context.Context, resour if err != nil { err = autorest.NewErrorWithError(err, "policy.AssignmentsClient", "ListForResourceGroup", resp, "Failure responding to request") } + if result.alr.hasNextLink() && result.alr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -833,7 +834,6 @@ func (client AssignmentsClient) ListForResourceGroupSender(req *http.Request) (* func (client AssignmentsClient) ListForResourceGroupResponder(resp *http.Response) (result AssignmentListResult, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) diff --git a/services/resources/mgmt/2016-04-01/policy/definitions.go b/services/resources/mgmt/2016-04-01/policy/definitions.go index 7d6b3945d36f..8f8a888bdc5c 100644 --- a/services/resources/mgmt/2016-04-01/policy/definitions.go +++ b/services/resources/mgmt/2016-04-01/policy/definitions.go @@ -112,7 +112,6 @@ func (client DefinitionsClient) CreateOrUpdateSender(req *http.Request) (*http.R func (client DefinitionsClient) CreateOrUpdateResponder(resp *http.Response) (result Definition, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -186,7 +185,6 @@ func (client DefinitionsClient) DeleteSender(req *http.Request) (*http.Response, func (client DefinitionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByClosing()) result.Response = resp @@ -259,7 +257,6 @@ func (client DefinitionsClient) GetSender(req *http.Request) (*http.Response, er func (client DefinitionsClient) GetResponder(resp *http.Response) (result Definition, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -299,6 +296,9 @@ func (client DefinitionsClient) List(ctx context.Context, filter string) (result if err != nil { err = autorest.NewErrorWithError(err, "policy.DefinitionsClient", "List", resp, "Failure responding to request") } + if result.dlr.hasNextLink() && result.dlr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -336,7 +336,6 @@ func (client DefinitionsClient) ListSender(req *http.Request) (*http.Response, e func (client DefinitionsClient) ListResponder(resp *http.Response) (result DefinitionListResult, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) diff --git a/services/resources/mgmt/2016-04-01/policy/enums.go b/services/resources/mgmt/2016-04-01/policy/enums.go new file mode 100644 index 000000000000..5bfb5ee65183 --- /dev/null +++ b/services/resources/mgmt/2016-04-01/policy/enums.go @@ -0,0 +1,35 @@ +package policy + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// Type enumerates the values for type. +type Type string + +const ( + // BuiltIn ... + BuiltIn Type = "BuiltIn" + // Custom ... + Custom Type = "Custom" + // NotSpecified ... + NotSpecified Type = "NotSpecified" +) + +// PossibleTypeValues returns an array of possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{BuiltIn, Custom, NotSpecified} +} diff --git a/services/resources/mgmt/2016-04-01/policy/models.go b/services/resources/mgmt/2016-04-01/policy/models.go index 4e27ae4f7049..7b45e54bf90b 100644 --- a/services/resources/mgmt/2016-04-01/policy/models.go +++ b/services/resources/mgmt/2016-04-01/policy/models.go @@ -29,23 +29,6 @@ import ( // The package's fully qualified name. const fqdn = "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-04-01/policy" -// Type enumerates the values for type. -type Type string - -const ( - // BuiltIn ... - BuiltIn Type = "BuiltIn" - // Custom ... - Custom Type = "Custom" - // NotSpecified ... - NotSpecified Type = "NotSpecified" -) - -// PossibleTypeValues returns an array of possible values for the Type const type. -func PossibleTypeValues() []Type { - return []Type{BuiltIn, Custom, NotSpecified} -} - // Assignment the policy assignment. type Assignment struct { autorest.Response `json:"-"` @@ -205,10 +188,15 @@ func (alr AssignmentListResult) IsEmpty() bool { return alr.Value == nil || len(*alr.Value) == 0 } +// hasNextLink returns true if the NextLink is not empty. +func (alr AssignmentListResult) hasNextLink() bool { + return alr.NextLink != nil && len(*alr.NextLink) != 0 +} + // assignmentListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. func (alr AssignmentListResult) assignmentListResultPreparer(ctx context.Context) (*http.Request, error) { - if alr.NextLink == nil || len(to.String(alr.NextLink)) < 1 { + if !alr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), @@ -236,11 +224,16 @@ func (page *AssignmentListResultPage) NextWithContext(ctx context.Context) (err tracing.EndSpan(ctx, sc, err) }() } - next, err := page.fn(ctx, page.alr) - if err != nil { - return err + for { + next, err := page.fn(ctx, page.alr) + if err != nil { + return err + } + page.alr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } } - page.alr = next return nil } @@ -426,10 +419,15 @@ func (dlr DefinitionListResult) IsEmpty() bool { return dlr.Value == nil || len(*dlr.Value) == 0 } +// hasNextLink returns true if the NextLink is not empty. +func (dlr DefinitionListResult) hasNextLink() bool { + return dlr.NextLink != nil && len(*dlr.NextLink) != 0 +} + // definitionListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. func (dlr DefinitionListResult) definitionListResultPreparer(ctx context.Context) (*http.Request, error) { - if dlr.NextLink == nil || len(to.String(dlr.NextLink)) < 1 { + if !dlr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), @@ -457,11 +455,16 @@ func (page *DefinitionListResultPage) NextWithContext(ctx context.Context) (err tracing.EndSpan(ctx, sc, err) }() } - next, err := page.fn(ctx, page.dlr) - if err != nil { - return err + for { + next, err := page.fn(ctx, page.dlr) + if err != nil { + return err + } + page.dlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } } - page.dlr = next return nil } diff --git a/services/resources/mgmt/2016-04-01/policy/version.go b/services/resources/mgmt/2016-04-01/policy/version.go index c7b2979c3418..dd0cd479c32a 100644 --- a/services/resources/mgmt/2016-04-01/policy/version.go +++ b/services/resources/mgmt/2016-04-01/policy/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 + " policy/2016-04-01" + return "Azure-SDK-For-Go/" + Version() + " policy/2016-04-01" } // Version returns the semantic version (see http://semver.org) of the client.