diff --git a/services/preview/subscription/mgmt/2017-11-01-preview/subscription/definitions.go b/services/preview/subscription/mgmt/2017-11-01-preview/subscription/definitions.go index b465232f71ef..6aa895f7364e 100644 --- a/services/preview/subscription/mgmt/2017-11-01-preview/subscription/definitions.go +++ b/services/preview/subscription/mgmt/2017-11-01-preview/subscription/definitions.go @@ -114,7 +114,6 @@ func (client DefinitionsClient) CreateSender(req *http.Request) (future Definiti func (client DefinitionsClient) CreateResponder(resp *http.Response) (result Definition, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -187,7 +186,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()) @@ -262,7 +260,6 @@ func (client DefinitionsClient) GetOperationStatusSender(req *http.Request) (*ht func (client DefinitionsClient) GetOperationStatusResponder(resp *http.Response) (result Definition, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -300,6 +297,9 @@ func (client DefinitionsClient) List(ctx context.Context) (result DefinitionList if err != nil { err = autorest.NewErrorWithError(err, "subscription.DefinitionsClient", "List", resp, "Failure responding to request") } + if result.dl.hasNextLink() && result.dl.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -330,7 +330,6 @@ func (client DefinitionsClient) ListSender(req *http.Request) (*http.Response, e func (client DefinitionsClient) ListResponder(resp *http.Response) (result DefinitionList, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) diff --git a/services/preview/subscription/mgmt/2017-11-01-preview/subscription/definitionsoperationmetadata.go b/services/preview/subscription/mgmt/2017-11-01-preview/subscription/definitionsoperationmetadata.go index f0e85297e15a..bc52d45952bc 100644 --- a/services/preview/subscription/mgmt/2017-11-01-preview/subscription/definitionsoperationmetadata.go +++ b/services/preview/subscription/mgmt/2017-11-01-preview/subscription/definitionsoperationmetadata.go @@ -73,6 +73,9 @@ func (client DefinitionsOperationMetadataClient) List(ctx context.Context) (resu if err != nil { err = autorest.NewErrorWithError(err, "subscription.DefinitionsOperationMetadataClient", "List", resp, "Failure responding to request") } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -103,7 +106,6 @@ func (client DefinitionsOperationMetadataClient) ListSender(req *http.Request) ( func (client DefinitionsOperationMetadataClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) diff --git a/services/preview/subscription/mgmt/2017-11-01-preview/subscription/models.go b/services/preview/subscription/mgmt/2017-11-01-preview/subscription/models.go index f5b09694ada2..1bff2655da82 100644 --- a/services/preview/subscription/mgmt/2017-11-01-preview/subscription/models.go +++ b/services/preview/subscription/mgmt/2017-11-01-preview/subscription/models.go @@ -180,10 +180,15 @@ func (dl DefinitionList) IsEmpty() bool { return dl.Value == nil || len(*dl.Value) == 0 } +// hasNextLink returns true if the NextLink is not empty. +func (dl DefinitionList) hasNextLink() bool { + return dl.NextLink != nil && len(*dl.NextLink) != 0 +} + // definitionListPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. func (dl DefinitionList) definitionListPreparer(ctx context.Context) (*http.Request, error) { - if dl.NextLink == nil || len(to.String(dl.NextLink)) < 1 { + if !dl.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), @@ -211,11 +216,16 @@ func (page *DefinitionListPage) NextWithContext(ctx context.Context) (err error) tracing.EndSpan(ctx, sc, err) }() } - next, err := page.fn(ctx, page.dl) - if err != nil { - return err + for { + next, err := page.fn(ctx, page.dl) + if err != nil { + return err + } + page.dl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } } - page.dl = next return nil } @@ -261,6 +271,21 @@ type DefinitionProperties struct { Etag *string `json:"etag,omitempty"` } +// MarshalJSON is the custom marshaler for DefinitionProperties. +func (dp DefinitionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dp.SubscriptionDisplayName != nil { + objectMap["subscriptionDisplayName"] = dp.SubscriptionDisplayName + } + if dp.OfferType != nil { + objectMap["offerType"] = dp.OfferType + } + if dp.Etag != nil { + objectMap["etag"] = dp.Etag + } + return json.Marshal(objectMap) +} + // DefinitionsCreateFuture an abstraction for monitoring and retrieving the results of a long-running // operation. type DefinitionsCreateFuture struct { @@ -394,10 +419,15 @@ func (olr OperationListResult) IsEmpty() bool { return olr.Value == nil || len(*olr.Value) == 0 } +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + // operationListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { - if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + if !olr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), @@ -425,11 +455,16 @@ func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err e tracing.EndSpan(ctx, sc, err) }() } - next, err := page.fn(ctx, page.olr) - if err != nil { - return err + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } } - page.olr = next return nil } diff --git a/services/preview/subscription/mgmt/2017-11-01-preview/subscription/version.go b/services/preview/subscription/mgmt/2017-11-01-preview/subscription/version.go index dfef3716abf0..d4e7187b92b0 100644 --- a/services/preview/subscription/mgmt/2017-11-01-preview/subscription/version.go +++ b/services/preview/subscription/mgmt/2017-11-01-preview/subscription/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 + " subscription/2017-11-01-preview" + return "Azure-SDK-For-Go/" + Version() + " subscription/2017-11-01-preview" } // Version returns the semantic version (see http://semver.org) of the client.