diff --git a/services/preview/subscription/mgmt/2018-03-01-preview/subscription/enums.go b/services/preview/subscription/mgmt/2018-03-01-preview/subscription/enums.go new file mode 100644 index 000000000000..ef5afc692989 --- /dev/null +++ b/services/preview/subscription/mgmt/2018-03-01-preview/subscription/enums.go @@ -0,0 +1,71 @@ +package subscription + +// 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. + +// OfferType enumerates the values for offer type. +type OfferType string + +const ( + // MSAZR0017P ... + MSAZR0017P OfferType = "MS-AZR-0017P" + // MSAZR0148P ... + MSAZR0148P OfferType = "MS-AZR-0148P" +) + +// PossibleOfferTypeValues returns an array of possible values for the OfferType const type. +func PossibleOfferTypeValues() []OfferType { + return []OfferType{MSAZR0017P, MSAZR0148P} +} + +// SpendingLimit enumerates the values for spending limit. +type SpendingLimit string + +const ( + // CurrentPeriodOff ... + CurrentPeriodOff SpendingLimit = "CurrentPeriodOff" + // Off ... + Off SpendingLimit = "Off" + // On ... + On SpendingLimit = "On" +) + +// PossibleSpendingLimitValues returns an array of possible values for the SpendingLimit const type. +func PossibleSpendingLimitValues() []SpendingLimit { + return []SpendingLimit{CurrentPeriodOff, Off, On} +} + +// State enumerates the values for state. +type State string + +const ( + // Deleted ... + Deleted State = "Deleted" + // Disabled ... + Disabled State = "Disabled" + // Enabled ... + Enabled State = "Enabled" + // PastDue ... + PastDue State = "PastDue" + // Warned ... + Warned State = "Warned" +) + +// PossibleStateValues returns an array of possible values for the State const type. +func PossibleStateValues() []State { + return []State{Deleted, Disabled, Enabled, PastDue, Warned} +} diff --git a/services/preview/subscription/mgmt/2018-03-01-preview/subscription/factory.go b/services/preview/subscription/mgmt/2018-03-01-preview/subscription/factory.go index 809bba95f340..fb63d10a12cc 100644 --- a/services/preview/subscription/mgmt/2018-03-01-preview/subscription/factory.go +++ b/services/preview/subscription/mgmt/2018-03-01-preview/subscription/factory.go @@ -109,7 +109,6 @@ func (client FactoryClient) CreateSubscriptionInEnrollmentAccountSender(req *htt func (client FactoryClient) CreateSubscriptionInEnrollmentAccountResponder(resp *http.Response) (result CreationResult, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) diff --git a/services/preview/subscription/mgmt/2018-03-01-preview/subscription/models.go b/services/preview/subscription/mgmt/2018-03-01-preview/subscription/models.go index 8863260e24a2..a28bc7e5d116 100644 --- a/services/preview/subscription/mgmt/2018-03-01-preview/subscription/models.go +++ b/services/preview/subscription/mgmt/2018-03-01-preview/subscription/models.go @@ -30,59 +30,6 @@ import ( // The package's fully qualified name. const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/subscription/mgmt/2018-03-01-preview/subscription" -// OfferType enumerates the values for offer type. -type OfferType string - -const ( - // MSAZR0017P ... - MSAZR0017P OfferType = "MS-AZR-0017P" - // MSAZR0148P ... - MSAZR0148P OfferType = "MS-AZR-0148P" -) - -// PossibleOfferTypeValues returns an array of possible values for the OfferType const type. -func PossibleOfferTypeValues() []OfferType { - return []OfferType{MSAZR0017P, MSAZR0148P} -} - -// SpendingLimit enumerates the values for spending limit. -type SpendingLimit string - -const ( - // CurrentPeriodOff ... - CurrentPeriodOff SpendingLimit = "CurrentPeriodOff" - // Off ... - Off SpendingLimit = "Off" - // On ... - On SpendingLimit = "On" -) - -// PossibleSpendingLimitValues returns an array of possible values for the SpendingLimit const type. -func PossibleSpendingLimitValues() []SpendingLimit { - return []SpendingLimit{CurrentPeriodOff, Off, On} -} - -// State enumerates the values for state. -type State string - -const ( - // Deleted ... - Deleted State = "Deleted" - // Disabled ... - Disabled State = "Disabled" - // Enabled ... - Enabled State = "Enabled" - // PastDue ... - PastDue State = "PastDue" - // Warned ... - Warned State = "Warned" -) - -// PossibleStateValues returns an array of possible values for the State const type. -func PossibleStateValues() []State { - return []State{Deleted, Disabled, Enabled, PastDue, Warned} -} - // AdPrincipal active Directory Principal who’ll get owner access on the new subscription. type AdPrincipal struct { // ObjectID - Object id of the Principal @@ -134,8 +81,8 @@ type ErrorResponse struct { Message *string `json:"message,omitempty"` } -// FactoryCreateSubscriptionInEnrollmentAccountFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. +// FactoryCreateSubscriptionInEnrollmentAccountFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. type FactoryCreateSubscriptionInEnrollmentAccountFuture struct { azure.Future } @@ -240,10 +187,15 @@ func (lr ListResult) IsEmpty() bool { return lr.Value == nil || len(*lr.Value) == 0 } +// hasNextLink returns true if the NextLink is not empty. +func (lr ListResult) hasNextLink() bool { + return lr.NextLink != nil && len(*lr.NextLink) != 0 +} + // listResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. func (lr ListResult) listResultPreparer(ctx context.Context) (*http.Request, error) { - if lr.NextLink == nil || len(to.String(lr.NextLink)) < 1 { + if !lr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), @@ -271,11 +223,16 @@ func (page *ListResultPage) NextWithContext(ctx context.Context) (err error) { tracing.EndSpan(ctx, sc, err) }() } - next, err := page.fn(ctx, page.lr) - if err != nil { - return err + for { + next, err := page.fn(ctx, page.lr) + if err != nil { + return err + } + page.lr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } } - page.lr = next return nil } @@ -349,6 +306,18 @@ type Model struct { AuthorizationSource *string `json:"authorizationSource,omitempty"` } +// MarshalJSON is the custom marshaler for Model. +func (mVar Model) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mVar.SubscriptionPolicies != nil { + objectMap["subscriptionPolicies"] = mVar.SubscriptionPolicies + } + if mVar.AuthorizationSource != nil { + objectMap["authorizationSource"] = mVar.AuthorizationSource + } + return json.Marshal(objectMap) +} + // Operation status of the subscription POST operation. type Operation struct { // ID - READ-ONLY; The operation Id. @@ -359,6 +328,18 @@ type Operation struct { StatusDetail *string `json:"statusDetail,omitempty"` } +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if o.Status != nil { + objectMap["status"] = o.Status + } + if o.StatusDetail != nil { + objectMap["statusDetail"] = o.StatusDetail + } + return json.Marshal(objectMap) +} + // OperationListResult a list of pending subscription operations. type OperationListResult struct { autorest.Response `json:"-"` @@ -461,10 +442,15 @@ func (tlr TenantListResult) IsEmpty() bool { return tlr.Value == nil || len(*tlr.Value) == 0 } +// hasNextLink returns true if the NextLink is not empty. +func (tlr TenantListResult) hasNextLink() bool { + return tlr.NextLink != nil && len(*tlr.NextLink) != 0 +} + // tenantListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. func (tlr TenantListResult) tenantListResultPreparer(ctx context.Context) (*http.Request, error) { - if tlr.NextLink == nil || len(to.String(tlr.NextLink)) < 1 { + if !tlr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), @@ -492,11 +478,16 @@ func (page *TenantListResultPage) NextWithContext(ctx context.Context) (err erro tracing.EndSpan(ctx, sc, err) }() } - next, err := page.fn(ctx, page.tlr) - if err != nil { - return err + for { + next, err := page.fn(ctx, page.tlr) + if err != nil { + return err + } + page.tlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } } - page.tlr = next return nil } diff --git a/services/preview/subscription/mgmt/2018-03-01-preview/subscription/operations.go b/services/preview/subscription/mgmt/2018-03-01-preview/subscription/operations.go index 445ed18ac638..463495d47b5d 100644 --- a/services/preview/subscription/mgmt/2018-03-01-preview/subscription/operations.go +++ b/services/preview/subscription/mgmt/2018-03-01-preview/subscription/operations.go @@ -100,7 +100,6 @@ func (client OperationsClient) ListSender(req *http.Request) (*http.Response, er func (client OperationsClient) 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/2018-03-01-preview/subscription/subscriptions.go b/services/preview/subscription/mgmt/2018-03-01-preview/subscription/subscriptions.go index 1bf96d086805..b62a0faa2e4e 100644 --- a/services/preview/subscription/mgmt/2018-03-01-preview/subscription/subscriptions.go +++ b/services/preview/subscription/mgmt/2018-03-01-preview/subscription/subscriptions.go @@ -106,7 +106,6 @@ func (client SubscriptionsClient) GetSender(req *http.Request) (*http.Response, func (client SubscriptionsClient) GetResponder(resp *http.Response) (result Model, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -144,6 +143,9 @@ func (client SubscriptionsClient) List(ctx context.Context) (result ListResultPa if err != nil { err = autorest.NewErrorWithError(err, "subscription.SubscriptionsClient", "List", resp, "Failure responding to request") } + if result.lr.hasNextLink() && result.lr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -174,7 +176,6 @@ func (client SubscriptionsClient) ListSender(req *http.Request) (*http.Response, func (client SubscriptionsClient) ListResponder(resp *http.Response) (result ListResult, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) @@ -285,7 +286,6 @@ func (client SubscriptionsClient) ListLocationsSender(req *http.Request) (*http. func (client SubscriptionsClient) ListLocationsResponder(resp *http.Response) (result LocationListResult, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) diff --git a/services/preview/subscription/mgmt/2018-03-01-preview/subscription/tenants.go b/services/preview/subscription/mgmt/2018-03-01-preview/subscription/tenants.go index 7f352213a512..fe6c381147c1 100644 --- a/services/preview/subscription/mgmt/2018-03-01-preview/subscription/tenants.go +++ b/services/preview/subscription/mgmt/2018-03-01-preview/subscription/tenants.go @@ -71,6 +71,9 @@ func (client TenantsClient) List(ctx context.Context) (result TenantListResultPa if err != nil { err = autorest.NewErrorWithError(err, "subscription.TenantsClient", "List", resp, "Failure responding to request") } + if result.tlr.hasNextLink() && result.tlr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -101,7 +104,6 @@ func (client TenantsClient) ListSender(req *http.Request) (*http.Response, error func (client TenantsClient) ListResponder(resp *http.Response) (result TenantListResult, err error) { err = autorest.Respond( resp, - client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) diff --git a/services/preview/subscription/mgmt/2018-03-01-preview/subscription/version.go b/services/preview/subscription/mgmt/2018-03-01-preview/subscription/version.go index e599f3c39cfe..0eb16c7ccf9e 100644 --- a/services/preview/subscription/mgmt/2018-03-01-preview/subscription/version.go +++ b/services/preview/subscription/mgmt/2018-03-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/2018-03-01-preview" + return "Azure-SDK-For-Go/" + Version() + " subscription/2018-03-01-preview" } // Version returns the semantic version (see http://semver.org) of the client.