diff --git a/services/billing/mgmt/2021-10-01/billing/CHANGELOG.md b/services/billing/mgmt/2021-10-01/billing/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/billing/mgmt/2021-10-01/billing/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/billing/mgmt/2021-10-01/billing/_meta.json b/services/billing/mgmt/2021-10-01/billing/_meta.json new file mode 100644 index 000000000000..684730981e1c --- /dev/null +++ b/services/billing/mgmt/2021-10-01/billing/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "bc45d483dac4a7ecc0ab2a8064acf9a9726bac6b", + "readme": "/_/azure-rest-api-specs/specification/billing/resource-manager/readme.md", + "tag": "package-2021-10", + "use": "@microsoft.azure/autorest.go@2.1.187", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2021-10 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/billing/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/billing/mgmt/2021-10-01/billing/billingapi/interfaces.go b/services/billing/mgmt/2021-10-01/billing/billingapi/interfaces.go new file mode 100644 index 000000000000..357223b274b3 --- /dev/null +++ b/services/billing/mgmt/2021-10-01/billing/billingapi/interfaces.go @@ -0,0 +1,56 @@ +package billingapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/billing/mgmt/2021-10-01/billing" + "github.com/Azure/go-autorest/autorest" +) + +// PaymentMethodOwnedByUserClientAPI contains the set of methods on the PaymentMethodOwnedByUserClient type. +type PaymentMethodOwnedByUserClientAPI interface { + Delete(ctx context.Context, paymentMethodName string) (result autorest.Response, err error) + Get(ctx context.Context, paymentMethodName string) (result billing.PaymentMethod, err error) + List(ctx context.Context) (result billing.PaymentMethodsListResultPage, err error) + ListComplete(ctx context.Context) (result billing.PaymentMethodsListResultIterator, err error) +} + +var _ PaymentMethodOwnedByUserClientAPI = (*billing.PaymentMethodOwnedByUserClient)(nil) + +// PaymentMethodsClientAPI contains the set of methods on the PaymentMethodsClient type. +type PaymentMethodsClientAPI interface { + GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, paymentMethodName string) (result billing.PaymentMethodLink, err error) + ListByBillingAccount(ctx context.Context, billingAccountName string) (result billing.PaymentMethodsListResultPage, err error) + ListByBillingAccountComplete(ctx context.Context, billingAccountName string) (result billing.PaymentMethodsListResultIterator, err error) + ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.PaymentMethodLinksListResultPage, err error) + ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.PaymentMethodLinksListResultIterator, err error) +} + +var _ PaymentMethodsClientAPI = (*billing.PaymentMethodsClient)(nil) + +// PaymentMethodAtBillingAccountClientAPI contains the set of methods on the PaymentMethodAtBillingAccountClient type. +type PaymentMethodAtBillingAccountClientAPI interface { + Get(ctx context.Context, billingAccountName string, paymentMethodName string) (result billing.PaymentMethod, err error) +} + +var _ PaymentMethodAtBillingAccountClientAPI = (*billing.PaymentMethodAtBillingAccountClient)(nil) + +// PaymentMethodAtBillingProfileClientAPI contains the set of methods on the PaymentMethodAtBillingProfileClient type. +type PaymentMethodAtBillingProfileClientAPI interface { + Remove(ctx context.Context, billingAccountName string, billingProfileName string, paymentMethodName string) (result billing.PaymentMethodAtBillingProfileRemoveFuture, err error) +} + +var _ PaymentMethodAtBillingProfileClientAPI = (*billing.PaymentMethodAtBillingProfileClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result billing.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result billing.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*billing.OperationsClient)(nil) diff --git a/services/preview/billing/mgmt/2017-02-27-preview/billing/client.go b/services/billing/mgmt/2021-10-01/billing/client.go similarity index 61% rename from services/preview/billing/mgmt/2017-02-27-preview/billing/client.go rename to services/billing/mgmt/2021-10-01/billing/client.go index b9e6e2601786..7ef311abc3ca 100644 --- a/services/preview/billing/mgmt/2017-02-27-preview/billing/client.go +++ b/services/billing/mgmt/2021-10-01/billing/client.go @@ -1,7 +1,6 @@ -// Package billing implements the Azure ARM Billing service API version 2017-02-27-preview. +// Package billing implements the Azure ARM Billing service API version 2021-10-01. // -// Billing client provides access to billing resources for Azure Web-Direct subscriptions. Other subscription types -// which were not purchased directly through the Azure web portal are not supported through this preview API. +// Payment management client provides access to payment resources for Azure. package billing // Copyright (c) Microsoft Corporation. All rights reserved. @@ -22,21 +21,19 @@ const ( // BaseClient is the base client for Billing. type BaseClient struct { autorest.Client - BaseURI string - SubscriptionID string + BaseURI string } // New creates an instance of the BaseClient client. -func New(subscriptionID string) BaseClient { - return NewWithBaseURI(DefaultBaseURI, subscriptionID) +func New() BaseClient { + return NewWithBaseURI(DefaultBaseURI) } // NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with // an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { +func NewWithBaseURI(baseURI string) BaseClient { return BaseClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - SubscriptionID: subscriptionID, + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, } } diff --git a/services/billing/mgmt/2021-10-01/billing/enums.go b/services/billing/mgmt/2021-10-01/billing/enums.go new file mode 100644 index 000000000000..019f1478ffb1 --- /dev/null +++ b/services/billing/mgmt/2021-10-01/billing/enums.go @@ -0,0 +1,59 @@ +package billing + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// DetachPaymentMethodEligibilityErrorCode enumerates the values for detach payment method eligibility error +// code. +type DetachPaymentMethodEligibilityErrorCode string + +const ( + // AzureSubscriptions ... + AzureSubscriptions DetachPaymentMethodEligibilityErrorCode = "AzureSubscriptions" + // OutstandingCharges ... + OutstandingCharges DetachPaymentMethodEligibilityErrorCode = "OutstandingCharges" + // PendingCharges ... + PendingCharges DetachPaymentMethodEligibilityErrorCode = "PendingCharges" + // RecurringCharges ... + RecurringCharges DetachPaymentMethodEligibilityErrorCode = "RecurringCharges" + // ReservedInstances ... + ReservedInstances DetachPaymentMethodEligibilityErrorCode = "ReservedInstances" +) + +// PossibleDetachPaymentMethodEligibilityErrorCodeValues returns an array of possible values for the DetachPaymentMethodEligibilityErrorCode const type. +func PossibleDetachPaymentMethodEligibilityErrorCodeValues() []DetachPaymentMethodEligibilityErrorCode { + return []DetachPaymentMethodEligibilityErrorCode{AzureSubscriptions, OutstandingCharges, PendingCharges, RecurringCharges, ReservedInstances} +} + +// PaymentMethodFamily enumerates the values for payment method family. +type PaymentMethodFamily string + +const ( + // CheckWire ... + CheckWire PaymentMethodFamily = "CheckWire" + // CreditCard ... + CreditCard PaymentMethodFamily = "CreditCard" +) + +// PossiblePaymentMethodFamilyValues returns an array of possible values for the PaymentMethodFamily const type. +func PossiblePaymentMethodFamilyValues() []PaymentMethodFamily { + return []PaymentMethodFamily{CheckWire, CreditCard} +} + +// PaymentMethodStatus enumerates the values for payment method status. +type PaymentMethodStatus string + +const ( + // Active ... + Active PaymentMethodStatus = "active" + // Inactive ... + Inactive PaymentMethodStatus = "inactive" +) + +// PossiblePaymentMethodStatusValues returns an array of possible values for the PaymentMethodStatus const type. +func PossiblePaymentMethodStatusValues() []PaymentMethodStatus { + return []PaymentMethodStatus{Active, Inactive} +} diff --git a/services/billing/mgmt/2021-10-01/billing/models.go b/services/billing/mgmt/2021-10-01/billing/models.go new file mode 100644 index 000000000000..5b300f8fe7d5 --- /dev/null +++ b/services/billing/mgmt/2021-10-01/billing/models.go @@ -0,0 +1,925 @@ +package billing + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/billing/mgmt/2021-10-01/billing" + +// DetachPaymentMethodEligibilityError the details of the error. +type DetachPaymentMethodEligibilityError struct { + // Code - READ-ONLY; Error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; Error message. + Message *string `json:"message,omitempty"` + // Details - READ-ONLY; The list of detach payment method eligibility errors. + Details *[]DetachPaymentMethodErrorDetails `json:"details,omitempty"` +} + +// MarshalJSON is the custom marshaler for DetachPaymentMethodEligibilityError. +func (dpmee DetachPaymentMethodEligibilityError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DetachPaymentMethodEligibilityResult error response indicates that payment method cannot be detached +// from billing profile. +type DetachPaymentMethodEligibilityResult struct { + // Error - The details of the error. + Error *DetachPaymentMethodEligibilityError `json:"error,omitempty"` +} + +// DetachPaymentMethodErrorDetails error details of the detach payment method eligibility validation. +type DetachPaymentMethodErrorDetails struct { + // Code - Error code for the detach payment method eligibility validation. Possible values include: 'AzureSubscriptions', 'RecurringCharges', 'ReservedInstances', 'OutstandingCharges', 'PendingCharges' + Code DetachPaymentMethodEligibilityErrorCode `json:"code,omitempty"` + // Message - Error message for the detach payment method eligibility validation. + Message *string `json:"message,omitempty"` +} + +// ErrorDetails the details of the error. +type ErrorDetails struct { + // Code - READ-ONLY; Error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The target of the particular error. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The sub details of the error. + Details *[]ErrorSubDetailsItem `json:"details,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetails. +func (ed ErrorDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse error response indicates that the service is not able to process the incoming request. The +// reason is provided in the error message. +type ErrorResponse struct { + // Error - The details of the error. + Error *ErrorDetails `json:"error,omitempty"` +} + +// ErrorSubDetailsItem ... +type ErrorSubDetailsItem struct { + // Code - READ-ONLY; Error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The target of the particular error. + Target *string `json:"target,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorSubDetailsItem. +func (esdi ErrorSubDetailsItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Operation a Billing REST API operation. +type Operation struct { + // Name - READ-ONLY; Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + // IsDataAction - READ-ONLY; Identifies if the operation is a data operation. + IsDataAction *bool `json:"isDataAction,omitempty"` + // Display - The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if o.Display != nil { + objectMap["display"] = o.Display + } + return json.Marshal(objectMap) +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - READ-ONLY; Service provider: Microsoft.Billing. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Resource on which the operation is performed such as invoice and billing subscription. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Operation type such as read, write and delete. + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; Description of operation. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResult the list of billing operations and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of billing operations supported by the Microsoft.Billing resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationListResult. +func (olr OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// 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 *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.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 *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) 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 OperationListResultIterator) Response() OperationListResult { + 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 OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +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.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// 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 *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// PaymentMethod a payment method. +type PaymentMethod struct { + autorest.Response `json:"-"` + *PaymentMethodProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PaymentMethod. +func (pm PaymentMethod) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pm.PaymentMethodProperties != nil { + objectMap["properties"] = pm.PaymentMethodProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PaymentMethod struct. +func (pm *PaymentMethod) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var paymentMethodProperties PaymentMethodProperties + err = json.Unmarshal(*v, &paymentMethodProperties) + if err != nil { + return err + } + pm.PaymentMethodProperties = &paymentMethodProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pm.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pm.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pm.Type = &typeVar + } + } + } + + return nil +} + +// PaymentMethodAtBillingProfileRemoveFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PaymentMethodAtBillingProfileRemoveFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PaymentMethodAtBillingProfileClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PaymentMethodAtBillingProfileRemoveFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PaymentMethodAtBillingProfileRemoveFuture.Result. +func (future *PaymentMethodAtBillingProfileRemoveFuture) result(client PaymentMethodAtBillingProfileClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodAtBillingProfileRemoveFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("billing.PaymentMethodAtBillingProfileRemoveFuture") + return + } + ar.Response = future.Response() + return +} + +// PaymentMethodLink a payment method link. +type PaymentMethodLink struct { + autorest.Response `json:"-"` + *PaymentMethodLinkProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PaymentMethodLink. +func (pml PaymentMethodLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pml.PaymentMethodLinkProperties != nil { + objectMap["properties"] = pml.PaymentMethodLinkProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PaymentMethodLink struct. +func (pml *PaymentMethodLink) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var paymentMethodLinkProperties PaymentMethodLinkProperties + err = json.Unmarshal(*v, &paymentMethodLinkProperties) + if err != nil { + return err + } + pml.PaymentMethodLinkProperties = &paymentMethodLinkProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pml.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pml.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pml.Type = &typeVar + } + } + } + + return nil +} + +// PaymentMethodLinkProperties the properties of a payment method link. +type PaymentMethodLinkProperties struct { + // PaymentMethod - READ-ONLY; Projection of a payment method + PaymentMethod *PaymentMethodProjectionProperties `json:"paymentMethod,omitempty"` +} + +// MarshalJSON is the custom marshaler for PaymentMethodLinkProperties. +func (pmlp PaymentMethodLinkProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PaymentMethodLinksListResult the list of payment method links. +type PaymentMethodLinksListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of payment method links. + Value *[]PaymentMethodLink `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for PaymentMethodLinksListResult. +func (pmllr PaymentMethodLinksListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PaymentMethodLinksListResultIterator provides access to a complete listing of PaymentMethodLink values. +type PaymentMethodLinksListResultIterator struct { + i int + page PaymentMethodLinksListResultPage +} + +// 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 *PaymentMethodLinksListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodLinksListResultIterator.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 *PaymentMethodLinksListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PaymentMethodLinksListResultIterator) 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 PaymentMethodLinksListResultIterator) Response() PaymentMethodLinksListResult { + 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 PaymentMethodLinksListResultIterator) Value() PaymentMethodLink { + if !iter.page.NotDone() { + return PaymentMethodLink{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PaymentMethodLinksListResultIterator type. +func NewPaymentMethodLinksListResultIterator(page PaymentMethodLinksListResultPage) PaymentMethodLinksListResultIterator { + return PaymentMethodLinksListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (pmllr PaymentMethodLinksListResult) IsEmpty() bool { + return pmllr.Value == nil || len(*pmllr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (pmllr PaymentMethodLinksListResult) hasNextLink() bool { + return pmllr.NextLink != nil && len(*pmllr.NextLink) != 0 +} + +// paymentMethodLinksListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (pmllr PaymentMethodLinksListResult) paymentMethodLinksListResultPreparer(ctx context.Context) (*http.Request, error) { + if !pmllr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(pmllr.NextLink))) +} + +// PaymentMethodLinksListResultPage contains a page of PaymentMethodLink values. +type PaymentMethodLinksListResultPage struct { + fn func(context.Context, PaymentMethodLinksListResult) (PaymentMethodLinksListResult, error) + pmllr PaymentMethodLinksListResult +} + +// 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 *PaymentMethodLinksListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodLinksListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.pmllr) + if err != nil { + return err + } + page.pmllr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PaymentMethodLinksListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PaymentMethodLinksListResultPage) NotDone() bool { + return !page.pmllr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PaymentMethodLinksListResultPage) Response() PaymentMethodLinksListResult { + return page.pmllr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PaymentMethodLinksListResultPage) Values() []PaymentMethodLink { + if page.pmllr.IsEmpty() { + return nil + } + return *page.pmllr.Value +} + +// Creates a new instance of the PaymentMethodLinksListResultPage type. +func NewPaymentMethodLinksListResultPage(cur PaymentMethodLinksListResult, getNextPage func(context.Context, PaymentMethodLinksListResult) (PaymentMethodLinksListResult, error)) PaymentMethodLinksListResultPage { + return PaymentMethodLinksListResultPage{ + fn: getNextPage, + pmllr: cur, + } +} + +// PaymentMethodLogo logo of payment method. +type PaymentMethodLogo struct { + // MimeType - READ-ONLY; MIME type of the logo. + MimeType *string `json:"mimeType,omitempty"` + // URL - READ-ONLY; Public URL of image of the logo. + URL *string `json:"url,omitempty"` +} + +// MarshalJSON is the custom marshaler for PaymentMethodLogo. +func (pml PaymentMethodLogo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PaymentMethodProjectionProperties the properties of a payment method projection. +type PaymentMethodProjectionProperties struct { + // ID - READ-ONLY; Id of payment method. + ID *string `json:"id,omitempty"` + // Family - The family of payment method. Possible values include: 'CreditCard', 'CheckWire' + Family PaymentMethodFamily `json:"family,omitempty"` + // Type - READ-ONLY; The type of payment method. + Type *string `json:"type,omitempty"` + // AccountHolderName - READ-ONLY; The account holder name for the payment method. This is only supported for payment methods with family CreditCard. + AccountHolderName *string `json:"accountHolderName,omitempty"` + // Expiration - READ-ONLY; The expiration month and year of the payment method. This is only supported for payment methods with family CreditCard. + Expiration *string `json:"expiration,omitempty"` + // LastFourDigits - READ-ONLY; Last four digits of payment method. + LastFourDigits *string `json:"lastFourDigits,omitempty"` + // DisplayName - READ-ONLY; The display name of the payment method. + DisplayName *string `json:"displayName,omitempty"` + // Logos - The list of logos for the payment method. + Logos *[]PaymentMethodLogo `json:"logos,omitempty"` + // Status - Status of the payment method. Possible values include: 'Active', 'Inactive' + Status PaymentMethodStatus `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for PaymentMethodProjectionProperties. +func (pmpp PaymentMethodProjectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pmpp.Family != "" { + objectMap["family"] = pmpp.Family + } + if pmpp.Logos != nil { + objectMap["logos"] = pmpp.Logos + } + if pmpp.Status != "" { + objectMap["status"] = pmpp.Status + } + return json.Marshal(objectMap) +} + +// PaymentMethodProperties the properties of a payment method. +type PaymentMethodProperties struct { + // Family - The family of payment method. Possible values include: 'CreditCard', 'CheckWire' + Family PaymentMethodFamily `json:"family,omitempty"` + // Type - READ-ONLY; The type of payment method. + Type *string `json:"type,omitempty"` + // AccountHolderName - READ-ONLY; The account holder name for the payment method. This is only supported for payment methods with family CreditCard. + AccountHolderName *string `json:"accountHolderName,omitempty"` + // Expiration - READ-ONLY; The expiration month and year of the payment method. This is only supported for payment methods with family CreditCard. + Expiration *string `json:"expiration,omitempty"` + // LastFourDigits - READ-ONLY; Last four digits of payment method. + LastFourDigits *string `json:"lastFourDigits,omitempty"` + // DisplayName - READ-ONLY; The display name of the payment method. + DisplayName *string `json:"displayName,omitempty"` + // Logos - The list of logos for the payment method. + Logos *[]PaymentMethodLogo `json:"logos,omitempty"` + // Status - Status of the payment method. Possible values include: 'Active', 'Inactive' + Status PaymentMethodStatus `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for PaymentMethodProperties. +func (pmp PaymentMethodProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pmp.Family != "" { + objectMap["family"] = pmp.Family + } + if pmp.Logos != nil { + objectMap["logos"] = pmp.Logos + } + if pmp.Status != "" { + objectMap["status"] = pmp.Status + } + return json.Marshal(objectMap) +} + +// PaymentMethodResource the payment method resource model definition. +type PaymentMethodResource struct { + // PaymentMethodID - The ID that uniquely identifies a payment method. + PaymentMethodID *string `json:"paymentMethodId,omitempty"` +} + +// PaymentMethodsListResult the list of payment methods. +type PaymentMethodsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of payment methods. + Value *[]PaymentMethod `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for PaymentMethodsListResult. +func (pmlr PaymentMethodsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PaymentMethodsListResultIterator provides access to a complete listing of PaymentMethod values. +type PaymentMethodsListResultIterator struct { + i int + page PaymentMethodsListResultPage +} + +// 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 *PaymentMethodsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodsListResultIterator.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 *PaymentMethodsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PaymentMethodsListResultIterator) 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 PaymentMethodsListResultIterator) Response() PaymentMethodsListResult { + 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 PaymentMethodsListResultIterator) Value() PaymentMethod { + if !iter.page.NotDone() { + return PaymentMethod{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PaymentMethodsListResultIterator type. +func NewPaymentMethodsListResultIterator(page PaymentMethodsListResultPage) PaymentMethodsListResultIterator { + return PaymentMethodsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (pmlr PaymentMethodsListResult) IsEmpty() bool { + return pmlr.Value == nil || len(*pmlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (pmlr PaymentMethodsListResult) hasNextLink() bool { + return pmlr.NextLink != nil && len(*pmlr.NextLink) != 0 +} + +// paymentMethodsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (pmlr PaymentMethodsListResult) paymentMethodsListResultPreparer(ctx context.Context) (*http.Request, error) { + if !pmlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(pmlr.NextLink))) +} + +// PaymentMethodsListResultPage contains a page of PaymentMethod values. +type PaymentMethodsListResultPage struct { + fn func(context.Context, PaymentMethodsListResult) (PaymentMethodsListResult, error) + pmlr PaymentMethodsListResult +} + +// 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 *PaymentMethodsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodsListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.pmlr) + if err != nil { + return err + } + page.pmlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PaymentMethodsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PaymentMethodsListResultPage) NotDone() bool { + return !page.pmlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PaymentMethodsListResultPage) Response() PaymentMethodsListResult { + return page.pmlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PaymentMethodsListResultPage) Values() []PaymentMethod { + if page.pmlr.IsEmpty() { + return nil + } + return *page.pmlr.Value +} + +// Creates a new instance of the PaymentMethodsListResultPage type. +func NewPaymentMethodsListResultPage(cur PaymentMethodsListResult, getNextPage func(context.Context, PaymentMethodsListResult) (PaymentMethodsListResult, error)) PaymentMethodsListResultPage { + return PaymentMethodsListResultPage{ + fn: getNextPage, + pmlr: cur, + } +} + +// Resource the resource model definition. +type Resource struct { + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} diff --git a/services/preview/billing/mgmt/2017-02-27-preview/billing/operations.go b/services/billing/mgmt/2021-10-01/billing/operations.go similarity index 87% rename from services/preview/billing/mgmt/2017-02-27-preview/billing/operations.go rename to services/billing/mgmt/2021-10-01/billing/operations.go index 35091667f201..7f493ec5d465 100644 --- a/services/preview/billing/mgmt/2017-02-27-preview/billing/operations.go +++ b/services/billing/mgmt/2021-10-01/billing/operations.go @@ -14,25 +14,23 @@ import ( "net/http" ) -// OperationsClient is the billing client provides access to billing resources for Azure Web-Direct subscriptions. -// Other subscription types which were not purchased directly through the Azure web portal are not supported through -// this preview API. +// OperationsClient is the payment management client provides access to payment resources for Azure. type OperationsClient struct { BaseClient } // NewOperationsClient creates an instance of the OperationsClient client. -func NewOperationsClient(subscriptionID string) OperationsClient { - return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +func NewOperationsClient() OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI) } // NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this // when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { - return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewOperationsClientWithBaseURI(baseURI string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI)} } -// List lists all of the available billing REST API operations. +// List lists the available billing REST API operations. func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") @@ -73,7 +71,7 @@ func (client OperationsClient) List(ctx context.Context) (result OperationListRe // ListPreparer prepares the List request. func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2017-02-27-preview" + const APIVersion = "2021-10-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/services/billing/mgmt/2021-10-01/billing/paymentmethodatbillingaccount.go b/services/billing/mgmt/2021-10-01/billing/paymentmethodatbillingaccount.go new file mode 100644 index 000000000000..23863935f331 --- /dev/null +++ b/services/billing/mgmt/2021-10-01/billing/paymentmethodatbillingaccount.go @@ -0,0 +1,108 @@ +package billing + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PaymentMethodAtBillingAccountClient is the payment management client provides access to payment resources for Azure. +type PaymentMethodAtBillingAccountClient struct { + BaseClient +} + +// NewPaymentMethodAtBillingAccountClient creates an instance of the PaymentMethodAtBillingAccountClient client. +func NewPaymentMethodAtBillingAccountClient() PaymentMethodAtBillingAccountClient { + return NewPaymentMethodAtBillingAccountClientWithBaseURI(DefaultBaseURI) +} + +// NewPaymentMethodAtBillingAccountClientWithBaseURI creates an instance of the PaymentMethodAtBillingAccountClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewPaymentMethodAtBillingAccountClientWithBaseURI(baseURI string) PaymentMethodAtBillingAccountClient { + return PaymentMethodAtBillingAccountClient{NewWithBaseURI(baseURI)} +} + +// Get gets a payment method available for a billing account. The operation is supported only for billing accounts with +// agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// paymentMethodName - the ID that uniquely identifies a payment method. +func (client PaymentMethodAtBillingAccountClient) Get(ctx context.Context, billingAccountName string, paymentMethodName string) (result PaymentMethod, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodAtBillingAccountClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, billingAccountName, paymentMethodName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodAtBillingAccountClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PaymentMethodAtBillingAccountClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodAtBillingAccountClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PaymentMethodAtBillingAccountClient) GetPreparer(ctx context.Context, billingAccountName string, paymentMethodName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "paymentMethodName": autorest.Encode("path", paymentMethodName), + } + + const APIVersion = "2021-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/paymentMethods/{paymentMethodName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PaymentMethodAtBillingAccountClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PaymentMethodAtBillingAccountClient) GetResponder(resp *http.Response) (result PaymentMethod, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/billing/mgmt/2021-10-01/billing/paymentmethodatbillingprofile.go b/services/billing/mgmt/2021-10-01/billing/paymentmethodatbillingprofile.go new file mode 100644 index 000000000000..54181e09f9f9 --- /dev/null +++ b/services/billing/mgmt/2021-10-01/billing/paymentmethodatbillingprofile.go @@ -0,0 +1,112 @@ +package billing + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PaymentMethodAtBillingProfileClient is the payment management client provides access to payment resources for Azure. +type PaymentMethodAtBillingProfileClient struct { + BaseClient +} + +// NewPaymentMethodAtBillingProfileClient creates an instance of the PaymentMethodAtBillingProfileClient client. +func NewPaymentMethodAtBillingProfileClient() PaymentMethodAtBillingProfileClient { + return NewPaymentMethodAtBillingProfileClientWithBaseURI(DefaultBaseURI) +} + +// NewPaymentMethodAtBillingProfileClientWithBaseURI creates an instance of the PaymentMethodAtBillingProfileClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewPaymentMethodAtBillingProfileClientWithBaseURI(baseURI string) PaymentMethodAtBillingProfileClient { + return PaymentMethodAtBillingProfileClient{NewWithBaseURI(baseURI)} +} + +// Remove deletes a payment method link and removes the payment method from a billing profile. The operation is +// supported only for billing accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// paymentMethodName - the ID that uniquely identifies a payment method. +func (client PaymentMethodAtBillingProfileClient) Remove(ctx context.Context, billingAccountName string, billingProfileName string, paymentMethodName string) (result PaymentMethodAtBillingProfileRemoveFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodAtBillingProfileClient.Remove") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RemovePreparer(ctx, billingAccountName, billingProfileName, paymentMethodName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodAtBillingProfileClient", "Remove", nil, "Failure preparing request") + return + } + + result, err = client.RemoveSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodAtBillingProfileClient", "Remove", result.Response(), "Failure sending request") + return + } + + return +} + +// RemovePreparer prepares the Remove request. +func (client PaymentMethodAtBillingProfileClient) RemovePreparer(ctx context.Context, billingAccountName string, billingProfileName string, paymentMethodName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "paymentMethodName": autorest.Encode("path", paymentMethodName), + } + + const APIVersion = "2021-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/paymentMethodLinks/{paymentMethodName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RemoveSender sends the Remove request. The method will close the +// http.Response Body if it receives an error. +func (client PaymentMethodAtBillingProfileClient) RemoveSender(req *http.Request) (future PaymentMethodAtBillingProfileRemoveFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RemoveResponder handles the response to the Remove request. The method always +// closes the http.Response Body. +func (client PaymentMethodAtBillingProfileClient) RemoveResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/billing/mgmt/2021-10-01/billing/paymentmethodownedbyuser.go b/services/billing/mgmt/2021-10-01/billing/paymentmethodownedbyuser.go new file mode 100644 index 000000000000..164ba3874340 --- /dev/null +++ b/services/billing/mgmt/2021-10-01/billing/paymentmethodownedbyuser.go @@ -0,0 +1,286 @@ +package billing + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PaymentMethodOwnedByUserClient is the payment management client provides access to payment resources for Azure. +type PaymentMethodOwnedByUserClient struct { + BaseClient +} + +// NewPaymentMethodOwnedByUserClient creates an instance of the PaymentMethodOwnedByUserClient client. +func NewPaymentMethodOwnedByUserClient() PaymentMethodOwnedByUserClient { + return NewPaymentMethodOwnedByUserClientWithBaseURI(DefaultBaseURI) +} + +// NewPaymentMethodOwnedByUserClientWithBaseURI creates an instance of the PaymentMethodOwnedByUserClient client using +// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPaymentMethodOwnedByUserClientWithBaseURI(baseURI string) PaymentMethodOwnedByUserClient { + return PaymentMethodOwnedByUserClient{NewWithBaseURI(baseURI)} +} + +// Delete deletes a payment method owned by the caller. +// Parameters: +// paymentMethodName - the ID that uniquely identifies a payment method. +func (client PaymentMethodOwnedByUserClient) Delete(ctx context.Context, paymentMethodName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodOwnedByUserClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, paymentMethodName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodOwnedByUserClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "billing.PaymentMethodOwnedByUserClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodOwnedByUserClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PaymentMethodOwnedByUserClient) DeletePreparer(ctx context.Context, paymentMethodName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "paymentMethodName": autorest.Encode("path", paymentMethodName), + } + + const APIVersion = "2021-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/paymentMethods/{paymentMethodName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PaymentMethodOwnedByUserClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PaymentMethodOwnedByUserClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a payment method owned by the caller. +// Parameters: +// paymentMethodName - the ID that uniquely identifies a payment method. +func (client PaymentMethodOwnedByUserClient) Get(ctx context.Context, paymentMethodName string) (result PaymentMethod, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodOwnedByUserClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, paymentMethodName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodOwnedByUserClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PaymentMethodOwnedByUserClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodOwnedByUserClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PaymentMethodOwnedByUserClient) GetPreparer(ctx context.Context, paymentMethodName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "paymentMethodName": autorest.Encode("path", paymentMethodName), + } + + const APIVersion = "2021-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/paymentMethods/{paymentMethodName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PaymentMethodOwnedByUserClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PaymentMethodOwnedByUserClient) GetResponder(resp *http.Response) (result PaymentMethod, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the payment methods owned by the caller. +func (client PaymentMethodOwnedByUserClient) List(ctx context.Context) (result PaymentMethodsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodOwnedByUserClient.List") + defer func() { + sc := -1 + if result.pmlr.Response.Response != nil { + sc = result.pmlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodOwnedByUserClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.pmlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PaymentMethodOwnedByUserClient", "List", resp, "Failure sending request") + return + } + + result.pmlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodOwnedByUserClient", "List", resp, "Failure responding to request") + return + } + if result.pmlr.hasNextLink() && result.pmlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PaymentMethodOwnedByUserClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Billing/paymentMethods"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client PaymentMethodOwnedByUserClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PaymentMethodOwnedByUserClient) ListResponder(resp *http.Response) (result PaymentMethodsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PaymentMethodOwnedByUserClient) listNextResults(ctx context.Context, lastResults PaymentMethodsListResult) (result PaymentMethodsListResult, err error) { + req, err := lastResults.paymentMethodsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.PaymentMethodOwnedByUserClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.PaymentMethodOwnedByUserClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodOwnedByUserClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PaymentMethodOwnedByUserClient) ListComplete(ctx context.Context) (result PaymentMethodsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodOwnedByUserClient.List") + 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.List(ctx) + return +} diff --git a/services/billing/mgmt/2021-10-01/billing/paymentmethods.go b/services/billing/mgmt/2021-10-01/billing/paymentmethods.go new file mode 100644 index 000000000000..bdf2ca5524c1 --- /dev/null +++ b/services/billing/mgmt/2021-10-01/billing/paymentmethods.go @@ -0,0 +1,344 @@ +package billing + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PaymentMethodsClient is the payment management client provides access to payment resources for Azure. +type PaymentMethodsClient struct { + BaseClient +} + +// NewPaymentMethodsClient creates an instance of the PaymentMethodsClient client. +func NewPaymentMethodsClient() PaymentMethodsClient { + return NewPaymentMethodsClientWithBaseURI(DefaultBaseURI) +} + +// NewPaymentMethodsClientWithBaseURI creates an instance of the PaymentMethodsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPaymentMethodsClientWithBaseURI(baseURI string) PaymentMethodsClient { + return PaymentMethodsClient{NewWithBaseURI(baseURI)} +} + +// GetByBillingProfile gets a payment method linked with a billing profile. The operation is supported only for billing +// accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// paymentMethodName - the ID that uniquely identifies a payment method. +func (client PaymentMethodsClient) GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, paymentMethodName string) (result PaymentMethodLink, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodsClient.GetByBillingProfile") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByBillingProfilePreparer(ctx, billingAccountName, billingProfileName, paymentMethodName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "GetByBillingProfile", nil, "Failure preparing request") + return + } + + resp, err := client.GetByBillingProfileSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "GetByBillingProfile", resp, "Failure sending request") + return + } + + result, err = client.GetByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "GetByBillingProfile", resp, "Failure responding to request") + return + } + + return +} + +// GetByBillingProfilePreparer prepares the GetByBillingProfile request. +func (client PaymentMethodsClient) GetByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string, paymentMethodName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "paymentMethodName": autorest.Encode("path", paymentMethodName), + } + + const APIVersion = "2021-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/paymentMethodLinks/{paymentMethodName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByBillingProfileSender sends the GetByBillingProfile request. The method will close the +// http.Response Body if it receives an error. +func (client PaymentMethodsClient) GetByBillingProfileSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByBillingProfileResponder handles the response to the GetByBillingProfile request. The method always +// closes the http.Response Body. +func (client PaymentMethodsClient) GetByBillingProfileResponder(resp *http.Response) (result PaymentMethodLink, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByBillingAccount lists the payment methods available for a billing account. Along with the payment methods owned +// by the caller, these payment methods can be attached to a billing profile to make payments. The operation is +// supported only for billing accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +func (client PaymentMethodsClient) ListByBillingAccount(ctx context.Context, billingAccountName string) (result PaymentMethodsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodsClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.pmlr.Response.Response != nil { + sc = result.pmlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingAccountNextResults + req, err := client.ListByBillingAccountPreparer(ctx, billingAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "ListByBillingAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.pmlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "ListByBillingAccount", resp, "Failure sending request") + return + } + + result.pmlr, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "ListByBillingAccount", resp, "Failure responding to request") + return + } + if result.pmlr.hasNextLink() && result.pmlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByBillingAccountPreparer prepares the ListByBillingAccount request. +func (client PaymentMethodsClient) ListByBillingAccountPreparer(ctx context.Context, billingAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2021-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/paymentMethods", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingAccountSender sends the ListByBillingAccount request. The method will close the +// http.Response Body if it receives an error. +func (client PaymentMethodsClient) ListByBillingAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingAccountResponder handles the response to the ListByBillingAccount request. The method always +// closes the http.Response Body. +func (client PaymentMethodsClient) ListByBillingAccountResponder(resp *http.Response) (result PaymentMethodsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingAccountNextResults retrieves the next set of results, if any. +func (client PaymentMethodsClient) listByBillingAccountNextResults(ctx context.Context, lastResults PaymentMethodsListResult) (result PaymentMethodsListResult, err error) { + req, err := lastResults.paymentMethodsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "listByBillingAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "listByBillingAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "listByBillingAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client PaymentMethodsClient) ListByBillingAccountComplete(ctx context.Context, billingAccountName string) (result PaymentMethodsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodsClient.ListByBillingAccount") + 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.ListByBillingAccount(ctx, billingAccountName) + return +} + +// ListByBillingProfile lists payment methods attached to a billing profile. The operation is supported only for +// billing accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +func (client PaymentMethodsClient) ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result PaymentMethodLinksListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodsClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.pmllr.Response.Response != nil { + sc = result.pmllr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingProfileNextResults + req, err := client.ListByBillingProfilePreparer(ctx, billingAccountName, billingProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "ListByBillingProfile", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.pmllr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "ListByBillingProfile", resp, "Failure sending request") + return + } + + result.pmllr, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "ListByBillingProfile", resp, "Failure responding to request") + return + } + if result.pmllr.hasNextLink() && result.pmllr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByBillingProfilePreparer prepares the ListByBillingProfile request. +func (client PaymentMethodsClient) ListByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2021-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/paymentMethodLinks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingProfileSender sends the ListByBillingProfile request. The method will close the +// http.Response Body if it receives an error. +func (client PaymentMethodsClient) ListByBillingProfileSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingProfileResponder handles the response to the ListByBillingProfile request. The method always +// closes the http.Response Body. +func (client PaymentMethodsClient) ListByBillingProfileResponder(resp *http.Response) (result PaymentMethodLinksListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingProfileNextResults retrieves the next set of results, if any. +func (client PaymentMethodsClient) listByBillingProfileNextResults(ctx context.Context, lastResults PaymentMethodLinksListResult) (result PaymentMethodLinksListResult, err error) { + req, err := lastResults.paymentMethodLinksListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "listByBillingProfileNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "listByBillingProfileNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "listByBillingProfileNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingProfileComplete enumerates all values, automatically crossing page boundaries as required. +func (client PaymentMethodsClient) ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result PaymentMethodLinksListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodsClient.ListByBillingProfile") + 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.ListByBillingProfile(ctx, billingAccountName, billingProfileName) + return +} diff --git a/services/preview/billing/mgmt/2017-02-27-preview/billing/version.go b/services/billing/mgmt/2021-10-01/billing/version.go similarity index 89% rename from services/preview/billing/mgmt/2017-02-27-preview/billing/version.go rename to services/billing/mgmt/2021-10-01/billing/version.go index fae8d45d1391..05daac831f35 100644 --- a/services/preview/billing/mgmt/2017-02-27-preview/billing/version.go +++ b/services/billing/mgmt/2021-10-01/billing/version.go @@ -10,7 +10,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() + " billing/2017-02-27-preview" + return "Azure-SDK-For-Go/" + Version() + " billing/2021-10-01" } // Version returns the semantic version (see http://semver.org) of the client. diff --git a/services/preview/billing/mgmt/2017-02-27-preview/billing/CHANGELOG.md b/services/preview/billing/mgmt/2017-02-27-preview/billing/CHANGELOG.md deleted file mode 100644 index a436ca8f7451..000000000000 --- a/services/preview/billing/mgmt/2017-02-27-preview/billing/CHANGELOG.md +++ /dev/null @@ -1,12 +0,0 @@ -# Change History - -## Additive Changes - -### New Funcs - -1. DownloadURL.MarshalJSON() ([]byte, error) -1. ErrorDetails.MarshalJSON() ([]byte, error) -1. InvoicesListResult.MarshalJSON() ([]byte, error) -1. OperationDisplay.MarshalJSON() ([]byte, error) -1. OperationListResult.MarshalJSON() ([]byte, error) -1. Resource.MarshalJSON() ([]byte, error) diff --git a/services/preview/billing/mgmt/2017-02-27-preview/billing/_meta.json b/services/preview/billing/mgmt/2017-02-27-preview/billing/_meta.json deleted file mode 100644 index a78bc83149f7..000000000000 --- a/services/preview/billing/mgmt/2017-02-27-preview/billing/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", - "readme": "/_/azure-rest-api-specs/specification/billing/resource-manager/readme.md", - "tag": "package-2017-02-preview", - "use": "@microsoft.azure/autorest.go@2.1.183", - "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-2017-02-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/billing/resource-manager/readme.md", - "additional_properties": { - "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION" - } -} \ No newline at end of file diff --git a/services/preview/billing/mgmt/2017-02-27-preview/billing/billingapi/interfaces.go b/services/preview/billing/mgmt/2017-02-27-preview/billing/billingapi/interfaces.go deleted file mode 100644 index 1f2ad6d4c2df..000000000000 --- a/services/preview/billing/mgmt/2017-02-27-preview/billing/billingapi/interfaces.go +++ /dev/null @@ -1,30 +0,0 @@ -package billingapi - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/azure-sdk-for-go/services/preview/billing/mgmt/2017-02-27-preview/billing" -) - -// InvoicesClientAPI contains the set of methods on the InvoicesClient type. -type InvoicesClientAPI interface { - Get(ctx context.Context, invoiceName string) (result billing.Invoice, err error) - GetLatest(ctx context.Context) (result billing.Invoice, err error) - List(ctx context.Context, expand string, filter string, skiptoken string, top *int32) (result billing.InvoicesListResultPage, err error) - ListComplete(ctx context.Context, expand string, filter string, skiptoken string, top *int32) (result billing.InvoicesListResultIterator, err error) -} - -var _ InvoicesClientAPI = (*billing.InvoicesClient)(nil) - -// OperationsClientAPI contains the set of methods on the OperationsClient type. -type OperationsClientAPI interface { - List(ctx context.Context) (result billing.OperationListResultPage, err error) - ListComplete(ctx context.Context) (result billing.OperationListResultIterator, err error) -} - -var _ OperationsClientAPI = (*billing.OperationsClient)(nil) diff --git a/services/preview/billing/mgmt/2017-02-27-preview/billing/invoices.go b/services/preview/billing/mgmt/2017-02-27-preview/billing/invoices.go deleted file mode 100644 index 4df76927aeb0..000000000000 --- a/services/preview/billing/mgmt/2017-02-27-preview/billing/invoices.go +++ /dev/null @@ -1,327 +0,0 @@ -package billing - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// InvoicesClient is the billing client provides access to billing resources for Azure Web-Direct subscriptions. Other -// subscription types which were not purchased directly through the Azure web portal are not supported through this -// preview API. -type InvoicesClient struct { - BaseClient -} - -// NewInvoicesClient creates an instance of the InvoicesClient client. -func NewInvoicesClient(subscriptionID string) InvoicesClient { - return NewInvoicesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewInvoicesClientWithBaseURI creates an instance of the InvoicesClient client using a custom endpoint. Use this -// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewInvoicesClientWithBaseURI(baseURI string, subscriptionID string) InvoicesClient { - return InvoicesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Get gets a named invoice resource. When getting a single invoice, the downloadUrl property is expanded -// automatically. -// Parameters: -// invoiceName - the name of an invoice resource. -func (client InvoicesClient) Get(ctx context.Context, invoiceName string) (result Invoice, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetPreparer(ctx, invoiceName) - if err != nil { - err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client InvoicesClient) GetPreparer(ctx context.Context, invoiceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "invoiceName": autorest.Encode("path", invoiceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-02-27-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices/{invoiceName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client InvoicesClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client InvoicesClient) GetResponder(resp *http.Response) (result Invoice, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetLatest gets the most recent invoice. When getting a single invoice, the downloadUrl property is expanded -// automatically. -func (client InvoicesClient) GetLatest(ctx context.Context) (result Invoice, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesClient.GetLatest") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetLatestPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "GetLatest", nil, "Failure preparing request") - return - } - - resp, err := client.GetLatestSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "GetLatest", resp, "Failure sending request") - return - } - - result, err = client.GetLatestResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "GetLatest", resp, "Failure responding to request") - return - } - - return -} - -// GetLatestPreparer prepares the GetLatest request. -func (client InvoicesClient) GetLatestPreparer(ctx context.Context) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-02-27-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices/latest", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetLatestSender sends the GetLatest request. The method will close the -// http.Response Body if it receives an error. -func (client InvoicesClient) GetLatestSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetLatestResponder handles the response to the GetLatest request. The method always -// closes the http.Response Body. -func (client InvoicesClient) GetLatestResponder(resp *http.Response) (result Invoice, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List lists the available invoices for a subscription in reverse chronological order beginning with the most recent -// invoice. In preview, invoices are available via this API only for invoice periods which end December 1, 2016 or -// later -// Parameters: -// expand - may be used to expand the downloadUrl property within a list of invoices. This enables download -// links to be generated for multiple invoices at once. By default, downloadURLs are not included when listing -// invoices. -// filter - may be used to filter invoices by invoicePeriodEndDate. The filter supports 'eq', 'lt', 'gt', 'le', -// 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not' -// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response -// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that -// specifies a starting point to use for subsequent calls. -// top - may be used to limit the number of results to the most recent N invoices. -func (client InvoicesClient) List(ctx context.Context, expand string, filter string, skiptoken string, top *int32) (result InvoicesListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesClient.List") - defer func() { - sc := -1 - if result.ilr.Response.Response != nil { - sc = result.ilr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: top, - Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(100), Chain: nil}, - {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("billing.InvoicesClient", "List", err.Error()) - } - - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, expand, filter, skiptoken, top) - if err != nil { - err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.ilr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "List", resp, "Failure sending request") - return - } - - result.ilr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "List", resp, "Failure responding to request") - return - } - if result.ilr.hasNextLink() && result.ilr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client InvoicesClient) ListPreparer(ctx context.Context, expand string, filter string, skiptoken string, top *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-02-27-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(expand) > 0 { - queryParameters["$expand"] = autorest.Encode("query", expand) - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - if len(skiptoken) > 0 { - queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client InvoicesClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client InvoicesClient) ListResponder(resp *http.Response) (result InvoicesListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client InvoicesClient) listNextResults(ctx context.Context, lastResults InvoicesListResult) (result InvoicesListResult, err error) { - req, err := lastResults.invoicesListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "billing.InvoicesClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "billing.InvoicesClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client InvoicesClient) ListComplete(ctx context.Context, expand string, filter string, skiptoken string, top *int32) (result InvoicesListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesClient.List") - 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.List(ctx, expand, filter, skiptoken, top) - return -} diff --git a/services/preview/billing/mgmt/2017-02-27-preview/billing/models.go b/services/preview/billing/mgmt/2017-02-27-preview/billing/models.go deleted file mode 100644 index cb9da1fc22fd..000000000000 --- a/services/preview/billing/mgmt/2017-02-27-preview/billing/models.go +++ /dev/null @@ -1,528 +0,0 @@ -package billing - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "encoding/json" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/date" - "github.com/Azure/go-autorest/autorest/to" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// The package's fully qualified name. -const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/billing/mgmt/2017-02-27-preview/billing" - -// DownloadURL a secure URL that can be used to download a PDF invoice until the URL expires. -type DownloadURL struct { - // ExpiryTime - READ-ONLY; The time in UTC at which this download URL will expire. - ExpiryTime *date.Time `json:"expiryTime,omitempty"` - // URL - READ-ONLY; The URL to the PDF file. - URL *string `json:"url,omitempty"` -} - -// MarshalJSON is the custom marshaler for DownloadURL. -func (du DownloadURL) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// ErrorDetails the details of the error. -type ErrorDetails struct { - // Code - READ-ONLY; Error code. - Code *string `json:"code,omitempty"` - // Message - READ-ONLY; Error message indicating why the operation failed. - Message *string `json:"message,omitempty"` - // Target - READ-ONLY; The target of the particular error. - Target *string `json:"target,omitempty"` -} - -// MarshalJSON is the custom marshaler for ErrorDetails. -func (ed ErrorDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// ErrorResponse error response indicates that the service is not able to process the incoming request. The -// reason is provided in the error message. -type ErrorResponse struct { - Error *ErrorDetails `json:"error,omitempty"` -} - -// Invoice an invoice resource can be used download a PDF version of an invoice. -type Invoice struct { - autorest.Response `json:"-"` - *InvoiceProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for Invoice. -func (i Invoice) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if i.InvoiceProperties != nil { - objectMap["properties"] = i.InvoiceProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for Invoice struct. -func (i *Invoice) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var invoiceProperties InvoiceProperties - err = json.Unmarshal(*v, &invoiceProperties) - if err != nil { - return err - } - i.InvoiceProperties = &invoiceProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - i.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - i.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - i.Type = &typeVar - } - } - } - - return nil -} - -// InvoiceProperties the properties of the invoice. -type InvoiceProperties struct { - // InvoicePeriodStartDate - READ-ONLY; The start of the date range covered by the invoice. - InvoicePeriodStartDate *date.Date `json:"invoicePeriodStartDate,omitempty"` - // InvoicePeriodEndDate - READ-ONLY; The end of the date range covered by the invoice. - InvoicePeriodEndDate *date.Date `json:"invoicePeriodEndDate,omitempty"` - // DownloadURL - A secure link to download the PDF version of an invoice. The link will cease to work after its expiry time is reached. - DownloadURL *DownloadURL `json:"downloadUrl,omitempty"` -} - -// MarshalJSON is the custom marshaler for InvoiceProperties. -func (IP InvoiceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if IP.DownloadURL != nil { - objectMap["downloadUrl"] = IP.DownloadURL - } - return json.Marshal(objectMap) -} - -// InvoicesListResult result of the request to list invoices. It contains a list of available invoices in -// reverse chronological order. -type InvoicesListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; The list of invoices. - Value *[]Invoice `json:"value,omitempty"` - // NextLink - READ-ONLY; the link (url) to the next page of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for InvoicesListResult. -func (ilr InvoicesListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// InvoicesListResultIterator provides access to a complete listing of Invoice values. -type InvoicesListResultIterator struct { - i int - page InvoicesListResultPage -} - -// 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 *InvoicesListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesListResultIterator.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 *InvoicesListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter InvoicesListResultIterator) 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 InvoicesListResultIterator) Response() InvoicesListResult { - 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 InvoicesListResultIterator) Value() Invoice { - if !iter.page.NotDone() { - return Invoice{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the InvoicesListResultIterator type. -func NewInvoicesListResultIterator(page InvoicesListResultPage) InvoicesListResultIterator { - return InvoicesListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (ilr InvoicesListResult) IsEmpty() bool { - return ilr.Value == nil || len(*ilr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (ilr InvoicesListResult) hasNextLink() bool { - return ilr.NextLink != nil && len(*ilr.NextLink) != 0 -} - -// invoicesListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (ilr InvoicesListResult) invoicesListResultPreparer(ctx context.Context) (*http.Request, error) { - if !ilr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(ilr.NextLink))) -} - -// InvoicesListResultPage contains a page of Invoice values. -type InvoicesListResultPage struct { - fn func(context.Context, InvoicesListResult) (InvoicesListResult, error) - ilr InvoicesListResult -} - -// 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 *InvoicesListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.ilr) - if err != nil { - return err - } - page.ilr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *InvoicesListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page InvoicesListResultPage) NotDone() bool { - return !page.ilr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page InvoicesListResultPage) Response() InvoicesListResult { - return page.ilr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page InvoicesListResultPage) Values() []Invoice { - if page.ilr.IsEmpty() { - return nil - } - return *page.ilr.Value -} - -// Creates a new instance of the InvoicesListResultPage type. -func NewInvoicesListResultPage(cur InvoicesListResult, getNextPage func(context.Context, InvoicesListResult) (InvoicesListResult, error)) InvoicesListResultPage { - return InvoicesListResultPage{ - fn: getNextPage, - ilr: cur, - } -} - -// Operation a Billing REST API operation -type Operation struct { - // Name - READ-ONLY; Operation name: {provider}/{resource}/{operation} - Name *string `json:"name,omitempty"` - // Display - The object that represents the operation. - Display *OperationDisplay `json:"display,omitempty"` -} - -// MarshalJSON is the custom marshaler for Operation. -func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if o.Display != nil { - objectMap["display"] = o.Display - } - return json.Marshal(objectMap) -} - -// OperationDisplay the object that represents the operation. -type OperationDisplay struct { - // Provider - READ-ONLY; Service provider: Microsoft.Billing - Provider *string `json:"provider,omitempty"` - // Resource - READ-ONLY; Resource on which the operation is performed: Invoice, etc. - Resource *string `json:"resource,omitempty"` - // Operation - READ-ONLY; Operation type: Read, write, delete, etc. - Operation *string `json:"operation,omitempty"` -} - -// MarshalJSON is the custom marshaler for OperationDisplay. -func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// OperationListResult result of the request to list billing operations. It contains a list of operations -// and a URL link to get the next set of results. -type OperationListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of billing operations supported by the Microsoft.Billing resource provider. - Value *[]Operation `json:"value,omitempty"` - // NextLink - READ-ONLY; URL to get the next set of operation list results if there are any. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for OperationListResult. -func (olr OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// OperationListResultIterator provides access to a complete listing of Operation values. -type OperationListResultIterator struct { - i int - page OperationListResultPage -} - -// 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 *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.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 *OperationListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter OperationListResultIterator) 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 OperationListResultIterator) Response() OperationListResult { - 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 OperationListResultIterator) Value() Operation { - if !iter.page.NotDone() { - return Operation{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the OperationListResultIterator type. -func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { - return OperationListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -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.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(olr.NextLink))) -} - -// OperationListResultPage contains a page of Operation values. -type OperationListResultPage struct { - fn func(context.Context, OperationListResult) (OperationListResult, error) - olr OperationListResult -} - -// 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 *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.olr) - if err != nil { - return err - } - page.olr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *OperationListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page OperationListResultPage) NotDone() bool { - return !page.olr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page OperationListResultPage) Response() OperationListResult { - return page.olr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page OperationListResultPage) Values() []Operation { - if page.olr.IsEmpty() { - return nil - } - return *page.olr.Value -} - -// Creates a new instance of the OperationListResultPage type. -func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { - return OperationListResultPage{ - fn: getNextPage, - olr: cur, - } -} - -// Resource the Resource model definition. -type Resource struct { - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for Resource. -func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} diff --git a/services/preview/billing/mgmt/2017-04-24-preview/billing/CHANGELOG.md b/services/preview/billing/mgmt/2017-04-24-preview/billing/CHANGELOG.md index dca6eee2c150..a1ecf841edb0 100644 --- a/services/preview/billing/mgmt/2017-04-24-preview/billing/CHANGELOG.md +++ b/services/preview/billing/mgmt/2017-04-24-preview/billing/CHANGELOG.md @@ -1,14 +1,2 @@ -# Change History +# Unreleased -## Additive Changes - -### New Funcs - -1. DownloadURL.MarshalJSON() ([]byte, error) -1. ErrorDetails.MarshalJSON() ([]byte, error) -1. InvoicesListResult.MarshalJSON() ([]byte, error) -1. OperationDisplay.MarshalJSON() ([]byte, error) -1. OperationListResult.MarshalJSON() ([]byte, error) -1. PeriodProperties.MarshalJSON() ([]byte, error) -1. PeriodsListResult.MarshalJSON() ([]byte, error) -1. Resource.MarshalJSON() ([]byte, error) diff --git a/services/preview/billing/mgmt/2017-04-24-preview/billing/_meta.json b/services/preview/billing/mgmt/2017-04-24-preview/billing/_meta.json index 55a44b78479d..d1144f4c7abd 100644 --- a/services/preview/billing/mgmt/2017-04-24-preview/billing/_meta.json +++ b/services/preview/billing/mgmt/2017-04-24-preview/billing/_meta.json @@ -1,10 +1,10 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "bc45d483dac4a7ecc0ab2a8064acf9a9726bac6b", "readme": "/_/azure-rest-api-specs/specification/billing/resource-manager/readme.md", "tag": "package-2017-04-preview", - "use": "@microsoft.azure/autorest.go@2.1.183", + "use": "@microsoft.azure/autorest.go@2.1.187", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-2017-04-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/billing/resource-manager/readme.md", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2017-04-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/billing/resource-manager/readme.md", "additional_properties": { "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION" } diff --git a/services/preview/billing/mgmt/2018-03-01-preview/billing/CHANGELOG.md b/services/preview/billing/mgmt/2018-03-01-preview/billing/CHANGELOG.md index e48119a148f1..a1ecf841edb0 100644 --- a/services/preview/billing/mgmt/2018-03-01-preview/billing/CHANGELOG.md +++ b/services/preview/billing/mgmt/2018-03-01-preview/billing/CHANGELOG.md @@ -1,16 +1,2 @@ -# Change History +# Unreleased -## Additive Changes - -### New Funcs - -1. DownloadURL.MarshalJSON() ([]byte, error) -1. EnrollmentAccountListResult.MarshalJSON() ([]byte, error) -1. EnrollmentAccountProperties.MarshalJSON() ([]byte, error) -1. ErrorDetails.MarshalJSON() ([]byte, error) -1. InvoicesListResult.MarshalJSON() ([]byte, error) -1. OperationDisplay.MarshalJSON() ([]byte, error) -1. OperationListResult.MarshalJSON() ([]byte, error) -1. PeriodProperties.MarshalJSON() ([]byte, error) -1. PeriodsListResult.MarshalJSON() ([]byte, error) -1. Resource.MarshalJSON() ([]byte, error) diff --git a/services/preview/billing/mgmt/2018-03-01-preview/billing/_meta.json b/services/preview/billing/mgmt/2018-03-01-preview/billing/_meta.json index 2d5f1b1cd5bb..a4039a60739a 100644 --- a/services/preview/billing/mgmt/2018-03-01-preview/billing/_meta.json +++ b/services/preview/billing/mgmt/2018-03-01-preview/billing/_meta.json @@ -1,10 +1,10 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "bc45d483dac4a7ecc0ab2a8064acf9a9726bac6b", "readme": "/_/azure-rest-api-specs/specification/billing/resource-manager/readme.md", "tag": "package-2018-03-preview", - "use": "@microsoft.azure/autorest.go@2.1.183", + "use": "@microsoft.azure/autorest.go@2.1.187", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-2018-03-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/billing/resource-manager/readme.md", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2018-03-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/billing/resource-manager/readme.md", "additional_properties": { "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION" } diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/CHANGELOG.md b/services/preview/billing/mgmt/2018-11-01-preview/billing/CHANGELOG.md index 942f7d6660b8..a1ecf841edb0 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/CHANGELOG.md +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/CHANGELOG.md @@ -1,41 +1,2 @@ -# Change History +# Unreleased -## Additive Changes - -### New Funcs - -1. AccountListResult.MarshalJSON() ([]byte, error) -1. AgreementListResult.MarshalJSON() ([]byte, error) -1. AvailableBalanceProperties.MarshalJSON() ([]byte, error) -1. CustomerListResult.MarshalJSON() ([]byte, error) -1. DepartmentListResult.MarshalJSON() ([]byte, error) -1. DownloadProperties.MarshalJSON() ([]byte, error) -1. DownloadURL.MarshalJSON() ([]byte, error) -1. EnrollmentAccountListResult.MarshalJSON() ([]byte, error) -1. EnrollmentPolicies.MarshalJSON() ([]byte, error) -1. Error.MarshalJSON() ([]byte, error) -1. ErrorDetails.MarshalJSON() ([]byte, error) -1. InvoiceListResult.MarshalJSON() ([]byte, error) -1. InvoiceSectionListResult.MarshalJSON() ([]byte, error) -1. InvoiceSummaryProperties.MarshalJSON() ([]byte, error) -1. OperationDisplay.MarshalJSON() ([]byte, error) -1. OperationListResult.MarshalJSON() ([]byte, error) -1. Participants.MarshalJSON() ([]byte, error) -1. PaymentMethodsListResult.MarshalJSON() ([]byte, error) -1. PaymentProperties.MarshalJSON() ([]byte, error) -1. PermissionsListResult.MarshalJSON() ([]byte, error) -1. PermissionsProperties.MarshalJSON() ([]byte, error) -1. ProductsListResult.MarshalJSON() ([]byte, error) -1. ProfileListResult.MarshalJSON() ([]byte, error) -1. PropertySummary.MarshalJSON() ([]byte, error) -1. RecipientTransferDetailsListResult.MarshalJSON() ([]byte, error) -1. RecipientTransferProperties.MarshalJSON() ([]byte, error) -1. Reseller.MarshalJSON() ([]byte, error) -1. Resource.MarshalJSON() ([]byte, error) -1. RoleAssignmentListResult.MarshalJSON() ([]byte, error) -1. RoleAssignmentProperties.MarshalJSON() ([]byte, error) -1. RoleDefinitionListResult.MarshalJSON() ([]byte, error) -1. SubscriptionsListResult.MarshalJSON() ([]byte, error) -1. TransactionsListResult.MarshalJSON() ([]byte, error) -1. TransferDetailsListResult.MarshalJSON() ([]byte, error) -1. TransferProperties.MarshalJSON() ([]byte, error) diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/_meta.json b/services/preview/billing/mgmt/2018-11-01-preview/billing/_meta.json index 4a279b25c1b9..f250430aeda6 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/_meta.json +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/_meta.json @@ -1,10 +1,10 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "bc45d483dac4a7ecc0ab2a8064acf9a9726bac6b", "readme": "/_/azure-rest-api-specs/specification/billing/resource-manager/readme.md", "tag": "package-2018-11-preview", - "use": "@microsoft.azure/autorest.go@2.1.183", + "use": "@microsoft.azure/autorest.go@2.1.187", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-2018-11-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/billing/resource-manager/readme.md", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2018-11-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/billing/resource-manager/readme.md", "additional_properties": { "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION" } diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/accounts.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/accounts.go index 4c65c6734f76..4b723a78c3d5 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/accounts.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/accounts.go @@ -244,7 +244,7 @@ func (client AccountsClient) Update(ctx context.Context, billingAccountName stri result, err = client.UpdateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "billing.AccountsClient", "Update", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "Update", result.Response(), "Failure sending request") return } @@ -276,6 +276,7 @@ func (client AccountsClient) UpdatePreparer(ctx context.Context, billingAccountN // http.Response Body if it receives an error. func (client AccountsClient) UpdateSender(req *http.Request) (future AccountsUpdateFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { return diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesections.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesections.go index e66156657631..93f7395f13b7 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesections.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesections.go @@ -53,7 +53,7 @@ func (client InvoiceSectionsClient) Create(ctx context.Context, billingAccountNa result, err = client.CreateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Create", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Create", result.Response(), "Failure sending request") return } @@ -85,6 +85,7 @@ func (client InvoiceSectionsClient) CreatePreparer(ctx context.Context, billingA // http.Response Body if it receives an error. func (client InvoiceSectionsClient) CreateSender(req *http.Request) (future InvoiceSectionsCreateFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { return @@ -592,7 +593,7 @@ func (client InvoiceSectionsClient) Update(ctx context.Context, billingAccountNa result, err = client.UpdateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Update", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Update", result.Response(), "Failure sending request") return } @@ -625,6 +626,7 @@ func (client InvoiceSectionsClient) UpdatePreparer(ctx context.Context, billingA // http.Response Body if it receives an error. func (client InvoiceSectionsClient) UpdateSender(req *http.Request) (future InvoiceSectionsUpdateFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { return diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/lineofcredits.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/lineofcredits.go index a2104ed6cc9f..40e0d9cc2c84 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/lineofcredits.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/lineofcredits.go @@ -123,7 +123,7 @@ func (client LineOfCreditsClient) Update(ctx context.Context, parameters LineOfC result, err = client.UpdateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "billing.LineOfCreditsClient", "Update", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.LineOfCreditsClient", "Update", result.Response(), "Failure sending request") return } @@ -155,6 +155,7 @@ func (client LineOfCreditsClient) UpdatePreparer(ctx context.Context, parameters // http.Response Body if it receives an error. func (client LineOfCreditsClient) UpdateSender(req *http.Request) (future LineOfCreditsUpdateFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/pricesheet.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/pricesheet.go index 0b490ba9ad9c..d296ce77c322 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/pricesheet.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/pricesheet.go @@ -53,7 +53,7 @@ func (client PriceSheetClient) Download(ctx context.Context, billingAccountName result, err = client.DownloadSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "billing.PriceSheetClient", "Download", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.PriceSheetClient", "Download", result.Response(), "Failure sending request") return } @@ -84,6 +84,7 @@ func (client PriceSheetClient) DownloadPreparer(ctx context.Context, billingAcco // http.Response Body if it receives an error. func (client PriceSheetClient) DownloadSender(req *http.Request) (future PriceSheetDownloadFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { return diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/profiles.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/profiles.go index b830a4761d2f..42676029ef77 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/profiles.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/profiles.go @@ -53,7 +53,7 @@ func (client ProfilesClient) Create(ctx context.Context, billingAccountName stri result, err = client.CreateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "Create", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "Create", result.Response(), "Failure sending request") return } @@ -85,6 +85,7 @@ func (client ProfilesClient) CreatePreparer(ctx context.Context, billingAccountN // http.Response Body if it receives an error. func (client ProfilesClient) CreateSender(req *http.Request) (future ProfilesCreateFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { return @@ -330,7 +331,7 @@ func (client ProfilesClient) Update(ctx context.Context, billingAccountName stri result, err = client.UpdateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "Update", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "Update", result.Response(), "Failure sending request") return } @@ -363,6 +364,7 @@ func (client ProfilesClient) UpdatePreparer(ctx context.Context, billingAccountN // http.Response Body if it receives an error. func (client ProfilesClient) UpdateSender(req *http.Request) (future ProfilesUpdateFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { return diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/subscriptions.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/subscriptions.go index 72ff20ec643c..96d834d9d213 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/subscriptions.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/subscriptions.go @@ -675,7 +675,7 @@ func (client SubscriptionsClient) Transfer(ctx context.Context, billingAccountNa result, err = client.TransferSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "Transfer", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "Transfer", result.Response(), "Failure sending request") return } @@ -703,6 +703,7 @@ func (client SubscriptionsClient) TransferPreparer(ctx context.Context, billingA // http.Response Body if it receives an error. func (client SubscriptionsClient) TransferSender(req *http.Request) (future SubscriptionsTransferFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { return diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/CHANGELOG.md b/services/preview/billing/mgmt/2020-05-01-preview/billing/CHANGELOG.md index 8821e5b04ed1..c490e7745378 100644 --- a/services/preview/billing/mgmt/2020-05-01-preview/billing/CHANGELOG.md +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/CHANGELOG.md @@ -1,35 +1,101 @@ -# Change History +# Unreleased + +## Breaking Changes + +### Removed Constants + +1. TransactionTypeKind.All +1. TransactionTypeKind.Reservation + +### Struct Changes + +#### Removed Struct Fields + +1. EnrollmentPolicies.MarketplacesEnabled ## Additive Changes +### New Constants + +1. SubscriptionTransferValidationErrorCode.SubscriptionTransferValidationErrorCodeBillingAccountInactive +1. SubscriptionTransferValidationErrorCode.SubscriptionTransferValidationErrorCodeDestinationBillingProfileInactive +1. SubscriptionTransferValidationErrorCode.SubscriptionTransferValidationErrorCodeDestinationBillingProfileNotFound +1. SubscriptionTransferValidationErrorCode.SubscriptionTransferValidationErrorCodeDestinationInvoiceSectionInactive +1. SubscriptionTransferValidationErrorCode.SubscriptionTransferValidationErrorCodeDestinationInvoiceSectionNotFound +1. SubscriptionTransferValidationErrorCode.SubscriptionTransferValidationErrorCodeInvalidDestination +1. SubscriptionTransferValidationErrorCode.SubscriptionTransferValidationErrorCodeMarketplaceNotEnabledOnDestination +1. SubscriptionTransferValidationErrorCode.SubscriptionTransferValidationErrorCodeProductInactive +1. SubscriptionTransferValidationErrorCode.SubscriptionTransferValidationErrorCodeProductNotFound +1. SubscriptionTransferValidationErrorCode.SubscriptionTransferValidationErrorCodeProductTypeNotSupported +1. SubscriptionTransferValidationErrorCode.SubscriptionTransferValidationErrorCodeSourceBillingProfilePastDue +1. SubscriptionTransferValidationErrorCode.SubscriptionTransferValidationErrorCodeSourceInvoiceSectionInactive +1. TransactionTypeKind.TransactionTypeKindAll +1. TransactionTypeKind.TransactionTypeKindReservation + ### New Funcs -1. AccountListResult.MarshalJSON() ([]byte, error) -1. AgreementListResult.MarshalJSON() ([]byte, error) -1. AvailableBalanceProperties.MarshalJSON() ([]byte, error) -1. CustomerListResult.MarshalJSON() ([]byte, error) -1. Document.MarshalJSON() ([]byte, error) -1. DownloadURL.MarshalJSON() ([]byte, error) -1. EnrollmentAccountListResult.MarshalJSON() ([]byte, error) -1. EnrollmentAccountSummaryProperties.MarshalJSON() ([]byte, error) -1. EnrollmentPolicies.MarshalJSON() ([]byte, error) -1. ErrorDetails.MarshalJSON() ([]byte, error) -1. ErrorSubDetailsItem.MarshalJSON() ([]byte, error) -1. InstructionListResult.MarshalJSON() ([]byte, error) -1. InvoiceListResult.MarshalJSON() ([]byte, error) -1. InvoiceSectionListResult.MarshalJSON() ([]byte, error) -1. OperationDisplay.MarshalJSON() ([]byte, error) -1. OperationListResult.MarshalJSON() ([]byte, error) -1. Participants.MarshalJSON() ([]byte, error) -1. PeriodProperties.MarshalJSON() ([]byte, error) -1. PeriodsListResult.MarshalJSON() ([]byte, error) -1. PermissionsListResult.MarshalJSON() ([]byte, error) -1. PermissionsProperties.MarshalJSON() ([]byte, error) -1. ProductsListResult.MarshalJSON() ([]byte, error) -1. ProfileListResult.MarshalJSON() ([]byte, error) -1. Reseller.MarshalJSON() ([]byte, error) -1. Resource.MarshalJSON() ([]byte, error) -1. RoleAssignmentListResult.MarshalJSON() ([]byte, error) -1. RoleDefinitionListResult.MarshalJSON() ([]byte, error) -1. SubscriptionsListResult.MarshalJSON() ([]byte, error) -1. TransactionListResult.MarshalJSON() ([]byte, error) +1. *Reservation.UnmarshalJSON([]byte) error +1. *ReservationsListResultIterator.Next() error +1. *ReservationsListResultIterator.NextWithContext(context.Context) error +1. *ReservationsListResultPage.Next() error +1. *ReservationsListResultPage.NextWithContext(context.Context) error +1. NewReservationsClient(string) ReservationsClient +1. NewReservationsClientWithBaseURI(string, string) ReservationsClient +1. NewReservationsListResultIterator(ReservationsListResultPage) ReservationsListResultIterator +1. NewReservationsListResultPage(ReservationsListResult, func(context.Context, ReservationsListResult) (ReservationsListResult, error)) ReservationsListResultPage +1. Reservation.MarshalJSON() ([]byte, error) +1. ReservationProperty.MarshalJSON() ([]byte, error) +1. ReservationPropertyUtilization.MarshalJSON() ([]byte, error) +1. ReservationSkuProperty.MarshalJSON() ([]byte, error) +1. ReservationSummary.MarshalJSON() ([]byte, error) +1. ReservationUtilizationAggregates.MarshalJSON() ([]byte, error) +1. ReservationsClient.ListByBillingAccount(context.Context, string, string, string, string, string) (ReservationsListResultPage, error) +1. ReservationsClient.ListByBillingAccountComplete(context.Context, string, string, string, string, string) (ReservationsListResultIterator, error) +1. ReservationsClient.ListByBillingAccountPreparer(context.Context, string, string, string, string, string) (*http.Request, error) +1. ReservationsClient.ListByBillingAccountResponder(*http.Response) (ReservationsListResult, error) +1. ReservationsClient.ListByBillingAccountSender(*http.Request) (*http.Response, error) +1. ReservationsClient.ListByBillingProfile(context.Context, string, string, string, string, string, string) (ReservationsListResultPage, error) +1. ReservationsClient.ListByBillingProfileComplete(context.Context, string, string, string, string, string, string) (ReservationsListResultIterator, error) +1. ReservationsClient.ListByBillingProfilePreparer(context.Context, string, string, string, string, string, string) (*http.Request, error) +1. ReservationsClient.ListByBillingProfileResponder(*http.Response) (ReservationsListResult, error) +1. ReservationsClient.ListByBillingProfileSender(*http.Request) (*http.Response, error) +1. ReservationsListResult.IsEmpty() bool +1. ReservationsListResult.MarshalJSON() ([]byte, error) +1. ReservationsListResultIterator.NotDone() bool +1. ReservationsListResultIterator.Response() ReservationsListResult +1. ReservationsListResultIterator.Value() Reservation +1. ReservationsListResultPage.NotDone() bool +1. ReservationsListResultPage.Response() ReservationsListResult +1. ReservationsListResultPage.Values() []Reservation + +### Struct Changes + +#### New Structs + +1. Reservation +1. ReservationProperty +1. ReservationPropertyUtilization +1. ReservationSkuProperty +1. ReservationSummary +1. ReservationUtilizationAggregates +1. ReservationsClient +1. ReservationsListResult +1. ReservationsListResultIterator +1. ReservationsListResultPage + +#### New Struct Fields + +1. AccountProperties.NotificationEmailAddress +1. AddressDetails.MiddleName +1. CustomerListResult.TotalCount +1. EnrollmentAccountProperties.AccountOwnerEmail +1. EnrollmentPolicies.MarketplaceEnabled +1. InvoiceSectionListResult.TotalCount +1. InvoiceSectionProperties.Tags +1. Operation.IsDataAction +1. OperationDisplay.Description +1. ProductsListResult.TotalCount +1. ProfileProperties.Tags +1. SubscriptionProperties.SuspensionReasons +1. SubscriptionsListResult.TotalCount +1. TransactionListResult.TotalCount diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/_meta.json b/services/preview/billing/mgmt/2020-05-01-preview/billing/_meta.json index cc040847267f..d7d78fa8596f 100644 --- a/services/preview/billing/mgmt/2020-05-01-preview/billing/_meta.json +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/_meta.json @@ -1,10 +1,10 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "bc45d483dac4a7ecc0ab2a8064acf9a9726bac6b", "readme": "/_/azure-rest-api-specs/specification/billing/resource-manager/readme.md", "tag": "package-2020-05", - "use": "@microsoft.azure/autorest.go@2.1.183", + "use": "@microsoft.azure/autorest.go@2.1.187", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-2020-05 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/billing/resource-manager/readme.md", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2020-05 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/billing/resource-manager/readme.md", "additional_properties": { "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION" } diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/accounts.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/accounts.go index b300bf1b7b9f..44d6c54508a4 100644 --- a/services/preview/billing/mgmt/2020-05-01-preview/billing/accounts.go +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/accounts.go @@ -362,7 +362,7 @@ func (client AccountsClient) Update(ctx context.Context, billingAccountName stri result, err = client.UpdateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "billing.AccountsClient", "Update", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "Update", result.Response(), "Failure sending request") return } @@ -394,6 +394,7 @@ func (client AccountsClient) UpdatePreparer(ctx context.Context, billingAccountN // http.Response Body if it receives an error. func (client AccountsClient) UpdateSender(req *http.Request) (future AccountsUpdateFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { return diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/billingapi/interfaces.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/billingapi/interfaces.go index 9d46cf617422..cb628417b822 100644 --- a/services/preview/billing/mgmt/2020-05-01-preview/billing/billingapi/interfaces.go +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/billingapi/interfaces.go @@ -223,6 +223,16 @@ type AgreementsClientAPI interface { var _ AgreementsClientAPI = (*billing.AgreementsClient)(nil) +// ReservationsClientAPI contains the set of methods on the ReservationsClient type. +type ReservationsClientAPI interface { + ListByBillingAccount(ctx context.Context, billingAccountName string, filter string, orderby string, refreshSummary string, selectedState string) (result billing.ReservationsListResultPage, err error) + ListByBillingAccountComplete(ctx context.Context, billingAccountName string, filter string, orderby string, refreshSummary string, selectedState string) (result billing.ReservationsListResultIterator, err error) + ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, filter string, orderby string, refreshSummary string, selectedState string) (result billing.ReservationsListResultPage, err error) + ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string, filter string, orderby string, refreshSummary string, selectedState string) (result billing.ReservationsListResultIterator, err error) +} + +var _ ReservationsClientAPI = (*billing.ReservationsClient)(nil) + // EnrollmentAccountsClientAPI contains the set of methods on the EnrollmentAccountsClient type. type EnrollmentAccountsClientAPI interface { Get(ctx context.Context, name string) (result billing.EnrollmentAccountSummary, err error) diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/enums.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/enums.go index e59cd2f659d5..6fed178f00a9 100644 --- a/services/preview/billing/mgmt/2020-05-01-preview/billing/enums.go +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/enums.go @@ -528,18 +528,42 @@ func PossibleSubscriptionStatusTypeValues() []SubscriptionStatusType { type SubscriptionTransferValidationErrorCode string const ( + // SubscriptionTransferValidationErrorCodeBillingAccountInactive ... + SubscriptionTransferValidationErrorCodeBillingAccountInactive SubscriptionTransferValidationErrorCode = "BillingAccountInactive" // SubscriptionTransferValidationErrorCodeCrossBillingAccountNotAllowed ... SubscriptionTransferValidationErrorCodeCrossBillingAccountNotAllowed SubscriptionTransferValidationErrorCode = "CrossBillingAccountNotAllowed" + // SubscriptionTransferValidationErrorCodeDestinationBillingProfileInactive ... + SubscriptionTransferValidationErrorCodeDestinationBillingProfileInactive SubscriptionTransferValidationErrorCode = "DestinationBillingProfileInactive" + // SubscriptionTransferValidationErrorCodeDestinationBillingProfileNotFound ... + SubscriptionTransferValidationErrorCodeDestinationBillingProfileNotFound SubscriptionTransferValidationErrorCode = "DestinationBillingProfileNotFound" // SubscriptionTransferValidationErrorCodeDestinationBillingProfilePastDue ... SubscriptionTransferValidationErrorCodeDestinationBillingProfilePastDue SubscriptionTransferValidationErrorCode = "DestinationBillingProfilePastDue" + // SubscriptionTransferValidationErrorCodeDestinationInvoiceSectionInactive ... + SubscriptionTransferValidationErrorCodeDestinationInvoiceSectionInactive SubscriptionTransferValidationErrorCode = "DestinationInvoiceSectionInactive" + // SubscriptionTransferValidationErrorCodeDestinationInvoiceSectionNotFound ... + SubscriptionTransferValidationErrorCodeDestinationInvoiceSectionNotFound SubscriptionTransferValidationErrorCode = "DestinationInvoiceSectionNotFound" // SubscriptionTransferValidationErrorCodeInsufficientPermissionOnDestination ... SubscriptionTransferValidationErrorCodeInsufficientPermissionOnDestination SubscriptionTransferValidationErrorCode = "InsufficientPermissionOnDestination" // SubscriptionTransferValidationErrorCodeInsufficientPermissionOnSource ... SubscriptionTransferValidationErrorCodeInsufficientPermissionOnSource SubscriptionTransferValidationErrorCode = "InsufficientPermissionOnSource" + // SubscriptionTransferValidationErrorCodeInvalidDestination ... + SubscriptionTransferValidationErrorCodeInvalidDestination SubscriptionTransferValidationErrorCode = "InvalidDestination" // SubscriptionTransferValidationErrorCodeInvalidSource ... SubscriptionTransferValidationErrorCodeInvalidSource SubscriptionTransferValidationErrorCode = "InvalidSource" + // SubscriptionTransferValidationErrorCodeMarketplaceNotEnabledOnDestination ... + SubscriptionTransferValidationErrorCodeMarketplaceNotEnabledOnDestination SubscriptionTransferValidationErrorCode = "MarketplaceNotEnabledOnDestination" // SubscriptionTransferValidationErrorCodeNotAvailableForDestinationMarket ... SubscriptionTransferValidationErrorCodeNotAvailableForDestinationMarket SubscriptionTransferValidationErrorCode = "NotAvailableForDestinationMarket" + // SubscriptionTransferValidationErrorCodeProductInactive ... + SubscriptionTransferValidationErrorCodeProductInactive SubscriptionTransferValidationErrorCode = "ProductInactive" + // SubscriptionTransferValidationErrorCodeProductNotFound ... + SubscriptionTransferValidationErrorCodeProductNotFound SubscriptionTransferValidationErrorCode = "ProductNotFound" + // SubscriptionTransferValidationErrorCodeProductTypeNotSupported ... + SubscriptionTransferValidationErrorCodeProductTypeNotSupported SubscriptionTransferValidationErrorCode = "ProductTypeNotSupported" + // SubscriptionTransferValidationErrorCodeSourceBillingProfilePastDue ... + SubscriptionTransferValidationErrorCodeSourceBillingProfilePastDue SubscriptionTransferValidationErrorCode = "SourceBillingProfilePastDue" + // SubscriptionTransferValidationErrorCodeSourceInvoiceSectionInactive ... + SubscriptionTransferValidationErrorCodeSourceInvoiceSectionInactive SubscriptionTransferValidationErrorCode = "SourceInvoiceSectionInactive" // SubscriptionTransferValidationErrorCodeSubscriptionNotActive ... SubscriptionTransferValidationErrorCodeSubscriptionNotActive SubscriptionTransferValidationErrorCode = "SubscriptionNotActive" // SubscriptionTransferValidationErrorCodeSubscriptionTypeNotSupported ... @@ -548,7 +572,7 @@ const ( // PossibleSubscriptionTransferValidationErrorCodeValues returns an array of possible values for the SubscriptionTransferValidationErrorCode const type. func PossibleSubscriptionTransferValidationErrorCodeValues() []SubscriptionTransferValidationErrorCode { - return []SubscriptionTransferValidationErrorCode{SubscriptionTransferValidationErrorCodeCrossBillingAccountNotAllowed, SubscriptionTransferValidationErrorCodeDestinationBillingProfilePastDue, SubscriptionTransferValidationErrorCodeInsufficientPermissionOnDestination, SubscriptionTransferValidationErrorCodeInsufficientPermissionOnSource, SubscriptionTransferValidationErrorCodeInvalidSource, SubscriptionTransferValidationErrorCodeNotAvailableForDestinationMarket, SubscriptionTransferValidationErrorCodeSubscriptionNotActive, SubscriptionTransferValidationErrorCodeSubscriptionTypeNotSupported} + return []SubscriptionTransferValidationErrorCode{SubscriptionTransferValidationErrorCodeBillingAccountInactive, SubscriptionTransferValidationErrorCodeCrossBillingAccountNotAllowed, SubscriptionTransferValidationErrorCodeDestinationBillingProfileInactive, SubscriptionTransferValidationErrorCodeDestinationBillingProfileNotFound, SubscriptionTransferValidationErrorCodeDestinationBillingProfilePastDue, SubscriptionTransferValidationErrorCodeDestinationInvoiceSectionInactive, SubscriptionTransferValidationErrorCodeDestinationInvoiceSectionNotFound, SubscriptionTransferValidationErrorCodeInsufficientPermissionOnDestination, SubscriptionTransferValidationErrorCodeInsufficientPermissionOnSource, SubscriptionTransferValidationErrorCodeInvalidDestination, SubscriptionTransferValidationErrorCodeInvalidSource, SubscriptionTransferValidationErrorCodeMarketplaceNotEnabledOnDestination, SubscriptionTransferValidationErrorCodeNotAvailableForDestinationMarket, SubscriptionTransferValidationErrorCodeProductInactive, SubscriptionTransferValidationErrorCodeProductNotFound, SubscriptionTransferValidationErrorCodeProductTypeNotSupported, SubscriptionTransferValidationErrorCodeSourceBillingProfilePastDue, SubscriptionTransferValidationErrorCodeSourceInvoiceSectionInactive, SubscriptionTransferValidationErrorCodeSubscriptionNotActive, SubscriptionTransferValidationErrorCodeSubscriptionTypeNotSupported} } // TargetCloud enumerates the values for target cloud. @@ -572,15 +596,15 @@ func PossibleTargetCloudValues() []TargetCloud { type TransactionTypeKind string const ( - // All ... - All TransactionTypeKind = "all" - // Reservation ... - Reservation TransactionTypeKind = "reservation" + // TransactionTypeKindAll ... + TransactionTypeKindAll TransactionTypeKind = "all" + // TransactionTypeKindReservation ... + TransactionTypeKindReservation TransactionTypeKind = "reservation" ) // PossibleTransactionTypeKindValues returns an array of possible values for the TransactionTypeKind const type. func PossibleTransactionTypeKindValues() []TransactionTypeKind { - return []TransactionTypeKind{All, Reservation} + return []TransactionTypeKind{TransactionTypeKindAll, TransactionTypeKindReservation} } // ViewCharges enumerates the values for view charges. diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/invoices.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/invoices.go index 0de39db6945e..8013ef6fdc34 100644 --- a/services/preview/billing/mgmt/2020-05-01-preview/billing/invoices.go +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/invoices.go @@ -54,7 +54,7 @@ func (client InvoicesClient) DownloadBillingSubscriptionInvoice(ctx context.Cont result, err = client.DownloadBillingSubscriptionInvoiceSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "DownloadBillingSubscriptionInvoice", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "DownloadBillingSubscriptionInvoice", result.Response(), "Failure sending request") return } @@ -86,6 +86,7 @@ func (client InvoicesClient) DownloadBillingSubscriptionInvoicePreparer(ctx cont // http.Response Body if it receives an error. func (client InvoicesClient) DownloadBillingSubscriptionInvoiceSender(req *http.Request) (future InvoicesDownloadBillingSubscriptionInvoiceFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { return @@ -134,7 +135,7 @@ func (client InvoicesClient) DownloadInvoice(ctx context.Context, billingAccount result, err = client.DownloadInvoiceSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "DownloadInvoice", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "DownloadInvoice", result.Response(), "Failure sending request") return } @@ -166,6 +167,7 @@ func (client InvoicesClient) DownloadInvoicePreparer(ctx context.Context, billin // http.Response Body if it receives an error. func (client InvoicesClient) DownloadInvoiceSender(req *http.Request) (future InvoicesDownloadInvoiceFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { return @@ -220,7 +222,7 @@ func (client InvoicesClient) DownloadMultipleBillingProfileInvoices(ctx context. result, err = client.DownloadMultipleBillingProfileInvoicesSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "DownloadMultipleBillingProfileInvoices", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "DownloadMultipleBillingProfileInvoices", result.Response(), "Failure sending request") return } @@ -252,6 +254,7 @@ func (client InvoicesClient) DownloadMultipleBillingProfileInvoicesPreparer(ctx // http.Response Body if it receives an error. func (client InvoicesClient) DownloadMultipleBillingProfileInvoicesSender(req *http.Request) (future InvoicesDownloadMultipleBillingProfileInvoicesFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { return @@ -304,7 +307,7 @@ func (client InvoicesClient) DownloadMultipleBillingSubscriptionInvoices(ctx con result, err = client.DownloadMultipleBillingSubscriptionInvoicesSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "DownloadMultipleBillingSubscriptionInvoices", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "DownloadMultipleBillingSubscriptionInvoices", result.Response(), "Failure sending request") return } @@ -336,6 +339,7 @@ func (client InvoicesClient) DownloadMultipleBillingSubscriptionInvoicesPreparer // http.Response Body if it receives an error. func (client InvoicesClient) DownloadMultipleBillingSubscriptionInvoicesSender(req *http.Request) (future InvoicesDownloadMultipleBillingSubscriptionInvoicesFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { return diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/invoicesections.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/invoicesections.go index 1d36f429b1b1..a6d4c4847d2f 100644 --- a/services/preview/billing/mgmt/2020-05-01-preview/billing/invoicesections.go +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/invoicesections.go @@ -56,7 +56,7 @@ func (client InvoiceSectionsClient) CreateOrUpdate(ctx context.Context, billingA result, err = client.CreateOrUpdateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "CreateOrUpdate", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "CreateOrUpdate", result.Response(), "Failure sending request") return } @@ -90,6 +90,7 @@ func (client InvoiceSectionsClient) CreateOrUpdatePreparer(ctx context.Context, // http.Response Body if it receives an error. func (client InvoiceSectionsClient) CreateOrUpdateSender(req *http.Request) (future InvoiceSectionsCreateOrUpdateFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { return diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/models.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/models.go index 98070f62a25b..4a5a71c87440 100644 --- a/services/preview/billing/mgmt/2020-05-01-preview/billing/models.go +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/models.go @@ -281,6 +281,8 @@ type AccountProperties struct { EnrollmentAccounts *[]EnrollmentAccount `json:"enrollmentAccounts,omitempty"` // HasReadAccess - READ-ONLY; Indicates whether user has read access to the billing account. HasReadAccess *bool `json:"hasReadAccess,omitempty"` + // NotificationEmailAddress - Notification email address, only for legacy accounts + NotificationEmailAddress *string `json:"notificationEmailAddress,omitempty"` } // MarshalJSON is the custom marshaler for AccountProperties. @@ -301,6 +303,9 @@ func (ap AccountProperties) MarshalJSON() ([]byte, error) { if ap.EnrollmentAccounts != nil { objectMap["enrollmentAccounts"] = ap.EnrollmentAccounts } + if ap.NotificationEmailAddress != nil { + objectMap["notificationEmailAddress"] = ap.NotificationEmailAddress + } return json.Marshal(objectMap) } @@ -390,6 +395,8 @@ func (aur *AccountUpdateRequest) UnmarshalJSON(body []byte) error { type AddressDetails struct { // FirstName - First name. FirstName *string `json:"firstName,omitempty"` + // MiddleName - Middle name. + MiddleName *string `json:"middleName,omitempty"` // LastName - Last name. LastName *string `json:"lastName,omitempty"` // CompanyName - Company name. @@ -877,6 +884,8 @@ type CustomerListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; The list of customers. Value *[]Customer `json:"value,omitempty"` + // TotalCount - READ-ONLY; Total number of records. + TotalCount *float64 `json:"totalCount,omitempty"` // NextLink - READ-ONLY; The link (url) to the next page of results. NextLink *string `json:"nextLink,omitempty"` } @@ -1551,6 +1560,8 @@ type EnrollmentAccountProperties struct { CostCenter *string `json:"costCenter,omitempty"` // AccountOwner - The owner of the enrollment account. AccountOwner *string `json:"accountOwner,omitempty"` + // AccountOwnerEmail - The enrollment account owner email address. + AccountOwnerEmail *string `json:"accountOwnerEmail,omitempty"` // Status - The status of the enrollment account. Status *string `json:"status,omitempty"` // StartDate - The start date of the enrollment account. @@ -1652,8 +1663,8 @@ type EnrollmentPolicies struct { AccountOwnerViewCharges *bool `json:"accountOwnerViewCharges,omitempty"` // DepartmentAdminViewCharges - READ-ONLY; The policy that controls whether Department Administrators can view charges. DepartmentAdminViewCharges *bool `json:"departmentAdminViewCharges,omitempty"` - // MarketplacesEnabled - READ-ONLY; The policy that controls whether Azure marketplace purchases are allowed in the enrollment. - MarketplacesEnabled *bool `json:"marketplacesEnabled,omitempty"` + // MarketplaceEnabled - READ-ONLY; The policy that controls whether Azure marketplace purchases are allowed in the enrollment. + MarketplaceEnabled *bool `json:"marketplaceEnabled,omitempty"` // ReservedInstancesEnabled - READ-ONLY; The policy that controls whether Azure reservation purchases are allowed in the enrollment. ReservedInstancesEnabled *bool `json:"reservedInstancesEnabled,omitempty"` } @@ -2520,6 +2531,8 @@ type InvoiceSectionListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; The list of invoice sections. Value *[]InvoiceSection `json:"value,omitempty"` + // TotalCount - READ-ONLY; Total number of records. + TotalCount *float64 `json:"totalCount,omitempty"` // NextLink - READ-ONLY; The link (url) to the next page of results. NextLink *string `json:"nextLink,omitempty"` } @@ -2861,6 +2874,8 @@ type InvoiceSectionProperties struct { State InvoiceSectionState `json:"state,omitempty"` // SystemID - READ-ONLY; The system generated unique identifier for an invoice section. SystemID *string `json:"systemId,omitempty"` + // Tags - Dictionary of metadata associated with the invoice section. Maximum key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys can not contain < > % & \ ? / + Tags map[string]*string `json:"tags"` // TargetCloud - READ-ONLY; Identifies the cloud environments that are associated with an invoice section. This is a system managed optional field and gets updated as the invoice section gets associated with accounts in various clouds. Possible values include: 'USGov', 'USNat', 'USSec' TargetCloud TargetCloud `json:"targetCloud,omitempty"` } @@ -2874,6 +2889,9 @@ func (isp InvoiceSectionProperties) MarshalJSON() ([]byte, error) { if isp.Labels != nil { objectMap["labels"] = isp.Labels } + if isp.Tags != nil { + objectMap["tags"] = isp.Tags + } return json.Marshal(objectMap) } @@ -2975,6 +2993,8 @@ func (iswcsp InvoiceSectionWithCreateSubPermission) MarshalJSON() ([]byte, error type Operation struct { // Name - READ-ONLY; Operation name: {provider}/{resource}/{operation}. Name *string `json:"name,omitempty"` + // IsDataAction - READ-ONLY; Identifies if the operation is a data operation. + IsDataAction *bool `json:"isDataAction,omitempty"` // Display - The object that represents the operation. Display *OperationDisplay `json:"display,omitempty"` } @@ -2996,6 +3016,8 @@ type OperationDisplay struct { Resource *string `json:"resource,omitempty"` // Operation - READ-ONLY; Operation type such as read, write and delete. Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; Description of operation. + Description *string `json:"description,omitempty"` } // MarshalJSON is the custom marshaler for OperationDisplay. @@ -3866,6 +3888,8 @@ type ProductsListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; The list of products. Value *[]Product `json:"value,omitempty"` + // TotalCount - READ-ONLY; Total number of records. + TotalCount *float64 `json:"totalCount,omitempty"` // NextLink - READ-ONLY; The link (url) to the next page of results. NextLink *string `json:"nextLink,omitempty"` } @@ -4312,6 +4336,8 @@ type ProfileProperties struct { SpendingLimit SpendingLimit `json:"spendingLimit,omitempty"` // TargetClouds - READ-ONLY; Identifies the cloud environments that are associated with a billing profile. This is a system managed optional field and gets updated as the billing profile gets associated with accounts in various clouds. TargetClouds *[]TargetCloud `json:"targetClouds,omitempty"` + // Tags - Tags of billing profiles. + Tags map[string]*string `json:"tags"` } // MarshalJSON is the custom marshaler for ProfileProperties. @@ -4335,6 +4361,9 @@ func (pp ProfileProperties) MarshalJSON() ([]byte, error) { if pp.InvoiceSections != nil { objectMap["invoiceSections"] = pp.InvoiceSections } + if pp.Tags != nil { + objectMap["tags"] = pp.Tags + } return json.Marshal(objectMap) } @@ -4549,6 +4578,390 @@ func (r Reseller) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } +// Reservation the definition of the reservation. +type Reservation struct { + // ID - READ-ONLY; The id of the reservation. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the reservation. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the reservation. + Type *string `json:"type,omitempty"` + // Location - READ-ONLY; The location of the reservation. + Location *string `json:"location,omitempty"` + // Sku - The sku information associated to this reservation + Sku *ReservationSkuProperty `json:"sku,omitempty"` + // ReservationProperty - The properties associated to this reservation + *ReservationProperty `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Reservation. +func (r Reservation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.Sku != nil { + objectMap["sku"] = r.Sku + } + if r.ReservationProperty != nil { + objectMap["properties"] = r.ReservationProperty + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Reservation struct. +func (r *Reservation) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + r.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + r.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + r.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + r.Location = &location + } + case "sku": + if v != nil { + var sku ReservationSkuProperty + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + r.Sku = &sku + } + case "properties": + if v != nil { + var reservationProperty ReservationProperty + err = json.Unmarshal(*v, &reservationProperty) + if err != nil { + return err + } + r.ReservationProperty = &reservationProperty + } + } + } + + return nil +} + +// ReservationProperty the property of reservation object. +type ReservationProperty struct { + // AppliedScopes - The array of applied scopes of a reservation. Will be null if the reservation is in Shared scope + AppliedScopes *[]string `json:"appliedScopes,omitempty"` + // AppliedScopeType - READ-ONLY; The applied scope type of the reservation. + AppliedScopeType *string `json:"appliedScopeType,omitempty"` + // ReservedResourceType - READ-ONLY; The reserved source type of the reservation, e.g. virtual machine. + ReservedResourceType *string `json:"reservedResourceType,omitempty"` + // Quantity - READ-ONLY; The number of the reservation. + Quantity *float64 `json:"quantity,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state of the reservation, e.g. Succeeded + ProvisioningState *string `json:"provisioningState,omitempty"` + // ExpiryDate - READ-ONLY; The expiry date of the reservation + ExpiryDate *string `json:"expiryDate,omitempty"` + // ProvisioningSubState - READ-ONLY; The provisioning state of the reservation, e.g. Succeeded + ProvisioningSubState *string `json:"provisioningSubState,omitempty"` + // DisplayName - READ-ONLY; The display name of the reservation + DisplayName *string `json:"displayName,omitempty"` + // DisplayProvisioningState - READ-ONLY; The provisioning state of the reservation for display, e.g. Succeeded + DisplayProvisioningState *string `json:"displayProvisioningState,omitempty"` + // UserFriendlyRenewState - READ-ONLY; The renew state of the reservation for display, e.g. On + UserFriendlyRenewState *string `json:"userFriendlyRenewState,omitempty"` + // UserFriendlyAppliedScopeType - READ-ONLY; The applied scope type of the reservation for display, e.g. Shared + UserFriendlyAppliedScopeType *string `json:"userFriendlyAppliedScopeType,omitempty"` + // EffectiveDateTime - READ-ONLY; The effective date time of the reservation + EffectiveDateTime *string `json:"effectiveDateTime,omitempty"` + // SkuDescription - READ-ONLY; The sku description of the reservation + SkuDescription *string `json:"skuDescription,omitempty"` + // Term - READ-ONLY; The term of the reservation, e.g. P1Y + Term *string `json:"term,omitempty"` + // Renew - READ-ONLY; The renew state of the reservation + Renew *bool `json:"renew,omitempty"` + // RenewSource - READ-ONLY; The renew source of the reservation + RenewSource *string `json:"renewSource,omitempty"` + // Utilization - READ-ONLY; Reservation utilization + Utilization *ReservationPropertyUtilization `json:"utilization,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReservationProperty. +func (rp ReservationProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rp.AppliedScopes != nil { + objectMap["appliedScopes"] = rp.AppliedScopes + } + return json.Marshal(objectMap) +} + +// ReservationPropertyUtilization reservation utilization +type ReservationPropertyUtilization struct { + // Trend - READ-ONLY; The number of days trend for a reservation + Trend *string `json:"trend,omitempty"` + // Aggregates - The array of aggregates of a reservation's utilization + Aggregates *[]ReservationUtilizationAggregates `json:"aggregates,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReservationPropertyUtilization. +func (rp ReservationPropertyUtilization) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rp.Aggregates != nil { + objectMap["aggregates"] = rp.Aggregates + } + return json.Marshal(objectMap) +} + +// ReservationSkuProperty the property of reservation sku object. +type ReservationSkuProperty struct { + // Name - READ-ONLY; The name of the reservation sku. + Name *string `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReservationSkuProperty. +func (rsp ReservationSkuProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ReservationsListResult the list of reservations and summary of roll out count of reservations in each +// state. +type ReservationsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of reservations. + Value *[]Reservation `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` + // Summary - The roll out count summary of the reservations + Summary *ReservationSummary `json:"summary,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReservationsListResult. +func (rlr ReservationsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rlr.Summary != nil { + objectMap["summary"] = rlr.Summary + } + return json.Marshal(objectMap) +} + +// ReservationsListResultIterator provides access to a complete listing of Reservation values. +type ReservationsListResultIterator struct { + i int + page ReservationsListResultPage +} + +// 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 *ReservationsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReservationsListResultIterator.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 *ReservationsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ReservationsListResultIterator) 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 ReservationsListResultIterator) Response() ReservationsListResult { + 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 ReservationsListResultIterator) Value() Reservation { + if !iter.page.NotDone() { + return Reservation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ReservationsListResultIterator type. +func NewReservationsListResultIterator(page ReservationsListResultPage) ReservationsListResultIterator { + return ReservationsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rlr ReservationsListResult) IsEmpty() bool { + return rlr.Value == nil || len(*rlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rlr ReservationsListResult) hasNextLink() bool { + return rlr.NextLink != nil && len(*rlr.NextLink) != 0 +} + +// reservationsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rlr ReservationsListResult) reservationsListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rlr.NextLink))) +} + +// ReservationsListResultPage contains a page of Reservation values. +type ReservationsListResultPage struct { + fn func(context.Context, ReservationsListResult) (ReservationsListResult, error) + rlr ReservationsListResult +} + +// 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 *ReservationsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReservationsListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rlr) + if err != nil { + return err + } + page.rlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ReservationsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ReservationsListResultPage) NotDone() bool { + return !page.rlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ReservationsListResultPage) Response() ReservationsListResult { + return page.rlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ReservationsListResultPage) Values() []Reservation { + if page.rlr.IsEmpty() { + return nil + } + return *page.rlr.Value +} + +// Creates a new instance of the ReservationsListResultPage type. +func NewReservationsListResultPage(cur ReservationsListResult, getNextPage func(context.Context, ReservationsListResult) (ReservationsListResult, error)) ReservationsListResultPage { + return ReservationsListResultPage{ + fn: getNextPage, + rlr: cur, + } +} + +// ReservationSummary the roll up count summary of reservations in each state +type ReservationSummary struct { + // SucceededCount - READ-ONLY; The number of reservation in Succeeded state + SucceededCount *float64 `json:"succeededCount,omitempty"` + // FailedCount - READ-ONLY; The number of reservation in Failed state + FailedCount *float64 `json:"failedCount,omitempty"` + // ExpiringCount - READ-ONLY; The number of reservation in Expiring state + ExpiringCount *float64 `json:"expiringCount,omitempty"` + // ExpiredCount - READ-ONLY; The number of reservation in Expired state + ExpiredCount *float64 `json:"expiredCount,omitempty"` + // PendingCount - READ-ONLY; The number of reservation in Pending state + PendingCount *float64 `json:"pendingCount,omitempty"` + // CancelledCount - READ-ONLY; The number of reservation in Cancelled state + CancelledCount *float64 `json:"cancelledCount,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReservationSummary. +func (rs ReservationSummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ReservationUtilizationAggregates the aggregate values of reservation utilization +type ReservationUtilizationAggregates struct { + // Grain - READ-ONLY; The grain of the aggregate + Grain *float64 `json:"grain,omitempty"` + // GrainUnit - READ-ONLY; The grain unit of the aggregate + GrainUnit *string `json:"grainUnit,omitempty"` + // Value - READ-ONLY; The aggregate value + Value *float64 `json:"value,omitempty"` + // ValueUnit - READ-ONLY; The aggregate value unit + ValueUnit *string `json:"valueUnit,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReservationUtilizationAggregates. +func (rua ReservationUtilizationAggregates) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + // Resource the Resource model definition. type Resource struct { // ID - READ-ONLY; Resource Id. @@ -5209,6 +5622,8 @@ type SubscriptionProperties struct { SkuID *string `json:"skuId,omitempty"` // SkuDescription - READ-ONLY; The sku description of the Azure plan for the subscription. SkuDescription *string `json:"skuDescription,omitempty"` + // SuspensionReasons - READ-ONLY; The suspension reason for a subscription. Applies only to subscriptions in Microsoft Online Services Program billing accounts. + SuspensionReasons *[]string `json:"suspensionReasons,omitempty"` } // MarshalJSON is the custom marshaler for SubscriptionProperties. @@ -5231,6 +5646,8 @@ type SubscriptionsListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; The list of billing subscriptions. Value *[]Subscription `json:"value,omitempty"` + // TotalCount - READ-ONLY; Total number of records. + TotalCount *float64 `json:"totalCount,omitempty"` // NextLink - READ-ONLY; The link (url) to the next page of results. NextLink *string `json:"nextLink,omitempty"` } @@ -5510,6 +5927,8 @@ type TransactionListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; The list of transactions. Value *[]Transaction `json:"value,omitempty"` + // TotalCount - READ-ONLY; Total number of records. + TotalCount *float64 `json:"totalCount,omitempty"` // NextLink - READ-ONLY; The link (url) to the next page of results. NextLink *string `json:"nextLink,omitempty"` } @@ -5672,7 +6091,7 @@ func NewTransactionListResultPage(cur TransactionListResult, getNextPage func(co // TransactionProperties the properties of a transaction. type TransactionProperties struct { - // Kind - The kind of transaction. Options are all or reservation. Possible values include: 'All', 'Reservation' + // Kind - The kind of transaction. Options are all or reservation. Possible values include: 'TransactionTypeKindAll', 'TransactionTypeKindReservation' Kind TransactionTypeKind `json:"kind,omitempty"` // Date - READ-ONLY; The date of transaction. Date *date.Time `json:"date,omitempty"` @@ -5811,7 +6230,7 @@ func (vpter ValidateProductTransferEligibilityResult) MarshalJSON() ([]byte, err // ValidateSubscriptionTransferEligibilityError error details of the transfer eligibility validation type ValidateSubscriptionTransferEligibilityError struct { - // Code - Error code for the product transfer validation. Possible values include: 'SubscriptionTransferValidationErrorCodeInvalidSource', 'SubscriptionTransferValidationErrorCodeSubscriptionNotActive', 'SubscriptionTransferValidationErrorCodeInsufficientPermissionOnSource', 'SubscriptionTransferValidationErrorCodeInsufficientPermissionOnDestination', 'SubscriptionTransferValidationErrorCodeDestinationBillingProfilePastDue', 'SubscriptionTransferValidationErrorCodeSubscriptionTypeNotSupported', 'SubscriptionTransferValidationErrorCodeCrossBillingAccountNotAllowed', 'SubscriptionTransferValidationErrorCodeNotAvailableForDestinationMarket' + // Code - Error code for the product transfer validation. Possible values include: 'SubscriptionTransferValidationErrorCodeBillingAccountInactive', 'SubscriptionTransferValidationErrorCodeCrossBillingAccountNotAllowed', 'SubscriptionTransferValidationErrorCodeDestinationBillingProfileInactive', 'SubscriptionTransferValidationErrorCodeDestinationBillingProfileNotFound', 'SubscriptionTransferValidationErrorCodeDestinationBillingProfilePastDue', 'SubscriptionTransferValidationErrorCodeDestinationInvoiceSectionInactive', 'SubscriptionTransferValidationErrorCodeDestinationInvoiceSectionNotFound', 'SubscriptionTransferValidationErrorCodeInsufficientPermissionOnDestination', 'SubscriptionTransferValidationErrorCodeInsufficientPermissionOnSource', 'SubscriptionTransferValidationErrorCodeInvalidDestination', 'SubscriptionTransferValidationErrorCodeInvalidSource', 'SubscriptionTransferValidationErrorCodeMarketplaceNotEnabledOnDestination', 'SubscriptionTransferValidationErrorCodeNotAvailableForDestinationMarket', 'SubscriptionTransferValidationErrorCodeProductInactive', 'SubscriptionTransferValidationErrorCodeProductNotFound', 'SubscriptionTransferValidationErrorCodeProductTypeNotSupported', 'SubscriptionTransferValidationErrorCodeSourceBillingProfilePastDue', 'SubscriptionTransferValidationErrorCodeSourceInvoiceSectionInactive', 'SubscriptionTransferValidationErrorCodeSubscriptionNotActive', 'SubscriptionTransferValidationErrorCodeSubscriptionTypeNotSupported' Code SubscriptionTransferValidationErrorCode `json:"code,omitempty"` // Message - The error message. Message *string `json:"message,omitempty"` diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/profiles.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/profiles.go index 816caa752745..40262548595f 100644 --- a/services/preview/billing/mgmt/2020-05-01-preview/billing/profiles.go +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/profiles.go @@ -67,7 +67,7 @@ func (client ProfilesClient) CreateOrUpdate(ctx context.Context, billingAccountN result, err = client.CreateOrUpdateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "CreateOrUpdate", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "CreateOrUpdate", result.Response(), "Failure sending request") return } @@ -100,6 +100,7 @@ func (client ProfilesClient) CreateOrUpdatePreparer(ctx context.Context, billing // http.Response Body if it receives an error. func (client ProfilesClient) CreateOrUpdateSender(req *http.Request) (future ProfilesCreateOrUpdateFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { return diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/reservations.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/reservations.go new file mode 100644 index 000000000000..c3d4845e7acf --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/reservations.go @@ -0,0 +1,301 @@ +package billing + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ReservationsClient is the billing client provides access to billing resources for Azure subscriptions. +type ReservationsClient struct { + BaseClient +} + +// NewReservationsClient creates an instance of the ReservationsClient client. +func NewReservationsClient(subscriptionID string) ReservationsClient { + return NewReservationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewReservationsClientWithBaseURI creates an instance of the ReservationsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewReservationsClientWithBaseURI(baseURI string, subscriptionID string) ReservationsClient { + return ReservationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByBillingAccount lists the reservations for a billing account and the roll up counts of reservations group by +// provisioning states. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// filter - may be used to filter by reservation properties. The filter supports 'eq', 'or', and 'and'. It does +// not currently support 'ne', 'gt', 'le', 'ge', or 'not'. +// orderby - may be used to sort order by reservation properties. +// refreshSummary - to indicate whether to refresh the roll up counts of the reservations group by provisioning +// states +// selectedState - the selected provisioning state +func (client ReservationsClient) ListByBillingAccount(ctx context.Context, billingAccountName string, filter string, orderby string, refreshSummary string, selectedState string) (result ReservationsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReservationsClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.rlr.Response.Response != nil { + sc = result.rlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingAccountNextResults + req, err := client.ListByBillingAccountPreparer(ctx, billingAccountName, filter, orderby, refreshSummary, selectedState) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ReservationsClient", "ListByBillingAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.rlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ReservationsClient", "ListByBillingAccount", resp, "Failure sending request") + return + } + + result.rlr, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ReservationsClient", "ListByBillingAccount", resp, "Failure responding to request") + return + } + if result.rlr.hasNextLink() && result.rlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByBillingAccountPreparer prepares the ListByBillingAccount request. +func (client ReservationsClient) ListByBillingAccountPreparer(ctx context.Context, billingAccountName string, filter string, orderby string, refreshSummary string, selectedState string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + if len(refreshSummary) > 0 { + queryParameters["refreshSummary"] = autorest.Encode("query", refreshSummary) + } + if len(selectedState) > 0 { + queryParameters["selectedState"] = autorest.Encode("query", selectedState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingAccountSender sends the ListByBillingAccount request. The method will close the +// http.Response Body if it receives an error. +func (client ReservationsClient) ListByBillingAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingAccountResponder handles the response to the ListByBillingAccount request. The method always +// closes the http.Response Body. +func (client ReservationsClient) ListByBillingAccountResponder(resp *http.Response) (result ReservationsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingAccountNextResults retrieves the next set of results, if any. +func (client ReservationsClient) listByBillingAccountNextResults(ctx context.Context, lastResults ReservationsListResult) (result ReservationsListResult, err error) { + req, err := lastResults.reservationsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.ReservationsClient", "listByBillingAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.ReservationsClient", "listByBillingAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ReservationsClient", "listByBillingAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client ReservationsClient) ListByBillingAccountComplete(ctx context.Context, billingAccountName string, filter string, orderby string, refreshSummary string, selectedState string) (result ReservationsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReservationsClient.ListByBillingAccount") + 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.ListByBillingAccount(ctx, billingAccountName, filter, orderby, refreshSummary, selectedState) + return +} + +// ListByBillingProfile lists the reservations for a billing profile and the roll up counts of reservations group by +// provisioning state. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// filter - may be used to filter by reservation properties. The filter supports 'eq', 'or', and 'and'. It does +// not currently support 'ne', 'gt', 'le', 'ge', or 'not'. +// orderby - may be used to sort order by reservation properties. +// refreshSummary - to indicate whether to refresh the roll up counts of the reservations group by provisioning +// state +// selectedState - the selected provisioning state +func (client ReservationsClient) ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, filter string, orderby string, refreshSummary string, selectedState string) (result ReservationsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReservationsClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.rlr.Response.Response != nil { + sc = result.rlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingProfileNextResults + req, err := client.ListByBillingProfilePreparer(ctx, billingAccountName, billingProfileName, filter, orderby, refreshSummary, selectedState) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ReservationsClient", "ListByBillingProfile", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.rlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ReservationsClient", "ListByBillingProfile", resp, "Failure sending request") + return + } + + result.rlr, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ReservationsClient", "ListByBillingProfile", resp, "Failure responding to request") + return + } + if result.rlr.hasNextLink() && result.rlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByBillingProfilePreparer prepares the ListByBillingProfile request. +func (client ReservationsClient) ListByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string, filter string, orderby string, refreshSummary string, selectedState string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + if len(refreshSummary) > 0 { + queryParameters["refreshSummary"] = autorest.Encode("query", refreshSummary) + } + if len(selectedState) > 0 { + queryParameters["selectedState"] = autorest.Encode("query", selectedState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/reservations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingProfileSender sends the ListByBillingProfile request. The method will close the +// http.Response Body if it receives an error. +func (client ReservationsClient) ListByBillingProfileSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingProfileResponder handles the response to the ListByBillingProfile request. The method always +// closes the http.Response Body. +func (client ReservationsClient) ListByBillingProfileResponder(resp *http.Response) (result ReservationsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingProfileNextResults retrieves the next set of results, if any. +func (client ReservationsClient) listByBillingProfileNextResults(ctx context.Context, lastResults ReservationsListResult) (result ReservationsListResult, err error) { + req, err := lastResults.reservationsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.ReservationsClient", "listByBillingProfileNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.ReservationsClient", "listByBillingProfileNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ReservationsClient", "listByBillingProfileNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingProfileComplete enumerates all values, automatically crossing page boundaries as required. +func (client ReservationsClient) ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string, filter string, orderby string, refreshSummary string, selectedState string) (result ReservationsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReservationsClient.ListByBillingProfile") + 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.ListByBillingProfile(ctx, billingAccountName, billingProfileName, filter, orderby, refreshSummary, selectedState) + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/subscriptions.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/subscriptions.go index 9b60d1abe316..e89a3602d4c9 100644 --- a/services/preview/billing/mgmt/2020-05-01-preview/billing/subscriptions.go +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/subscriptions.go @@ -609,7 +609,7 @@ func (client SubscriptionsClient) Move(ctx context.Context, billingAccountName s result, err = client.MoveSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "Move", nil, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "Move", result.Response(), "Failure sending request") return } @@ -642,6 +642,7 @@ func (client SubscriptionsClient) MovePreparer(ctx context.Context, billingAccou // http.Response Body if it receives an error. func (client SubscriptionsClient) MoveSender(req *http.Request) (future SubscriptionsMoveFuture, err error) { var resp *http.Response + future.FutureAPI = &azure.Future{} resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { return