diff --git a/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go b/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go index f5096010e396..35f842ad958b 100644 --- a/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go +++ b/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go @@ -19,9 +19,45 @@ package billingapi -import original "github.com/Azure/azure-sdk-for-go/services/preview/billing/mgmt/2018-03-01-preview/billing/billingapi" +import original "github.com/Azure/azure-sdk-for-go/services/preview/billing/mgmt/2018-11-01-preview/billing/billingapi" +type AccountBillingPermissionsClientAPI = original.AccountBillingPermissionsClientAPI +type AccountBillingRoleAssignmentClientAPI = original.AccountBillingRoleAssignmentClientAPI +type AccountBillingRoleDefinitionClientAPI = original.AccountBillingRoleDefinitionClientAPI +type AccountsClientAPI = original.AccountsClientAPI +type AccountsWithCreateInvoiceSectionPermissionClientAPI = original.AccountsWithCreateInvoiceSectionPermissionClientAPI +type AvailableBalanceByBillingProfileClientAPI = original.AvailableBalanceByBillingProfileClientAPI +type BaseClientAPI = original.BaseClientAPI +type DepartmentsByBillingAccountNameClientAPI = original.DepartmentsByBillingAccountNameClientAPI +type DepartmentsClientAPI = original.DepartmentsClientAPI +type EnrollmentAccountsByBillingAccountNameClientAPI = original.EnrollmentAccountsByBillingAccountNameClientAPI type EnrollmentAccountsClientAPI = original.EnrollmentAccountsClientAPI -type InvoicesClientAPI = original.InvoicesClientAPI +type InvoiceClientAPI = original.InvoiceClientAPI +type InvoicePricesheetClientAPI = original.InvoicePricesheetClientAPI +type InvoiceSectionBillingRoleAssignmentClientAPI = original.InvoiceSectionBillingRoleAssignmentClientAPI +type InvoiceSectionBillingRoleDefinitionClientAPI = original.InvoiceSectionBillingRoleDefinitionClientAPI +type InvoiceSectionsBillingPermissionsClientAPI = original.InvoiceSectionsBillingPermissionsClientAPI +type InvoiceSectionsByBillingAccountNameClientAPI = original.InvoiceSectionsByBillingAccountNameClientAPI +type InvoiceSectionsClientAPI = original.InvoiceSectionsClientAPI +type InvoiceSectionsWithCreateSubscriptionPermissionClientAPI = original.InvoiceSectionsWithCreateSubscriptionPermissionClientAPI +type InvoicesByBillingAccountClientAPI = original.InvoicesByBillingAccountClientAPI +type InvoicesByBillingProfileClientAPI = original.InvoicesByBillingProfileClientAPI type OperationsClientAPI = original.OperationsClientAPI -type PeriodsClientAPI = original.PeriodsClientAPI +type PaymentMethodsByBillingProfileClientAPI = original.PaymentMethodsByBillingProfileClientAPI +type PolicyClientAPI = original.PolicyClientAPI +type ProductsByBillingAccountClientAPI = original.ProductsByBillingAccountClientAPI +type ProductsByBillingSubscriptionsClientAPI = original.ProductsByBillingSubscriptionsClientAPI +type ProductsByInvoiceSectionClientAPI = original.ProductsByInvoiceSectionClientAPI +type ProductsClientAPI = original.ProductsClientAPI +type ProfileBillingPermissionsClientAPI = original.ProfileBillingPermissionsClientAPI +type ProfileBillingRoleAssignmentClientAPI = original.ProfileBillingRoleAssignmentClientAPI +type ProfileBillingRoleDefinitionClientAPI = original.ProfileBillingRoleDefinitionClientAPI +type ProfilesByBillingAccountNameClientAPI = original.ProfilesByBillingAccountNameClientAPI +type ProfilesClientAPI = original.ProfilesClientAPI +type PropertyClientAPI = original.PropertyClientAPI +type RecipientTransfersClientAPI = original.RecipientTransfersClientAPI +type SubscriptionClientAPI = original.SubscriptionClientAPI +type SubscriptionsByBillingProfileClientAPI = original.SubscriptionsByBillingProfileClientAPI +type SubscriptionsByInvoiceSectionClientAPI = original.SubscriptionsByInvoiceSectionClientAPI +type TransactionsByBillingAccountClientAPI = original.TransactionsByBillingAccountClientAPI +type TransfersClientAPI = original.TransfersClientAPI diff --git a/profiles/preview/preview/billing/mgmt/billing/models.go b/profiles/preview/preview/billing/mgmt/billing/models.go index b4430da31da9..ace6c14a63d1 100644 --- a/profiles/preview/preview/billing/mgmt/billing/models.go +++ b/profiles/preview/preview/billing/mgmt/billing/models.go @@ -22,51 +22,330 @@ package billing import ( "context" - original "github.com/Azure/azure-sdk-for-go/services/preview/billing/mgmt/2018-03-01-preview/billing" + original "github.com/Azure/azure-sdk-for-go/services/preview/billing/mgmt/2018-11-01-preview/billing" ) const ( DefaultBaseURI = original.DefaultBaseURI ) +type AccountType = original.AccountType + +const ( + AccountTypeEnrollment AccountType = original.AccountTypeEnrollment + AccountTypeOrganization AccountType = original.AccountTypeOrganization +) + +type EligibleProductType = original.EligibleProductType + +const ( + AzureReservation EligibleProductType = original.AzureReservation + DevTestAzureSubscription EligibleProductType = original.DevTestAzureSubscription + StandardAzureSubscription EligibleProductType = original.StandardAzureSubscription +) + +type Frequency = original.Frequency + +const ( + Monthly Frequency = original.Monthly + OneTime Frequency = original.OneTime + UsageBased Frequency = original.UsageBased +) + +type Kind = original.Kind + +const ( + CreditNote Kind = original.CreditNote + Invoice Kind = original.Invoice + Receipt Kind = original.Receipt + VoidNote Kind = original.VoidNote +) + +type PaymentMethodType = original.PaymentMethodType + +const ( + ChequeWire PaymentMethodType = original.ChequeWire + Credits PaymentMethodType = original.Credits +) + +type ProductStatusType = original.ProductStatusType + +const ( + Active ProductStatusType = original.Active + AutoRenew ProductStatusType = original.AutoRenew + Cancelled ProductStatusType = original.Cancelled + Disabled ProductStatusType = original.Disabled + Expired ProductStatusType = original.Expired + Expiring ProductStatusType = original.Expiring + Inactive ProductStatusType = original.Inactive + PastDue ProductStatusType = original.PastDue +) + +type ProductTransferStatus = original.ProductTransferStatus + +const ( + Completed ProductTransferStatus = original.Completed + Failed ProductTransferStatus = original.Failed + InProgress ProductTransferStatus = original.InProgress + NotStarted ProductTransferStatus = original.NotStarted +) + +type ProductType = original.ProductType + +const ( + ProductTypeAzureReservation ProductType = original.ProductTypeAzureReservation + ProductTypeAzureSubscription ProductType = original.ProductTypeAzureSubscription +) + +type ReservationType = original.ReservationType + +const ( + Purchase ReservationType = original.Purchase + UsageCharge ReservationType = original.UsageCharge +) + +type Status = original.Status + +const ( + StatusDue Status = original.StatusDue + StatusPaid Status = original.StatusPaid + StatusPastDue Status = original.StatusPastDue + StatusVoid Status = original.StatusVoid +) + +type SubscriptionStatusType = original.SubscriptionStatusType + +const ( + SubscriptionStatusTypeAbandoned SubscriptionStatusType = original.SubscriptionStatusTypeAbandoned + SubscriptionStatusTypeActive SubscriptionStatusType = original.SubscriptionStatusTypeActive + SubscriptionStatusTypeDeleted SubscriptionStatusType = original.SubscriptionStatusTypeDeleted + SubscriptionStatusTypeInactive SubscriptionStatusType = original.SubscriptionStatusTypeInactive + SubscriptionStatusTypeWarning SubscriptionStatusType = original.SubscriptionStatusTypeWarning +) + +type TransactionTypeKind = original.TransactionTypeKind + +const ( + All TransactionTypeKind = original.All + Reservation TransactionTypeKind = original.Reservation +) + +type TransferStatus = original.TransferStatus + +const ( + TransferStatusCanceled TransferStatus = original.TransferStatusCanceled + TransferStatusCompleted TransferStatus = original.TransferStatusCompleted + TransferStatusCompletedWithErrors TransferStatus = original.TransferStatusCompletedWithErrors + TransferStatusDeclined TransferStatus = original.TransferStatusDeclined + TransferStatusFailed TransferStatus = original.TransferStatusFailed + TransferStatusInProgress TransferStatus = original.TransferStatusInProgress + TransferStatusPending TransferStatus = original.TransferStatusPending +) + +type UpdateAutoRenew = original.UpdateAutoRenew + +const ( + False UpdateAutoRenew = original.False + True UpdateAutoRenew = original.True +) + +type AcceptTransferProperties = original.AcceptTransferProperties +type AcceptTransferRequest = original.AcceptTransferRequest +type Account = original.Account +type AccountBillingPermissionsClient = original.AccountBillingPermissionsClient +type AccountBillingRoleAssignmentClient = original.AccountBillingRoleAssignmentClient +type AccountBillingRoleDefinitionClient = original.AccountBillingRoleDefinitionClient +type AccountListResult = original.AccountListResult +type AccountProperties = original.AccountProperties +type AccountsClient = original.AccountsClient +type AccountsWithCreateInvoiceSectionPermissionClient = original.AccountsWithCreateInvoiceSectionPermissionClient +type Address = original.Address +type Amount = original.Amount +type AvailableBalance = original.AvailableBalance +type AvailableBalanceByBillingProfileClient = original.AvailableBalanceByBillingProfileClient +type AvailableBalanceProperties = original.AvailableBalanceProperties type BaseClient = original.BaseClient +type Department = original.Department +type DepartmentListResult = original.DepartmentListResult +type DepartmentProperties = original.DepartmentProperties +type DepartmentsByBillingAccountNameClient = original.DepartmentsByBillingAccountNameClient +type DepartmentsClient = original.DepartmentsClient +type DetailedTransferStatus = original.DetailedTransferStatus +type DownloadProperties = original.DownloadProperties type DownloadURL = original.DownloadURL +type EnabledAzureSKUs = original.EnabledAzureSKUs +type Enrollment = original.Enrollment type EnrollmentAccount = original.EnrollmentAccount +type EnrollmentAccountContext = original.EnrollmentAccountContext type EnrollmentAccountListResult = original.EnrollmentAccountListResult -type EnrollmentAccountListResultIterator = original.EnrollmentAccountListResultIterator -type EnrollmentAccountListResultPage = original.EnrollmentAccountListResultPage type EnrollmentAccountProperties = original.EnrollmentAccountProperties +type EnrollmentAccountsByBillingAccountNameClient = original.EnrollmentAccountsByBillingAccountNameClient type EnrollmentAccountsClient = original.EnrollmentAccountsClient +type EnrollmentPolicies = original.EnrollmentPolicies +type Error = original.Error type ErrorDetails = original.ErrorDetails type ErrorResponse = original.ErrorResponse -type Invoice = original.Invoice -type InvoiceProperties = original.InvoiceProperties -type InvoicesClient = original.InvoicesClient -type InvoicesListResult = original.InvoicesListResult -type InvoicesListResultIterator = original.InvoicesListResultIterator -type InvoicesListResultPage = original.InvoicesListResultPage +type InitiateTransferProperties = original.InitiateTransferProperties +type InitiateTransferRequest = original.InitiateTransferRequest +type InvoiceClient = original.InvoiceClient +type InvoiceListResult = original.InvoiceListResult +type InvoicePricesheetClient = original.InvoicePricesheetClient +type InvoicePricesheetDownloadFuture = original.InvoicePricesheetDownloadFuture +type InvoiceSection = original.InvoiceSection +type InvoiceSectionBillingRoleAssignmentClient = original.InvoiceSectionBillingRoleAssignmentClient +type InvoiceSectionBillingRoleDefinitionClient = original.InvoiceSectionBillingRoleDefinitionClient +type InvoiceSectionListResult = original.InvoiceSectionListResult +type InvoiceSectionProperties = original.InvoiceSectionProperties +type InvoiceSectionsBillingPermissionsClient = original.InvoiceSectionsBillingPermissionsClient +type InvoiceSectionsByBillingAccountNameClient = original.InvoiceSectionsByBillingAccountNameClient +type InvoiceSectionsClient = original.InvoiceSectionsClient +type InvoiceSectionsCreateFuture = original.InvoiceSectionsCreateFuture +type InvoiceSectionsUpdateFuture = original.InvoiceSectionsUpdateFuture +type InvoiceSectionsWithCreateSubscriptionPermissionClient = original.InvoiceSectionsWithCreateSubscriptionPermissionClient +type InvoiceSummary = original.InvoiceSummary +type InvoiceSummaryProperties = original.InvoiceSummaryProperties +type InvoicesByBillingAccountClient = original.InvoicesByBillingAccountClient +type InvoicesByBillingProfileClient = original.InvoicesByBillingProfileClient type Operation = original.Operation type OperationDisplay = original.OperationDisplay type OperationListResult = original.OperationListResult type OperationListResultIterator = original.OperationListResultIterator type OperationListResultPage = original.OperationListResultPage +type OperationStatus = original.OperationStatus type OperationsClient = original.OperationsClient -type Period = original.Period -type PeriodProperties = original.PeriodProperties -type PeriodsClient = original.PeriodsClient -type PeriodsListResult = original.PeriodsListResult -type PeriodsListResultIterator = original.PeriodsListResultIterator -type PeriodsListResultPage = original.PeriodsListResultPage +type PaymentMethod = original.PaymentMethod +type PaymentMethodProperties = original.PaymentMethodProperties +type PaymentMethodsByBillingProfileClient = original.PaymentMethodsByBillingProfileClient +type PaymentMethodsListResult = original.PaymentMethodsListResult +type PaymentMethodsListResultIterator = original.PaymentMethodsListResultIterator +type PaymentMethodsListResultPage = original.PaymentMethodsListResultPage +type PaymentProperties = original.PaymentProperties +type Permissions = original.Permissions +type PermissionsListResult = original.PermissionsListResult +type Policy = original.Policy +type PolicyClient = original.PolicyClient +type PolicyProperties = original.PolicyProperties +type ProductDetails = original.ProductDetails +type ProductSummary = original.ProductSummary +type ProductSummaryProperties = original.ProductSummaryProperties +type ProductsByBillingAccountClient = original.ProductsByBillingAccountClient +type ProductsByBillingSubscriptionsClient = original.ProductsByBillingSubscriptionsClient +type ProductsByInvoiceSectionClient = original.ProductsByInvoiceSectionClient +type ProductsClient = original.ProductsClient +type ProductsListResult = original.ProductsListResult +type ProductsListResultIterator = original.ProductsListResultIterator +type ProductsListResultPage = original.ProductsListResultPage +type Profile = original.Profile +type ProfileBillingPermissionsClient = original.ProfileBillingPermissionsClient +type ProfileBillingRoleAssignmentClient = original.ProfileBillingRoleAssignmentClient +type ProfileBillingRoleDefinitionClient = original.ProfileBillingRoleDefinitionClient +type ProfileListResult = original.ProfileListResult +type ProfileProperties = original.ProfileProperties +type ProfilesByBillingAccountNameClient = original.ProfilesByBillingAccountNameClient +type ProfilesClient = original.ProfilesClient +type ProfilesUpdateFuture = original.ProfilesUpdateFuture +type Property = original.Property +type PropertyClient = original.PropertyClient +type RecipientTransferDetails = original.RecipientTransferDetails +type RecipientTransferDetailsListResult = original.RecipientTransferDetailsListResult +type RecipientTransferDetailsListResultIterator = original.RecipientTransferDetailsListResultIterator +type RecipientTransferDetailsListResultPage = original.RecipientTransferDetailsListResultPage +type RecipientTransferProperties = original.RecipientTransferProperties +type RecipientTransfersClient = original.RecipientTransfersClient type Resource = original.Resource +type RoleAssignment = original.RoleAssignment +type RoleAssignmentListResult = original.RoleAssignmentListResult +type RoleAssignmentPayload = original.RoleAssignmentPayload +type RoleAssignmentProperties = original.RoleAssignmentProperties +type RoleDefinition = original.RoleDefinition +type RoleDefinitionListResult = original.RoleDefinitionListResult +type RoleDefinitionProperties = original.RoleDefinitionProperties +type SubscriptionClient = original.SubscriptionClient +type SubscriptionProperties = original.SubscriptionProperties +type SubscriptionSummary = original.SubscriptionSummary +type SubscriptionTransferFuture = original.SubscriptionTransferFuture +type SubscriptionsByBillingProfileClient = original.SubscriptionsByBillingProfileClient +type SubscriptionsByInvoiceSectionClient = original.SubscriptionsByInvoiceSectionClient +type SubscriptionsListResult = original.SubscriptionsListResult +type SubscriptionsListResultIterator = original.SubscriptionsListResultIterator +type SubscriptionsListResultPage = original.SubscriptionsListResultPage +type TransactionsByBillingAccountClient = original.TransactionsByBillingAccountClient +type TransactionsListResult = original.TransactionsListResult +type TransactionsListResultIterator = original.TransactionsListResultIterator +type TransactionsListResultPage = original.TransactionsListResultPage +type TransactionsSummary = original.TransactionsSummary +type TransactionsSummaryProperties = original.TransactionsSummaryProperties +type TransferBillingSubscriptionRequest = original.TransferBillingSubscriptionRequest +type TransferBillingSubscriptionRequestProperties = original.TransferBillingSubscriptionRequestProperties +type TransferBillingSubscriptionResult = original.TransferBillingSubscriptionResult +type TransferBillingSubscriptionResultProperties = original.TransferBillingSubscriptionResultProperties +type TransferDetails = original.TransferDetails +type TransferDetailsListResult = original.TransferDetailsListResult +type TransferDetailsListResultIterator = original.TransferDetailsListResultIterator +type TransferDetailsListResultPage = original.TransferDetailsListResultPage +type TransferProductRequestProperties = original.TransferProductRequestProperties +type TransferProperties = original.TransferProperties +type TransfersClient = original.TransfersClient +type UpdateAutoRenewOperationSummary = original.UpdateAutoRenewOperationSummary +type UpdateAutoRenewOperationSummaryProperties = original.UpdateAutoRenewOperationSummaryProperties +type UpdateAutoRenewRequest = original.UpdateAutoRenewRequest func New(subscriptionID string) BaseClient { return original.New(subscriptionID) } -func NewEnrollmentAccountListResultIterator(page EnrollmentAccountListResultPage) EnrollmentAccountListResultIterator { - return original.NewEnrollmentAccountListResultIterator(page) +func NewAccountBillingPermissionsClient(subscriptionID string) AccountBillingPermissionsClient { + return original.NewAccountBillingPermissionsClient(subscriptionID) +} +func NewAccountBillingPermissionsClientWithBaseURI(baseURI string, subscriptionID string) AccountBillingPermissionsClient { + return original.NewAccountBillingPermissionsClientWithBaseURI(baseURI, subscriptionID) +} +func NewAccountBillingRoleAssignmentClient(subscriptionID string) AccountBillingRoleAssignmentClient { + return original.NewAccountBillingRoleAssignmentClient(subscriptionID) +} +func NewAccountBillingRoleAssignmentClientWithBaseURI(baseURI string, subscriptionID string) AccountBillingRoleAssignmentClient { + return original.NewAccountBillingRoleAssignmentClientWithBaseURI(baseURI, subscriptionID) +} +func NewAccountBillingRoleDefinitionClient(subscriptionID string) AccountBillingRoleDefinitionClient { + return original.NewAccountBillingRoleDefinitionClient(subscriptionID) +} +func NewAccountBillingRoleDefinitionClientWithBaseURI(baseURI string, subscriptionID string) AccountBillingRoleDefinitionClient { + return original.NewAccountBillingRoleDefinitionClientWithBaseURI(baseURI, subscriptionID) +} +func NewAccountsClient(subscriptionID string) AccountsClient { + return original.NewAccountsClient(subscriptionID) +} +func NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) AccountsClient { + return original.NewAccountsClientWithBaseURI(baseURI, subscriptionID) +} +func NewAccountsWithCreateInvoiceSectionPermissionClient(subscriptionID string) AccountsWithCreateInvoiceSectionPermissionClient { + return original.NewAccountsWithCreateInvoiceSectionPermissionClient(subscriptionID) } -func NewEnrollmentAccountListResultPage(getNextPage func(context.Context, EnrollmentAccountListResult) (EnrollmentAccountListResult, error)) EnrollmentAccountListResultPage { - return original.NewEnrollmentAccountListResultPage(getNextPage) +func NewAccountsWithCreateInvoiceSectionPermissionClientWithBaseURI(baseURI string, subscriptionID string) AccountsWithCreateInvoiceSectionPermissionClient { + return original.NewAccountsWithCreateInvoiceSectionPermissionClientWithBaseURI(baseURI, subscriptionID) +} +func NewAvailableBalanceByBillingProfileClient(subscriptionID string) AvailableBalanceByBillingProfileClient { + return original.NewAvailableBalanceByBillingProfileClient(subscriptionID) +} +func NewAvailableBalanceByBillingProfileClientWithBaseURI(baseURI string, subscriptionID string) AvailableBalanceByBillingProfileClient { + return original.NewAvailableBalanceByBillingProfileClientWithBaseURI(baseURI, subscriptionID) +} +func NewDepartmentsByBillingAccountNameClient(subscriptionID string) DepartmentsByBillingAccountNameClient { + return original.NewDepartmentsByBillingAccountNameClient(subscriptionID) +} +func NewDepartmentsByBillingAccountNameClientWithBaseURI(baseURI string, subscriptionID string) DepartmentsByBillingAccountNameClient { + return original.NewDepartmentsByBillingAccountNameClientWithBaseURI(baseURI, subscriptionID) +} +func NewDepartmentsClient(subscriptionID string) DepartmentsClient { + return original.NewDepartmentsClient(subscriptionID) +} +func NewDepartmentsClientWithBaseURI(baseURI string, subscriptionID string) DepartmentsClient { + return original.NewDepartmentsClientWithBaseURI(baseURI, subscriptionID) +} +func NewEnrollmentAccountsByBillingAccountNameClient(subscriptionID string) EnrollmentAccountsByBillingAccountNameClient { + return original.NewEnrollmentAccountsByBillingAccountNameClient(subscriptionID) +} +func NewEnrollmentAccountsByBillingAccountNameClientWithBaseURI(baseURI string, subscriptionID string) EnrollmentAccountsByBillingAccountNameClient { + return original.NewEnrollmentAccountsByBillingAccountNameClientWithBaseURI(baseURI, subscriptionID) } func NewEnrollmentAccountsClient(subscriptionID string) EnrollmentAccountsClient { return original.NewEnrollmentAccountsClient(subscriptionID) @@ -74,17 +353,65 @@ func NewEnrollmentAccountsClient(subscriptionID string) EnrollmentAccountsClient func NewEnrollmentAccountsClientWithBaseURI(baseURI string, subscriptionID string) EnrollmentAccountsClient { return original.NewEnrollmentAccountsClientWithBaseURI(baseURI, subscriptionID) } -func NewInvoicesClient(subscriptionID string) InvoicesClient { - return original.NewInvoicesClient(subscriptionID) +func NewInvoiceClient(subscriptionID string) InvoiceClient { + return original.NewInvoiceClient(subscriptionID) +} +func NewInvoiceClientWithBaseURI(baseURI string, subscriptionID string) InvoiceClient { + return original.NewInvoiceClientWithBaseURI(baseURI, subscriptionID) } -func NewInvoicesClientWithBaseURI(baseURI string, subscriptionID string) InvoicesClient { - return original.NewInvoicesClientWithBaseURI(baseURI, subscriptionID) +func NewInvoicePricesheetClient(subscriptionID string) InvoicePricesheetClient { + return original.NewInvoicePricesheetClient(subscriptionID) } -func NewInvoicesListResultIterator(page InvoicesListResultPage) InvoicesListResultIterator { - return original.NewInvoicesListResultIterator(page) +func NewInvoicePricesheetClientWithBaseURI(baseURI string, subscriptionID string) InvoicePricesheetClient { + return original.NewInvoicePricesheetClientWithBaseURI(baseURI, subscriptionID) } -func NewInvoicesListResultPage(getNextPage func(context.Context, InvoicesListResult) (InvoicesListResult, error)) InvoicesListResultPage { - return original.NewInvoicesListResultPage(getNextPage) +func NewInvoiceSectionBillingRoleAssignmentClient(subscriptionID string) InvoiceSectionBillingRoleAssignmentClient { + return original.NewInvoiceSectionBillingRoleAssignmentClient(subscriptionID) +} +func NewInvoiceSectionBillingRoleAssignmentClientWithBaseURI(baseURI string, subscriptionID string) InvoiceSectionBillingRoleAssignmentClient { + return original.NewInvoiceSectionBillingRoleAssignmentClientWithBaseURI(baseURI, subscriptionID) +} +func NewInvoiceSectionBillingRoleDefinitionClient(subscriptionID string) InvoiceSectionBillingRoleDefinitionClient { + return original.NewInvoiceSectionBillingRoleDefinitionClient(subscriptionID) +} +func NewInvoiceSectionBillingRoleDefinitionClientWithBaseURI(baseURI string, subscriptionID string) InvoiceSectionBillingRoleDefinitionClient { + return original.NewInvoiceSectionBillingRoleDefinitionClientWithBaseURI(baseURI, subscriptionID) +} +func NewInvoiceSectionsBillingPermissionsClient(subscriptionID string) InvoiceSectionsBillingPermissionsClient { + return original.NewInvoiceSectionsBillingPermissionsClient(subscriptionID) +} +func NewInvoiceSectionsBillingPermissionsClientWithBaseURI(baseURI string, subscriptionID string) InvoiceSectionsBillingPermissionsClient { + return original.NewInvoiceSectionsBillingPermissionsClientWithBaseURI(baseURI, subscriptionID) +} +func NewInvoiceSectionsByBillingAccountNameClient(subscriptionID string) InvoiceSectionsByBillingAccountNameClient { + return original.NewInvoiceSectionsByBillingAccountNameClient(subscriptionID) +} +func NewInvoiceSectionsByBillingAccountNameClientWithBaseURI(baseURI string, subscriptionID string) InvoiceSectionsByBillingAccountNameClient { + return original.NewInvoiceSectionsByBillingAccountNameClientWithBaseURI(baseURI, subscriptionID) +} +func NewInvoiceSectionsClient(subscriptionID string) InvoiceSectionsClient { + return original.NewInvoiceSectionsClient(subscriptionID) +} +func NewInvoiceSectionsClientWithBaseURI(baseURI string, subscriptionID string) InvoiceSectionsClient { + return original.NewInvoiceSectionsClientWithBaseURI(baseURI, subscriptionID) +} +func NewInvoiceSectionsWithCreateSubscriptionPermissionClient(subscriptionID string) InvoiceSectionsWithCreateSubscriptionPermissionClient { + return original.NewInvoiceSectionsWithCreateSubscriptionPermissionClient(subscriptionID) +} +func NewInvoiceSectionsWithCreateSubscriptionPermissionClientWithBaseURI(baseURI string, subscriptionID string) InvoiceSectionsWithCreateSubscriptionPermissionClient { + return original.NewInvoiceSectionsWithCreateSubscriptionPermissionClientWithBaseURI(baseURI, subscriptionID) +} +func NewInvoicesByBillingAccountClient(subscriptionID string) InvoicesByBillingAccountClient { + return original.NewInvoicesByBillingAccountClient(subscriptionID) +} +func NewInvoicesByBillingAccountClientWithBaseURI(baseURI string, subscriptionID string) InvoicesByBillingAccountClient { + return original.NewInvoicesByBillingAccountClientWithBaseURI(baseURI, subscriptionID) +} +func NewInvoicesByBillingProfileClient(subscriptionID string) InvoicesByBillingProfileClient { + return original.NewInvoicesByBillingProfileClient(subscriptionID) +} +func NewInvoicesByBillingProfileClientWithBaseURI(baseURI string, subscriptionID string) InvoicesByBillingProfileClient { + return original.NewInvoicesByBillingProfileClientWithBaseURI(baseURI, subscriptionID) } func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { return original.NewOperationListResultIterator(page) @@ -98,21 +425,195 @@ func NewOperationsClient(subscriptionID string) OperationsClient { func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) } -func NewPeriodsClient(subscriptionID string) PeriodsClient { - return original.NewPeriodsClient(subscriptionID) +func NewPaymentMethodsByBillingProfileClient(subscriptionID string) PaymentMethodsByBillingProfileClient { + return original.NewPaymentMethodsByBillingProfileClient(subscriptionID) +} +func NewPaymentMethodsByBillingProfileClientWithBaseURI(baseURI string, subscriptionID string) PaymentMethodsByBillingProfileClient { + return original.NewPaymentMethodsByBillingProfileClientWithBaseURI(baseURI, subscriptionID) +} +func NewPaymentMethodsListResultIterator(page PaymentMethodsListResultPage) PaymentMethodsListResultIterator { + return original.NewPaymentMethodsListResultIterator(page) +} +func NewPaymentMethodsListResultPage(getNextPage func(context.Context, PaymentMethodsListResult) (PaymentMethodsListResult, error)) PaymentMethodsListResultPage { + return original.NewPaymentMethodsListResultPage(getNextPage) +} +func NewPolicyClient(subscriptionID string) PolicyClient { + return original.NewPolicyClient(subscriptionID) +} +func NewPolicyClientWithBaseURI(baseURI string, subscriptionID string) PolicyClient { + return original.NewPolicyClientWithBaseURI(baseURI, subscriptionID) +} +func NewProductsByBillingAccountClient(subscriptionID string) ProductsByBillingAccountClient { + return original.NewProductsByBillingAccountClient(subscriptionID) +} +func NewProductsByBillingAccountClientWithBaseURI(baseURI string, subscriptionID string) ProductsByBillingAccountClient { + return original.NewProductsByBillingAccountClientWithBaseURI(baseURI, subscriptionID) +} +func NewProductsByBillingSubscriptionsClient(subscriptionID string) ProductsByBillingSubscriptionsClient { + return original.NewProductsByBillingSubscriptionsClient(subscriptionID) +} +func NewProductsByBillingSubscriptionsClientWithBaseURI(baseURI string, subscriptionID string) ProductsByBillingSubscriptionsClient { + return original.NewProductsByBillingSubscriptionsClientWithBaseURI(baseURI, subscriptionID) +} +func NewProductsByInvoiceSectionClient(subscriptionID string) ProductsByInvoiceSectionClient { + return original.NewProductsByInvoiceSectionClient(subscriptionID) +} +func NewProductsByInvoiceSectionClientWithBaseURI(baseURI string, subscriptionID string) ProductsByInvoiceSectionClient { + return original.NewProductsByInvoiceSectionClientWithBaseURI(baseURI, subscriptionID) +} +func NewProductsClient(subscriptionID string) ProductsClient { + return original.NewProductsClient(subscriptionID) +} +func NewProductsClientWithBaseURI(baseURI string, subscriptionID string) ProductsClient { + return original.NewProductsClientWithBaseURI(baseURI, subscriptionID) +} +func NewProductsListResultIterator(page ProductsListResultPage) ProductsListResultIterator { + return original.NewProductsListResultIterator(page) +} +func NewProductsListResultPage(getNextPage func(context.Context, ProductsListResult) (ProductsListResult, error)) ProductsListResultPage { + return original.NewProductsListResultPage(getNextPage) +} +func NewProfileBillingPermissionsClient(subscriptionID string) ProfileBillingPermissionsClient { + return original.NewProfileBillingPermissionsClient(subscriptionID) +} +func NewProfileBillingPermissionsClientWithBaseURI(baseURI string, subscriptionID string) ProfileBillingPermissionsClient { + return original.NewProfileBillingPermissionsClientWithBaseURI(baseURI, subscriptionID) +} +func NewProfileBillingRoleAssignmentClient(subscriptionID string) ProfileBillingRoleAssignmentClient { + return original.NewProfileBillingRoleAssignmentClient(subscriptionID) +} +func NewProfileBillingRoleAssignmentClientWithBaseURI(baseURI string, subscriptionID string) ProfileBillingRoleAssignmentClient { + return original.NewProfileBillingRoleAssignmentClientWithBaseURI(baseURI, subscriptionID) +} +func NewProfileBillingRoleDefinitionClient(subscriptionID string) ProfileBillingRoleDefinitionClient { + return original.NewProfileBillingRoleDefinitionClient(subscriptionID) +} +func NewProfileBillingRoleDefinitionClientWithBaseURI(baseURI string, subscriptionID string) ProfileBillingRoleDefinitionClient { + return original.NewProfileBillingRoleDefinitionClientWithBaseURI(baseURI, subscriptionID) +} +func NewProfilesByBillingAccountNameClient(subscriptionID string) ProfilesByBillingAccountNameClient { + return original.NewProfilesByBillingAccountNameClient(subscriptionID) } -func NewPeriodsClientWithBaseURI(baseURI string, subscriptionID string) PeriodsClient { - return original.NewPeriodsClientWithBaseURI(baseURI, subscriptionID) +func NewProfilesByBillingAccountNameClientWithBaseURI(baseURI string, subscriptionID string) ProfilesByBillingAccountNameClient { + return original.NewProfilesByBillingAccountNameClientWithBaseURI(baseURI, subscriptionID) } -func NewPeriodsListResultIterator(page PeriodsListResultPage) PeriodsListResultIterator { - return original.NewPeriodsListResultIterator(page) +func NewProfilesClient(subscriptionID string) ProfilesClient { + return original.NewProfilesClient(subscriptionID) } -func NewPeriodsListResultPage(getNextPage func(context.Context, PeriodsListResult) (PeriodsListResult, error)) PeriodsListResultPage { - return original.NewPeriodsListResultPage(getNextPage) +func NewProfilesClientWithBaseURI(baseURI string, subscriptionID string) ProfilesClient { + return original.NewProfilesClientWithBaseURI(baseURI, subscriptionID) +} +func NewPropertyClient(subscriptionID string) PropertyClient { + return original.NewPropertyClient(subscriptionID) +} +func NewPropertyClientWithBaseURI(baseURI string, subscriptionID string) PropertyClient { + return original.NewPropertyClientWithBaseURI(baseURI, subscriptionID) +} +func NewRecipientTransferDetailsListResultIterator(page RecipientTransferDetailsListResultPage) RecipientTransferDetailsListResultIterator { + return original.NewRecipientTransferDetailsListResultIterator(page) +} +func NewRecipientTransferDetailsListResultPage(getNextPage func(context.Context, RecipientTransferDetailsListResult) (RecipientTransferDetailsListResult, error)) RecipientTransferDetailsListResultPage { + return original.NewRecipientTransferDetailsListResultPage(getNextPage) +} +func NewRecipientTransfersClient(subscriptionID string) RecipientTransfersClient { + return original.NewRecipientTransfersClient(subscriptionID) +} +func NewRecipientTransfersClientWithBaseURI(baseURI string, subscriptionID string) RecipientTransfersClient { + return original.NewRecipientTransfersClientWithBaseURI(baseURI, subscriptionID) +} +func NewSubscriptionClient(subscriptionID string) SubscriptionClient { + return original.NewSubscriptionClient(subscriptionID) +} +func NewSubscriptionClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionClient { + return original.NewSubscriptionClientWithBaseURI(baseURI, subscriptionID) +} +func NewSubscriptionsByBillingProfileClient(subscriptionID string) SubscriptionsByBillingProfileClient { + return original.NewSubscriptionsByBillingProfileClient(subscriptionID) +} +func NewSubscriptionsByBillingProfileClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionsByBillingProfileClient { + return original.NewSubscriptionsByBillingProfileClientWithBaseURI(baseURI, subscriptionID) +} +func NewSubscriptionsByInvoiceSectionClient(subscriptionID string) SubscriptionsByInvoiceSectionClient { + return original.NewSubscriptionsByInvoiceSectionClient(subscriptionID) +} +func NewSubscriptionsByInvoiceSectionClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionsByInvoiceSectionClient { + return original.NewSubscriptionsByInvoiceSectionClientWithBaseURI(baseURI, subscriptionID) +} +func NewSubscriptionsListResultIterator(page SubscriptionsListResultPage) SubscriptionsListResultIterator { + return original.NewSubscriptionsListResultIterator(page) +} +func NewSubscriptionsListResultPage(getNextPage func(context.Context, SubscriptionsListResult) (SubscriptionsListResult, error)) SubscriptionsListResultPage { + return original.NewSubscriptionsListResultPage(getNextPage) +} +func NewTransactionsByBillingAccountClient(subscriptionID string) TransactionsByBillingAccountClient { + return original.NewTransactionsByBillingAccountClient(subscriptionID) +} +func NewTransactionsByBillingAccountClientWithBaseURI(baseURI string, subscriptionID string) TransactionsByBillingAccountClient { + return original.NewTransactionsByBillingAccountClientWithBaseURI(baseURI, subscriptionID) +} +func NewTransactionsListResultIterator(page TransactionsListResultPage) TransactionsListResultIterator { + return original.NewTransactionsListResultIterator(page) +} +func NewTransactionsListResultPage(getNextPage func(context.Context, TransactionsListResult) (TransactionsListResult, error)) TransactionsListResultPage { + return original.NewTransactionsListResultPage(getNextPage) +} +func NewTransferDetailsListResultIterator(page TransferDetailsListResultPage) TransferDetailsListResultIterator { + return original.NewTransferDetailsListResultIterator(page) +} +func NewTransferDetailsListResultPage(getNextPage func(context.Context, TransferDetailsListResult) (TransferDetailsListResult, error)) TransferDetailsListResultPage { + return original.NewTransferDetailsListResultPage(getNextPage) +} +func NewTransfersClient(subscriptionID string) TransfersClient { + return original.NewTransfersClient(subscriptionID) +} +func NewTransfersClientWithBaseURI(baseURI string, subscriptionID string) TransfersClient { + return original.NewTransfersClientWithBaseURI(baseURI, subscriptionID) } func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { return original.NewWithBaseURI(baseURI, subscriptionID) } +func PossibleAccountTypeValues() []AccountType { + return original.PossibleAccountTypeValues() +} +func PossibleEligibleProductTypeValues() []EligibleProductType { + return original.PossibleEligibleProductTypeValues() +} +func PossibleFrequencyValues() []Frequency { + return original.PossibleFrequencyValues() +} +func PossibleKindValues() []Kind { + return original.PossibleKindValues() +} +func PossiblePaymentMethodTypeValues() []PaymentMethodType { + return original.PossiblePaymentMethodTypeValues() +} +func PossibleProductStatusTypeValues() []ProductStatusType { + return original.PossibleProductStatusTypeValues() +} +func PossibleProductTransferStatusValues() []ProductTransferStatus { + return original.PossibleProductTransferStatusValues() +} +func PossibleProductTypeValues() []ProductType { + return original.PossibleProductTypeValues() +} +func PossibleReservationTypeValues() []ReservationType { + return original.PossibleReservationTypeValues() +} +func PossibleStatusValues() []Status { + return original.PossibleStatusValues() +} +func PossibleSubscriptionStatusTypeValues() []SubscriptionStatusType { + return original.PossibleSubscriptionStatusTypeValues() +} +func PossibleTransactionTypeKindValues() []TransactionTypeKind { + return original.PossibleTransactionTypeKindValues() +} +func PossibleTransferStatusValues() []TransferStatus { + return original.PossibleTransferStatusValues() +} +func PossibleUpdateAutoRenewValues() []UpdateAutoRenew { + return original.PossibleUpdateAutoRenewValues() +} func UserAgent() string { return original.UserAgent() + " profiles/preview" } diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/accountbillingpermissions.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/accountbillingpermissions.go new file mode 100644 index 000000000000..aa36084c2101 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/accountbillingpermissions.go @@ -0,0 +1,115 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AccountBillingPermissionsClient is the billing client provides access to billing resources for Azure subscriptions. +type AccountBillingPermissionsClient struct { + BaseClient +} + +// NewAccountBillingPermissionsClient creates an instance of the AccountBillingPermissionsClient client. +func NewAccountBillingPermissionsClient(subscriptionID string) AccountBillingPermissionsClient { + return NewAccountBillingPermissionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccountBillingPermissionsClientWithBaseURI creates an instance of the AccountBillingPermissionsClient client. +func NewAccountBillingPermissionsClientWithBaseURI(baseURI string, subscriptionID string) AccountBillingPermissionsClient { + return AccountBillingPermissionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all billingPermissions for the caller has for a billing account. +// Parameters: +// billingAccountName - billing Account Id. +func (client AccountBillingPermissionsClient) List(ctx context.Context, billingAccountName string) (result PermissionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountBillingPermissionsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountBillingPermissionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.AccountBillingPermissionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountBillingPermissionsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AccountBillingPermissionsClient) ListPreparer(ctx context.Context, billingAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/providers/Microsoft.Billing/billingPermissions", 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 AccountBillingPermissionsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 AccountBillingPermissionsClient) ListResponder(resp *http.Response) (result PermissionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/accountbillingroleassignment.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/accountbillingroleassignment.go new file mode 100644 index 000000000000..e11d422ca37b --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/accountbillingroleassignment.go @@ -0,0 +1,346 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AccountBillingRoleAssignmentClient is the billing client provides access to billing resources for Azure +// subscriptions. +type AccountBillingRoleAssignmentClient struct { + BaseClient +} + +// NewAccountBillingRoleAssignmentClient creates an instance of the AccountBillingRoleAssignmentClient client. +func NewAccountBillingRoleAssignmentClient(subscriptionID string) AccountBillingRoleAssignmentClient { + return NewAccountBillingRoleAssignmentClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccountBillingRoleAssignmentClientWithBaseURI creates an instance of the AccountBillingRoleAssignmentClient +// client. +func NewAccountBillingRoleAssignmentClientWithBaseURI(baseURI string, subscriptionID string) AccountBillingRoleAssignmentClient { + return AccountBillingRoleAssignmentClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Add the operation to add a role assignment to a billing account. +// Parameters: +// billingAccountName - billing Account Id. +// parameters - parameters supplied to add a role assignment. +func (client AccountBillingRoleAssignmentClient) Add(ctx context.Context, billingAccountName string, parameters RoleAssignmentPayload) (result RoleAssignmentListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountBillingRoleAssignmentClient.Add") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.AddPreparer(ctx, billingAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountBillingRoleAssignmentClient", "Add", nil, "Failure preparing request") + return + } + + resp, err := client.AddSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.AccountBillingRoleAssignmentClient", "Add", resp, "Failure sending request") + return + } + + result, err = client.AddResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountBillingRoleAssignmentClient", "Add", resp, "Failure responding to request") + } + + return +} + +// AddPreparer prepares the Add request. +func (client AccountBillingRoleAssignmentClient) AddPreparer(ctx context.Context, billingAccountName string, parameters RoleAssignmentPayload) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/providers/Microsoft.Billing/createBillingRoleAssignment", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AddSender sends the Add request. The method will close the +// http.Response Body if it receives an error. +func (client AccountBillingRoleAssignmentClient) AddSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// AddResponder handles the response to the Add request. The method always +// closes the http.Response Body. +func (client AccountBillingRoleAssignmentClient) AddResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the role assignment on this billing account +// Parameters: +// billingAccountName - billing Account Id. +// billingRoleAssignmentName - role assignment id. +func (client AccountBillingRoleAssignmentClient) Delete(ctx context.Context, billingAccountName string, billingRoleAssignmentName string) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountBillingRoleAssignmentClient.Delete") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, billingAccountName, billingRoleAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountBillingRoleAssignmentClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.AccountBillingRoleAssignmentClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountBillingRoleAssignmentClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AccountBillingRoleAssignmentClient) DeletePreparer(ctx context.Context, billingAccountName string, billingRoleAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingRoleAssignmentName": autorest.Encode("path", billingRoleAssignmentName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/providers/Microsoft.Billing/billingRoleAssignments/{billingRoleAssignmentName}", 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 AccountBillingRoleAssignmentClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 AccountBillingRoleAssignmentClient) DeleteResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the role assignment for the caller +// Parameters: +// billingAccountName - billing Account Id. +// billingRoleAssignmentName - role assignment id. +func (client AccountBillingRoleAssignmentClient) Get(ctx context.Context, billingAccountName string, billingRoleAssignmentName string) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountBillingRoleAssignmentClient.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, billingRoleAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountBillingRoleAssignmentClient", "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.AccountBillingRoleAssignmentClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountBillingRoleAssignmentClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AccountBillingRoleAssignmentClient) GetPreparer(ctx context.Context, billingAccountName string, billingRoleAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingRoleAssignmentName": autorest.Encode("path", billingRoleAssignmentName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/providers/Microsoft.Billing/billingRoleAssignments/{billingRoleAssignmentName}", 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 AccountBillingRoleAssignmentClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 AccountBillingRoleAssignmentClient) GetResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get the role assignments on the Billing Account +// Parameters: +// billingAccountName - billing Account Id. +func (client AccountBillingRoleAssignmentClient) List(ctx context.Context, billingAccountName string) (result RoleAssignmentListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountBillingRoleAssignmentClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountBillingRoleAssignmentClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.AccountBillingRoleAssignmentClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountBillingRoleAssignmentClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AccountBillingRoleAssignmentClient) ListPreparer(ctx context.Context, billingAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/providers/Microsoft.Billing/billingRoleAssignments", 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 AccountBillingRoleAssignmentClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 AccountBillingRoleAssignmentClient) ListResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/accountbillingroledefinition.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/accountbillingroledefinition.go new file mode 100644 index 000000000000..8f8d3bbd6aa6 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/accountbillingroledefinition.go @@ -0,0 +1,193 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AccountBillingRoleDefinitionClient is the billing client provides access to billing resources for Azure +// subscriptions. +type AccountBillingRoleDefinitionClient struct { + BaseClient +} + +// NewAccountBillingRoleDefinitionClient creates an instance of the AccountBillingRoleDefinitionClient client. +func NewAccountBillingRoleDefinitionClient(subscriptionID string) AccountBillingRoleDefinitionClient { + return NewAccountBillingRoleDefinitionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccountBillingRoleDefinitionClientWithBaseURI creates an instance of the AccountBillingRoleDefinitionClient +// client. +func NewAccountBillingRoleDefinitionClientWithBaseURI(baseURI string, subscriptionID string) AccountBillingRoleDefinitionClient { + return AccountBillingRoleDefinitionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the role definition for a role +// Parameters: +// billingAccountName - billing Account Id. +// billingRoleDefinitionName - role definition id. +func (client AccountBillingRoleDefinitionClient) Get(ctx context.Context, billingAccountName string, billingRoleDefinitionName string) (result RoleDefinition, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountBillingRoleDefinitionClient.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, billingRoleDefinitionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountBillingRoleDefinitionClient", "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.AccountBillingRoleDefinitionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountBillingRoleDefinitionClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AccountBillingRoleDefinitionClient) GetPreparer(ctx context.Context, billingAccountName string, billingRoleDefinitionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingRoleDefinitionName": autorest.Encode("path", billingRoleDefinitionName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/providers/Microsoft.Billing/billingRoleDefinitions/{billingRoleDefinitionName}", 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 AccountBillingRoleDefinitionClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 AccountBillingRoleDefinitionClient) GetResponder(resp *http.Response) (result RoleDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the role definition for a billing account +// Parameters: +// billingAccountName - billing Account Id. +func (client AccountBillingRoleDefinitionClient) List(ctx context.Context, billingAccountName string) (result RoleDefinitionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountBillingRoleDefinitionClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountBillingRoleDefinitionClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.AccountBillingRoleDefinitionClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountBillingRoleDefinitionClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AccountBillingRoleDefinitionClient) ListPreparer(ctx context.Context, billingAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/providers/Microsoft.Billing/billingRoleDefinitions", 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 AccountBillingRoleDefinitionClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 AccountBillingRoleDefinitionClient) ListResponder(resp *http.Response) (result RoleDefinitionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} 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 new file mode 100644 index 000000000000..605447199594 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/accounts.go @@ -0,0 +1,192 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AccountsClient is the billing client provides access to billing resources for Azure subscriptions. +type AccountsClient struct { + BaseClient +} + +// NewAccountsClient creates an instance of the AccountsClient client. +func NewAccountsClient(subscriptionID string) AccountsClient { + return NewAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccountsClientWithBaseURI creates an instance of the AccountsClient client. +func NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) AccountsClient { + return AccountsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the billing account by id. +// Parameters: +// billingAccountName - billing Account Id. +// expand - may be used to expand the invoiceSections and billingProfiles. +func (client AccountsClient) Get(ctx context.Context, billingAccountName string, expand string) (result Account, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.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, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "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.AccountsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AccountsClient) GetPreparer(ctx context.Context, billingAccountName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}", 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 AccountsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 AccountsClient) GetResponder(resp *http.Response) (result Account, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all billing accounts for a user which he has access to. +// Parameters: +// expand - may be used to expand the invoiceSections and billingProfiles. +func (client AccountsClient) List(ctx context.Context, expand string) (result AccountListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AccountsClient) ListPreparer(ctx context.Context, expand string) (*http.Request, error) { + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Billing/billingAccounts"), + 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 AccountsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 AccountsClient) ListResponder(resp *http.Response) (result AccountListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/accountswithcreateinvoicesectionpermission.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/accountswithcreateinvoicesectionpermission.go new file mode 100644 index 000000000000..e853a87853f7 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/accountswithcreateinvoicesectionpermission.go @@ -0,0 +1,117 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AccountsWithCreateInvoiceSectionPermissionClient is the billing client provides access to billing resources for +// Azure subscriptions. +type AccountsWithCreateInvoiceSectionPermissionClient struct { + BaseClient +} + +// NewAccountsWithCreateInvoiceSectionPermissionClient creates an instance of the +// AccountsWithCreateInvoiceSectionPermissionClient client. +func NewAccountsWithCreateInvoiceSectionPermissionClient(subscriptionID string) AccountsWithCreateInvoiceSectionPermissionClient { + return NewAccountsWithCreateInvoiceSectionPermissionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccountsWithCreateInvoiceSectionPermissionClientWithBaseURI creates an instance of the +// AccountsWithCreateInvoiceSectionPermissionClient client. +func NewAccountsWithCreateInvoiceSectionPermissionClientWithBaseURI(baseURI string, subscriptionID string) AccountsWithCreateInvoiceSectionPermissionClient { + return AccountsWithCreateInvoiceSectionPermissionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all billing accounts with create invoiceSection permission for a user. +// Parameters: +// expand - may be used to expand the invoiceSections and billingProfiles. +func (client AccountsWithCreateInvoiceSectionPermissionClient) List(ctx context.Context, expand string) (result AccountListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsWithCreateInvoiceSectionPermissionClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsWithCreateInvoiceSectionPermissionClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.AccountsWithCreateInvoiceSectionPermissionClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsWithCreateInvoiceSectionPermissionClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AccountsWithCreateInvoiceSectionPermissionClient) ListPreparer(ctx context.Context, expand string) (*http.Request, error) { + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Billing/listBillingAccountsWithCreateInvoiceSectionPermission"), + 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 AccountsWithCreateInvoiceSectionPermissionClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 AccountsWithCreateInvoiceSectionPermissionClient) ListResponder(resp *http.Response) (result AccountListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/availablebalancebybillingprofile.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/availablebalancebybillingprofile.go new file mode 100644 index 000000000000..b31b3c665215 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/availablebalancebybillingprofile.go @@ -0,0 +1,119 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AvailableBalanceByBillingProfileClient is the billing client provides access to billing resources for Azure +// subscriptions. +type AvailableBalanceByBillingProfileClient struct { + BaseClient +} + +// NewAvailableBalanceByBillingProfileClient creates an instance of the AvailableBalanceByBillingProfileClient client. +func NewAvailableBalanceByBillingProfileClient(subscriptionID string) AvailableBalanceByBillingProfileClient { + return NewAvailableBalanceByBillingProfileClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAvailableBalanceByBillingProfileClientWithBaseURI creates an instance of the +// AvailableBalanceByBillingProfileClient client. +func NewAvailableBalanceByBillingProfileClientWithBaseURI(baseURI string, subscriptionID string) AvailableBalanceByBillingProfileClient { + return AvailableBalanceByBillingProfileClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get the latest available credit balance for a given billingAccountName and billingProfileName. +// Parameters: +// billingAccountName - billing Account Id. +// billingProfileName - billing Profile Id. +func (client AvailableBalanceByBillingProfileClient) Get(ctx context.Context, billingAccountName string, billingProfileName string) (result AvailableBalance, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AvailableBalanceByBillingProfileClient.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, billingProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AvailableBalanceByBillingProfileClient", "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.AvailableBalanceByBillingProfileClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AvailableBalanceByBillingProfileClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AvailableBalanceByBillingProfileClient) GetPreparer(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 = "2018-11-01-preview" + 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}/availableBalance/default", 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 AvailableBalanceByBillingProfileClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 AvailableBalanceByBillingProfileClient) GetResponder(resp *http.Response) (result AvailableBalance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/billingapi/interfaces.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/billingapi/interfaces.go new file mode 100644 index 000000000000..280a25ff4195 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/billingapi/interfaces.go @@ -0,0 +1,330 @@ +package billingapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/billing/mgmt/2018-11-01-preview/billing" +) + +// BaseClientAPI contains the set of methods on the BaseClient type. +type BaseClientAPI interface { + TransactionsByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, startDate string, endDate string, filter string) (result billing.TransactionsListResult, err error) + UpdateAutoRenewForBillingAccount(ctx context.Context, billingAccountName string, productName string, body billing.UpdateAutoRenewRequest) (result billing.UpdateAutoRenewOperationSummary, err error) + UpdateAutoRenewForInvoiceSection(ctx context.Context, billingAccountName string, invoiceSectionName string, productName string, body billing.UpdateAutoRenewRequest) (result billing.UpdateAutoRenewOperationSummary, err error) +} + +var _ BaseClientAPI = (*billing.BaseClient)(nil) + +// AccountsClientAPI contains the set of methods on the AccountsClient type. +type AccountsClientAPI interface { + Get(ctx context.Context, billingAccountName string, expand string) (result billing.Account, err error) + List(ctx context.Context, expand string) (result billing.AccountListResult, err error) +} + +var _ AccountsClientAPI = (*billing.AccountsClient)(nil) + +// AccountsWithCreateInvoiceSectionPermissionClientAPI contains the set of methods on the AccountsWithCreateInvoiceSectionPermissionClient type. +type AccountsWithCreateInvoiceSectionPermissionClientAPI interface { + List(ctx context.Context, expand string) (result billing.AccountListResult, err error) +} + +var _ AccountsWithCreateInvoiceSectionPermissionClientAPI = (*billing.AccountsWithCreateInvoiceSectionPermissionClient)(nil) + +// AvailableBalanceByBillingProfileClientAPI contains the set of methods on the AvailableBalanceByBillingProfileClient type. +type AvailableBalanceByBillingProfileClientAPI interface { + Get(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.AvailableBalance, err error) +} + +var _ AvailableBalanceByBillingProfileClientAPI = (*billing.AvailableBalanceByBillingProfileClient)(nil) + +// PaymentMethodsByBillingProfileClientAPI contains the set of methods on the PaymentMethodsByBillingProfileClient type. +type PaymentMethodsByBillingProfileClientAPI interface { + List(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.PaymentMethodsListResultPage, err error) +} + +var _ PaymentMethodsByBillingProfileClientAPI = (*billing.PaymentMethodsByBillingProfileClient)(nil) + +// ProfilesByBillingAccountNameClientAPI contains the set of methods on the ProfilesByBillingAccountNameClient type. +type ProfilesByBillingAccountNameClientAPI interface { + List(ctx context.Context, billingAccountName string, expand string) (result billing.ProfileListResult, err error) +} + +var _ ProfilesByBillingAccountNameClientAPI = (*billing.ProfilesByBillingAccountNameClient)(nil) + +// ProfilesClientAPI contains the set of methods on the ProfilesClient type. +type ProfilesClientAPI interface { + Get(ctx context.Context, billingAccountName string, billingProfileName string, expand string) (result billing.Profile, err error) + Update(ctx context.Context, billingAccountName string, billingProfileName string, parameters billing.Profile) (result billing.ProfilesUpdateFuture, err error) +} + +var _ ProfilesClientAPI = (*billing.ProfilesClient)(nil) + +// InvoiceSectionsByBillingAccountNameClientAPI contains the set of methods on the InvoiceSectionsByBillingAccountNameClient type. +type InvoiceSectionsByBillingAccountNameClientAPI interface { + List(ctx context.Context, billingAccountName string, expand string) (result billing.InvoiceSectionListResult, err error) +} + +var _ InvoiceSectionsByBillingAccountNameClientAPI = (*billing.InvoiceSectionsByBillingAccountNameClient)(nil) + +// InvoiceSectionsClientAPI contains the set of methods on the InvoiceSectionsClient type. +type InvoiceSectionsClientAPI interface { + Create(ctx context.Context, billingAccountName string, parameters billing.InvoiceSectionProperties) (result billing.InvoiceSectionsCreateFuture, err error) + Get(ctx context.Context, billingAccountName string, invoiceSectionName string, expand string) (result billing.InvoiceSection, err error) + Update(ctx context.Context, billingAccountName string, invoiceSectionName string, parameters billing.InvoiceSection) (result billing.InvoiceSectionsUpdateFuture, err error) +} + +var _ InvoiceSectionsClientAPI = (*billing.InvoiceSectionsClient)(nil) + +// InvoiceSectionsWithCreateSubscriptionPermissionClientAPI contains the set of methods on the InvoiceSectionsWithCreateSubscriptionPermissionClient type. +type InvoiceSectionsWithCreateSubscriptionPermissionClientAPI interface { + List(ctx context.Context, billingAccountName string, expand string) (result billing.InvoiceSectionListResult, err error) +} + +var _ InvoiceSectionsWithCreateSubscriptionPermissionClientAPI = (*billing.InvoiceSectionsWithCreateSubscriptionPermissionClient)(nil) + +// DepartmentsByBillingAccountNameClientAPI contains the set of methods on the DepartmentsByBillingAccountNameClient type. +type DepartmentsByBillingAccountNameClientAPI interface { + List(ctx context.Context, billingAccountName string, expand string, filter string) (result billing.DepartmentListResult, err error) +} + +var _ DepartmentsByBillingAccountNameClientAPI = (*billing.DepartmentsByBillingAccountNameClient)(nil) + +// DepartmentsClientAPI contains the set of methods on the DepartmentsClient type. +type DepartmentsClientAPI interface { + Get(ctx context.Context, billingAccountName string, departmentName string, expand string, filter string) (result billing.Department, err error) +} + +var _ DepartmentsClientAPI = (*billing.DepartmentsClient)(nil) + +// EnrollmentAccountsByBillingAccountNameClientAPI contains the set of methods on the EnrollmentAccountsByBillingAccountNameClient type. +type EnrollmentAccountsByBillingAccountNameClientAPI interface { + List(ctx context.Context, billingAccountName string, expand string, filter string) (result billing.EnrollmentAccountListResult, err error) +} + +var _ EnrollmentAccountsByBillingAccountNameClientAPI = (*billing.EnrollmentAccountsByBillingAccountNameClient)(nil) + +// EnrollmentAccountsClientAPI contains the set of methods on the EnrollmentAccountsClient type. +type EnrollmentAccountsClientAPI interface { + GetByEnrollmentAccountAccountID(ctx context.Context, billingAccountName string, enrollmentAccountName string, expand string, filter string) (result billing.EnrollmentAccount, err error) +} + +var _ EnrollmentAccountsClientAPI = (*billing.EnrollmentAccountsClient)(nil) + +// InvoicesByBillingAccountClientAPI contains the set of methods on the InvoicesByBillingAccountClient type. +type InvoicesByBillingAccountClientAPI interface { + List(ctx context.Context, billingAccountName string, periodStartDate string, periodEndDate string) (result billing.InvoiceListResult, err error) +} + +var _ InvoicesByBillingAccountClientAPI = (*billing.InvoicesByBillingAccountClient)(nil) + +// InvoicePricesheetClientAPI contains the set of methods on the InvoicePricesheetClient type. +type InvoicePricesheetClientAPI interface { + Download(ctx context.Context, billingAccountName string, invoiceName string) (result billing.InvoicePricesheetDownloadFuture, err error) +} + +var _ InvoicePricesheetClientAPI = (*billing.InvoicePricesheetClient)(nil) + +// InvoicesByBillingProfileClientAPI contains the set of methods on the InvoicesByBillingProfileClient type. +type InvoicesByBillingProfileClientAPI interface { + List(ctx context.Context, billingAccountName string, billingProfileName string, periodStartDate string, periodEndDate string) (result billing.InvoiceListResult, err error) +} + +var _ InvoicesByBillingProfileClientAPI = (*billing.InvoicesByBillingProfileClient)(nil) + +// InvoiceClientAPI contains the set of methods on the InvoiceClient type. +type InvoiceClientAPI interface { + Get(ctx context.Context, billingAccountName string, billingProfileName string, invoiceName string) (result billing.InvoiceSummary, err error) +} + +var _ InvoiceClientAPI = (*billing.InvoiceClient)(nil) + +// ProductsByBillingSubscriptionsClientAPI contains the set of methods on the ProductsByBillingSubscriptionsClient type. +type ProductsByBillingSubscriptionsClientAPI interface { + List(ctx context.Context, billingAccountName string) (result billing.SubscriptionsListResultPage, err error) +} + +var _ ProductsByBillingSubscriptionsClientAPI = (*billing.ProductsByBillingSubscriptionsClient)(nil) + +// SubscriptionsByBillingProfileClientAPI contains the set of methods on the SubscriptionsByBillingProfileClient type. +type SubscriptionsByBillingProfileClientAPI interface { + List(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.SubscriptionsListResult, err error) +} + +var _ SubscriptionsByBillingProfileClientAPI = (*billing.SubscriptionsByBillingProfileClient)(nil) + +// SubscriptionsByInvoiceSectionClientAPI contains the set of methods on the SubscriptionsByInvoiceSectionClient type. +type SubscriptionsByInvoiceSectionClientAPI interface { + List(ctx context.Context, billingAccountName string, invoiceSectionName string) (result billing.SubscriptionsListResult, err error) +} + +var _ SubscriptionsByInvoiceSectionClientAPI = (*billing.SubscriptionsByInvoiceSectionClient)(nil) + +// SubscriptionClientAPI contains the set of methods on the SubscriptionClient type. +type SubscriptionClientAPI interface { + Get(ctx context.Context, billingAccountName string, invoiceSectionName string, billingSubscriptionName string) (result billing.SubscriptionSummary, err error) + Transfer(ctx context.Context, billingAccountName string, invoiceSectionName string, billingSubscriptionName string, parameters billing.TransferBillingSubscriptionRequestProperties) (result billing.SubscriptionTransferFuture, err error) +} + +var _ SubscriptionClientAPI = (*billing.SubscriptionClient)(nil) + +// ProductsByBillingAccountClientAPI contains the set of methods on the ProductsByBillingAccountClient type. +type ProductsByBillingAccountClientAPI interface { + List(ctx context.Context, billingAccountName string, filter string) (result billing.ProductsListResultPage, err error) +} + +var _ ProductsByBillingAccountClientAPI = (*billing.ProductsByBillingAccountClient)(nil) + +// ProductsByInvoiceSectionClientAPI contains the set of methods on the ProductsByInvoiceSectionClient type. +type ProductsByInvoiceSectionClientAPI interface { + List(ctx context.Context, billingAccountName string, invoiceSectionName string, filter string) (result billing.ProductsListResult, err error) +} + +var _ ProductsByInvoiceSectionClientAPI = (*billing.ProductsByInvoiceSectionClient)(nil) + +// ProductsClientAPI contains the set of methods on the ProductsClient type. +type ProductsClientAPI interface { + Get(ctx context.Context, billingAccountName string, invoiceSectionName string, productName string) (result billing.ProductSummary, err error) + Transfer(ctx context.Context, billingAccountName string, invoiceSectionName string, productName string, parameters billing.TransferProductRequestProperties) (result billing.ProductSummary, err error) +} + +var _ ProductsClientAPI = (*billing.ProductsClient)(nil) + +// TransactionsByBillingAccountClientAPI contains the set of methods on the TransactionsByBillingAccountClient type. +type TransactionsByBillingAccountClientAPI interface { + List(ctx context.Context, billingAccountName string, startDate string, endDate string, filter string) (result billing.TransactionsListResultPage, err error) +} + +var _ TransactionsByBillingAccountClientAPI = (*billing.TransactionsByBillingAccountClient)(nil) + +// PolicyClientAPI contains the set of methods on the PolicyClient type. +type PolicyClientAPI interface { + GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.Policy, err error) + Update(ctx context.Context, billingAccountName string, billingProfileName string, parameters billing.Policy) (result billing.Policy, err error) +} + +var _ PolicyClientAPI = (*billing.PolicyClient)(nil) + +// PropertyClientAPI contains the set of methods on the PropertyClient type. +type PropertyClientAPI interface { + Get(ctx context.Context) (result billing.Property, err error) +} + +var _ PropertyClientAPI = (*billing.PropertyClient)(nil) + +// TransfersClientAPI contains the set of methods on the TransfersClient type. +type TransfersClientAPI interface { + Cancel(ctx context.Context, billingAccountName string, invoiceSectionName string, transferName string) (result billing.TransferDetails, err error) + Get(ctx context.Context, billingAccountName string, invoiceSectionName string, transferName string) (result billing.TransferDetails, err error) + Initiate(ctx context.Context, billingAccountName string, invoiceSectionName string, body billing.InitiateTransferRequest) (result billing.TransferDetails, err error) + List(ctx context.Context, billingAccountName string, invoiceSectionName string) (result billing.TransferDetailsListResultPage, err error) +} + +var _ TransfersClientAPI = (*billing.TransfersClient)(nil) + +// RecipientTransfersClientAPI contains the set of methods on the RecipientTransfersClient type. +type RecipientTransfersClientAPI interface { + Accept(ctx context.Context, transferName string, body billing.AcceptTransferRequest) (result billing.RecipientTransferDetails, err error) + Decline(ctx context.Context, transferName string) (result billing.RecipientTransferDetails, err error) + Get(ctx context.Context, transferName string) (result billing.RecipientTransferDetails, err error) + List(ctx context.Context) (result billing.RecipientTransferDetailsListResultPage, err error) +} + +var _ RecipientTransfersClientAPI = (*billing.RecipientTransfersClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result billing.OperationListResultPage, err error) +} + +var _ OperationsClientAPI = (*billing.OperationsClient)(nil) + +// AccountBillingPermissionsClientAPI contains the set of methods on the AccountBillingPermissionsClient type. +type AccountBillingPermissionsClientAPI interface { + List(ctx context.Context, billingAccountName string) (result billing.PermissionsListResult, err error) +} + +var _ AccountBillingPermissionsClientAPI = (*billing.AccountBillingPermissionsClient)(nil) + +// InvoiceSectionsBillingPermissionsClientAPI contains the set of methods on the InvoiceSectionsBillingPermissionsClient type. +type InvoiceSectionsBillingPermissionsClientAPI interface { + List(ctx context.Context, billingAccountName string, invoiceSectionName string) (result billing.PermissionsListResult, err error) +} + +var _ InvoiceSectionsBillingPermissionsClientAPI = (*billing.InvoiceSectionsBillingPermissionsClient)(nil) + +// ProfileBillingPermissionsClientAPI contains the set of methods on the ProfileBillingPermissionsClient type. +type ProfileBillingPermissionsClientAPI interface { + List(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.PermissionsListResult, err error) +} + +var _ ProfileBillingPermissionsClientAPI = (*billing.ProfileBillingPermissionsClient)(nil) + +// AccountBillingRoleDefinitionClientAPI contains the set of methods on the AccountBillingRoleDefinitionClient type. +type AccountBillingRoleDefinitionClientAPI interface { + Get(ctx context.Context, billingAccountName string, billingRoleDefinitionName string) (result billing.RoleDefinition, err error) + List(ctx context.Context, billingAccountName string) (result billing.RoleDefinitionListResult, err error) +} + +var _ AccountBillingRoleDefinitionClientAPI = (*billing.AccountBillingRoleDefinitionClient)(nil) + +// InvoiceSectionBillingRoleDefinitionClientAPI contains the set of methods on the InvoiceSectionBillingRoleDefinitionClient type. +type InvoiceSectionBillingRoleDefinitionClientAPI interface { + Get(ctx context.Context, billingAccountName string, invoiceSectionName string, billingRoleDefinitionName string) (result billing.RoleDefinition, err error) + List(ctx context.Context, billingAccountName string, invoiceSectionName string) (result billing.RoleDefinitionListResult, err error) +} + +var _ InvoiceSectionBillingRoleDefinitionClientAPI = (*billing.InvoiceSectionBillingRoleDefinitionClient)(nil) + +// ProfileBillingRoleDefinitionClientAPI contains the set of methods on the ProfileBillingRoleDefinitionClient type. +type ProfileBillingRoleDefinitionClientAPI interface { + Get(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleDefinitionName string) (result billing.RoleDefinition, err error) + List(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.RoleDefinitionListResult, err error) +} + +var _ ProfileBillingRoleDefinitionClientAPI = (*billing.ProfileBillingRoleDefinitionClient)(nil) + +// AccountBillingRoleAssignmentClientAPI contains the set of methods on the AccountBillingRoleAssignmentClient type. +type AccountBillingRoleAssignmentClientAPI interface { + Add(ctx context.Context, billingAccountName string, parameters billing.RoleAssignmentPayload) (result billing.RoleAssignmentListResult, err error) + Delete(ctx context.Context, billingAccountName string, billingRoleAssignmentName string) (result billing.RoleAssignment, err error) + Get(ctx context.Context, billingAccountName string, billingRoleAssignmentName string) (result billing.RoleAssignment, err error) + List(ctx context.Context, billingAccountName string) (result billing.RoleAssignmentListResult, err error) +} + +var _ AccountBillingRoleAssignmentClientAPI = (*billing.AccountBillingRoleAssignmentClient)(nil) + +// InvoiceSectionBillingRoleAssignmentClientAPI contains the set of methods on the InvoiceSectionBillingRoleAssignmentClient type. +type InvoiceSectionBillingRoleAssignmentClientAPI interface { + Add(ctx context.Context, billingAccountName string, invoiceSectionName string, parameters billing.RoleAssignmentPayload) (result billing.RoleAssignmentListResult, err error) + Delete(ctx context.Context, billingAccountName string, invoiceSectionName string, billingRoleAssignmentName string) (result billing.RoleAssignment, err error) + Get(ctx context.Context, billingAccountName string, invoiceSectionName string, billingRoleAssignmentName string) (result billing.RoleAssignment, err error) + List(ctx context.Context, billingAccountName string, invoiceSectionName string) (result billing.RoleAssignmentListResult, err error) +} + +var _ InvoiceSectionBillingRoleAssignmentClientAPI = (*billing.InvoiceSectionBillingRoleAssignmentClient)(nil) + +// ProfileBillingRoleAssignmentClientAPI contains the set of methods on the ProfileBillingRoleAssignmentClient type. +type ProfileBillingRoleAssignmentClientAPI interface { + Add(ctx context.Context, billingAccountName string, billingProfileName string, parameters billing.RoleAssignmentPayload) (result billing.RoleAssignmentListResult, err error) + Delete(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string) (result billing.RoleAssignment, err error) + Get(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string) (result billing.RoleAssignment, err error) + List(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.RoleAssignmentListResult, err error) +} + +var _ ProfileBillingRoleAssignmentClientAPI = (*billing.ProfileBillingRoleAssignmentClient)(nil) diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/client.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/client.go new file mode 100644 index 000000000000..c554b2040e5a --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/client.go @@ -0,0 +1,301 @@ +// Package billing implements the Azure ARM Billing service API version 2018-11-01-preview. +// +// Billing client provides access to billing resources for Azure subscriptions. +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +const ( + // DefaultBaseURI is the default URI used for the service Billing + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Billing. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} + +// TransactionsByBillingProfile lists the transactions by billingProfileName for given start date and end date. +// Parameters: +// billingAccountName - billing Account Id. +// billingProfileName - billing Profile Id. +// startDate - start date +// endDate - end date +// filter - may be used to filter by transaction kind. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and +// 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key +// and value is separated by a colon (:). +func (client BaseClient) TransactionsByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, startDate string, endDate string, filter string) (result TransactionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.TransactionsByBillingProfile") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.TransactionsByBillingProfilePreparer(ctx, billingAccountName, billingProfileName, startDate, endDate, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.BaseClient", "TransactionsByBillingProfile", nil, "Failure preparing request") + return + } + + resp, err := client.TransactionsByBillingProfileSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.BaseClient", "TransactionsByBillingProfile", resp, "Failure sending request") + return + } + + result, err = client.TransactionsByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.BaseClient", "TransactionsByBillingProfile", resp, "Failure responding to request") + } + + return +} + +// TransactionsByBillingProfilePreparer prepares the TransactionsByBillingProfile request. +func (client BaseClient) TransactionsByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string, startDate string, endDate string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "endDate": autorest.Encode("query", endDate), + "startDate": autorest.Encode("query", startDate), + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/transactions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// TransactionsByBillingProfileSender sends the TransactionsByBillingProfile request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) TransactionsByBillingProfileSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// TransactionsByBillingProfileResponder handles the response to the TransactionsByBillingProfile request. The method always +// closes the http.Response Body. +func (client BaseClient) TransactionsByBillingProfileResponder(resp *http.Response) (result TransactionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateAutoRenewForBillingAccount cancel product by product id +// Parameters: +// billingAccountName - billing Account Id. +// productName - invoice Id. +// body - update auto renew request parameters. +func (client BaseClient) UpdateAutoRenewForBillingAccount(ctx context.Context, billingAccountName string, productName string, body UpdateAutoRenewRequest) (result UpdateAutoRenewOperationSummary, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.UpdateAutoRenewForBillingAccount") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdateAutoRenewForBillingAccountPreparer(ctx, billingAccountName, productName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.BaseClient", "UpdateAutoRenewForBillingAccount", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateAutoRenewForBillingAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.BaseClient", "UpdateAutoRenewForBillingAccount", resp, "Failure sending request") + return + } + + result, err = client.UpdateAutoRenewForBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.BaseClient", "UpdateAutoRenewForBillingAccount", resp, "Failure responding to request") + } + + return +} + +// UpdateAutoRenewForBillingAccountPreparer prepares the UpdateAutoRenewForBillingAccount request. +func (client BaseClient) UpdateAutoRenewForBillingAccountPreparer(ctx context.Context, billingAccountName string, productName string, body UpdateAutoRenewRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "productName": autorest.Encode("path", productName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/updateAutoRenew", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateAutoRenewForBillingAccountSender sends the UpdateAutoRenewForBillingAccount request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) UpdateAutoRenewForBillingAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UpdateAutoRenewForBillingAccountResponder handles the response to the UpdateAutoRenewForBillingAccount request. The method always +// closes the http.Response Body. +func (client BaseClient) UpdateAutoRenewForBillingAccountResponder(resp *http.Response) (result UpdateAutoRenewOperationSummary, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateAutoRenewForInvoiceSection cancel auto renew for product by product id +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +// productName - invoice Id. +// body - update auto renew request parameters. +func (client BaseClient) UpdateAutoRenewForInvoiceSection(ctx context.Context, billingAccountName string, invoiceSectionName string, productName string, body UpdateAutoRenewRequest) (result UpdateAutoRenewOperationSummary, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.UpdateAutoRenewForInvoiceSection") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdateAutoRenewForInvoiceSectionPreparer(ctx, billingAccountName, invoiceSectionName, productName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.BaseClient", "UpdateAutoRenewForInvoiceSection", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateAutoRenewForInvoiceSectionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.BaseClient", "UpdateAutoRenewForInvoiceSection", resp, "Failure sending request") + return + } + + result, err = client.UpdateAutoRenewForInvoiceSectionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.BaseClient", "UpdateAutoRenewForInvoiceSection", resp, "Failure responding to request") + } + + return +} + +// UpdateAutoRenewForInvoiceSectionPreparer prepares the UpdateAutoRenewForInvoiceSection request. +func (client BaseClient) UpdateAutoRenewForInvoiceSectionPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, productName string, body UpdateAutoRenewRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + "productName": autorest.Encode("path", productName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/products/{productName}/updateAutoRenew", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateAutoRenewForInvoiceSectionSender sends the UpdateAutoRenewForInvoiceSection request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) UpdateAutoRenewForInvoiceSectionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UpdateAutoRenewForInvoiceSectionResponder handles the response to the UpdateAutoRenewForInvoiceSection request. The method always +// closes the http.Response Body. +func (client BaseClient) UpdateAutoRenewForInvoiceSectionResponder(resp *http.Response) (result UpdateAutoRenewOperationSummary, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/departments.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/departments.go new file mode 100644 index 000000000000..056ca42c5013 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/departments.go @@ -0,0 +1,126 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DepartmentsClient is the billing client provides access to billing resources for Azure subscriptions. +type DepartmentsClient struct { + BaseClient +} + +// NewDepartmentsClient creates an instance of the DepartmentsClient client. +func NewDepartmentsClient(subscriptionID string) DepartmentsClient { + return NewDepartmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDepartmentsClientWithBaseURI creates an instance of the DepartmentsClient client. +func NewDepartmentsClientWithBaseURI(baseURI string, subscriptionID string) DepartmentsClient { + return DepartmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the department by id. +// Parameters: +// billingAccountName - billing Account Id. +// departmentName - department Id. +// expand - may be used to expand the enrollmentAccounts. +// filter - the filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', +// 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). +func (client DepartmentsClient) Get(ctx context.Context, billingAccountName string, departmentName string, expand string, filter string) (result Department, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DepartmentsClient.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, departmentName, expand, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.DepartmentsClient", "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.DepartmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.DepartmentsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DepartmentsClient) GetPreparer(ctx context.Context, billingAccountName string, departmentName string, expand string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "departmentName": autorest.Encode("path", departmentName), + } + + const APIVersion = "2018-11-01-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) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments/{departmentName}", 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 DepartmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 DepartmentsClient) GetResponder(resp *http.Response) (result Department, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/departmentsbybillingaccountname.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/departmentsbybillingaccountname.go new file mode 100644 index 000000000000..31cd0581094d --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/departmentsbybillingaccountname.go @@ -0,0 +1,126 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DepartmentsByBillingAccountNameClient is the billing client provides access to billing resources for Azure +// subscriptions. +type DepartmentsByBillingAccountNameClient struct { + BaseClient +} + +// NewDepartmentsByBillingAccountNameClient creates an instance of the DepartmentsByBillingAccountNameClient client. +func NewDepartmentsByBillingAccountNameClient(subscriptionID string) DepartmentsByBillingAccountNameClient { + return NewDepartmentsByBillingAccountNameClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDepartmentsByBillingAccountNameClientWithBaseURI creates an instance of the DepartmentsByBillingAccountNameClient +// client. +func NewDepartmentsByBillingAccountNameClientWithBaseURI(baseURI string, subscriptionID string) DepartmentsByBillingAccountNameClient { + return DepartmentsByBillingAccountNameClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all departments for a user which he has access to. +// Parameters: +// billingAccountName - billing Account Id. +// expand - may be used to expand the enrollmentAccounts. +// filter - the filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', +// 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). +func (client DepartmentsByBillingAccountNameClient) List(ctx context.Context, billingAccountName string, expand string, filter string) (result DepartmentListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DepartmentsByBillingAccountNameClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName, expand, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.DepartmentsByBillingAccountNameClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.DepartmentsByBillingAccountNameClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.DepartmentsByBillingAccountNameClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client DepartmentsByBillingAccountNameClient) ListPreparer(ctx context.Context, billingAccountName string, expand string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-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) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/departments", 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 DepartmentsByBillingAccountNameClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 DepartmentsByBillingAccountNameClient) ListResponder(resp *http.Response) (result DepartmentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/enrollmentaccounts.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/enrollmentaccounts.go new file mode 100644 index 000000000000..e1ad9f8e3ea6 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/enrollmentaccounts.go @@ -0,0 +1,126 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// EnrollmentAccountsClient is the billing client provides access to billing resources for Azure subscriptions. +type EnrollmentAccountsClient struct { + BaseClient +} + +// NewEnrollmentAccountsClient creates an instance of the EnrollmentAccountsClient client. +func NewEnrollmentAccountsClient(subscriptionID string) EnrollmentAccountsClient { + return NewEnrollmentAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewEnrollmentAccountsClientWithBaseURI creates an instance of the EnrollmentAccountsClient client. +func NewEnrollmentAccountsClientWithBaseURI(baseURI string, subscriptionID string) EnrollmentAccountsClient { + return EnrollmentAccountsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetByEnrollmentAccountAccountID get the enrollment account by id. +// Parameters: +// billingAccountName - billing Account Id. +// enrollmentAccountName - enrollment Account Id. +// expand - may be used to expand the Department. +// filter - the filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', +// 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). +func (client EnrollmentAccountsClient) GetByEnrollmentAccountAccountID(ctx context.Context, billingAccountName string, enrollmentAccountName string, expand string, filter string) (result EnrollmentAccount, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EnrollmentAccountsClient.GetByEnrollmentAccountAccountID") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByEnrollmentAccountAccountIDPreparer(ctx, billingAccountName, enrollmentAccountName, expand, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.EnrollmentAccountsClient", "GetByEnrollmentAccountAccountID", nil, "Failure preparing request") + return + } + + resp, err := client.GetByEnrollmentAccountAccountIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.EnrollmentAccountsClient", "GetByEnrollmentAccountAccountID", resp, "Failure sending request") + return + } + + result, err = client.GetByEnrollmentAccountAccountIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.EnrollmentAccountsClient", "GetByEnrollmentAccountAccountID", resp, "Failure responding to request") + } + + return +} + +// GetByEnrollmentAccountAccountIDPreparer prepares the GetByEnrollmentAccountAccountID request. +func (client EnrollmentAccountsClient) GetByEnrollmentAccountAccountIDPreparer(ctx context.Context, billingAccountName string, enrollmentAccountName string, expand string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "enrollmentAccountName": autorest.Encode("path", enrollmentAccountName), + } + + const APIVersion = "2018-11-01-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) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByEnrollmentAccountAccountIDSender sends the GetByEnrollmentAccountAccountID request. The method will close the +// http.Response Body if it receives an error. +func (client EnrollmentAccountsClient) GetByEnrollmentAccountAccountIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByEnrollmentAccountAccountIDResponder handles the response to the GetByEnrollmentAccountAccountID request. The method always +// closes the http.Response Body. +func (client EnrollmentAccountsClient) GetByEnrollmentAccountAccountIDResponder(resp *http.Response) (result EnrollmentAccount, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/enrollmentaccountsbybillingaccountname.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/enrollmentaccountsbybillingaccountname.go new file mode 100644 index 000000000000..cd5669383686 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/enrollmentaccountsbybillingaccountname.go @@ -0,0 +1,127 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// EnrollmentAccountsByBillingAccountNameClient is the billing client provides access to billing resources for Azure +// subscriptions. +type EnrollmentAccountsByBillingAccountNameClient struct { + BaseClient +} + +// NewEnrollmentAccountsByBillingAccountNameClient creates an instance of the +// EnrollmentAccountsByBillingAccountNameClient client. +func NewEnrollmentAccountsByBillingAccountNameClient(subscriptionID string) EnrollmentAccountsByBillingAccountNameClient { + return NewEnrollmentAccountsByBillingAccountNameClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewEnrollmentAccountsByBillingAccountNameClientWithBaseURI creates an instance of the +// EnrollmentAccountsByBillingAccountNameClient client. +func NewEnrollmentAccountsByBillingAccountNameClientWithBaseURI(baseURI string, subscriptionID string) EnrollmentAccountsByBillingAccountNameClient { + return EnrollmentAccountsByBillingAccountNameClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all Enrollment Accounts for a user which he has access to. +// Parameters: +// billingAccountName - billing Account Id. +// expand - may be used to expand the department. +// filter - the filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', +// 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). +func (client EnrollmentAccountsByBillingAccountNameClient) List(ctx context.Context, billingAccountName string, expand string, filter string) (result EnrollmentAccountListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EnrollmentAccountsByBillingAccountNameClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName, expand, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.EnrollmentAccountsByBillingAccountNameClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.EnrollmentAccountsByBillingAccountNameClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.EnrollmentAccountsByBillingAccountNameClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client EnrollmentAccountsByBillingAccountNameClient) ListPreparer(ctx context.Context, billingAccountName string, expand string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-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) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/enrollmentAccounts", 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 EnrollmentAccountsByBillingAccountNameClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 EnrollmentAccountsByBillingAccountNameClient) ListResponder(resp *http.Response) (result EnrollmentAccountListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/invoice.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoice.go new file mode 100644 index 000000000000..8be120575cfb --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoice.go @@ -0,0 +1,119 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// InvoiceClient is the billing client provides access to billing resources for Azure subscriptions. +type InvoiceClient struct { + BaseClient +} + +// NewInvoiceClient creates an instance of the InvoiceClient client. +func NewInvoiceClient(subscriptionID string) InvoiceClient { + return NewInvoiceClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInvoiceClientWithBaseURI creates an instance of the InvoiceClient client. +func NewInvoiceClientWithBaseURI(baseURI string, subscriptionID string) InvoiceClient { + return InvoiceClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the invoice by id. +// Parameters: +// billingAccountName - billing Account Id. +// billingProfileName - billing Profile Id. +// invoiceName - invoice Id. +func (client InvoiceClient) Get(ctx context.Context, billingAccountName string, billingProfileName string, invoiceName string) (result InvoiceSummary, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceClient.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, billingProfileName, invoiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceClient", "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.InvoiceClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client InvoiceClient) GetPreparer(ctx context.Context, billingAccountName string, billingProfileName string, invoiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "invoiceName": autorest.Encode("path", invoiceName), + } + + const APIVersion = "2018-11-01-preview" + 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}/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 InvoiceClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 InvoiceClient) GetResponder(resp *http.Response) (result InvoiceSummary, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicepricesheet.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicepricesheet.go new file mode 100644 index 000000000000..7e1facda3db5 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicepricesheet.go @@ -0,0 +1,117 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// InvoicePricesheetClient is the billing client provides access to billing resources for Azure subscriptions. +type InvoicePricesheetClient struct { + BaseClient +} + +// NewInvoicePricesheetClient creates an instance of the InvoicePricesheetClient client. +func NewInvoicePricesheetClient(subscriptionID string) InvoicePricesheetClient { + return NewInvoicePricesheetClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInvoicePricesheetClientWithBaseURI creates an instance of the InvoicePricesheetClient client. +func NewInvoicePricesheetClientWithBaseURI(baseURI string, subscriptionID string) InvoicePricesheetClient { + return InvoicePricesheetClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Download get pricesheet data for invoice id (invoiceName). +// Parameters: +// billingAccountName - azure Billing Account ID. +// invoiceName - the name of an invoice resource. +func (client InvoicePricesheetClient) Download(ctx context.Context, billingAccountName string, invoiceName string) (result InvoicePricesheetDownloadFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoicePricesheetClient.Download") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DownloadPreparer(ctx, billingAccountName, invoiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicePricesheetClient", "Download", nil, "Failure preparing request") + return + } + + result, err = client.DownloadSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicePricesheetClient", "Download", result.Response(), "Failure sending request") + return + } + + return +} + +// DownloadPreparer prepares the Download request. +func (client InvoicePricesheetClient) DownloadPreparer(ctx context.Context, billingAccountName string, invoiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceName": autorest.Encode("path", invoiceName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/pricesheet/default/download", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DownloadSender sends the Download request. The method will close the +// http.Response Body if it receives an error. +func (client InvoicePricesheetClient) DownloadSender(req *http.Request) (future InvoicePricesheetDownloadFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DownloadResponder handles the response to the Download request. The method always +// closes the http.Response Body. +func (client InvoicePricesheetClient) DownloadResponder(resp *http.Response) (result DownloadURL, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesbybillingaccount.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesbybillingaccount.go new file mode 100644 index 000000000000..608fef064806 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesbybillingaccount.go @@ -0,0 +1,119 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// InvoicesByBillingAccountClient is the billing client provides access to billing resources for Azure subscriptions. +type InvoicesByBillingAccountClient struct { + BaseClient +} + +// NewInvoicesByBillingAccountClient creates an instance of the InvoicesByBillingAccountClient client. +func NewInvoicesByBillingAccountClient(subscriptionID string) InvoicesByBillingAccountClient { + return NewInvoicesByBillingAccountClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInvoicesByBillingAccountClientWithBaseURI creates an instance of the InvoicesByBillingAccountClient client. +func NewInvoicesByBillingAccountClientWithBaseURI(baseURI string, subscriptionID string) InvoicesByBillingAccountClient { + return InvoicesByBillingAccountClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List list of invoices for a billing account. +// Parameters: +// billingAccountName - billing Account Id. +// periodStartDate - invoice period start date. +// periodEndDate - invoice period end date. +func (client InvoicesByBillingAccountClient) List(ctx context.Context, billingAccountName string, periodStartDate string, periodEndDate string) (result InvoiceListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesByBillingAccountClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName, periodStartDate, periodEndDate) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesByBillingAccountClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InvoicesByBillingAccountClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesByBillingAccountClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client InvoicesByBillingAccountClient) ListPreparer(ctx context.Context, billingAccountName string, periodStartDate string, periodEndDate string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "periodEndDate": autorest.Encode("query", periodEndDate), + "periodStartDate": autorest.Encode("query", periodStartDate), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/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 InvoicesByBillingAccountClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 InvoicesByBillingAccountClient) ListResponder(resp *http.Response) (result InvoiceListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesbybillingprofile.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesbybillingprofile.go new file mode 100644 index 000000000000..92ef9e800a9f --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesbybillingprofile.go @@ -0,0 +1,121 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// InvoicesByBillingProfileClient is the billing client provides access to billing resources for Azure subscriptions. +type InvoicesByBillingProfileClient struct { + BaseClient +} + +// NewInvoicesByBillingProfileClient creates an instance of the InvoicesByBillingProfileClient client. +func NewInvoicesByBillingProfileClient(subscriptionID string) InvoicesByBillingProfileClient { + return NewInvoicesByBillingProfileClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInvoicesByBillingProfileClientWithBaseURI creates an instance of the InvoicesByBillingProfileClient client. +func NewInvoicesByBillingProfileClientWithBaseURI(baseURI string, subscriptionID string) InvoicesByBillingProfileClient { + return InvoicesByBillingProfileClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List list of invoices for a billing profile. +// Parameters: +// billingAccountName - billing Account Id. +// billingProfileName - billing Profile Id. +// periodStartDate - invoice period start date. +// periodEndDate - invoice period end date. +func (client InvoicesByBillingProfileClient) List(ctx context.Context, billingAccountName string, billingProfileName string, periodStartDate string, periodEndDate string) (result InvoiceListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesByBillingProfileClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName, billingProfileName, periodStartDate, periodEndDate) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesByBillingProfileClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InvoicesByBillingProfileClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesByBillingProfileClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client InvoicesByBillingProfileClient) ListPreparer(ctx context.Context, billingAccountName string, billingProfileName string, periodStartDate string, periodEndDate string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "periodEndDate": autorest.Encode("query", periodEndDate), + "periodStartDate": autorest.Encode("query", periodStartDate), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/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 InvoicesByBillingProfileClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 InvoicesByBillingProfileClient) ListResponder(resp *http.Response) (result InvoiceListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesectionbillingroleassignment.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesectionbillingroleassignment.go new file mode 100644 index 000000000000..ee1b3d457981 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesectionbillingroleassignment.go @@ -0,0 +1,355 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// InvoiceSectionBillingRoleAssignmentClient is the billing client provides access to billing resources for Azure +// subscriptions. +type InvoiceSectionBillingRoleAssignmentClient struct { + BaseClient +} + +// NewInvoiceSectionBillingRoleAssignmentClient creates an instance of the InvoiceSectionBillingRoleAssignmentClient +// client. +func NewInvoiceSectionBillingRoleAssignmentClient(subscriptionID string) InvoiceSectionBillingRoleAssignmentClient { + return NewInvoiceSectionBillingRoleAssignmentClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInvoiceSectionBillingRoleAssignmentClientWithBaseURI creates an instance of the +// InvoiceSectionBillingRoleAssignmentClient client. +func NewInvoiceSectionBillingRoleAssignmentClientWithBaseURI(baseURI string, subscriptionID string) InvoiceSectionBillingRoleAssignmentClient { + return InvoiceSectionBillingRoleAssignmentClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Add the operation to add a role assignment to a invoice Section. +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +// parameters - parameters supplied to add a role assignment. +func (client InvoiceSectionBillingRoleAssignmentClient) Add(ctx context.Context, billingAccountName string, invoiceSectionName string, parameters RoleAssignmentPayload) (result RoleAssignmentListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionBillingRoleAssignmentClient.Add") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.AddPreparer(ctx, billingAccountName, invoiceSectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionBillingRoleAssignmentClient", "Add", nil, "Failure preparing request") + return + } + + resp, err := client.AddSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionBillingRoleAssignmentClient", "Add", resp, "Failure sending request") + return + } + + result, err = client.AddResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionBillingRoleAssignmentClient", "Add", resp, "Failure responding to request") + } + + return +} + +// AddPreparer prepares the Add request. +func (client InvoiceSectionBillingRoleAssignmentClient) AddPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, parameters RoleAssignmentPayload) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Billing/createBillingRoleAssignment", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AddSender sends the Add request. The method will close the +// http.Response Body if it receives an error. +func (client InvoiceSectionBillingRoleAssignmentClient) AddSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// AddResponder handles the response to the Add request. The method always +// closes the http.Response Body. +func (client InvoiceSectionBillingRoleAssignmentClient) AddResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the role assignment on this invoice Section +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +// billingRoleAssignmentName - role assignment id. +func (client InvoiceSectionBillingRoleAssignmentClient) Delete(ctx context.Context, billingAccountName string, invoiceSectionName string, billingRoleAssignmentName string) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionBillingRoleAssignmentClient.Delete") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, billingAccountName, invoiceSectionName, billingRoleAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionBillingRoleAssignmentClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionBillingRoleAssignmentClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionBillingRoleAssignmentClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client InvoiceSectionBillingRoleAssignmentClient) DeletePreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, billingRoleAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingRoleAssignmentName": autorest.Encode("path", billingRoleAssignmentName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Billing/billingRoleAssignments/{billingRoleAssignmentName}", 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 InvoiceSectionBillingRoleAssignmentClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 InvoiceSectionBillingRoleAssignmentClient) DeleteResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the role assignment for the caller on the invoice Section +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +// billingRoleAssignmentName - role assignment id. +func (client InvoiceSectionBillingRoleAssignmentClient) Get(ctx context.Context, billingAccountName string, invoiceSectionName string, billingRoleAssignmentName string) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionBillingRoleAssignmentClient.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, invoiceSectionName, billingRoleAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionBillingRoleAssignmentClient", "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.InvoiceSectionBillingRoleAssignmentClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionBillingRoleAssignmentClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client InvoiceSectionBillingRoleAssignmentClient) GetPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, billingRoleAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingRoleAssignmentName": autorest.Encode("path", billingRoleAssignmentName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Billing/billingRoleAssignments/{billingRoleAssignmentName}", 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 InvoiceSectionBillingRoleAssignmentClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 InvoiceSectionBillingRoleAssignmentClient) GetResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get the role assignments on the invoice Section +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +func (client InvoiceSectionBillingRoleAssignmentClient) List(ctx context.Context, billingAccountName string, invoiceSectionName string) (result RoleAssignmentListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionBillingRoleAssignmentClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName, invoiceSectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionBillingRoleAssignmentClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionBillingRoleAssignmentClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionBillingRoleAssignmentClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client InvoiceSectionBillingRoleAssignmentClient) ListPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Billing/billingRoleAssignments", 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 InvoiceSectionBillingRoleAssignmentClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 InvoiceSectionBillingRoleAssignmentClient) ListResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesectionbillingroledefinition.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesectionbillingroledefinition.go new file mode 100644 index 000000000000..73b02df6ebef --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesectionbillingroledefinition.go @@ -0,0 +1,198 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// InvoiceSectionBillingRoleDefinitionClient is the billing client provides access to billing resources for Azure +// subscriptions. +type InvoiceSectionBillingRoleDefinitionClient struct { + BaseClient +} + +// NewInvoiceSectionBillingRoleDefinitionClient creates an instance of the InvoiceSectionBillingRoleDefinitionClient +// client. +func NewInvoiceSectionBillingRoleDefinitionClient(subscriptionID string) InvoiceSectionBillingRoleDefinitionClient { + return NewInvoiceSectionBillingRoleDefinitionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInvoiceSectionBillingRoleDefinitionClientWithBaseURI creates an instance of the +// InvoiceSectionBillingRoleDefinitionClient client. +func NewInvoiceSectionBillingRoleDefinitionClientWithBaseURI(baseURI string, subscriptionID string) InvoiceSectionBillingRoleDefinitionClient { + return InvoiceSectionBillingRoleDefinitionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the role definition for a role +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +// billingRoleDefinitionName - role definition id. +func (client InvoiceSectionBillingRoleDefinitionClient) Get(ctx context.Context, billingAccountName string, invoiceSectionName string, billingRoleDefinitionName string) (result RoleDefinition, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionBillingRoleDefinitionClient.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, invoiceSectionName, billingRoleDefinitionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionBillingRoleDefinitionClient", "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.InvoiceSectionBillingRoleDefinitionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionBillingRoleDefinitionClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client InvoiceSectionBillingRoleDefinitionClient) GetPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, billingRoleDefinitionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingRoleDefinitionName": autorest.Encode("path", billingRoleDefinitionName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Billing/billingRoleDefinitions/{billingRoleDefinitionName}", 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 InvoiceSectionBillingRoleDefinitionClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 InvoiceSectionBillingRoleDefinitionClient) GetResponder(resp *http.Response) (result RoleDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the role definition for a invoice Section +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +func (client InvoiceSectionBillingRoleDefinitionClient) List(ctx context.Context, billingAccountName string, invoiceSectionName string) (result RoleDefinitionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionBillingRoleDefinitionClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName, invoiceSectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionBillingRoleDefinitionClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionBillingRoleDefinitionClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionBillingRoleDefinitionClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client InvoiceSectionBillingRoleDefinitionClient) ListPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Billing/billingRoleDefinitions", 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 InvoiceSectionBillingRoleDefinitionClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 InvoiceSectionBillingRoleDefinitionClient) ListResponder(resp *http.Response) (result RoleDefinitionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + 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 new file mode 100644 index 000000000000..b6b53d07a515 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesections.go @@ -0,0 +1,277 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// InvoiceSectionsClient is the billing client provides access to billing resources for Azure subscriptions. +type InvoiceSectionsClient struct { + BaseClient +} + +// NewInvoiceSectionsClient creates an instance of the InvoiceSectionsClient client. +func NewInvoiceSectionsClient(subscriptionID string) InvoiceSectionsClient { + return NewInvoiceSectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInvoiceSectionsClientWithBaseURI creates an instance of the InvoiceSectionsClient client. +func NewInvoiceSectionsClientWithBaseURI(baseURI string, subscriptionID string) InvoiceSectionsClient { + return InvoiceSectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create the operation to create a InvoiceSection. +// Parameters: +// billingAccountName - billing Account Id. +// parameters - parameters supplied to the Create InvoiceSection operation. +func (client InvoiceSectionsClient) Create(ctx context.Context, billingAccountName string, parameters InvoiceSectionProperties) (result InvoiceSectionsCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.Create") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreatePreparer(ctx, billingAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client InvoiceSectionsClient) CreatePreparer(ctx context.Context, billingAccountName string, parameters InvoiceSectionProperties) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client InvoiceSectionsClient) CreateSender(req *http.Request) (future InvoiceSectionsCreateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client InvoiceSectionsClient) CreateResponder(resp *http.Response) (result InvoiceSection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the InvoiceSection by id. +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +// expand - may be used to expand the billingProfiles. +func (client InvoiceSectionsClient) Get(ctx context.Context, billingAccountName string, invoiceSectionName string, expand string) (result InvoiceSection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.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, invoiceSectionName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "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.InvoiceSectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client InvoiceSectionsClient) GetPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}", 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 InvoiceSectionsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 InvoiceSectionsClient) GetResponder(resp *http.Response) (result InvoiceSection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update the operation to update a InvoiceSection. +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +// parameters - parameters supplied to the Create InvoiceSection operation. +func (client InvoiceSectionsClient) Update(ctx context.Context, billingAccountName string, invoiceSectionName string, parameters InvoiceSection) (result InvoiceSectionsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, billingAccountName, invoiceSectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client InvoiceSectionsClient) UpdatePreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, parameters InvoiceSection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client InvoiceSectionsClient) UpdateSender(req *http.Request) (future InvoiceSectionsUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client InvoiceSectionsClient) UpdateResponder(resp *http.Response) (result InvoiceSection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesectionsbillingpermissions.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesectionsbillingpermissions.go new file mode 100644 index 000000000000..8751a7ddb29e --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesectionsbillingpermissions.go @@ -0,0 +1,120 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// InvoiceSectionsBillingPermissionsClient is the billing client provides access to billing resources for Azure +// subscriptions. +type InvoiceSectionsBillingPermissionsClient struct { + BaseClient +} + +// NewInvoiceSectionsBillingPermissionsClient creates an instance of the InvoiceSectionsBillingPermissionsClient +// client. +func NewInvoiceSectionsBillingPermissionsClient(subscriptionID string) InvoiceSectionsBillingPermissionsClient { + return NewInvoiceSectionsBillingPermissionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInvoiceSectionsBillingPermissionsClientWithBaseURI creates an instance of the +// InvoiceSectionsBillingPermissionsClient client. +func NewInvoiceSectionsBillingPermissionsClientWithBaseURI(baseURI string, subscriptionID string) InvoiceSectionsBillingPermissionsClient { + return InvoiceSectionsBillingPermissionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all billingPermissions for the caller has for a Invoice Section. +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +func (client InvoiceSectionsBillingPermissionsClient) List(ctx context.Context, billingAccountName string, invoiceSectionName string) (result PermissionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsBillingPermissionsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName, invoiceSectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsBillingPermissionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsBillingPermissionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsBillingPermissionsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client InvoiceSectionsBillingPermissionsClient) ListPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Billing/billingPermissions", 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 InvoiceSectionsBillingPermissionsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 InvoiceSectionsBillingPermissionsClient) ListResponder(resp *http.Response) (result PermissionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesectionsbybillingaccountname.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesectionsbybillingaccountname.go new file mode 100644 index 000000000000..53421e61167d --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesectionsbybillingaccountname.go @@ -0,0 +1,122 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// InvoiceSectionsByBillingAccountNameClient is the billing client provides access to billing resources for Azure +// subscriptions. +type InvoiceSectionsByBillingAccountNameClient struct { + BaseClient +} + +// NewInvoiceSectionsByBillingAccountNameClient creates an instance of the InvoiceSectionsByBillingAccountNameClient +// client. +func NewInvoiceSectionsByBillingAccountNameClient(subscriptionID string) InvoiceSectionsByBillingAccountNameClient { + return NewInvoiceSectionsByBillingAccountNameClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInvoiceSectionsByBillingAccountNameClientWithBaseURI creates an instance of the +// InvoiceSectionsByBillingAccountNameClient client. +func NewInvoiceSectionsByBillingAccountNameClientWithBaseURI(baseURI string, subscriptionID string) InvoiceSectionsByBillingAccountNameClient { + return InvoiceSectionsByBillingAccountNameClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all invoice sections for a user which he has access to. +// Parameters: +// billingAccountName - billing Account Id. +// expand - may be used to expand the billingProfiles. +func (client InvoiceSectionsByBillingAccountNameClient) List(ctx context.Context, billingAccountName string, expand string) (result InvoiceSectionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsByBillingAccountNameClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsByBillingAccountNameClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsByBillingAccountNameClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsByBillingAccountNameClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client InvoiceSectionsByBillingAccountNameClient) ListPreparer(ctx context.Context, billingAccountName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections", 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 InvoiceSectionsByBillingAccountNameClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 InvoiceSectionsByBillingAccountNameClient) ListResponder(resp *http.Response) (result InvoiceSectionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesectionswithcreatesubscriptionpermission.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesectionswithcreatesubscriptionpermission.go new file mode 100644 index 000000000000..2348a3045a23 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesectionswithcreatesubscriptionpermission.go @@ -0,0 +1,122 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// InvoiceSectionsWithCreateSubscriptionPermissionClient is the billing client provides access to billing resources for +// Azure subscriptions. +type InvoiceSectionsWithCreateSubscriptionPermissionClient struct { + BaseClient +} + +// NewInvoiceSectionsWithCreateSubscriptionPermissionClient creates an instance of the +// InvoiceSectionsWithCreateSubscriptionPermissionClient client. +func NewInvoiceSectionsWithCreateSubscriptionPermissionClient(subscriptionID string) InvoiceSectionsWithCreateSubscriptionPermissionClient { + return NewInvoiceSectionsWithCreateSubscriptionPermissionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInvoiceSectionsWithCreateSubscriptionPermissionClientWithBaseURI creates an instance of the +// InvoiceSectionsWithCreateSubscriptionPermissionClient client. +func NewInvoiceSectionsWithCreateSubscriptionPermissionClientWithBaseURI(baseURI string, subscriptionID string) InvoiceSectionsWithCreateSubscriptionPermissionClient { + return InvoiceSectionsWithCreateSubscriptionPermissionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all invoiceSections with create subscription permission for a user. +// Parameters: +// billingAccountName - billing Account Id. +// expand - may be used to expand the billingProfiles. +func (client InvoiceSectionsWithCreateSubscriptionPermissionClient) List(ctx context.Context, billingAccountName string, expand string) (result InvoiceSectionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsWithCreateSubscriptionPermissionClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsWithCreateSubscriptionPermissionClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsWithCreateSubscriptionPermissionClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsWithCreateSubscriptionPermissionClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client InvoiceSectionsWithCreateSubscriptionPermissionClient) ListPreparer(ctx context.Context, billingAccountName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/listInvoiceSectionsWithCreateSubscriptionPermission", 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 InvoiceSectionsWithCreateSubscriptionPermissionClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 InvoiceSectionsWithCreateSubscriptionPermissionClient) ListResponder(resp *http.Response) (result InvoiceSectionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/models.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/models.go new file mode 100644 index 000000000000..85c81de7c112 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/models.go @@ -0,0 +1,3601 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "github.com/satori/go.uuid" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/billing/mgmt/2018-11-01-preview/billing" + +// AccountType enumerates the values for account type. +type AccountType string + +const ( + // AccountTypeEnrollment ... + AccountTypeEnrollment AccountType = "Enrollment" + // AccountTypeOrganization ... + AccountTypeOrganization AccountType = "Organization" +) + +// PossibleAccountTypeValues returns an array of possible values for the AccountType const type. +func PossibleAccountTypeValues() []AccountType { + return []AccountType{AccountTypeEnrollment, AccountTypeOrganization} +} + +// EligibleProductType enumerates the values for eligible product type. +type EligibleProductType string + +const ( + // AzureReservation ... + AzureReservation EligibleProductType = "AzureReservation" + // DevTestAzureSubscription ... + DevTestAzureSubscription EligibleProductType = "DevTestAzureSubscription" + // StandardAzureSubscription ... + StandardAzureSubscription EligibleProductType = "StandardAzureSubscription" +) + +// PossibleEligibleProductTypeValues returns an array of possible values for the EligibleProductType const type. +func PossibleEligibleProductTypeValues() []EligibleProductType { + return []EligibleProductType{AzureReservation, DevTestAzureSubscription, StandardAzureSubscription} +} + +// Frequency enumerates the values for frequency. +type Frequency string + +const ( + // Monthly ... + Monthly Frequency = "Monthly" + // OneTime ... + OneTime Frequency = "OneTime" + // UsageBased ... + UsageBased Frequency = "UsageBased" +) + +// PossibleFrequencyValues returns an array of possible values for the Frequency const type. +func PossibleFrequencyValues() []Frequency { + return []Frequency{Monthly, OneTime, UsageBased} +} + +// Kind enumerates the values for kind. +type Kind string + +const ( + // CreditNote ... + CreditNote Kind = "CreditNote" + // Invoice ... + Invoice Kind = "Invoice" + // Receipt ... + Receipt Kind = "Receipt" + // VoidNote ... + VoidNote Kind = "VoidNote" +) + +// PossibleKindValues returns an array of possible values for the Kind const type. +func PossibleKindValues() []Kind { + return []Kind{CreditNote, Invoice, Receipt, VoidNote} +} + +// PaymentMethodType enumerates the values for payment method type. +type PaymentMethodType string + +const ( + // ChequeWire ... + ChequeWire PaymentMethodType = "ChequeWire" + // Credits ... + Credits PaymentMethodType = "Credits" +) + +// PossiblePaymentMethodTypeValues returns an array of possible values for the PaymentMethodType const type. +func PossiblePaymentMethodTypeValues() []PaymentMethodType { + return []PaymentMethodType{ChequeWire, Credits} +} + +// ProductStatusType enumerates the values for product status type. +type ProductStatusType string + +const ( + // Active ... + Active ProductStatusType = "Active" + // AutoRenew ... + AutoRenew ProductStatusType = "AutoRenew" + // Cancelled ... + Cancelled ProductStatusType = "Cancelled" + // Disabled ... + Disabled ProductStatusType = "Disabled" + // Expired ... + Expired ProductStatusType = "Expired" + // Expiring ... + Expiring ProductStatusType = "Expiring" + // Inactive ... + Inactive ProductStatusType = "Inactive" + // PastDue ... + PastDue ProductStatusType = "PastDue" +) + +// PossibleProductStatusTypeValues returns an array of possible values for the ProductStatusType const type. +func PossibleProductStatusTypeValues() []ProductStatusType { + return []ProductStatusType{Active, AutoRenew, Cancelled, Disabled, Expired, Expiring, Inactive, PastDue} +} + +// ProductTransferStatus enumerates the values for product transfer status. +type ProductTransferStatus string + +const ( + // Completed ... + Completed ProductTransferStatus = "Completed" + // Failed ... + Failed ProductTransferStatus = "Failed" + // InProgress ... + InProgress ProductTransferStatus = "InProgress" + // NotStarted ... + NotStarted ProductTransferStatus = "NotStarted" +) + +// PossibleProductTransferStatusValues returns an array of possible values for the ProductTransferStatus const type. +func PossibleProductTransferStatusValues() []ProductTransferStatus { + return []ProductTransferStatus{Completed, Failed, InProgress, NotStarted} +} + +// ProductType enumerates the values for product type. +type ProductType string + +const ( + // ProductTypeAzureReservation ... + ProductTypeAzureReservation ProductType = "AzureReservation" + // ProductTypeAzureSubscription ... + ProductTypeAzureSubscription ProductType = "AzureSubscription" +) + +// PossibleProductTypeValues returns an array of possible values for the ProductType const type. +func PossibleProductTypeValues() []ProductType { + return []ProductType{ProductTypeAzureReservation, ProductTypeAzureSubscription} +} + +// ReservationType enumerates the values for reservation type. +type ReservationType string + +const ( + // Purchase ... + Purchase ReservationType = "Purchase" + // UsageCharge ... + UsageCharge ReservationType = "Usage Charge" +) + +// PossibleReservationTypeValues returns an array of possible values for the ReservationType const type. +func PossibleReservationTypeValues() []ReservationType { + return []ReservationType{Purchase, UsageCharge} +} + +// Status enumerates the values for status. +type Status string + +const ( + // StatusDue ... + StatusDue Status = "Due" + // StatusPaid ... + StatusPaid Status = "Paid" + // StatusPastDue ... + StatusPastDue Status = "PastDue" + // StatusVoid ... + StatusVoid Status = "Void" +) + +// PossibleStatusValues returns an array of possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{StatusDue, StatusPaid, StatusPastDue, StatusVoid} +} + +// SubscriptionStatusType enumerates the values for subscription status type. +type SubscriptionStatusType string + +const ( + // SubscriptionStatusTypeAbandoned ... + SubscriptionStatusTypeAbandoned SubscriptionStatusType = "Abandoned" + // SubscriptionStatusTypeActive ... + SubscriptionStatusTypeActive SubscriptionStatusType = "Active" + // SubscriptionStatusTypeDeleted ... + SubscriptionStatusTypeDeleted SubscriptionStatusType = "Deleted" + // SubscriptionStatusTypeInactive ... + SubscriptionStatusTypeInactive SubscriptionStatusType = "Inactive" + // SubscriptionStatusTypeWarning ... + SubscriptionStatusTypeWarning SubscriptionStatusType = "Warning" +) + +// PossibleSubscriptionStatusTypeValues returns an array of possible values for the SubscriptionStatusType const type. +func PossibleSubscriptionStatusTypeValues() []SubscriptionStatusType { + return []SubscriptionStatusType{SubscriptionStatusTypeAbandoned, SubscriptionStatusTypeActive, SubscriptionStatusTypeDeleted, SubscriptionStatusTypeInactive, SubscriptionStatusTypeWarning} +} + +// TransactionTypeKind enumerates the values for transaction type kind. +type TransactionTypeKind string + +const ( + // All ... + All TransactionTypeKind = "all" + // Reservation ... + Reservation TransactionTypeKind = "reservation" +) + +// PossibleTransactionTypeKindValues returns an array of possible values for the TransactionTypeKind const type. +func PossibleTransactionTypeKindValues() []TransactionTypeKind { + return []TransactionTypeKind{All, Reservation} +} + +// TransferStatus enumerates the values for transfer status. +type TransferStatus string + +const ( + // TransferStatusCanceled ... + TransferStatusCanceled TransferStatus = "Canceled" + // TransferStatusCompleted ... + TransferStatusCompleted TransferStatus = "Completed" + // TransferStatusCompletedWithErrors ... + TransferStatusCompletedWithErrors TransferStatus = "CompletedWithErrors" + // TransferStatusDeclined ... + TransferStatusDeclined TransferStatus = "Declined" + // TransferStatusFailed ... + TransferStatusFailed TransferStatus = "Failed" + // TransferStatusInProgress ... + TransferStatusInProgress TransferStatus = "InProgress" + // TransferStatusPending ... + TransferStatusPending TransferStatus = "Pending" +) + +// PossibleTransferStatusValues returns an array of possible values for the TransferStatus const type. +func PossibleTransferStatusValues() []TransferStatus { + return []TransferStatus{TransferStatusCanceled, TransferStatusCompleted, TransferStatusCompletedWithErrors, TransferStatusDeclined, TransferStatusFailed, TransferStatusInProgress, TransferStatusPending} +} + +// UpdateAutoRenew enumerates the values for update auto renew. +type UpdateAutoRenew string + +const ( + // False ... + False UpdateAutoRenew = "false" + // True ... + True UpdateAutoRenew = "true" +) + +// PossibleUpdateAutoRenewValues returns an array of possible values for the UpdateAutoRenew const type. +func PossibleUpdateAutoRenewValues() []UpdateAutoRenew { + return []UpdateAutoRenew{False, True} +} + +// AcceptTransferProperties request parameters to accept transfer. +type AcceptTransferProperties struct { + // ProductDetails - Request parameters to accept transfer. + ProductDetails *[]ProductDetails `json:"productDetails,omitempty"` +} + +// AcceptTransferRequest request parameters to accept transfer. +type AcceptTransferRequest struct { + // AcceptTransferProperties - Request parameters to accept transfer. + *AcceptTransferProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AcceptTransferRequest. +func (atr AcceptTransferRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if atr.AcceptTransferProperties != nil { + objectMap["properties"] = atr.AcceptTransferProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AcceptTransferRequest struct. +func (atr *AcceptTransferRequest) 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 acceptTransferProperties AcceptTransferProperties + err = json.Unmarshal(*v, &acceptTransferProperties) + if err != nil { + return err + } + atr.AcceptTransferProperties = &acceptTransferProperties + } + } + } + + return nil +} + +// Account a billing account resource. +type Account struct { + autorest.Response `json:"-"` + // AccountProperties - A billing account. + *AccountProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Account. +func (a Account) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.AccountProperties != nil { + objectMap["properties"] = a.AccountProperties + } + if a.ID != nil { + objectMap["id"] = a.ID + } + if a.Name != nil { + objectMap["name"] = a.Name + } + if a.Type != nil { + objectMap["type"] = a.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Account struct. +func (a *Account) 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 accountProperties AccountProperties + err = json.Unmarshal(*v, &accountProperties) + if err != nil { + return err + } + a.AccountProperties = &accountProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + a.Type = &typeVar + } + } + } + + return nil +} + +// AccountListResult result of listing billing accounts. +type AccountListResult struct { + autorest.Response `json:"-"` + // Value - The list of billing accounts. + Value *[]Account `json:"value,omitempty"` + // NextLink - The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// AccountProperties the properties of the billing account. +type AccountProperties struct { + // DisplayName - The billing account name. + DisplayName *string `json:"displayName,omitempty"` + // Company - The Company this billing account belongs to. + Company *string `json:"company,omitempty"` + // AccountType - The billing account Type. Possible values include: 'AccountTypeOrganization', 'AccountTypeEnrollment' + AccountType AccountType `json:"accountType,omitempty"` + // Address - The address associated with billing account. + Address *Address `json:"address,omitempty"` + // Country - The country associated with billing account.. + Country *string `json:"country,omitempty"` + // InvoiceSections - The invoice sections associated to the billing account. + InvoiceSections *[]InvoiceSection `json:"invoiceSections,omitempty"` + // BillingProfiles - The billing profiles associated to the billing account. + BillingProfiles *[]Profile `json:"billingProfiles,omitempty"` + // EnrollmentDetails - The details about the associated legacy enrollment. By default this is not populated, unless it's specified in $expand. + EnrollmentDetails *Enrollment `json:"enrollmentDetails,omitempty"` + // Departments - The departments associated to the enrollment. + Departments *[]Department `json:"departments,omitempty"` + // EnrollmentAccounts - The accounts associated to the enrollment. + EnrollmentAccounts *[]EnrollmentAccount `json:"enrollmentAccounts,omitempty"` +} + +// Address address details. +type Address struct { + // FirstName - First Name. + FirstName *string `json:"firstName,omitempty"` + // LastName - Last Name. + LastName *string `json:"lastName,omitempty"` + // CompanyName - Company Name. + CompanyName *string `json:"companyName,omitempty"` + // AddressLine1 - Address Line1. + AddressLine1 *string `json:"addressLine1,omitempty"` + // AddressLine2 - Address Line2. + AddressLine2 *string `json:"addressLine2,omitempty"` + // AddressLine3 - Address Line3. + AddressLine3 *string `json:"addressLine3,omitempty"` + // City - Address City. + City *string `json:"city,omitempty"` + // Region - Address Region. + Region *string `json:"region,omitempty"` + // Country - Country code uses ISO2, 2-digit format. + Country *string `json:"country,omitempty"` + // PostalCode - Address Postal Code. + PostalCode *string `json:"postalCode,omitempty"` +} + +// Amount the Amount. +type Amount struct { + // Currency - The currency for the amount value. + Currency *string `json:"currency,omitempty"` + // Value - Amount value. + Value *float64 `json:"value,omitempty"` +} + +// AvailableBalance latest available balance on Monetary Credit PI. +type AvailableBalance struct { + autorest.Response `json:"-"` + *AvailableBalanceProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AvailableBalance. +func (ab AvailableBalance) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ab.AvailableBalanceProperties != nil { + objectMap["properties"] = ab.AvailableBalanceProperties + } + if ab.ID != nil { + objectMap["id"] = ab.ID + } + if ab.Name != nil { + objectMap["name"] = ab.Name + } + if ab.Type != nil { + objectMap["type"] = ab.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AvailableBalance struct. +func (ab *AvailableBalance) 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 availableBalanceProperties AvailableBalanceProperties + err = json.Unmarshal(*v, &availableBalanceProperties) + if err != nil { + return err + } + ab.AvailableBalanceProperties = &availableBalanceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ab.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ab.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ab.Type = &typeVar + } + } + } + + return nil +} + +// AvailableBalanceProperties the properties of available balance. +type AvailableBalanceProperties struct { + // Amount - Balance Amount. + Amount *Amount `json:"amount,omitempty"` +} + +// Department a department resource. +type Department struct { + autorest.Response `json:"-"` + // DepartmentProperties - A department. + *DepartmentProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Department. +func (d Department) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.DepartmentProperties != nil { + objectMap["properties"] = d.DepartmentProperties + } + if d.ID != nil { + objectMap["id"] = d.ID + } + if d.Name != nil { + objectMap["name"] = d.Name + } + if d.Type != nil { + objectMap["type"] = d.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Department struct. +func (d *Department) 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 departmentProperties DepartmentProperties + err = json.Unmarshal(*v, &departmentProperties) + if err != nil { + return err + } + d.DepartmentProperties = &departmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + d.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + d.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + d.Type = &typeVar + } + } + } + + return nil +} + +// DepartmentListResult result of listing departments. +type DepartmentListResult struct { + autorest.Response `json:"-"` + // Value - The list of departments. + Value *[]Department `json:"value,omitempty"` + // NextLink - The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// DepartmentProperties the properties of the department. +type DepartmentProperties struct { + // DepartmentName - The name for department. + DepartmentName *string `json:"departmentName,omitempty"` + // CostCenter - The cost center name. + CostCenter *string `json:"costCenter,omitempty"` + // Status - The status for department. + Status *string `json:"status,omitempty"` + // EnrollmentAccounts - Associated enrollment accounts. By default this is not populated, unless it's specified in $expand. + EnrollmentAccounts *[]EnrollmentAccount `json:"enrollmentAccounts,omitempty"` +} + +// DetailedTransferStatus detailed transfer status. +type DetailedTransferStatus struct { + // ProductType - Type of product being transferred. Possible values include: 'ProductTypeAzureSubscription', 'ProductTypeAzureReservation' + ProductType ProductType `json:"productType,omitempty"` + // ProductID - Id of product being transferred. + ProductID *string `json:"productId,omitempty"` + // TransferStatus - Transfer status. Possible values include: 'NotStarted', 'InProgress', 'Completed', 'Failed' + TransferStatus ProductTransferStatus `json:"transferStatus,omitempty"` + // ErrorDetails - Error details for transfer execution. + ErrorDetails *Error `json:"errorDetails,omitempty"` +} + +// DownloadProperties the properties of the invoice download. +type DownloadProperties struct { + // Kind - Document type. Possible values include: 'Invoice', 'VoidNote', 'Receipt', 'CreditNote' + Kind Kind `json:"kind,omitempty"` + // URL - Document URL. + URL *string `json:"url,omitempty"` +} + +// DownloadURL a secure URL that can be used to download a an entity until the URL expires. +type DownloadURL struct { + autorest.Response `json:"-"` + // ExpiryTime - The time in UTC at which this download URL will expire. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // URL - The URL to the PDF file. + URL *string `json:"url,omitempty"` +} + +// EnabledAzureSKUs details about the product. +type EnabledAzureSKUs struct { + // SkuID - The sku id. + SkuID *string `json:"skuId,omitempty"` + // SkuDescription - The sku description. + SkuDescription *string `json:"skuDescription,omitempty"` +} + +// Enrollment current entity level details +type Enrollment struct { + // StartDate - Enrollment Start Date + StartDate *date.Time `json:"startDate,omitempty"` + // EndDate - Enrollment End Date + EndDate *date.Time `json:"endDate,omitempty"` + // Currency - The currency associated with enrollment + Currency *string `json:"currency,omitempty"` + // Channel - The channel for Enrollment + Channel *string `json:"channel,omitempty"` + // Policies - The attributes associated with legacy enrollment. + Policies *EnrollmentPolicies `json:"policies,omitempty"` + // Language - The language for Enrollment + Language *string `json:"language,omitempty"` + // CountryCode - The countryCode for Enrollment + CountryCode *string `json:"countryCode,omitempty"` + // Status - Enrollment status + Status *string `json:"status,omitempty"` + // BillingCycle - Enrollment billing cycle + BillingCycle *string `json:"billingCycle,omitempty"` +} + +// EnrollmentAccount an account resource. +type EnrollmentAccount struct { + autorest.Response `json:"-"` + // EnrollmentAccountProperties - An account. + *EnrollmentAccountProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for EnrollmentAccount. +func (ea EnrollmentAccount) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ea.EnrollmentAccountProperties != nil { + objectMap["properties"] = ea.EnrollmentAccountProperties + } + if ea.ID != nil { + objectMap["id"] = ea.ID + } + if ea.Name != nil { + objectMap["name"] = ea.Name + } + if ea.Type != nil { + objectMap["type"] = ea.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for EnrollmentAccount struct. +func (ea *EnrollmentAccount) 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 enrollmentAccountProperties EnrollmentAccountProperties + err = json.Unmarshal(*v, &enrollmentAccountProperties) + if err != nil { + return err + } + ea.EnrollmentAccountProperties = &enrollmentAccountProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ea.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ea.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ea.Type = &typeVar + } + } + } + + return nil +} + +// EnrollmentAccountContext the rating context. +type EnrollmentAccountContext struct { + // CostCenter - The cost center name. + CostCenter *string `json:"costCenter,omitempty"` + // StartDate - Account Start Date + StartDate *date.Time `json:"startDate,omitempty"` + // EndDate - Account End Date + EndDate *date.Time `json:"endDate,omitempty"` + // EnrollmentAccountName - The enrollment account id. + EnrollmentAccountName *string `json:"enrollmentAccountName,omitempty"` +} + +// EnrollmentAccountListResult result of listing enrollment accounts. +type EnrollmentAccountListResult struct { + autorest.Response `json:"-"` + // Value - The list of enrollment accounts. + Value *[]EnrollmentAccount `json:"value,omitempty"` + // NextLink - The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// EnrollmentAccountProperties the properties of the account. +type EnrollmentAccountProperties struct { + // AccountName - The account name. + AccountName *string `json:"accountName,omitempty"` + // CostCenter - The cost center name. + CostCenter *string `json:"costCenter,omitempty"` + // AccountOwner - The account owner + AccountOwner *string `json:"accountOwner,omitempty"` + // Status - The status for account. + Status *string `json:"status,omitempty"` + // StartDate - Account Start Date + StartDate *date.Time `json:"startDate,omitempty"` + // EndDate - Account End Date + EndDate *date.Time `json:"endDate,omitempty"` + // Department - Associated department. By default this is not populated, unless it's specified in $expand. + Department *Department `json:"department,omitempty"` +} + +// EnrollmentPolicies the attributes associated with legacy enrollment +type EnrollmentPolicies struct { + // AccountOwnerViewCharges - The accountOwnerViewCharges flag for Enrollment + AccountOwnerViewCharges *bool `json:"accountOwnerViewCharges,omitempty"` + // DepartmentAdminViewCharges - The departmentAdminViewCharges flag for Enrollment + DepartmentAdminViewCharges *bool `json:"departmentAdminViewCharges,omitempty"` + // MarketplacesEnabled - The marketplaces flag for Enrollment + MarketplacesEnabled *bool `json:"marketplacesEnabled,omitempty"` + // ReservedInstancesEnabled - The reserved instances flag for Enrollment + ReservedInstancesEnabled *bool `json:"reservedInstancesEnabled,omitempty"` +} + +// Error error details for transfer execution. +type Error struct { + // ErrorCode - Error code. + ErrorCode *string `json:"errorCode,omitempty"` + // ErrorMessage - Error message. + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// ErrorDetails the details of the error. +type ErrorDetails struct { + // Code - Error code. + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` + // Target - The target of the particular error. + Target *string `json:"target,omitempty"` +} + +// 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"` +} + +// InitiateTransferProperties request parameters to initiate transfer. +type InitiateTransferProperties struct { + // BillingProfileID - Target Usage context for devTest subscriptions. + BillingProfileID *string `json:"billingProfileId,omitempty"` + // RecipientEmailID - Email Id of recipient for transfer. + RecipientEmailID *string `json:"recipientEmailId,omitempty"` +} + +// InitiateTransferRequest request parameters to initiate transfer. +type InitiateTransferRequest struct { + // InitiateTransferProperties - Request parameters to initiate transfer. + *InitiateTransferProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for InitiateTransferRequest. +func (itr InitiateTransferRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if itr.InitiateTransferProperties != nil { + objectMap["properties"] = itr.InitiateTransferProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for InitiateTransferRequest struct. +func (itr *InitiateTransferRequest) 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 initiateTransferProperties InitiateTransferProperties + err = json.Unmarshal(*v, &initiateTransferProperties) + if err != nil { + return err + } + itr.InitiateTransferProperties = &initiateTransferProperties + } + } + } + + return nil +} + +// InvoiceListResult result of listing invoices. +type InvoiceListResult struct { + autorest.Response `json:"-"` + // Value - The list of invoices. + Value *[]InvoiceSummary `json:"value,omitempty"` + // NextLink - The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// InvoicePricesheetDownloadFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type InvoicePricesheetDownloadFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *InvoicePricesheetDownloadFuture) Result(client InvoicePricesheetClient) (du DownloadURL, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicePricesheetDownloadFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("billing.InvoicePricesheetDownloadFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if du.Response.Response, err = future.GetResult(sender); err == nil && du.Response.Response.StatusCode != http.StatusNoContent { + du, err = client.DownloadResponder(du.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicePricesheetDownloadFuture", "Result", du.Response.Response, "Failure responding to request") + } + } + return +} + +// InvoiceSection an InvoiceSection resource. +type InvoiceSection struct { + autorest.Response `json:"-"` + // InvoiceSectionProperties - The InvoiceSection. + *InvoiceSectionProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for InvoiceSection. +func (is InvoiceSection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if is.InvoiceSectionProperties != nil { + objectMap["properties"] = is.InvoiceSectionProperties + } + if is.ID != nil { + objectMap["id"] = is.ID + } + if is.Name != nil { + objectMap["name"] = is.Name + } + if is.Type != nil { + objectMap["type"] = is.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for InvoiceSection struct. +func (is *InvoiceSection) 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 invoiceSectionProperties InvoiceSectionProperties + err = json.Unmarshal(*v, &invoiceSectionProperties) + if err != nil { + return err + } + is.InvoiceSectionProperties = &invoiceSectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + is.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + is.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + is.Type = &typeVar + } + } + } + + return nil +} + +// InvoiceSectionListResult result of listing invoice sections. +type InvoiceSectionListResult struct { + autorest.Response `json:"-"` + // Value - The list of invoice sections. + Value *[]InvoiceSection `json:"value,omitempty"` + // NextLink - The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// InvoiceSectionProperties the properties of an InvoiceSection. +type InvoiceSectionProperties struct { + // DisplayName - The name of the InvoiceSection. + DisplayName *string `json:"displayName,omitempty"` + // BillingProfiles - The billing profiles associated to the billing account. + BillingProfiles *[]Profile `json:"billingProfiles,omitempty"` +} + +// InvoiceSectionsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type InvoiceSectionsCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *InvoiceSectionsCreateFuture) Result(client InvoiceSectionsClient) (is InvoiceSection, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("billing.InvoiceSectionsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if is.Response.Response, err = future.GetResult(sender); err == nil && is.Response.Response.StatusCode != http.StatusNoContent { + is, err = client.CreateResponder(is.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsCreateFuture", "Result", is.Response.Response, "Failure responding to request") + } + } + return +} + +// InvoiceSectionsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type InvoiceSectionsUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *InvoiceSectionsUpdateFuture) Result(client InvoiceSectionsClient) (is InvoiceSection, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("billing.InvoiceSectionsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if is.Response.Response, err = future.GetResult(sender); err == nil && is.Response.Response.StatusCode != http.StatusNoContent { + is, err = client.UpdateResponder(is.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsUpdateFuture", "Result", is.Response.Response, "Failure responding to request") + } + } + return +} + +// InvoiceSummary an invoice resource. +type InvoiceSummary struct { + autorest.Response `json:"-"` + // InvoiceSummaryProperties - An invoice. + *InvoiceSummaryProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for InvoiceSummary. +func (is InvoiceSummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if is.InvoiceSummaryProperties != nil { + objectMap["properties"] = is.InvoiceSummaryProperties + } + if is.ID != nil { + objectMap["id"] = is.ID + } + if is.Name != nil { + objectMap["name"] = is.Name + } + if is.Type != nil { + objectMap["type"] = is.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for InvoiceSummary struct. +func (is *InvoiceSummary) 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 invoiceSummaryProperties InvoiceSummaryProperties + err = json.Unmarshal(*v, &invoiceSummaryProperties) + if err != nil { + return err + } + is.InvoiceSummaryProperties = &invoiceSummaryProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + is.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + is.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + is.Type = &typeVar + } + } + } + + return nil +} + +// InvoiceSummaryProperties the properties of the invoice. +type InvoiceSummaryProperties struct { + // DueDate - The due date for invoice. + DueDate *date.Time `json:"dueDate,omitempty"` + // InvoiceDate - The date when invoice was created. + InvoiceDate *date.Time `json:"invoiceDate,omitempty"` + // Status - Invoice status. Possible values include: 'StatusPastDue', 'StatusDue', 'StatusPaid', 'StatusVoid' + Status Status `json:"status,omitempty"` + // AmountDue - Amount due. + AmountDue *Amount `json:"amountDue,omitempty"` + // BilledAmount - Amount billed. + BilledAmount *Amount `json:"billedAmount,omitempty"` + // InvoicePeriodStartDate - The start date of the billing period. + InvoicePeriodStartDate *date.Time `json:"invoicePeriodStartDate,omitempty"` + // InvoicePeriodEndDate - The end date of the billing period. + InvoicePeriodEndDate *date.Time `json:"invoicePeriodEndDate,omitempty"` + // BillingProfile - The profile id which invoice belongs to. + BillingProfile *string `json:"billingProfile,omitempty"` + // BillingProfileName - The profile name which invoice belongs to. + BillingProfileName *string `json:"billingProfileName,omitempty"` + // PurchaseOrderNumber - The purchase identifier for the invoice. + PurchaseOrderNumber *string `json:"purchaseOrderNumber,omitempty"` + // DocumentUrls - List of document urls available to download including invoice and tax documents. + DocumentUrls *[]DownloadProperties `json:"documentUrls,omitempty"` + // Payments - List of payments. + Payments *[]PaymentProperties `json:"payments,omitempty"` +} + +// Operation a Billing REST API operation. +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + // Display - The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - Service provider: Microsoft.Billing. + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed: Invoice, etc. + Resource *string `json:"resource,omitempty"` + // Operation - Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult result listing 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 - List of billing operations supported by the Microsoft.Billing resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// 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 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + 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) + }() + } + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{fn: getNextPage} +} + +// OperationStatus status of the Billing POST/PUT operation. +type OperationStatus struct { + // ID - The operation Id. + ID *string `json:"id,omitempty"` + // Status - Status of the pending operation + Status *string `json:"status,omitempty"` + // StatusDetail - Status Detail of the pending operation + StatusDetail *string `json:"statusDetail,omitempty"` +} + +// PaymentMethod a payment method resource. +type PaymentMethod struct { + *PaymentMethodProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if pm.ID != nil { + objectMap["id"] = pm.ID + } + if pm.Name != nil { + objectMap["name"] = pm.Name + } + if pm.Type != nil { + objectMap["type"] = pm.Type + } + 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 +} + +// PaymentMethodProperties the properties of the payment method. +type PaymentMethodProperties struct { + // MethodType - Payment method type. Possible values include: 'Credits', 'ChequeWire' + MethodType PaymentMethodType `json:"methodType,omitempty"` + // Details - Details about the payment method. + Details *string `json:"details,omitempty"` + // Expiration - Expiration date. + Expiration *date.Time `json:"expiration,omitempty"` + // Currency - The currency associated with the payment method. + Currency *string `json:"currency,omitempty"` +} + +// PaymentMethodsListResult result of listing payment methods. +type PaymentMethodsListResult struct { + autorest.Response `json:"-"` + // Value - The list of payment methods. + Value *[]PaymentMethod `json:"value,omitempty"` + // NextLink - The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// 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 +} + +// 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.NextLink == nil || len(to.String(pmlr.NextLink)) < 1 { + 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) + }() + } + next, err := page.fn(ctx, page.pmlr) + if err != nil { + return err + } + page.pmlr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(getNextPage func(context.Context, PaymentMethodsListResult) (PaymentMethodsListResult, error)) PaymentMethodsListResultPage { + return PaymentMethodsListResultPage{fn: getNextPage} +} + +// PaymentProperties the properties of the payment. +type PaymentProperties struct { + // PaymentType - The type of payment. + PaymentType *string `json:"paymentType,omitempty"` + // Amount - The paid amount. + Amount *Amount `json:"amount,omitempty"` + // Date - The date of the payment. + Date *date.Time `json:"date,omitempty"` +} + +// Permissions the set of allowed action and not allowed actions a caller has on a billing account +type Permissions struct { + // Actions - The set of actions that the caller is allowed to do + Actions *[]string `json:"actions,omitempty"` + // NotActions - The set of actions the caller is not allowed to do + NotActions *[]string `json:"notActions,omitempty"` +} + +// PermissionsListResult result of list billingPermissions a caller has on a billing account. +type PermissionsListResult struct { + autorest.Response `json:"-"` + // Value - The list OF billingPermissions a caller has on a billing account. + Value *[]Permissions `json:"value,omitempty"` +} + +// Policy the Policy. +type Policy struct { + autorest.Response `json:"-"` + *PolicyProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Policy. +func (p Policy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if p.PolicyProperties != nil { + objectMap["properties"] = p.PolicyProperties + } + if p.ID != nil { + objectMap["id"] = p.ID + } + if p.Name != nil { + objectMap["name"] = p.Name + } + if p.Type != nil { + objectMap["type"] = p.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Policy struct. +func (p *Policy) 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 policyProperties PolicyProperties + err = json.Unmarshal(*v, &policyProperties) + if err != nil { + return err + } + p.PolicyProperties = &policyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + p.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + p.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + p.Type = &typeVar + } + } + } + + return nil +} + +// PolicyProperties the properties of policy. +type PolicyProperties struct { + // ReservationPurchasesAllowed - The reservationPurchasesAllowed flag. + ReservationPurchasesAllowed *bool `json:"reservationPurchasesAllowed,omitempty"` + // MarketplacePurchasesAllowed - The marketplacePurchasesAllowed flag. + MarketplacePurchasesAllowed *bool `json:"marketplacePurchasesAllowed,omitempty"` +} + +// ProductDetails details of the product to be transferred. +type ProductDetails struct { + // ProductType - Type of the product to be transferred. Possible values include: 'ProductTypeAzureSubscription', 'ProductTypeAzureReservation' + ProductType ProductType `json:"productType,omitempty"` + // ProductID - Id of product to be transferred. + ProductID *string `json:"productId,omitempty"` +} + +// ProductsListResult result of listing products summary. It contains a list of available products +// summaries in reverse chronological order by purchase date. +type ProductsListResult struct { + autorest.Response `json:"-"` + // Value - The list of products summary. + Value *[]ProductSummary `json:"value,omitempty"` + // NextLink - The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ProductsListResultIterator provides access to a complete listing of ProductSummary values. +type ProductsListResultIterator struct { + i int + page ProductsListResultPage +} + +// 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 *ProductsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsListResultIterator.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 *ProductsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ProductsListResultIterator) 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 ProductsListResultIterator) Response() ProductsListResult { + 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 ProductsListResultIterator) Value() ProductSummary { + if !iter.page.NotDone() { + return ProductSummary{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ProductsListResultIterator type. +func NewProductsListResultIterator(page ProductsListResultPage) ProductsListResultIterator { + return ProductsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plr ProductsListResult) IsEmpty() bool { + return plr.Value == nil || len(*plr.Value) == 0 +} + +// productsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plr ProductsListResult) productsListResultPreparer(ctx context.Context) (*http.Request, error) { + if plr.NextLink == nil || len(to.String(plr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plr.NextLink))) +} + +// ProductsListResultPage contains a page of ProductSummary values. +type ProductsListResultPage struct { + fn func(context.Context, ProductsListResult) (ProductsListResult, error) + plr ProductsListResult +} + +// 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 *ProductsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.plr) + if err != nil { + return err + } + page.plr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ProductsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ProductsListResultPage) NotDone() bool { + return !page.plr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ProductsListResultPage) Response() ProductsListResult { + return page.plr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ProductsListResultPage) Values() []ProductSummary { + if page.plr.IsEmpty() { + return nil + } + return *page.plr.Value +} + +// Creates a new instance of the ProductsListResultPage type. +func NewProductsListResultPage(getNextPage func(context.Context, ProductsListResult) (ProductsListResult, error)) ProductsListResultPage { + return ProductsListResultPage{fn: getNextPage} +} + +// ProductSummary a product summary resource. +type ProductSummary struct { + autorest.Response `json:"-"` + *ProductSummaryProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProductSummary. +func (ps ProductSummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ps.ProductSummaryProperties != nil { + objectMap["properties"] = ps.ProductSummaryProperties + } + if ps.ID != nil { + objectMap["id"] = ps.ID + } + if ps.Name != nil { + objectMap["name"] = ps.Name + } + if ps.Type != nil { + objectMap["type"] = ps.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ProductSummary struct. +func (ps *ProductSummary) 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 productSummaryProperties ProductSummaryProperties + err = json.Unmarshal(*v, &productSummaryProperties) + if err != nil { + return err + } + ps.ProductSummaryProperties = &productSummaryProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ps.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ps.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ps.Type = &typeVar + } + } + } + + return nil +} + +// ProductSummaryProperties the properties of the product summary. +type ProductSummaryProperties struct { + // DisplayName - The display name of the product. + DisplayName *string `json:"displayName,omitempty"` + // PurchaseDate - The date of purchase. + PurchaseDate *date.Time `json:"purchaseDate,omitempty"` + // ProductTypeID - The product type id. + ProductTypeID *string `json:"productTypeId,omitempty"` + // ProductType - The type of product. + ProductType *string `json:"productType,omitempty"` + // Status - Product status. Possible values include: 'Active', 'Inactive', 'PastDue', 'Expiring', 'Expired', 'Disabled', 'Cancelled', 'AutoRenew' + Status ProductStatusType `json:"status,omitempty"` + // EndDate - end date. + EndDate *date.Time `json:"endDate,omitempty"` + // BillingFrequency - Billing frequency. Possible values include: 'OneTime', 'Monthly', 'UsageBased' + BillingFrequency Frequency `json:"billingFrequency,omitempty"` + // LastCharge - Last month charges. + LastCharge *Amount `json:"lastCharge,omitempty"` + // LastChargeDate - The date of the last charge. + LastChargeDate *date.Time `json:"lastChargeDate,omitempty"` + // Quantity - The purchased product quantity. + Quantity *float64 `json:"quantity,omitempty"` + // SkuID - Sku Id. + SkuID *string `json:"skuId,omitempty"` + // SkuDescription - Sku description. + SkuDescription *string `json:"skuDescription,omitempty"` + // AvailabilityID - Availability Id. + AvailabilityID *string `json:"availabilityId,omitempty"` + // ParentProductID - Parent Product Id. + ParentProductID *string `json:"parentProductId,omitempty"` + // InvoiceSectionID - Invoice section id to which this product belongs. + InvoiceSectionID *string `json:"invoiceSectionId,omitempty"` + // InvoiceSectionName - Invoice section name to which this product belongs. + InvoiceSectionName *string `json:"invoiceSectionName,omitempty"` + // BillingProfileID - Billing Profile id to which this product belongs. + BillingProfileID *string `json:"billingProfileId,omitempty"` + // BillingProfileName - Billing Profile name to which this product belongs. + BillingProfileName *string `json:"billingProfileName,omitempty"` +} + +// Profile a billing profile resource. +type Profile struct { + autorest.Response `json:"-"` + // ProfileProperties - A billing profile. + *ProfileProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Profile. +func (p Profile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if p.ProfileProperties != nil { + objectMap["properties"] = p.ProfileProperties + } + if p.ID != nil { + objectMap["id"] = p.ID + } + if p.Name != nil { + objectMap["name"] = p.Name + } + if p.Type != nil { + objectMap["type"] = p.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Profile struct. +func (p *Profile) 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 profileProperties ProfileProperties + err = json.Unmarshal(*v, &profileProperties) + if err != nil { + return err + } + p.ProfileProperties = &profileProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + p.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + p.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + p.Type = &typeVar + } + } + } + + return nil +} + +// ProfileListResult result of listing billing profiles. +type ProfileListResult struct { + autorest.Response `json:"-"` + // Value - The list of billing profiles. + Value *[]Profile `json:"value,omitempty"` + // NextLink - The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ProfileProperties the properties of the billing profile. +type ProfileProperties struct { + // DisplayName - The billing profile name. + DisplayName *string `json:"displayName,omitempty"` + // PoNumber - Purchase order number. + PoNumber *string `json:"poNumber,omitempty"` + // BillingAddress - Billing address. + BillingAddress *Address `json:"billingAddress,omitempty"` + // InvoiceEmailOptIn - If the billing profile is opted in to receive invoices via email. + InvoiceEmailOptIn *bool `json:"invoiceEmailOptIn,omitempty"` + // IsClassic - Is OMS bootstrapped billing profile. + IsClassic *bool `json:"isClassic,omitempty"` + // InvoiceDay - Invoice day. + InvoiceDay *int32 `json:"invoiceDay,omitempty"` + // Currency - The currency associated with the billing profile. + Currency *string `json:"currency,omitempty"` + // EnabledAzureSKUs - Information about the product. + EnabledAzureSKUs *[]EnabledAzureSKUs `json:"enabledAzureSKUs,omitempty"` + // InvoiceSections - The invoice sections associated to the billing profile. + InvoiceSections *[]InvoiceSection `json:"invoiceSections,omitempty"` +} + +// ProfilesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ProfilesUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ProfilesUpdateFuture) Result(client ProfilesClient) (p Profile, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("billing.ProfilesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if p.Response.Response, err = future.GetResult(sender); err == nil && p.Response.Response.StatusCode != http.StatusNoContent { + p, err = client.UpdateResponder(p.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesUpdateFuture", "Result", p.Response.Response, "Failure responding to request") + } + } + return +} + +// Property the billing property. +type Property struct { + autorest.Response `json:"-"` + // ProductID - Product Id. + ProductID *string `json:"productId,omitempty"` + // BillingTenantID - Billing tenant Id. + BillingTenantID *string `json:"billingTenantId,omitempty"` + // BillingAccountID - Billing account Id. + BillingAccountID *string `json:"billingAccountId,omitempty"` + // BillingAccountName - Billing account name. + BillingAccountName *string `json:"billingAccountName,omitempty"` + // BillingProfileID - Billing profile Id. + BillingProfileID *string `json:"billingProfileId,omitempty"` + // BillingProfileName - Billing profile name. + BillingProfileName *string `json:"billingProfileName,omitempty"` + // InvoiceSectionID - Invoice Section Id. + InvoiceSectionID *string `json:"invoiceSectionId,omitempty"` + // InvoiceSectionName - Invoice Section name. + InvoiceSectionName *string `json:"invoiceSectionName,omitempty"` + // SkuID - SKU Id. + SkuID *string `json:"skuId,omitempty"` + // SkuDescription - SKU description. + SkuDescription *string `json:"skuDescription,omitempty"` +} + +// RecipientTransferDetails details of the transfer. +type RecipientTransferDetails struct { + autorest.Response `json:"-"` + // RecipientTransferProperties - Details of the transfer. + *RecipientTransferProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecipientTransferDetails. +func (rtd RecipientTransferDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rtd.RecipientTransferProperties != nil { + objectMap["properties"] = rtd.RecipientTransferProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecipientTransferDetails struct. +func (rtd *RecipientTransferDetails) 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 recipientTransferProperties RecipientTransferProperties + err = json.Unmarshal(*v, &recipientTransferProperties) + if err != nil { + return err + } + rtd.RecipientTransferProperties = &recipientTransferProperties + } + } + } + + return nil +} + +// RecipientTransferDetailsListResult result of listing details of the transfer received by caller. +type RecipientTransferDetailsListResult struct { + autorest.Response `json:"-"` + // Value - The list of transfers received by caller. + Value *[]RecipientTransferDetails `json:"value,omitempty"` + // NextLink - The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// RecipientTransferDetailsListResultIterator provides access to a complete listing of +// RecipientTransferDetails values. +type RecipientTransferDetailsListResultIterator struct { + i int + page RecipientTransferDetailsListResultPage +} + +// 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 *RecipientTransferDetailsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecipientTransferDetailsListResultIterator.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 *RecipientTransferDetailsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RecipientTransferDetailsListResultIterator) 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 RecipientTransferDetailsListResultIterator) Response() RecipientTransferDetailsListResult { + 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 RecipientTransferDetailsListResultIterator) Value() RecipientTransferDetails { + if !iter.page.NotDone() { + return RecipientTransferDetails{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RecipientTransferDetailsListResultIterator type. +func NewRecipientTransferDetailsListResultIterator(page RecipientTransferDetailsListResultPage) RecipientTransferDetailsListResultIterator { + return RecipientTransferDetailsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rtdlr RecipientTransferDetailsListResult) IsEmpty() bool { + return rtdlr.Value == nil || len(*rtdlr.Value) == 0 +} + +// recipientTransferDetailsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rtdlr RecipientTransferDetailsListResult) recipientTransferDetailsListResultPreparer(ctx context.Context) (*http.Request, error) { + if rtdlr.NextLink == nil || len(to.String(rtdlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rtdlr.NextLink))) +} + +// RecipientTransferDetailsListResultPage contains a page of RecipientTransferDetails values. +type RecipientTransferDetailsListResultPage struct { + fn func(context.Context, RecipientTransferDetailsListResult) (RecipientTransferDetailsListResult, error) + rtdlr RecipientTransferDetailsListResult +} + +// 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 *RecipientTransferDetailsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecipientTransferDetailsListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.rtdlr) + if err != nil { + return err + } + page.rtdlr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RecipientTransferDetailsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RecipientTransferDetailsListResultPage) NotDone() bool { + return !page.rtdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RecipientTransferDetailsListResultPage) Response() RecipientTransferDetailsListResult { + return page.rtdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RecipientTransferDetailsListResultPage) Values() []RecipientTransferDetails { + if page.rtdlr.IsEmpty() { + return nil + } + return *page.rtdlr.Value +} + +// Creates a new instance of the RecipientTransferDetailsListResultPage type. +func NewRecipientTransferDetailsListResultPage(getNextPage func(context.Context, RecipientTransferDetailsListResult) (RecipientTransferDetailsListResult, error)) RecipientTransferDetailsListResultPage { + return RecipientTransferDetailsListResultPage{fn: getNextPage} +} + +// RecipientTransferProperties transfer Details. +type RecipientTransferProperties struct { + // CreationTime - Transfer creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // ExpirationTime - Transfer expiration time. + ExpirationTime *date.Time `json:"expirationTime,omitempty"` + // AllowedProductType - Type of subscriptions that can be transferred. + AllowedProductType *[]EligibleProductType `json:"allowedProductType,omitempty"` + // TransferStatus - Overall transfer status. Possible values include: 'TransferStatusPending', 'TransferStatusInProgress', 'TransferStatusCompleted', 'TransferStatusCompletedWithErrors', 'TransferStatusFailed', 'TransferStatusCanceled', 'TransferStatusDeclined' + TransferStatus TransferStatus `json:"transferStatus,omitempty"` + // RecipientEmailID - Email Id of recipient of transfer. + RecipientEmailID *string `json:"recipientEmailId,omitempty"` + // InitiatorEmailID - Email Id of initiator of transfer. + InitiatorEmailID *string `json:"initiatorEmailId,omitempty"` + // CanceledBy - Email Id who user canceled the transfer. + CanceledBy *string `json:"canceledBy,omitempty"` + // LastModifiedTime - Transfer last modification time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // DetailedTransferStatus - Detailed transfer status. + DetailedTransferStatus *[]DetailedTransferStatus `json:"detailedTransferStatus,omitempty"` +} + +// Resource the Resource model definition. +type Resource struct { + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// RoleAssignment a role assignment +type RoleAssignment struct { + autorest.Response `json:"-"` + // RoleAssignmentProperties - The role assignment the caller has + *RoleAssignmentProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleAssignment. +func (ra RoleAssignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ra.RoleAssignmentProperties != nil { + objectMap["properties"] = ra.RoleAssignmentProperties + } + if ra.ID != nil { + objectMap["id"] = ra.ID + } + if ra.Name != nil { + objectMap["name"] = ra.Name + } + if ra.Type != nil { + objectMap["type"] = ra.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoleAssignment struct. +func (ra *RoleAssignment) 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 roleAssignmentProperties RoleAssignmentProperties + err = json.Unmarshal(*v, &roleAssignmentProperties) + if err != nil { + return err + } + ra.RoleAssignmentProperties = &roleAssignmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ra.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ra.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ra.Type = &typeVar + } + } + } + + return nil +} + +// RoleAssignmentListResult result of get list of role assignments +type RoleAssignmentListResult struct { + autorest.Response `json:"-"` + // Value - The list role assignments + Value *[]RoleAssignment `json:"value,omitempty"` +} + +// RoleAssignmentPayload the payload use to update role assignment on a scope +type RoleAssignmentPayload struct { + // PrincipalID - The user's principal id that the role gets assigned to + PrincipalID *string `json:"principalId,omitempty"` + // BillingRoleDefinitionName - The role definition id + BillingRoleDefinitionName *string `json:"billingRoleDefinitionName,omitempty"` +} + +// RoleAssignmentProperties the properties of the a role assignment. +type RoleAssignmentProperties struct { + // CreatedOn - the date the role assignment is created + CreatedOn *string `json:"createdOn,omitempty"` + // CreatedByPrincipalTenantID - the creator's tenant Id + CreatedByPrincipalTenantID *string `json:"createdByPrincipalTenantId,omitempty"` + // CreatedByPrincipalID - the creator's principal Id + CreatedByPrincipalID *string `json:"createdByPrincipalId,omitempty"` + // Name - the name of the role assignment + Name *string `json:"name,omitempty"` + // PrincipalID - The user's principal id that the role gets assigned to + PrincipalID *string `json:"principalId,omitempty"` + // RoleDefinitionName - The role definition id + RoleDefinitionName *string `json:"roleDefinitionName,omitempty"` + // Scope - The scope the role get assigned to + Scope *string `json:"scope,omitempty"` +} + +// RoleDefinition result of get role definition for a role. +type RoleDefinition struct { + autorest.Response `json:"-"` + // RoleDefinitionProperties - The role definition for a role. + *RoleDefinitionProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleDefinition. +func (rd RoleDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rd.RoleDefinitionProperties != nil { + objectMap["properties"] = rd.RoleDefinitionProperties + } + if rd.ID != nil { + objectMap["id"] = rd.ID + } + if rd.Name != nil { + objectMap["name"] = rd.Name + } + if rd.Type != nil { + objectMap["type"] = rd.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoleDefinition struct. +func (rd *RoleDefinition) 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 roleDefinitionProperties RoleDefinitionProperties + err = json.Unmarshal(*v, &roleDefinitionProperties) + if err != nil { + return err + } + rd.RoleDefinitionProperties = &roleDefinitionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rd.Type = &typeVar + } + } + } + + return nil +} + +// RoleDefinitionListResult list the role definitions. +type RoleDefinitionListResult struct { + autorest.Response `json:"-"` + // Value - The list of role definitions. + Value *[]RoleDefinition `json:"value,omitempty"` +} + +// RoleDefinitionProperties the properties of the a role definition. +type RoleDefinitionProperties struct { + // Description - The role description + Description *string `json:"description,omitempty"` + // PermissionsListResult - The billingPermissions the role has + *PermissionsListResult `json:"permissions,omitempty"` + // RoleName - The name of the role + RoleName *string `json:"roleName,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleDefinitionProperties. +func (rdp RoleDefinitionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rdp.Description != nil { + objectMap["description"] = rdp.Description + } + if rdp.PermissionsListResult != nil { + objectMap["permissions"] = rdp.PermissionsListResult + } + if rdp.RoleName != nil { + objectMap["roleName"] = rdp.RoleName + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoleDefinitionProperties struct. +func (rdp *RoleDefinitionProperties) 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 "description": + if v != nil { + var description string + err = json.Unmarshal(*v, &description) + if err != nil { + return err + } + rdp.Description = &description + } + case "permissions": + if v != nil { + var permissionsListResult PermissionsListResult + err = json.Unmarshal(*v, &permissionsListResult) + if err != nil { + return err + } + rdp.PermissionsListResult = &permissionsListResult + } + case "roleName": + if v != nil { + var roleName string + err = json.Unmarshal(*v, &roleName) + if err != nil { + return err + } + rdp.RoleName = &roleName + } + } + } + + return nil +} + +// SubscriptionProperties the usage context properties. +type SubscriptionProperties struct { + // DisplayName - display name. + DisplayName *string `json:"displayName,omitempty"` + // SubscriptionID - Subscription Id. + SubscriptionID *uuid.UUID `json:"subscriptionId,omitempty"` + // SubscriptionBillingStatus - Subscription billing status. Possible values include: 'SubscriptionStatusTypeActive', 'SubscriptionStatusTypeInactive', 'SubscriptionStatusTypeAbandoned', 'SubscriptionStatusTypeDeleted', 'SubscriptionStatusTypeWarning' + SubscriptionBillingStatus SubscriptionStatusType `json:"subscriptionBillingStatus,omitempty"` + // LastMonthCharges - Last month charges. + LastMonthCharges *Amount `json:"lastMonthCharges,omitempty"` + // MonthToDateCharges - Month to date charges. + MonthToDateCharges *Amount `json:"monthToDateCharges,omitempty"` + // EnrollmentAccountContext - The enrollment account context. + EnrollmentAccountContext *EnrollmentAccountContext `json:"enrollmentAccountContext,omitempty"` + // BillingProfileID - Billing Profile id to which this product belongs. + BillingProfileID *string `json:"billingProfileId,omitempty"` + // BillingProfileName - Billing Profile name to which this product belongs. + BillingProfileName *string `json:"billingProfileName,omitempty"` + // SkuID - The sku id. + SkuID *string `json:"skuId,omitempty"` + // SkuDescription - The sku description. + SkuDescription *string `json:"skuDescription,omitempty"` +} + +// SubscriptionsListResult result of listing billing subscriptions summary. +type SubscriptionsListResult struct { + autorest.Response `json:"-"` + // Value - The list of billing subscriptions summary. + Value *[]SubscriptionSummary `json:"value,omitempty"` + // NextLink - The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SubscriptionsListResultIterator provides access to a complete listing of SubscriptionSummary values. +type SubscriptionsListResultIterator struct { + i int + page SubscriptionsListResultPage +} + +// 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 *SubscriptionsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsListResultIterator.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 *SubscriptionsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SubscriptionsListResultIterator) 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 SubscriptionsListResultIterator) Response() SubscriptionsListResult { + 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 SubscriptionsListResultIterator) Value() SubscriptionSummary { + if !iter.page.NotDone() { + return SubscriptionSummary{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SubscriptionsListResultIterator type. +func NewSubscriptionsListResultIterator(page SubscriptionsListResultPage) SubscriptionsListResultIterator { + return SubscriptionsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (slr SubscriptionsListResult) IsEmpty() bool { + return slr.Value == nil || len(*slr.Value) == 0 +} + +// subscriptionsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (slr SubscriptionsListResult) subscriptionsListResultPreparer(ctx context.Context) (*http.Request, error) { + if slr.NextLink == nil || len(to.String(slr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(slr.NextLink))) +} + +// SubscriptionsListResultPage contains a page of SubscriptionSummary values. +type SubscriptionsListResultPage struct { + fn func(context.Context, SubscriptionsListResult) (SubscriptionsListResult, error) + slr SubscriptionsListResult +} + +// 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 *SubscriptionsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.slr) + if err != nil { + return err + } + page.slr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SubscriptionsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SubscriptionsListResultPage) NotDone() bool { + return !page.slr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SubscriptionsListResultPage) Response() SubscriptionsListResult { + return page.slr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SubscriptionsListResultPage) Values() []SubscriptionSummary { + if page.slr.IsEmpty() { + return nil + } + return *page.slr.Value +} + +// Creates a new instance of the SubscriptionsListResultPage type. +func NewSubscriptionsListResultPage(getNextPage func(context.Context, SubscriptionsListResult) (SubscriptionsListResult, error)) SubscriptionsListResultPage { + return SubscriptionsListResultPage{fn: getNextPage} +} + +// SubscriptionSummary a billing Subscription summary resource. +type SubscriptionSummary struct { + autorest.Response `json:"-"` + *SubscriptionProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubscriptionSummary. +func (ss SubscriptionSummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ss.SubscriptionProperties != nil { + objectMap["properties"] = ss.SubscriptionProperties + } + if ss.ID != nil { + objectMap["id"] = ss.ID + } + if ss.Name != nil { + objectMap["name"] = ss.Name + } + if ss.Type != nil { + objectMap["type"] = ss.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SubscriptionSummary struct. +func (ss *SubscriptionSummary) 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 subscriptionProperties SubscriptionProperties + err = json.Unmarshal(*v, &subscriptionProperties) + if err != nil { + return err + } + ss.SubscriptionProperties = &subscriptionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ss.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ss.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ss.Type = &typeVar + } + } + } + + return nil +} + +// SubscriptionTransferFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SubscriptionTransferFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *SubscriptionTransferFuture) Result(client SubscriptionClient) (tbsr TransferBillingSubscriptionResult, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionTransferFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("billing.SubscriptionTransferFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tbsr.Response.Response, err = future.GetResult(sender); err == nil && tbsr.Response.Response.StatusCode != http.StatusNoContent { + tbsr, err = client.TransferResponder(tbsr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionTransferFuture", "Result", tbsr.Response.Response, "Failure responding to request") + } + } + return +} + +// TransactionsListResult result of listing reservation transactions summary. +type TransactionsListResult struct { + autorest.Response `json:"-"` + // Value - The list of reservation transactions summary. + Value *[]TransactionsSummary `json:"value,omitempty"` + // NextLink - The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// TransactionsListResultIterator provides access to a complete listing of TransactionsSummary values. +type TransactionsListResultIterator struct { + i int + page TransactionsListResultPage +} + +// 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 *TransactionsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransactionsListResultIterator.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 *TransactionsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter TransactionsListResultIterator) 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 TransactionsListResultIterator) Response() TransactionsListResult { + 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 TransactionsListResultIterator) Value() TransactionsSummary { + if !iter.page.NotDone() { + return TransactionsSummary{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the TransactionsListResultIterator type. +func NewTransactionsListResultIterator(page TransactionsListResultPage) TransactionsListResultIterator { + return TransactionsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (tlr TransactionsListResult) IsEmpty() bool { + return tlr.Value == nil || len(*tlr.Value) == 0 +} + +// transactionsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (tlr TransactionsListResult) transactionsListResultPreparer(ctx context.Context) (*http.Request, error) { + if tlr.NextLink == nil || len(to.String(tlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(tlr.NextLink))) +} + +// TransactionsListResultPage contains a page of TransactionsSummary values. +type TransactionsListResultPage struct { + fn func(context.Context, TransactionsListResult) (TransactionsListResult, error) + tlr TransactionsListResult +} + +// 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 *TransactionsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransactionsListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.tlr) + if err != nil { + return err + } + page.tlr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *TransactionsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page TransactionsListResultPage) NotDone() bool { + return !page.tlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page TransactionsListResultPage) Response() TransactionsListResult { + return page.tlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page TransactionsListResultPage) Values() []TransactionsSummary { + if page.tlr.IsEmpty() { + return nil + } + return *page.tlr.Value +} + +// Creates a new instance of the TransactionsListResultPage type. +func NewTransactionsListResultPage(getNextPage func(context.Context, TransactionsListResult) (TransactionsListResult, error)) TransactionsListResultPage { + return TransactionsListResultPage{fn: getNextPage} +} + +// TransactionsSummary a reservation transaction summary resource. +type TransactionsSummary struct { + *TransactionsSummaryProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TransactionsSummary. +func (ts TransactionsSummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ts.TransactionsSummaryProperties != nil { + objectMap["properties"] = ts.TransactionsSummaryProperties + } + if ts.ID != nil { + objectMap["id"] = ts.ID + } + if ts.Name != nil { + objectMap["name"] = ts.Name + } + if ts.Type != nil { + objectMap["type"] = ts.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TransactionsSummary struct. +func (ts *TransactionsSummary) 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 transactionsSummaryProperties TransactionsSummaryProperties + err = json.Unmarshal(*v, &transactionsSummaryProperties) + if err != nil { + return err + } + ts.TransactionsSummaryProperties = &transactionsSummaryProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ts.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ts.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ts.Type = &typeVar + } + } + } + + return nil +} + +// TransactionsSummaryProperties the properties of the reservation transaction summary. +type TransactionsSummaryProperties struct { + // Kind - The kind of transaction. Choices are all and reservation. Possible values include: 'All', 'Reservation' + Kind TransactionTypeKind `json:"kind,omitempty"` + // Date - The date of reservation transaction. + Date *date.Time `json:"date,omitempty"` + // Invoice - Invoice number or 'pending' if not invoiced. + Invoice *string `json:"invoice,omitempty"` + // OrderID - The reservation order id. + OrderID *string `json:"orderId,omitempty"` + // OrderName - The reservation order name. + OrderName *string `json:"orderName,omitempty"` + // ProductTypeID - The product type id. + ProductTypeID *string `json:"productTypeId,omitempty"` + // ProductType - The type of product. + ProductType *string `json:"productType,omitempty"` + // ProductDescription - Product description. + ProductDescription *string `json:"productDescription,omitempty"` + // TransactionType - Transaction types. Possible values include: 'Purchase', 'UsageCharge' + TransactionType ReservationType `json:"transactionType,omitempty"` + // TransactionAmount - Last charge associated with the purchase. + TransactionAmount *Amount `json:"transactionAmount,omitempty"` + // Quantity - Purchase quantity. + Quantity *int32 `json:"quantity,omitempty"` + // InvoiceSectionID - Invoice section id to which this product belongs. + InvoiceSectionID *string `json:"invoiceSectionId,omitempty"` + // InvoiceSectionName - Invoice section name to which this product belongs. + InvoiceSectionName *string `json:"invoiceSectionName,omitempty"` + // BillingProfileID - Billing Profile id to which this product belongs. + BillingProfileID *string `json:"billingProfileId,omitempty"` + // BillingProfileName - Billing Profile name to which this product belongs. + BillingProfileName *string `json:"billingProfileName,omitempty"` + // SubscriptionID - The subscription id. + SubscriptionID *string `json:"subscriptionId,omitempty"` + // SubscriptionName - The subscription name. + SubscriptionName *string `json:"subscriptionName,omitempty"` +} + +// TransferBillingSubscriptionRequest request parameters to transfer billing subscription. +type TransferBillingSubscriptionRequest struct { + // TransferBillingSubscriptionRequestProperties - Request parameters to transfer billing subscription. + *TransferBillingSubscriptionRequestProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for TransferBillingSubscriptionRequest. +func (tbsr TransferBillingSubscriptionRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tbsr.TransferBillingSubscriptionRequestProperties != nil { + objectMap["properties"] = tbsr.TransferBillingSubscriptionRequestProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TransferBillingSubscriptionRequest struct. +func (tbsr *TransferBillingSubscriptionRequest) 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 transferBillingSubscriptionRequestProperties TransferBillingSubscriptionRequestProperties + err = json.Unmarshal(*v, &transferBillingSubscriptionRequestProperties) + if err != nil { + return err + } + tbsr.TransferBillingSubscriptionRequestProperties = &transferBillingSubscriptionRequestProperties + } + } + } + + return nil +} + +// TransferBillingSubscriptionRequestProperties request parameters to transfer billing subscription. +type TransferBillingSubscriptionRequestProperties struct { + // DestinationInvoiceSectionName - The destination invoiceSectionName. + DestinationInvoiceSectionName *string `json:"destinationInvoiceSectionName,omitempty"` +} + +// TransferBillingSubscriptionResult request parameters to transfer billing subscription. +type TransferBillingSubscriptionResult struct { + autorest.Response `json:"-"` + // TransferBillingSubscriptionResultProperties - Request parameters to transfer billing subscription. + *TransferBillingSubscriptionResultProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for TransferBillingSubscriptionResult. +func (tbsr TransferBillingSubscriptionResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tbsr.TransferBillingSubscriptionResultProperties != nil { + objectMap["properties"] = tbsr.TransferBillingSubscriptionResultProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TransferBillingSubscriptionResult struct. +func (tbsr *TransferBillingSubscriptionResult) 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 transferBillingSubscriptionResultProperties TransferBillingSubscriptionResultProperties + err = json.Unmarshal(*v, &transferBillingSubscriptionResultProperties) + if err != nil { + return err + } + tbsr.TransferBillingSubscriptionResultProperties = &transferBillingSubscriptionResultProperties + } + } + } + + return nil +} + +// TransferBillingSubscriptionResultProperties transfer billing subscription result properties. +type TransferBillingSubscriptionResultProperties struct { + // BillingSubscriptionName - The destination billing subscription id. + BillingSubscriptionName *string `json:"billingSubscriptionName,omitempty"` +} + +// TransferDetails details of the transfer. +type TransferDetails struct { + autorest.Response `json:"-"` + // TransferProperties - Details of the transfer. + *TransferProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for TransferDetails. +func (td TransferDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if td.TransferProperties != nil { + objectMap["properties"] = td.TransferProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TransferDetails struct. +func (td *TransferDetails) 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 transferProperties TransferProperties + err = json.Unmarshal(*v, &transferProperties) + if err != nil { + return err + } + td.TransferProperties = &transferProperties + } + } + } + + return nil +} + +// TransferDetailsListResult result of listing details of the transfer initiated by caller. +type TransferDetailsListResult struct { + autorest.Response `json:"-"` + // Value - The list of transfers initiated by caller. + Value *[]TransferDetails `json:"value,omitempty"` + // NextLink - The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// TransferDetailsListResultIterator provides access to a complete listing of TransferDetails values. +type TransferDetailsListResultIterator struct { + i int + page TransferDetailsListResultPage +} + +// 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 *TransferDetailsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransferDetailsListResultIterator.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 *TransferDetailsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter TransferDetailsListResultIterator) 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 TransferDetailsListResultIterator) Response() TransferDetailsListResult { + 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 TransferDetailsListResultIterator) Value() TransferDetails { + if !iter.page.NotDone() { + return TransferDetails{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the TransferDetailsListResultIterator type. +func NewTransferDetailsListResultIterator(page TransferDetailsListResultPage) TransferDetailsListResultIterator { + return TransferDetailsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (tdlr TransferDetailsListResult) IsEmpty() bool { + return tdlr.Value == nil || len(*tdlr.Value) == 0 +} + +// transferDetailsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (tdlr TransferDetailsListResult) transferDetailsListResultPreparer(ctx context.Context) (*http.Request, error) { + if tdlr.NextLink == nil || len(to.String(tdlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(tdlr.NextLink))) +} + +// TransferDetailsListResultPage contains a page of TransferDetails values. +type TransferDetailsListResultPage struct { + fn func(context.Context, TransferDetailsListResult) (TransferDetailsListResult, error) + tdlr TransferDetailsListResult +} + +// 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 *TransferDetailsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransferDetailsListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.tdlr) + if err != nil { + return err + } + page.tdlr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *TransferDetailsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page TransferDetailsListResultPage) NotDone() bool { + return !page.tdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page TransferDetailsListResultPage) Response() TransferDetailsListResult { + return page.tdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page TransferDetailsListResultPage) Values() []TransferDetails { + if page.tdlr.IsEmpty() { + return nil + } + return *page.tdlr.Value +} + +// Creates a new instance of the TransferDetailsListResultPage type. +func NewTransferDetailsListResultPage(getNextPage func(context.Context, TransferDetailsListResult) (TransferDetailsListResult, error)) TransferDetailsListResultPage { + return TransferDetailsListResultPage{fn: getNextPage} +} + +// TransferProductRequestProperties the properties of the product to initiate a transfer. +type TransferProductRequestProperties struct { + // DestinationInvoiceSectionName - Destination invoice section id. + DestinationInvoiceSectionName *string `json:"destinationInvoiceSectionName,omitempty"` +} + +// TransferProperties transfer details +type TransferProperties struct { + // CreationTime - Transfer creation time. + CreationTime *date.Time `json:"creationTime,omitempty"` + // ExpirationTime - Transfer expiration time. + ExpirationTime *date.Time `json:"expirationTime,omitempty"` + // InvoiceSectionID - Target invoice section Id. + InvoiceSectionID *string `json:"invoiceSectionId,omitempty"` + // BillingAccountID - Target billing account Id. + BillingAccountID *string `json:"billingAccountId,omitempty"` + // TransferStatus - Overall transfer status. Possible values include: 'TransferStatusPending', 'TransferStatusInProgress', 'TransferStatusCompleted', 'TransferStatusCompletedWithErrors', 'TransferStatusFailed', 'TransferStatusCanceled', 'TransferStatusDeclined' + TransferStatus TransferStatus `json:"transferStatus,omitempty"` + // RecipientEmailID - Email Id of recipient of transfer. + RecipientEmailID *string `json:"recipientEmailId,omitempty"` + // InitiatorEmailID - Email Id of initiator of transfer. + InitiatorEmailID *string `json:"initiatorEmailId,omitempty"` + // CanceledBy - Email Id who user canceled the transfer. + CanceledBy *string `json:"canceledBy,omitempty"` + // LastModifiedTime - Transfer last modification time. + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + // DetailedTransferStatus - Detailed transfer status. + DetailedTransferStatus *[]DetailedTransferStatus `json:"detailedTransferStatus,omitempty"` +} + +// UpdateAutoRenewOperationSummary summary of cancel product operation +type UpdateAutoRenewOperationSummary struct { + autorest.Response `json:"-"` + // UpdateAutoRenewOperationSummaryProperties - Summary of update auto renew operation summary properties + *UpdateAutoRenewOperationSummaryProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for UpdateAutoRenewOperationSummary. +func (uaros UpdateAutoRenewOperationSummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if uaros.UpdateAutoRenewOperationSummaryProperties != nil { + objectMap["properties"] = uaros.UpdateAutoRenewOperationSummaryProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for UpdateAutoRenewOperationSummary struct. +func (uaros *UpdateAutoRenewOperationSummary) 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 updateAutoRenewOperationSummaryProperties UpdateAutoRenewOperationSummaryProperties + err = json.Unmarshal(*v, &updateAutoRenewOperationSummaryProperties) + if err != nil { + return err + } + uaros.UpdateAutoRenewOperationSummaryProperties = &updateAutoRenewOperationSummaryProperties + } + } + } + + return nil +} + +// UpdateAutoRenewOperationSummaryProperties update auto renew operation summary properties +type UpdateAutoRenewOperationSummaryProperties struct { + // EndDate - The end date of this asset + EndDate *date.Time `json:"endDate,omitempty"` +} + +// UpdateAutoRenewRequest request parameters to update auto renew for support product. +type UpdateAutoRenewRequest struct { + // AutoRenew - Request parameters to update auto renew policy a product. Possible values include: 'True', 'False' + AutoRenew UpdateAutoRenew `json:"autoRenew,omitempty"` +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/operations.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/operations.go new file mode 100644 index 000000000000..68e67b7fd8eb --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/operations.go @@ -0,0 +1,147 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the billing client provides access to billing resources for Azure subscriptions. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of 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") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.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.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Billing/operations"), + 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 OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.OperationsClient", "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.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.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/preview/billing/mgmt/2018-11-01-preview/billing/paymentmethodsbybillingprofile.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/paymentmethodsbybillingprofile.go new file mode 100644 index 000000000000..2b7675f2b57d --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/paymentmethodsbybillingprofile.go @@ -0,0 +1,157 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PaymentMethodsByBillingProfileClient is the billing client provides access to billing resources for Azure +// subscriptions. +type PaymentMethodsByBillingProfileClient struct { + BaseClient +} + +// NewPaymentMethodsByBillingProfileClient creates an instance of the PaymentMethodsByBillingProfileClient client. +func NewPaymentMethodsByBillingProfileClient(subscriptionID string) PaymentMethodsByBillingProfileClient { + return NewPaymentMethodsByBillingProfileClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPaymentMethodsByBillingProfileClientWithBaseURI creates an instance of the PaymentMethodsByBillingProfileClient +// client. +func NewPaymentMethodsByBillingProfileClientWithBaseURI(baseURI string, subscriptionID string) PaymentMethodsByBillingProfileClient { + return PaymentMethodsByBillingProfileClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists the Payment Methods by billing profile Id. +// Parameters: +// billingAccountName - billing Account Id. +// billingProfileName - billing Profile Id. +func (client PaymentMethodsByBillingProfileClient) List(ctx context.Context, billingAccountName string, billingProfileName string) (result PaymentMethodsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodsByBillingProfileClient.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, billingAccountName, billingProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsByBillingProfileClient", "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.PaymentMethodsByBillingProfileClient", "List", resp, "Failure sending request") + return + } + + result.pmlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsByBillingProfileClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client PaymentMethodsByBillingProfileClient) ListPreparer(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 = "2018-11-01-preview" + 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}/paymentMethods", 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 PaymentMethodsByBillingProfileClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 PaymentMethodsByBillingProfileClient) ListResponder(resp *http.Response) (result PaymentMethodsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 PaymentMethodsByBillingProfileClient) listNextResults(ctx context.Context, lastResults PaymentMethodsListResult) (result PaymentMethodsListResult, err error) { + req, err := lastResults.paymentMethodsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.PaymentMethodsByBillingProfileClient", "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.PaymentMethodsByBillingProfileClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsByBillingProfileClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PaymentMethodsByBillingProfileClient) ListComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result PaymentMethodsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodsByBillingProfileClient.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, billingAccountName, billingProfileName) + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/policy.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/policy.go new file mode 100644 index 000000000000..65c1bf805077 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/policy.go @@ -0,0 +1,196 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PolicyClient is the billing client provides access to billing resources for Azure subscriptions. +type PolicyClient struct { + BaseClient +} + +// NewPolicyClient creates an instance of the PolicyClient client. +func NewPolicyClient(subscriptionID string) PolicyClient { + return NewPolicyClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPolicyClientWithBaseURI creates an instance of the PolicyClient client. +func NewPolicyClientWithBaseURI(baseURI string, subscriptionID string) PolicyClient { + return PolicyClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetByBillingProfile the policy for a given billingAccountName and billingProfileName. +// Parameters: +// billingAccountName - billing Account Id. +// billingProfileName - billing Profile Id. +func (client PolicyClient) GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result Policy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyClient.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) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PolicyClient", "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.PolicyClient", "GetByBillingProfile", resp, "Failure sending request") + return + } + + result, err = client.GetByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PolicyClient", "GetByBillingProfile", resp, "Failure responding to request") + } + + return +} + +// GetByBillingProfilePreparer prepares the GetByBillingProfile request. +func (client PolicyClient) GetByBillingProfilePreparer(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 = "2018-11-01-preview" + 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}/policies/default", 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 PolicyClient) GetByBillingProfileSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 PolicyClient) GetByBillingProfileResponder(resp *http.Response) (result Policy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update the operation to update a policy. +// Parameters: +// billingAccountName - billing Account Id. +// billingProfileName - billing Profile Id. +// parameters - parameters supplied to the update policy operation. +func (client PolicyClient) Update(ctx context.Context, billingAccountName string, billingProfileName string, parameters Policy) (result Policy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, billingAccountName, billingProfileName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PolicyClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PolicyClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PolicyClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PolicyClient) UpdatePreparer(ctx context.Context, billingAccountName string, billingProfileName string, parameters Policy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PolicyClient) UpdateResponder(resp *http.Response) (result Policy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/products.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/products.go new file mode 100644 index 000000000000..e6ce2acad1eb --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/products.go @@ -0,0 +1,200 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ProductsClient is the billing client provides access to billing resources for Azure subscriptions. +type ProductsClient struct { + BaseClient +} + +// NewProductsClient creates an instance of the ProductsClient client. +func NewProductsClient(subscriptionID string) ProductsClient { + return NewProductsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProductsClientWithBaseURI creates an instance of the ProductsClient client. +func NewProductsClientWithBaseURI(baseURI string, subscriptionID string) ProductsClient { + return ProductsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get a single product by name. +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +// productName - invoice Id. +func (client ProductsClient) Get(ctx context.Context, billingAccountName string, invoiceSectionName string, productName string) (result ProductSummary, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsClient.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, invoiceSectionName, productName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "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.ProductsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ProductsClient) GetPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, productName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + "productName": autorest.Encode("path", productName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/products/{productName}", 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 ProductsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 ProductsClient) GetResponder(resp *http.Response) (result ProductSummary, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Transfer the operation to transfer a Product to another InvoiceSection. +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +// productName - invoice Id. +// parameters - parameters supplied to the Transfer Product operation. +func (client ProductsClient) Transfer(ctx context.Context, billingAccountName string, invoiceSectionName string, productName string, parameters TransferProductRequestProperties) (result ProductSummary, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsClient.Transfer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.TransferPreparer(ctx, billingAccountName, invoiceSectionName, productName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "Transfer", nil, "Failure preparing request") + return + } + + resp, err := client.TransferSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "Transfer", resp, "Failure sending request") + return + } + + result, err = client.TransferResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "Transfer", resp, "Failure responding to request") + } + + return +} + +// TransferPreparer prepares the Transfer request. +func (client ProductsClient) TransferPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, productName string, parameters TransferProductRequestProperties) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + "productName": autorest.Encode("path", productName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/products/{productName}/transfer", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// TransferSender sends the Transfer request. The method will close the +// http.Response Body if it receives an error. +func (client ProductsClient) TransferSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// TransferResponder handles the response to the Transfer request. The method always +// closes the http.Response Body. +func (client ProductsClient) TransferResponder(resp *http.Response) (result ProductSummary, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/productsbybillingaccount.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/productsbybillingaccount.go new file mode 100644 index 000000000000..7368cf3ff45f --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/productsbybillingaccount.go @@ -0,0 +1,159 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ProductsByBillingAccountClient is the billing client provides access to billing resources for Azure subscriptions. +type ProductsByBillingAccountClient struct { + BaseClient +} + +// NewProductsByBillingAccountClient creates an instance of the ProductsByBillingAccountClient client. +func NewProductsByBillingAccountClient(subscriptionID string) ProductsByBillingAccountClient { + return NewProductsByBillingAccountClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProductsByBillingAccountClientWithBaseURI creates an instance of the ProductsByBillingAccountClient client. +func NewProductsByBillingAccountClientWithBaseURI(baseURI string, subscriptionID string) ProductsByBillingAccountClient { + return ProductsByBillingAccountClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists products by billingAccountName. +// Parameters: +// billingAccountName - billing Account Id. +// filter - may be used to filter by product type. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. +// It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and +// value is separated by a colon (:). +func (client ProductsByBillingAccountClient) List(ctx context.Context, billingAccountName string, filter string) (result ProductsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsByBillingAccountClient.List") + defer func() { + sc := -1 + if result.plr.Response.Response != nil { + sc = result.plr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, billingAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsByBillingAccountClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.plr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProductsByBillingAccountClient", "List", resp, "Failure sending request") + return + } + + result.plr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsByBillingAccountClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ProductsByBillingAccountClient) ListPreparer(ctx context.Context, billingAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products", 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 ProductsByBillingAccountClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 ProductsByBillingAccountClient) ListResponder(resp *http.Response) (result ProductsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 ProductsByBillingAccountClient) listNextResults(ctx context.Context, lastResults ProductsListResult) (result ProductsListResult, err error) { + req, err := lastResults.productsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.ProductsByBillingAccountClient", "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.ProductsByBillingAccountClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsByBillingAccountClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ProductsByBillingAccountClient) ListComplete(ctx context.Context, billingAccountName string, filter string) (result ProductsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsByBillingAccountClient.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, billingAccountName, filter) + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/productsbybillingsubscriptions.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/productsbybillingsubscriptions.go new file mode 100644 index 000000000000..fc795fd359ae --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/productsbybillingsubscriptions.go @@ -0,0 +1,155 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ProductsByBillingSubscriptionsClient is the billing client provides access to billing resources for Azure +// subscriptions. +type ProductsByBillingSubscriptionsClient struct { + BaseClient +} + +// NewProductsByBillingSubscriptionsClient creates an instance of the ProductsByBillingSubscriptionsClient client. +func NewProductsByBillingSubscriptionsClient(subscriptionID string) ProductsByBillingSubscriptionsClient { + return NewProductsByBillingSubscriptionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProductsByBillingSubscriptionsClientWithBaseURI creates an instance of the ProductsByBillingSubscriptionsClient +// client. +func NewProductsByBillingSubscriptionsClientWithBaseURI(baseURI string, subscriptionID string) ProductsByBillingSubscriptionsClient { + return ProductsByBillingSubscriptionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists billing subscriptions by billingAccountName. +// Parameters: +// billingAccountName - billing Account Id. +func (client ProductsByBillingSubscriptionsClient) List(ctx context.Context, billingAccountName string) (result SubscriptionsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsByBillingSubscriptionsClient.List") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, billingAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsByBillingSubscriptionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProductsByBillingSubscriptionsClient", "List", resp, "Failure sending request") + return + } + + result.slr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsByBillingSubscriptionsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ProductsByBillingSubscriptionsClient) ListPreparer(ctx context.Context, billingAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions", 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 ProductsByBillingSubscriptionsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 ProductsByBillingSubscriptionsClient) ListResponder(resp *http.Response) (result SubscriptionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 ProductsByBillingSubscriptionsClient) listNextResults(ctx context.Context, lastResults SubscriptionsListResult) (result SubscriptionsListResult, err error) { + req, err := lastResults.subscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.ProductsByBillingSubscriptionsClient", "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.ProductsByBillingSubscriptionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsByBillingSubscriptionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ProductsByBillingSubscriptionsClient) ListComplete(ctx context.Context, billingAccountName string) (result SubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsByBillingSubscriptionsClient.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, billingAccountName) + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/productsbyinvoicesection.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/productsbyinvoicesection.go new file mode 100644 index 000000000000..95bc8c2f161f --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/productsbyinvoicesection.go @@ -0,0 +1,123 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ProductsByInvoiceSectionClient is the billing client provides access to billing resources for Azure subscriptions. +type ProductsByInvoiceSectionClient struct { + BaseClient +} + +// NewProductsByInvoiceSectionClient creates an instance of the ProductsByInvoiceSectionClient client. +func NewProductsByInvoiceSectionClient(subscriptionID string) ProductsByInvoiceSectionClient { + return NewProductsByInvoiceSectionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProductsByInvoiceSectionClientWithBaseURI creates an instance of the ProductsByInvoiceSectionClient client. +func NewProductsByInvoiceSectionClientWithBaseURI(baseURI string, subscriptionID string) ProductsByInvoiceSectionClient { + return ProductsByInvoiceSectionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists products by invoiceSectionName. +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +// filter - may be used to filter by product type. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. +// It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and +// value is separated by a colon (:). +func (client ProductsByInvoiceSectionClient) List(ctx context.Context, billingAccountName string, invoiceSectionName string, filter string) (result ProductsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsByInvoiceSectionClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName, invoiceSectionName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsByInvoiceSectionClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProductsByInvoiceSectionClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsByInvoiceSectionClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ProductsByInvoiceSectionClient) ListPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/products", 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 ProductsByInvoiceSectionClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 ProductsByInvoiceSectionClient) ListResponder(resp *http.Response) (result ProductsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/profilebillingpermissions.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/profilebillingpermissions.go new file mode 100644 index 000000000000..74daa475bbbc --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/profilebillingpermissions.go @@ -0,0 +1,117 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ProfileBillingPermissionsClient is the billing client provides access to billing resources for Azure subscriptions. +type ProfileBillingPermissionsClient struct { + BaseClient +} + +// NewProfileBillingPermissionsClient creates an instance of the ProfileBillingPermissionsClient client. +func NewProfileBillingPermissionsClient(subscriptionID string) ProfileBillingPermissionsClient { + return NewProfileBillingPermissionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProfileBillingPermissionsClientWithBaseURI creates an instance of the ProfileBillingPermissionsClient client. +func NewProfileBillingPermissionsClientWithBaseURI(baseURI string, subscriptionID string) ProfileBillingPermissionsClient { + return ProfileBillingPermissionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all billingPermissions for the caller has for a billing account. +// Parameters: +// billingAccountName - billing Account Id. +// billingProfileName - billing Profile Id. +func (client ProfileBillingPermissionsClient) List(ctx context.Context, billingAccountName string, billingProfileName string) (result PermissionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfileBillingPermissionsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName, billingProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfileBillingPermissionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProfileBillingPermissionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfileBillingPermissionsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ProfileBillingPermissionsClient) ListPreparer(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 = "2018-11-01-preview" + 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}/providers/Microsoft.Billing/billingPermissions", 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 ProfileBillingPermissionsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 ProfileBillingPermissionsClient) ListResponder(resp *http.Response) (result PermissionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/profilebillingroleassignment.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/profilebillingroleassignment.go new file mode 100644 index 000000000000..37f6e2132dc6 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/profilebillingroleassignment.go @@ -0,0 +1,354 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ProfileBillingRoleAssignmentClient is the billing client provides access to billing resources for Azure +// subscriptions. +type ProfileBillingRoleAssignmentClient struct { + BaseClient +} + +// NewProfileBillingRoleAssignmentClient creates an instance of the ProfileBillingRoleAssignmentClient client. +func NewProfileBillingRoleAssignmentClient(subscriptionID string) ProfileBillingRoleAssignmentClient { + return NewProfileBillingRoleAssignmentClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProfileBillingRoleAssignmentClientWithBaseURI creates an instance of the ProfileBillingRoleAssignmentClient +// client. +func NewProfileBillingRoleAssignmentClientWithBaseURI(baseURI string, subscriptionID string) ProfileBillingRoleAssignmentClient { + return ProfileBillingRoleAssignmentClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Add the operation to add a role assignment to a billing profile. +// Parameters: +// billingAccountName - billing Account Id. +// billingProfileName - billing Profile Id. +// parameters - parameters supplied to add a role assignment. +func (client ProfileBillingRoleAssignmentClient) Add(ctx context.Context, billingAccountName string, billingProfileName string, parameters RoleAssignmentPayload) (result RoleAssignmentListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfileBillingRoleAssignmentClient.Add") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.AddPreparer(ctx, billingAccountName, billingProfileName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfileBillingRoleAssignmentClient", "Add", nil, "Failure preparing request") + return + } + + resp, err := client.AddSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProfileBillingRoleAssignmentClient", "Add", resp, "Failure sending request") + return + } + + result, err = client.AddResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfileBillingRoleAssignmentClient", "Add", resp, "Failure responding to request") + } + + return +} + +// AddPreparer prepares the Add request. +func (client ProfileBillingRoleAssignmentClient) AddPreparer(ctx context.Context, billingAccountName string, billingProfileName string, parameters RoleAssignmentPayload) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Billing/createBillingRoleAssignment", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AddSender sends the Add request. The method will close the +// http.Response Body if it receives an error. +func (client ProfileBillingRoleAssignmentClient) AddSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// AddResponder handles the response to the Add request. The method always +// closes the http.Response Body. +func (client ProfileBillingRoleAssignmentClient) AddResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the role assignment on this Billing Profile +// Parameters: +// billingAccountName - billing Account Id. +// billingProfileName - billing Profile Id. +// billingRoleAssignmentName - role assignment id. +func (client ProfileBillingRoleAssignmentClient) Delete(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfileBillingRoleAssignmentClient.Delete") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, billingAccountName, billingProfileName, billingRoleAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfileBillingRoleAssignmentClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProfileBillingRoleAssignmentClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfileBillingRoleAssignmentClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ProfileBillingRoleAssignmentClient) DeletePreparer(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "billingRoleAssignmentName": autorest.Encode("path", billingRoleAssignmentName), + } + + const APIVersion = "2018-11-01-preview" + 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}/providers/Microsoft.Billing/billingRoleAssignments/{billingRoleAssignmentName}", 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 ProfileBillingRoleAssignmentClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 ProfileBillingRoleAssignmentClient) DeleteResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the role assignment for the caller on the Billing Profile +// Parameters: +// billingAccountName - billing Account Id. +// billingProfileName - billing Profile Id. +// billingRoleAssignmentName - role assignment id. +func (client ProfileBillingRoleAssignmentClient) Get(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfileBillingRoleAssignmentClient.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, billingProfileName, billingRoleAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfileBillingRoleAssignmentClient", "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.ProfileBillingRoleAssignmentClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfileBillingRoleAssignmentClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ProfileBillingRoleAssignmentClient) GetPreparer(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "billingRoleAssignmentName": autorest.Encode("path", billingRoleAssignmentName), + } + + const APIVersion = "2018-11-01-preview" + 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}/providers/Microsoft.Billing/billingRoleAssignments/{billingRoleAssignmentName}", 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 ProfileBillingRoleAssignmentClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 ProfileBillingRoleAssignmentClient) GetResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get the role assignments on the Billing Profile +// Parameters: +// billingAccountName - billing Account Id. +// billingProfileName - billing Profile Id. +func (client ProfileBillingRoleAssignmentClient) List(ctx context.Context, billingAccountName string, billingProfileName string) (result RoleAssignmentListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfileBillingRoleAssignmentClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName, billingProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfileBillingRoleAssignmentClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProfileBillingRoleAssignmentClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfileBillingRoleAssignmentClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ProfileBillingRoleAssignmentClient) ListPreparer(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 = "2018-11-01-preview" + 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}/providers/Microsoft.Billing/billingRoleAssignments", 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 ProfileBillingRoleAssignmentClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 ProfileBillingRoleAssignmentClient) ListResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/profilebillingroledefinition.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/profilebillingroledefinition.go new file mode 100644 index 000000000000..285f904a6675 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/profilebillingroledefinition.go @@ -0,0 +1,197 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ProfileBillingRoleDefinitionClient is the billing client provides access to billing resources for Azure +// subscriptions. +type ProfileBillingRoleDefinitionClient struct { + BaseClient +} + +// NewProfileBillingRoleDefinitionClient creates an instance of the ProfileBillingRoleDefinitionClient client. +func NewProfileBillingRoleDefinitionClient(subscriptionID string) ProfileBillingRoleDefinitionClient { + return NewProfileBillingRoleDefinitionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProfileBillingRoleDefinitionClientWithBaseURI creates an instance of the ProfileBillingRoleDefinitionClient +// client. +func NewProfileBillingRoleDefinitionClientWithBaseURI(baseURI string, subscriptionID string) ProfileBillingRoleDefinitionClient { + return ProfileBillingRoleDefinitionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the role definition for a role +// Parameters: +// billingAccountName - billing Account Id. +// billingProfileName - billing Profile Id. +// billingRoleDefinitionName - role definition id. +func (client ProfileBillingRoleDefinitionClient) Get(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleDefinitionName string) (result RoleDefinition, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfileBillingRoleDefinitionClient.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, billingProfileName, billingRoleDefinitionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfileBillingRoleDefinitionClient", "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.ProfileBillingRoleDefinitionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfileBillingRoleDefinitionClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ProfileBillingRoleDefinitionClient) GetPreparer(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleDefinitionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "billingRoleDefinitionName": autorest.Encode("path", billingRoleDefinitionName), + } + + const APIVersion = "2018-11-01-preview" + 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}/providers/Microsoft.Billing/billingRoleDefinitions/{billingRoleDefinitionName}", 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 ProfileBillingRoleDefinitionClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 ProfileBillingRoleDefinitionClient) GetResponder(resp *http.Response) (result RoleDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the role definition for a Billing Profile +// Parameters: +// billingAccountName - billing Account Id. +// billingProfileName - billing Profile Id. +func (client ProfileBillingRoleDefinitionClient) List(ctx context.Context, billingAccountName string, billingProfileName string) (result RoleDefinitionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfileBillingRoleDefinitionClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName, billingProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfileBillingRoleDefinitionClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProfileBillingRoleDefinitionClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfileBillingRoleDefinitionClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ProfileBillingRoleDefinitionClient) ListPreparer(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 = "2018-11-01-preview" + 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}/providers/Microsoft.Billing/billingRoleDefinitions", 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 ProfileBillingRoleDefinitionClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 ProfileBillingRoleDefinitionClient) ListResponder(resp *http.Response) (result RoleDefinitionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + 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 new file mode 100644 index 000000000000..2ef1d81373f8 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/profiles.go @@ -0,0 +1,200 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ProfilesClient is the billing client provides access to billing resources for Azure subscriptions. +type ProfilesClient struct { + BaseClient +} + +// NewProfilesClient creates an instance of the ProfilesClient client. +func NewProfilesClient(subscriptionID string) ProfilesClient { + return NewProfilesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProfilesClientWithBaseURI creates an instance of the ProfilesClient client. +func NewProfilesClientWithBaseURI(baseURI string, subscriptionID string) ProfilesClient { + return ProfilesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the billing profile by id. +// Parameters: +// billingAccountName - billing Account Id. +// billingProfileName - billing Profile Id. +// expand - may be used to expand the invoiceSections. +func (client ProfilesClient) Get(ctx context.Context, billingAccountName string, billingProfileName string, expand string) (result Profile, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesClient.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, billingProfileName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "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.ProfilesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ProfilesClient) GetPreparer(ctx context.Context, billingAccountName string, billingProfileName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}", 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 ProfilesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 ProfilesClient) GetResponder(resp *http.Response) (result Profile, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update the operation to update a billing profile. +// Parameters: +// billingAccountName - billing Account Id. +// billingProfileName - billing Profile Id. +// parameters - parameters supplied to the update billing profile operation. +func (client ProfilesClient) Update(ctx context.Context, billingAccountName string, billingProfileName string, parameters Profile) (result ProfilesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, billingAccountName, billingProfileName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ProfilesClient) UpdatePreparer(ctx context.Context, billingAccountName string, billingProfileName string, parameters Profile) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ProfilesClient) UpdateSender(req *http.Request) (future ProfilesUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ProfilesClient) UpdateResponder(resp *http.Response) (result Profile, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/profilesbybillingaccountname.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/profilesbybillingaccountname.go new file mode 100644 index 000000000000..63e58edfe54d --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/profilesbybillingaccountname.go @@ -0,0 +1,121 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ProfilesByBillingAccountNameClient is the billing client provides access to billing resources for Azure +// subscriptions. +type ProfilesByBillingAccountNameClient struct { + BaseClient +} + +// NewProfilesByBillingAccountNameClient creates an instance of the ProfilesByBillingAccountNameClient client. +func NewProfilesByBillingAccountNameClient(subscriptionID string) ProfilesByBillingAccountNameClient { + return NewProfilesByBillingAccountNameClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProfilesByBillingAccountNameClientWithBaseURI creates an instance of the ProfilesByBillingAccountNameClient +// client. +func NewProfilesByBillingAccountNameClientWithBaseURI(baseURI string, subscriptionID string) ProfilesByBillingAccountNameClient { + return ProfilesByBillingAccountNameClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all billing profiles for a user which that user has access to. +// Parameters: +// billingAccountName - billing Account Id. +// expand - may be used to expand the invoiceSections. +func (client ProfilesByBillingAccountNameClient) List(ctx context.Context, billingAccountName string, expand string) (result ProfileListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesByBillingAccountNameClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesByBillingAccountNameClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProfilesByBillingAccountNameClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesByBillingAccountNameClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ProfilesByBillingAccountNameClient) ListPreparer(ctx context.Context, billingAccountName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles", 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 ProfilesByBillingAccountNameClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 ProfilesByBillingAccountNameClient) ListResponder(resp *http.Response) (result ProfileListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/property.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/property.go new file mode 100644 index 000000000000..c04c14974b21 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/property.go @@ -0,0 +1,113 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PropertyClient is the billing client provides access to billing resources for Azure subscriptions. +type PropertyClient struct { + BaseClient +} + +// NewPropertyClient creates an instance of the PropertyClient client. +func NewPropertyClient(subscriptionID string) PropertyClient { + return NewPropertyClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPropertyClientWithBaseURI creates an instance of the PropertyClient client. +func NewPropertyClientWithBaseURI(baseURI string, subscriptionID string) PropertyClient { + return PropertyClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get billing property by subscription Id. +func (client PropertyClient) Get(ctx context.Context) (result Property, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PropertyClient.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) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PropertyClient", "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.PropertyClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PropertyClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client PropertyClient) GetPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingProperty", 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 PropertyClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PropertyClient) GetResponder(resp *http.Response) (result Property, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/recipienttransfers.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/recipienttransfers.go new file mode 100644 index 000000000000..989d11b6bbaa --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/recipienttransfers.go @@ -0,0 +1,348 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RecipientTransfersClient is the billing client provides access to billing resources for Azure subscriptions. +type RecipientTransfersClient struct { + BaseClient +} + +// NewRecipientTransfersClient creates an instance of the RecipientTransfersClient client. +func NewRecipientTransfersClient(subscriptionID string) RecipientTransfersClient { + return NewRecipientTransfersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRecipientTransfersClientWithBaseURI creates an instance of the RecipientTransfersClient client. +func NewRecipientTransfersClientWithBaseURI(baseURI string, subscriptionID string) RecipientTransfersClient { + return RecipientTransfersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Accept sends the accept request. +// Parameters: +// transferName - transfer Name. +// body - accept transfer parameters. +func (client RecipientTransfersClient) Accept(ctx context.Context, transferName string, body AcceptTransferRequest) (result RecipientTransferDetails, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecipientTransfersClient.Accept") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.AcceptPreparer(ctx, transferName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RecipientTransfersClient", "Accept", nil, "Failure preparing request") + return + } + + resp, err := client.AcceptSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RecipientTransfersClient", "Accept", resp, "Failure sending request") + return + } + + result, err = client.AcceptResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RecipientTransfersClient", "Accept", resp, "Failure responding to request") + } + + return +} + +// AcceptPreparer prepares the Accept request. +func (client RecipientTransfersClient) AcceptPreparer(ctx context.Context, transferName string, body AcceptTransferRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "transferName": autorest.Encode("path", transferName), + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/transfers/{transferName}/acceptTransfer", pathParameters), + autorest.WithJSON(body)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AcceptSender sends the Accept request. The method will close the +// http.Response Body if it receives an error. +func (client RecipientTransfersClient) AcceptSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// AcceptResponder handles the response to the Accept request. The method always +// closes the http.Response Body. +func (client RecipientTransfersClient) AcceptResponder(resp *http.Response) (result RecipientTransferDetails, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Decline sends the decline request. +// Parameters: +// transferName - transfer Name. +func (client RecipientTransfersClient) Decline(ctx context.Context, transferName string) (result RecipientTransferDetails, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecipientTransfersClient.Decline") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeclinePreparer(ctx, transferName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RecipientTransfersClient", "Decline", nil, "Failure preparing request") + return + } + + resp, err := client.DeclineSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RecipientTransfersClient", "Decline", resp, "Failure sending request") + return + } + + result, err = client.DeclineResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RecipientTransfersClient", "Decline", resp, "Failure responding to request") + } + + return +} + +// DeclinePreparer prepares the Decline request. +func (client RecipientTransfersClient) DeclinePreparer(ctx context.Context, transferName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "transferName": autorest.Encode("path", transferName), + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/transfers/{transferName}/declineTransfer", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeclineSender sends the Decline request. The method will close the +// http.Response Body if it receives an error. +func (client RecipientTransfersClient) DeclineSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeclineResponder handles the response to the Decline request. The method always +// closes the http.Response Body. +func (client RecipientTransfersClient) DeclineResponder(resp *http.Response) (result RecipientTransferDetails, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get sends the get request. +// Parameters: +// transferName - transfer Name. +func (client RecipientTransfersClient) Get(ctx context.Context, transferName string) (result RecipientTransferDetails, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecipientTransfersClient.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, transferName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RecipientTransfersClient", "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.RecipientTransfersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RecipientTransfersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RecipientTransfersClient) GetPreparer(ctx context.Context, transferName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "transferName": autorest.Encode("path", transferName), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/transfers/{transferName}/", pathParameters)) + 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 RecipientTransfersClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 RecipientTransfersClient) GetResponder(resp *http.Response) (result RecipientTransferDetails, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +func (client RecipientTransfersClient) List(ctx context.Context) (result RecipientTransferDetailsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecipientTransfersClient.List") + defer func() { + sc := -1 + if result.rtdlr.Response.Response != nil { + sc = result.rtdlr.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.RecipientTransfersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rtdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RecipientTransfersClient", "List", resp, "Failure sending request") + return + } + + result.rtdlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RecipientTransfersClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client RecipientTransfersClient) ListPreparer(ctx context.Context) (*http.Request, error) { + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Billing/transfers")) + 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 RecipientTransfersClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 RecipientTransfersClient) ListResponder(resp *http.Response) (result RecipientTransferDetailsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 RecipientTransfersClient) listNextResults(ctx context.Context, lastResults RecipientTransferDetailsListResult) (result RecipientTransferDetailsListResult, err error) { + req, err := lastResults.recipientTransferDetailsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.RecipientTransfersClient", "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.RecipientTransfersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RecipientTransfersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client RecipientTransfersClient) ListComplete(ctx context.Context) (result RecipientTransferDetailsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecipientTransfersClient.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/preview/billing/mgmt/2018-11-01-preview/billing/subscription.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/subscription.go new file mode 100644 index 000000000000..325d54ef7918 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/subscription.go @@ -0,0 +1,194 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SubscriptionClient is the billing client provides access to billing resources for Azure subscriptions. +type SubscriptionClient struct { + BaseClient +} + +// NewSubscriptionClient creates an instance of the SubscriptionClient client. +func NewSubscriptionClient(subscriptionID string) SubscriptionClient { + return NewSubscriptionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSubscriptionClientWithBaseURI creates an instance of the SubscriptionClient client. +func NewSubscriptionClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionClient { + return SubscriptionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get a single billing subscription by name. +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +// billingSubscriptionName - billing Subscription Id. +func (client SubscriptionClient) Get(ctx context.Context, billingAccountName string, invoiceSectionName string, billingSubscriptionName string) (result SubscriptionSummary, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionClient.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, invoiceSectionName, billingSubscriptionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionClient", "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.SubscriptionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SubscriptionClient) GetPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, billingSubscriptionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingSubscriptionName": autorest.Encode("path", billingSubscriptionName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/billingSubscriptions/{billingSubscriptionName}", 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 SubscriptionClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 SubscriptionClient) GetResponder(resp *http.Response) (result SubscriptionSummary, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Transfer transfers the GTM subscription from one invoice section to another within a billing account. +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +// billingSubscriptionName - billing Subscription Id. +// parameters - parameters supplied to the Transfer Billing Subscription operation. +func (client SubscriptionClient) Transfer(ctx context.Context, billingAccountName string, invoiceSectionName string, billingSubscriptionName string, parameters TransferBillingSubscriptionRequestProperties) (result SubscriptionTransferFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionClient.Transfer") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.TransferPreparer(ctx, billingAccountName, invoiceSectionName, billingSubscriptionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionClient", "Transfer", nil, "Failure preparing request") + return + } + + result, err = client.TransferSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionClient", "Transfer", result.Response(), "Failure sending request") + return + } + + return +} + +// TransferPreparer prepares the Transfer request. +func (client SubscriptionClient) TransferPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, billingSubscriptionName string, parameters TransferBillingSubscriptionRequestProperties) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingSubscriptionName": autorest.Encode("path", billingSubscriptionName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/billingSubscriptions/{billingSubscriptionName}/transfer", pathParameters), + autorest.WithJSON(parameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// TransferSender sends the Transfer request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionClient) TransferSender(req *http.Request) (future SubscriptionTransferFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// TransferResponder handles the response to the Transfer request. The method always +// closes the http.Response Body. +func (client SubscriptionClient) TransferResponder(resp *http.Response) (result TransferBillingSubscriptionResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/subscriptionsbybillingprofile.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/subscriptionsbybillingprofile.go new file mode 100644 index 000000000000..5a0355ba188b --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/subscriptionsbybillingprofile.go @@ -0,0 +1,119 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SubscriptionsByBillingProfileClient is the billing client provides access to billing resources for Azure +// subscriptions. +type SubscriptionsByBillingProfileClient struct { + BaseClient +} + +// NewSubscriptionsByBillingProfileClient creates an instance of the SubscriptionsByBillingProfileClient client. +func NewSubscriptionsByBillingProfileClient(subscriptionID string) SubscriptionsByBillingProfileClient { + return NewSubscriptionsByBillingProfileClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSubscriptionsByBillingProfileClientWithBaseURI creates an instance of the SubscriptionsByBillingProfileClient +// client. +func NewSubscriptionsByBillingProfileClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionsByBillingProfileClient { + return SubscriptionsByBillingProfileClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists billing subscriptions by billingProfileName. +// Parameters: +// billingAccountName - billing Account Id. +// billingProfileName - billing Profile Id. +func (client SubscriptionsByBillingProfileClient) List(ctx context.Context, billingAccountName string, billingProfileName string) (result SubscriptionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsByBillingProfileClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName, billingProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsByBillingProfileClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.SubscriptionsByBillingProfileClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsByBillingProfileClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SubscriptionsByBillingProfileClient) ListPreparer(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 = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfile/{billingProfileName}/billingSubscriptions", 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 SubscriptionsByBillingProfileClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 SubscriptionsByBillingProfileClient) ListResponder(resp *http.Response) (result SubscriptionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/subscriptionsbyinvoicesection.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/subscriptionsbyinvoicesection.go new file mode 100644 index 000000000000..42c88e841c05 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/subscriptionsbyinvoicesection.go @@ -0,0 +1,119 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SubscriptionsByInvoiceSectionClient is the billing client provides access to billing resources for Azure +// subscriptions. +type SubscriptionsByInvoiceSectionClient struct { + BaseClient +} + +// NewSubscriptionsByInvoiceSectionClient creates an instance of the SubscriptionsByInvoiceSectionClient client. +func NewSubscriptionsByInvoiceSectionClient(subscriptionID string) SubscriptionsByInvoiceSectionClient { + return NewSubscriptionsByInvoiceSectionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSubscriptionsByInvoiceSectionClientWithBaseURI creates an instance of the SubscriptionsByInvoiceSectionClient +// client. +func NewSubscriptionsByInvoiceSectionClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionsByInvoiceSectionClient { + return SubscriptionsByInvoiceSectionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists billing subscription by invoiceSectionName. +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +func (client SubscriptionsByInvoiceSectionClient) List(ctx context.Context, billingAccountName string, invoiceSectionName string) (result SubscriptionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsByInvoiceSectionClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, billingAccountName, invoiceSectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsByInvoiceSectionClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.SubscriptionsByInvoiceSectionClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsByInvoiceSectionClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SubscriptionsByInvoiceSectionClient) ListPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/billingSubscriptions", 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 SubscriptionsByInvoiceSectionClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 SubscriptionsByInvoiceSectionClient) ListResponder(resp *http.Response) (result SubscriptionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/transactionsbybillingaccount.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/transactionsbybillingaccount.go new file mode 100644 index 000000000000..2b8ee1e543cf --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/transactionsbybillingaccount.go @@ -0,0 +1,165 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TransactionsByBillingAccountClient is the billing client provides access to billing resources for Azure +// subscriptions. +type TransactionsByBillingAccountClient struct { + BaseClient +} + +// NewTransactionsByBillingAccountClient creates an instance of the TransactionsByBillingAccountClient client. +func NewTransactionsByBillingAccountClient(subscriptionID string) TransactionsByBillingAccountClient { + return NewTransactionsByBillingAccountClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTransactionsByBillingAccountClientWithBaseURI creates an instance of the TransactionsByBillingAccountClient +// client. +func NewTransactionsByBillingAccountClientWithBaseURI(baseURI string, subscriptionID string) TransactionsByBillingAccountClient { + return TransactionsByBillingAccountClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists the transactions by billingAccountName for given start and end date. +// Parameters: +// billingAccountName - billing Account Id. +// startDate - start date +// endDate - end date +// filter - may be used to filter by transaction kind. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and +// 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key +// and value is separated by a colon (:). +func (client TransactionsByBillingAccountClient) List(ctx context.Context, billingAccountName string, startDate string, endDate string, filter string) (result TransactionsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransactionsByBillingAccountClient.List") + defer func() { + sc := -1 + if result.tlr.Response.Response != nil { + sc = result.tlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, billingAccountName, startDate, endDate, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransactionsByBillingAccountClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.tlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.TransactionsByBillingAccountClient", "List", resp, "Failure sending request") + return + } + + result.tlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransactionsByBillingAccountClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client TransactionsByBillingAccountClient) ListPreparer(ctx context.Context, billingAccountName string, startDate string, endDate string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "endDate": autorest.Encode("query", endDate), + "startDate": autorest.Encode("query", startDate), + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/transactions", 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 TransactionsByBillingAccountClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 TransactionsByBillingAccountClient) ListResponder(resp *http.Response) (result TransactionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 TransactionsByBillingAccountClient) listNextResults(ctx context.Context, lastResults TransactionsListResult) (result TransactionsListResult, err error) { + req, err := lastResults.transactionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.TransactionsByBillingAccountClient", "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.TransactionsByBillingAccountClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransactionsByBillingAccountClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client TransactionsByBillingAccountClient) ListComplete(ctx context.Context, billingAccountName string, startDate string, endDate string, filter string) (result TransactionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransactionsByBillingAccountClient.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, billingAccountName, startDate, endDate, filter) + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/transfers.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/transfers.go new file mode 100644 index 000000000000..52aebc174c8c --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/transfers.go @@ -0,0 +1,366 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TransfersClient is the billing client provides access to billing resources for Azure subscriptions. +type TransfersClient struct { + BaseClient +} + +// NewTransfersClient creates an instance of the TransfersClient client. +func NewTransfersClient(subscriptionID string) TransfersClient { + return NewTransfersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTransfersClientWithBaseURI creates an instance of the TransfersClient client. +func NewTransfersClientWithBaseURI(baseURI string, subscriptionID string) TransfersClient { + return TransfersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel cancels the transfer for given transfer Id. +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +// transferName - transfer Name. +func (client TransfersClient) Cancel(ctx context.Context, billingAccountName string, invoiceSectionName string, transferName string) (result TransferDetails, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransfersClient.Cancel") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelPreparer(ctx, billingAccountName, invoiceSectionName, transferName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransfersClient", "Cancel", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.TransfersClient", "Cancel", resp, "Failure sending request") + return + } + + result, err = client.CancelResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransfersClient", "Cancel", resp, "Failure responding to request") + } + + return +} + +// CancelPreparer prepares the Cancel request. +func (client TransfersClient) CancelPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, transferName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + "transferName": autorest.Encode("path", transferName), + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/transfers/{transferName}", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CancelSender sends the Cancel request. The method will close the +// http.Response Body if it receives an error. +func (client TransfersClient) CancelSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client TransfersClient) CancelResponder(resp *http.Response) (result TransferDetails, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the transfer details for given transfer Id. +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +// transferName - transfer Name. +func (client TransfersClient) Get(ctx context.Context, billingAccountName string, invoiceSectionName string, transferName string) (result TransferDetails, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransfersClient.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, invoiceSectionName, transferName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransfersClient", "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.TransfersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransfersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client TransfersClient) GetPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, transferName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + "transferName": autorest.Encode("path", transferName), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/transfers/{transferName}", pathParameters)) + 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 TransfersClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 TransfersClient) GetResponder(resp *http.Response) (result TransferDetails, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Initiate initiates the request to transfer the GTM or legacy subscriptions or RIs to GTM. +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +// body - initiate transfer parameters. +func (client TransfersClient) Initiate(ctx context.Context, billingAccountName string, invoiceSectionName string, body InitiateTransferRequest) (result TransferDetails, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransfersClient.Initiate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.InitiatePreparer(ctx, billingAccountName, invoiceSectionName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransfersClient", "Initiate", nil, "Failure preparing request") + return + } + + resp, err := client.InitiateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.TransfersClient", "Initiate", resp, "Failure sending request") + return + } + + result, err = client.InitiateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransfersClient", "Initiate", resp, "Failure responding to request") + } + + return +} + +// InitiatePreparer prepares the Initiate request. +func (client TransfersClient) InitiatePreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, body InitiateTransferRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/initiateTransfer", pathParameters), + autorest.WithJSON(body)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// InitiateSender sends the Initiate request. The method will close the +// http.Response Body if it receives an error. +func (client TransfersClient) InitiateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// InitiateResponder handles the response to the Initiate request. The method always +// closes the http.Response Body. +func (client TransfersClient) InitiateResponder(resp *http.Response) (result TransferDetails, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all transfer's details initiated from given invoice section. +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +func (client TransfersClient) List(ctx context.Context, billingAccountName string, invoiceSectionName string) (result TransferDetailsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransfersClient.List") + defer func() { + sc := -1 + if result.tdlr.Response.Response != nil { + sc = result.tdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, billingAccountName, invoiceSectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransfersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.tdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.TransfersClient", "List", resp, "Failure sending request") + return + } + + result.tdlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransfersClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client TransfersClient) ListPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/transfers", pathParameters)) + 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 TransfersClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 TransfersClient) ListResponder(resp *http.Response) (result TransferDetailsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 TransfersClient) listNextResults(ctx context.Context, lastResults TransferDetailsListResult) (result TransferDetailsListResult, err error) { + req, err := lastResults.transferDetailsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.TransfersClient", "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.TransfersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransfersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client TransfersClient) ListComplete(ctx context.Context, billingAccountName string, invoiceSectionName string) (result TransferDetailsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransfersClient.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, billingAccountName, invoiceSectionName) + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/version.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/version.go new file mode 100644 index 000000000000..5fbcfa882646 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/version.go @@ -0,0 +1,30 @@ +package billing + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " billing/2018-11-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}